示例#1
0
 public List<BattleAction> getItemActionList(UsableItem i, int x, int y)
 {
     List<BattleAction> actionList = new List<BattleAction>();
     actionList.Add(new BattleAction() { character = ActiveCharacter, actionType = BattleActionType.UseItem, item = i, targetTile = board.getTileFromLocation(x, y) });
     return actionList;
 }
示例#2
0
        public bool UseItem(GameCharacter character, UsableItem item, Tile targetTile)
        {

            bool usedItem = false;

            if (!CoreHelper.checkEffect(character.activeEffects, character.passiveEffects, StatType.Stun))
            {
                if (character.CheckAP(item.actionPoints))
                {
                    if (item.activeEffects != null)
                    {
                        foreach (var a in item.activeEffects)
                        {
                            character.AddActiveEffect(a, this);
                        }
                        usedItem = true;
                        character.SpendAP(item.actionPoints);
                        item.uses--;
                    }

                    else if(item.itemAbility != null)
                    {
                        bool usedAbility = AbilityHelper.UseAbility(ActiveCharacter, item.itemAbility, targetTile, this);
                        if(usedAbility)
                        {
                            usedItem = true;
                            character.SpendAP(item.actionPoints);
                            item.uses--;
                        }
                    }

                    if (item.uses <= 0)
                    {
                        //should this logic be here?
                        battleLog.AddEntry(string.Format("{0} has no more uses.", item.name));

                        ActiveCharacter.removeUsableItem(item);
                        //ActiveCharacter.inventory.Remove(item);
                    }
                }
               
                if(usedItem)
                {
                    battleLog.AddEntry(string.Format("{0} used item {1}", character.name, item.name));
                    return true;
                }
                else
                {
                    battleLog.AddEntry(string.Format("{0} was unable to use item {1}", character.name, item.name));
                    return false;
                }
               
            }
            else{
                battleLog.AddEntry(string.Format("{0} is stunned and unable to use {1}.", character.name, item.name));
            }
            
            return false;

        }
示例#3
0
        public static UsableItem getUsableItemFromData(UsableItemData data, Dictionary<long, AbilityData> abilityDataDictionary, Dictionary<long, EffectData> effectDataDictionary)
        {
            Item i = getItemFromItemData(data, abilityDataDictionary, effectDataDictionary);
            UsableItem ui = new UsableItem()
            {

                activeEffects = i.activeEffects,
                ID = i.ID,
                name = i.name,
                passiveEffects = i.passiveEffects,
                sheetname = i.sheetname,
                spriteindex = i.spriteindex,
                type = i.type,
                uses = data.uses,
                actionPoints = data.actionPoints,
                price = data.price

            };


            if (data.itemAbility.Count > 0)
            {
                List<Ability> abilityList = new List<Ability>();

                foreach (long l in data.itemAbility)
                {
                    if (abilityDataDictionary.ContainsKey(l))
                    {
                        abilityList.Add(AbilityFactory.getAbilityFromAbilityData(abilityDataDictionary[l], effectDataDictionary));
                    }

                }
                ui.itemAbility = abilityList.FirstOrDefault(); //hack?  can we have multiple abilities on usable items?
            }
            return ui;
        }