Exemple #1
0
    public string CharacterSettingUseItem(ItemIns itemIns, bool save)
    {
        string message = "";

        if (itemIns == null)
        {
            return(message);
        }
        Debug.Log("ItemIns = " + itemIns.MyInfo());
        var item     = itemIns.Item;
        var userItem = itemIns.UserItem;

        switch (itemIns.Item.Type)
        {
        case ItemContainer.ItemType.Consumable:
            if (item.Recipe > 0)
            {
                if (_userDatabase.AddNewRandomUserRecipe())
                {
                    message = "You found a Recipe!!";
                }
                else
                {
                    return("Recipe you found is not readable!! ");
                }
            }
            if (item.Egg > 0)
            {
                if (_userDatabase.AddNewRandomUserCharacters())
                {
                    message = "You Hatched a New Character!!";
                }
                else
                {
                    return("The Egg you found is already rotten !! ");
                }
            }
            if (item.Health > 0)
            {
                AddCharacterSetting("Health", item.Health * userItem.StackCnt, false);
            }
            if (item.Mana > 0)
            {
                AddCharacterSetting("Mana", item.Mana * userItem.StackCnt, false);
            }
            if (item.Energy > 0)
            {
                AddCharacterSetting("Energy", item.Energy * userItem.StackCnt, false);
            }
            if (item.Coin > 0)
            {
                AddCharacterSetting("Coin", item.Coin * userItem.StackCnt, false);
            }
            if (item.Gem > 0)
            {
                AddCharacterSetting("Gem", item.Gem * userItem.StackCnt, false);
            }
            break;

        case ItemContainer.ItemType.Equipment:
            if (item.Agility > 0)
            {
                AddCharacterSetting("Agility", item.Agility, false);
            }
            if (item.Bravery > 0)
            {
                AddCharacterSetting("Bravery", item.Bravery, false);
            }
            if (item.Carry > 0)
            {
                AddCharacterSetting("Carry", item.Carry, false);
            }
            if (item.CarryCnt > 0)
            {
                AddCharacterSetting("CarryCnt", item.CarryCnt, false);
            }
            if (item.Charming > 0)
            {
                AddCharacterSetting("Charming", item.Charming, false);
            }
            if (item.Intellect > 0)
            {
                AddCharacterSetting("Intellect", item.Intellect, false);
            }
            if (item.Crafting > 0)
            {
                AddCharacterSetting("Crafting", item.Crafting, false);
            }
            if (item.Researching > 0)
            {
                AddCharacterSetting("Researching", item.Researching, false);
            }
            if (item.Speed > 0)
            {
                AddCharacterSetting("Speed", item.Speed, false);
            }
            if (item.Stamina > 0)
            {
                AddCharacterSetting("Stamina", item.Stamina, false);
            }
            if (item.Strength > 0)
            {
                AddCharacterSetting("Strength", item.Strength, false);
            }
            break;

        case ItemContainer.ItemType.Weapon:
            if (item.SpeedAttack > 0)
            {
                AddCharacterSetting("SpeedAttack", item.SpeedAttack, false);
            }
            if (item.SpeedDefense > 0)
            {
                AddCharacterSetting("SpeedDefense", item.SpeedDefense, false);
            }
            if (item.AbilityAttack > 0)
            {
                AddCharacterSetting("AbilityAttack", item.AbilityAttack, false);
            }
            if (item.AbilityDefense > 0)
            {
                AddCharacterSetting("AbilityDefense", item.AbilityDefense, false);
            }
            if (item.MagicAttack > 0)
            {
                AddCharacterSetting("MagicAttack", item.MagicAttack, false);
            }
            if (item.MagicDefense > 0)
            {
                AddCharacterSetting("MagicDefense", item.MagicDefense, false);
            }
            if (item.PoisonAttack > 0)
            {
                AddCharacterSetting("PoisonAttack", item.PoisonAttack, false);
            }
            if (item.PoisonDefense > 0)
            {
                AddCharacterSetting("PoisonDefense", item.PoisonDefense, false);
            }
            break;

        case ItemContainer.ItemType.Tool:
            return(message);
        }
        if (save)
        {
            SaveCharacterSetting(CharacterSetting);
        }
        return(message);
    }