示例#1
0
        public override void Init()
        {
            character = characterCreator.Create();
            var equipTable = new InventoryItemCreator[] {
                character.equipment.head,
                character.equipment.shoulder,
                character.equipment.feet,
                character.equipment.body,
                character.equipment.legs,
                character.equipment.neck,
                character.equipment.gloves,
                character.equipment.waist,
                character.equipment.ring1,
                character.equipment.ring2,
                character.equipment.weapon,
            };

            for (int i = 0; i < character.abilities.Count; i++)
            {
                SkillBook.Add(character.abilities[i].Create());
                SkillBook[i].Caster = this;
            }

            for (int i = 0; i < equipTable.Length; i++)
            {
                if (equipTable[i] != null)
                {
                    var item = equipTable[i].Create();
                    item.isEquipable = true;
                    itemManager.EquipItem(item, (EquipmentSlot)i);
                }
            }

            ActiveEquipment[(int)EquipmentSlot.Weapon].Use();
        }
示例#2
0
    public static InventoryItemCreator CreateScriptableObject()
    {
        InventoryItemCreator asset     = ScriptableObject.CreateInstance <InventoryItemCreator>();
        string        assetpath        = "Assets/InventoryItems/InventoryItem.asset";
        string        assetPathAndName = AssetDatabase.GenerateUniqueAssetPath(assetpath);
        InventoryItem item             = new InventoryItem();

        item.Id = Path.GetFileNameWithoutExtension(assetPathAndName);
        AssetSerializer serializer = new AssetSerializer();

        serializer.AddItem(item);
        asset.source = serializer.WriteToString();
        AssetDatabase.CreateAsset(asset, assetPathAndName);
        AssetDatabase.SaveAssets();
        AssetDatabase.Refresh();
        return(asset);
    }