private MouseEventHandler mouseEvent(List <Spells[]> spells, int k, PictureBox pic)
 {
     return((sender, e) =>
     {
         int charIndex = character.gameManager.TeamBlue.IndexOf(character);
         Spells[] currentSpell = spells[k];
         if (character.ActiveSpells.Count == 0)
         {
             character.DefaultSkill = currentSpell;
             gameNetworkManager.enqueueMsg(NetworkMsgPrefix.DefaultSkill, GameNetworkUtilities.serializeSpellActionMoving(currentSpell, charIndex));
         }
         character.ActiveSpells.Add(currentSpell);
         gameNetworkManager.enqueueMsg(NetworkMsgPrefix.AddActiveSpells, GameNetworkUtilities.serializeSpellAction(currentSpell, character.CurrentTile));
         character.InactiveSpells.Remove(currentSpell);
         refreshPanel(character.InactiveSpells);
         character.ChooseSpell.refreshPanel(character, character.ActiveSpells);
     });
 }
Example #2
0
 private MouseEventHandler mouseEvent(List <Spells[]> actives, int k)
 {
     return((sender, e) =>
     {
         int charIndex = character.gameManager.TeamBlue.IndexOf(character);
         Spells[] currentSpell = actives[k];
         if (character.gameManager.CurrentGameStage == StageManager.GameStage.Buy && e.Button == MouseButtons.Right)
         {
             character.InactiveSpells.Add(currentSpell);
             character.ActiveSpells.Remove(currentSpell);
             gameNetworkManager.enqueueMsg(NetworkMsgPrefix.RemActiveSpells, GameNetworkUtilities.serializeSpellAction(currentSpell, character.CurrentTile));
             refreshPanel(character, character.ActiveSpells);
             character.InactiveSpell.refreshPanel(character.InactiveSpells);
         }
         if (e.Button == MouseButtons.Left)
         {
             if (character.gameManager.CurrentGameStage == StageManager.GameStage.Fight && character.Stats[StatusType.Charge] == character.Stats[StatusType.ChargeMax])
             {
                 character.gameManager.removeRangeFromForm(this);
                 character.SpellReady = false;
                 character.resetMana();
                 currentSpell[character.SpellLevel[currentSpell]].castSpell(character);
             }
             if (character.Stats[StatusType.Charge] / character.Stats[StatusType.ChargeMax] < 0.9)
             {
                 character.DefaultSkill = currentSpell;
                 gameNetworkManager.enqueueMsg(NetworkMsgPrefix.DefaultSkill, GameNetworkUtilities.serializeSpellActionMoving(currentSpell, charIndex));
                 //gameNetworkManager.enqueueMsg(NetworkMsgPrefix.DefaultSkill, GameNetworkUtilities.serializeSpellAction(currentSpell,character.CurrentTile));
                 spellSwap(k);
                 gameNetworkManager.enqueueMsg(NetworkMsgPrefix.ExchActiveSpells, GameNetworkUtilities.serializeSpellSwap(k, charIndex));
                 if (character.gameManager.CurrentGameStage == StageManager.GameStage.Fight && e.Button == MouseButtons.Left)
                 {
                     character.hideChooseSpellUI();
                 }
                 refreshPanel(character, character.ActiveSpells);
             }
         }
     });
 }
Example #3
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);
        }