diff --git a/Assets/Prefabs/GridViewItem.prefab b/Assets/Prefabs/GridViewItem.prefab
index f2699cc..20ae9ff 100644
--- a/Assets/Prefabs/GridViewItem.prefab
+++ b/Assets/Prefabs/GridViewItem.prefab
@@ -20,7 +20,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
- m_IsActive: 0
+ m_IsActive: 1
--- !u!224 &2158945965616558227
RectTransform:
m_ObjectHideFlags: 0
@@ -170,9 +170,9 @@ RectTransform:
m_Father: {fileID: 8463177436804160159}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
- m_AnchorMin: {x: 0, y: 1}
- m_AnchorMax: {x: 0, y: 1}
- m_AnchoredPosition: {x: 100, y: -10}
+ m_AnchorMin: {x: 0, y: 0}
+ m_AnchorMax: {x: 0, y: 0}
+ m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 200, y: 20}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &6276336569359545557
@@ -338,9 +338,9 @@ RectTransform:
m_Father: {fileID: 2236248579476745813}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
- m_AnchorMin: {x: 0, y: 1}
- m_AnchorMax: {x: 0, y: 1}
- m_AnchoredPosition: {x: 100, y: -50}
+ m_AnchorMin: {x: 0, y: 0}
+ m_AnchorMax: {x: 0, y: 0}
+ m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 200, y: 50}
m_Pivot: {x: 0.5, y: 1}
--- !u!222 &6746999582958781488
@@ -664,9 +664,9 @@ RectTransform:
m_Father: {fileID: 2236248579476745813}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
- m_AnchorMin: {x: 0, y: 1}
- m_AnchorMax: {x: 0, y: 1}
- m_AnchoredPosition: {x: 100, y: -25}
+ m_AnchorMin: {x: 0, y: 0}
+ m_AnchorMax: {x: 0, y: 0}
+ m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 200, y: 50}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &6575481395058307399
@@ -983,9 +983,9 @@ RectTransform:
m_Father: {fileID: 2158945965616558227}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
- m_AnchorMin: {x: 0, y: 1}
- m_AnchorMax: {x: 0, y: 1}
- m_AnchoredPosition: {x: 100, y: 0}
+ m_AnchorMin: {x: 0, y: 0}
+ m_AnchorMax: {x: 0, y: 0}
+ m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 200, y: 75}
m_Pivot: {x: 0.5, y: 1}
--- !u!222 &1293282004875046429
@@ -1082,9 +1082,9 @@ RectTransform:
m_Father: {fileID: 2236248579476745813}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
- m_AnchorMin: {x: 0, y: 1}
- m_AnchorMax: {x: 0, y: 1}
- m_AnchoredPosition: {x: 100, y: -100}
+ m_AnchorMin: {x: 0, y: 0}
+ m_AnchorMax: {x: 0, y: 0}
+ m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 200, y: 50}
m_Pivot: {x: 0.5, y: 1}
--- !u!222 &2677774126614840048
@@ -1238,9 +1238,9 @@ RectTransform:
m_Father: {fileID: 8463177436804160159}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
- m_AnchorMin: {x: 0, y: 1}
- m_AnchorMax: {x: 0, y: 1}
- m_AnchoredPosition: {x: 100, y: -30}
+ m_AnchorMin: {x: 0, y: 0}
+ m_AnchorMax: {x: 0, y: 0}
+ m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 200, y: 15}
m_Pivot: {x: 0.5, y: 1}
--- !u!222 &6572675765595622057
@@ -1472,9 +1472,9 @@ RectTransform:
m_Father: {fileID: 2158945965616558227}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
- m_AnchorMin: {x: 0, y: 1}
- m_AnchorMax: {x: 0, y: 1}
- m_AnchoredPosition: {x: 100, y: -75}
+ m_AnchorMin: {x: 0, y: 0}
+ m_AnchorMax: {x: 0, y: 0}
+ m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 200, y: 125}
m_Pivot: {x: 0.5, y: 1}
--- !u!222 &644337133234863296
@@ -1647,9 +1647,9 @@ RectTransform:
m_Father: {fileID: 8463177436804160159}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
- m_AnchorMin: {x: 0, y: 1}
- m_AnchorMax: {x: 0, y: 1}
- m_AnchoredPosition: {x: 100, y: -25}
+ m_AnchorMin: {x: 0, y: 0}
+ m_AnchorMax: {x: 0, y: 0}
+ m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 100, y: 10}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &2480338273916655199
@@ -1692,9 +1692,9 @@ RectTransform:
m_Father: {fileID: 8463177436804160159}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
- m_AnchorMin: {x: 0, y: 1}
- m_AnchorMax: {x: 0, y: 1}
- m_AnchoredPosition: {x: 100, y: -45}
+ m_AnchorMin: {x: 0, y: 0}
+ m_AnchorMax: {x: 0, y: 0}
+ m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 200, y: 30}
m_Pivot: {x: 0.5, y: 1}
--- !u!222 &1794332670372956633
diff --git a/Assets/Resources/ScriptedItems/ActualSword.asset b/Assets/Resources/ScriptedItems/ActualSword.asset
new file mode 100644
index 0000000..20b5fb4
--- /dev/null
+++ b/Assets/Resources/ScriptedItems/ActualSword.asset
@@ -0,0 +1,20 @@
+%YAML 1.1
+%TAG !u! tag:unity3d.com,2011:
+--- !u!114 &11400000
+MonoBehaviour:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 0}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: 1a6faf63d685386429bab9c581992b61, type: 3}
+ m_Name: ActualSword
+ m_EditorClassIdentifier:
+ Name: Actual Sword
+ Description: This sword is actually a sword though
+ Sprite: {fileID: 3447626333678633045, guid: b00993d063fbc4a87983115070f6145c, type: 3}
+ Price: 1000
+ Attack: 35
+ Damage: 45
diff --git a/Assets/Resources/ScriptedItems/ActualSword.asset.meta b/Assets/Resources/ScriptedItems/ActualSword.asset.meta
new file mode 100644
index 0000000..a3f0c44
--- /dev/null
+++ b/Assets/Resources/ScriptedItems/ActualSword.asset.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 107c94e65e6618040a4ea352a7b7c0ed
+NativeFormatImporter:
+ externalObjects: {}
+ mainObjectFileID: 11400000
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Resources/StandardShopInventory.asset b/Assets/Resources/StandardShopInventory.asset
index c605385..7203ae1 100644
--- a/Assets/Resources/StandardShopInventory.asset
+++ b/Assets/Resources/StandardShopInventory.asset
@@ -13,15 +13,11 @@ MonoBehaviour:
m_Name: StandardShopInventory
m_EditorClassIdentifier:
Items:
- - {fileID: 11400000, guid: b0a77491a8b600245b47aa33287d7585, type: 2}
- - {fileID: 11400000, guid: b0a77491a8b600245b47aa33287d7585, type: 2}
- - {fileID: 11400000, guid: b0a77491a8b600245b47aa33287d7585, type: 2}
- - {fileID: 11400000, guid: b0a77491a8b600245b47aa33287d7585, type: 2}
- - {fileID: 11400000, guid: b0a77491a8b600245b47aa33287d7585, type: 2}
- - {fileID: 11400000, guid: b0a77491a8b600245b47aa33287d7585, type: 2}
- - {fileID: 11400000, guid: b0a77491a8b600245b47aa33287d7585, type: 2}
- - {fileID: 11400000, guid: b0a77491a8b600245b47aa33287d7585, type: 2}
- - {fileID: 11400000, guid: 8ec316abfe61e4b43862dd2c75f0f792, type: 2}
- - {fileID: 11400000, guid: 8ec316abfe61e4b43862dd2c75f0f792, type: 2}
- - {fileID: 11400000, guid: 8ec316abfe61e4b43862dd2c75f0f792, type: 2}
- - {fileID: 11400000, guid: 8ec316abfe61e4b43862dd2c75f0f792, type: 2}
+ - {fileID: 11400000, guid: 107c94e65e6618040a4ea352a7b7c0ed, type: 2}
+ - {fileID: 11400000, guid: 107c94e65e6618040a4ea352a7b7c0ed, type: 2}
+ - {fileID: 11400000, guid: 107c94e65e6618040a4ea352a7b7c0ed, type: 2}
+ - {fileID: 11400000, guid: 107c94e65e6618040a4ea352a7b7c0ed, type: 2}
+ - {fileID: 11400000, guid: 107c94e65e6618040a4ea352a7b7c0ed, type: 2}
+ - {fileID: 11400000, guid: 107c94e65e6618040a4ea352a7b7c0ed, type: 2}
+ - {fileID: 11400000, guid: 107c94e65e6618040a4ea352a7b7c0ed, type: 2}
+ - {fileID: 11400000, guid: 107c94e65e6618040a4ea352a7b7c0ed, type: 2}
diff --git a/Assets/Scripts/Shop/Model/Inventory.cs b/Assets/Scripts/Shop/Model/Inventory.cs
index 4221fdc..550ebcb 100644
--- a/Assets/Scripts/Shop/Model/Inventory.cs
+++ b/Assets/Scripts/Shop/Model/Inventory.cs
@@ -100,7 +100,7 @@ public class Inventory
Random random = new Random();
for (int index = 0; index < itemCount; index++)
{
- Item item = new Item("Student Sword", "items_" + random.Next(73, 145), 50); //item name, item icon, cost
+ Item item = new ItemWeapon("Student Sword", "items_" + random.Next(73, 145), 50,0,0); //item name, item icon, cost
itemList.Add(item);
}
}
diff --git a/Assets/Scripts/Shop/Model/Item.cs b/Assets/Scripts/Shop/Model/Item.cs
index 36fcd28..192837a 100644
--- a/Assets/Scripts/Shop/Model/Item.cs
+++ b/Assets/Scripts/Shop/Model/Item.cs
@@ -1,7 +1,7 @@
///
/// This class holds data for an Item. Currently it has a name, an iconName and a base price.
///
-public class Item
+public abstract class Item
{
public readonly string name;
public readonly string iconName;
@@ -18,5 +18,20 @@ public class Item
this.basePrice = pbasePrice;
}
+ // This is supposed to return what type an item identifies as, purely used for filtering
+ public abstract ItemType GetItemType();
+
+ // Returns a nicely formatted text about the item's stats. Implementation-specific, because different types of items generate these differently
+ public abstract string GetStats();
+}
+
+///
+/// Item type, mostly used as an identifier for item filters
+///
+public enum ItemType
+{
+ Weapon,
+ Armor,
+ Potion
}
diff --git a/Assets/Scripts/Shop/Model/ItemWeapon.cs b/Assets/Scripts/Shop/Model/ItemWeapon.cs
new file mode 100644
index 0000000..7ca7e06
--- /dev/null
+++ b/Assets/Scripts/Shop/Model/ItemWeapon.cs
@@ -0,0 +1,24 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class ItemWeapon : Item
+{
+ public readonly int Attack;
+ public readonly int Damage;
+ public ItemWeapon(string name, string iconName, int pbasePrice,int pAttack, int pDamage) : base(name, iconName, pbasePrice)
+ {
+ Attack = pAttack;
+ Damage = pDamage;
+ }
+
+ public override ItemType GetItemType()
+ {
+ return ItemType.Weapon;
+ }
+
+ public override string GetStats()
+ {
+ return "Attack: " + Attack + "\tDamage: " + Damage; // Empty placeholder
+ }
+}
diff --git a/Assets/Scripts/Shop/Model/ItemWeapon.cs.meta b/Assets/Scripts/Shop/Model/ItemWeapon.cs.meta
new file mode 100644
index 0000000..eddd767
--- /dev/null
+++ b/Assets/Scripts/Shop/Model/ItemWeapon.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: e79bc1667c7bddc44b31e38ddf9dd277
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Scripts/Shop/Scriptable Objects/ScriptedItem.cs b/Assets/Scripts/Shop/Scriptable Objects/ScriptedItem.cs
index c285601..eeca902 100644
--- a/Assets/Scripts/Shop/Scriptable Objects/ScriptedItem.cs
+++ b/Assets/Scripts/Shop/Scriptable Objects/ScriptedItem.cs
@@ -4,11 +4,12 @@ using UnityEngine;
///
/// This represents anything needed to construct one item with pre-scripted information
///
-[CreateAssetMenu]//Allows creating ViewConfig objects in Assets -> Create menu in the Unity Editor
-public class ScriptedItem : ScriptableObject
+public abstract class ScriptedItem : ScriptableObject
{
public string Name;
public string Description;
public Sprite Sprite;
public int Price;
+
+ public abstract Item GenerateItem();
}
diff --git a/Assets/Scripts/Shop/Scriptable Objects/ScriptedItemFactory.cs b/Assets/Scripts/Shop/Scriptable Objects/ScriptedItemFactory.cs
index 1df56d4..db89e37 100644
--- a/Assets/Scripts/Shop/Scriptable Objects/ScriptedItemFactory.cs
+++ b/Assets/Scripts/Shop/Scriptable Objects/ScriptedItemFactory.cs
@@ -12,7 +12,7 @@ public class ScriptedItemFactory : ItemFactory
{
foreach (var item in Items)
{
- model.inventory.AddItem(new Item(item.name,item.Sprite.name,item.Price));
+ model.inventory.AddItem(item.GenerateItem());
}
}
}
diff --git a/Assets/Scripts/Shop/Scriptable Objects/ScriptedWeapon.cs b/Assets/Scripts/Shop/Scriptable Objects/ScriptedWeapon.cs
new file mode 100644
index 0000000..68593c0
--- /dev/null
+++ b/Assets/Scripts/Shop/Scriptable Objects/ScriptedWeapon.cs
@@ -0,0 +1,16 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+///
+/// The scripted weapon generates a weapon type scripted item, adding attack and damage variables to it
+///
+[CreateAssetMenu]//Allows creating ViewConfig objects in Assets -> Create menu in the Unity Editor
+public class ScriptedWeapon : ScriptedItem
+{
+ public int Attack;
+ public int Damage;
+ public override Item GenerateItem()
+ {
+ return new ItemWeapon(Name, Sprite.name, Price, Attack, Damage);
+ }
+}
diff --git a/Assets/Scripts/Shop/Scriptable Objects/ScriptedWeapon.cs.meta b/Assets/Scripts/Shop/Scriptable Objects/ScriptedWeapon.cs.meta
new file mode 100644
index 0000000..8a9b6ca
--- /dev/null
+++ b/Assets/Scripts/Shop/Scriptable Objects/ScriptedWeapon.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 1a6faf63d685386429bab9c581992b61
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant: