Example #1
0
        public bool update()
        {
            if (spellsUIVisibleBuy)
            {
                gameManager.removeRangeFromForm(InactiveSpell, ChooseSpell);
                spellsUIVisibleBuy = false;
                return(true);
            }
            statusEffects = statusEffects.Where(effect =>
            {
                if (effect.RemoveEffectTimeStamp < gameManager.ElapsedTime)
                {
                    foreach (StatusEffect item in statusEffects)
                    {
                        if (statusEffects.IndexOf(effect) < statusEffects.IndexOf(item))
                        {
                            item.inverseValue();
                            applyStatusEffect(item);
                            effect.inverseValue();
                            applyStatusEffect(effect);
                            item.inverseValue();
                            applyStatusEffect(item);
                            return(false);
                        }
                    }
                    effect.inverseValue();
                    applyStatusEffect(effect);
                    return(false);
                }
                return(true);
            }).ToList();


            if (Stats[StatusType.Charge] == Stats[StatusType.ChargeMax] &&
                ActiveSpells.Count != 0)
            {
                if (DefaultSkill == null)
                {
                    int charIndex = gameManager.TeamBlue.IndexOf(this);
                    DefaultSkill = ActiveSpells[0];
                    gameNetworkManager.enqueueMsg(NetworkMsgPrefix.DefaultSkill, GameNetworkUtilities.serializeSpellActionMoving(ActiveSpells[0], charIndex));
                }
                DefaultSkill[SpellLevel[DefaultSkill]].castSpell(this);
                hideChooseSpellUI();
                resetMana();
            }

            if (ToMoveTo == null)
            {
                if (CurrentTarget == null ||
                    CurrentTarget.IsDead ||
                    PathFinding.getDistance(CurrentTile, CurrentTarget.CurrentTile) > Stats[StatusType.Range])
                {
                    List <Tile> path = null;
                    try
                    {
                        (path, CurrentTarget) = PathFinding.findPathToClosestEnemy(CurrentTile, team, grid, gameManager);
                    }
                    catch (PathFinding.PathNotFoundException)
                    {
                        return(false);
                    }
                    if (PathFinding.getDistance(CurrentTile, CurrentTarget.CurrentTile) > Stats[StatusType.Range])
                    {
                        ToMoveTo          = path[0];
                        ToMoveTo.Walkable = false;
                    }
                }
                else
                {
                    if (gameManager.ElapsedTime > nextAtttackTime)
                    {
                        nextAtttackTime = gameManager.ElapsedTime + Stats[StatusType.AttackSpeed];
                        CurrentTarget.takeDamage(Stats[StatusType.AttackDamage], DamageType.PhysicalDamage);
                        Stats[StatusType.Charge] = Math.Min(Stats[StatusType.Charge] + 4, Stats[StatusType.ChargeMax]);

                        return(true);
                    }
                }
            }
            return(false);
        }