Exemplo n.º 1
0
        private void EnemyMove()
        {
            var newNumber = randomizer.Next(10);

            if (newNumber < 4)
            {
                ChoiceVictim(1);
            }
            else if (newNumber >= 4 && newNumber < 7)
            {
                ChoiceVictim(0);
            }
            else if (newNumber >= 7 && newNumber < 8)
            {
                ChoiceVictim(-1);
            }
            else
            {
                var fNum = randomizer.Next(5);
                EventAggregator.OnEnemyAttack(fNum, randomizer.Next(5), enemy.ActiveFairies[fNum].Spells[0] != "EmptySlot" ? enemy.ActiveFairies[fNum].Spells[0] : enemy.ActiveFairies[fNum].Spells[2], "Player");
            }


            NewMove("Player");
        }
Exemplo n.º 2
0
        private bool ChoiceVictim(int effectiveness)
        {
            var i       = 0;
            var j       = 0;
            var attacks = new List <Attack>();

            foreach (var enemyFairy in enemy.ActiveFairies)
            {
                j = 0;
                foreach (var playerFairy in player.ActiveFairies)
                {
                    if (DataOfModels.TableOfEffectiveness[(int)enemyFairy.Element, (int)playerFairy.Element] == effectiveness)
                    {
                        if (enemyFairy.Spells[0] != "Empty Slot" && EnemySpells[i, 0].Mana > 0)
                        {
                            attacks.Add(new Attack(i, j, EnemySpells[i, 0]));
                        }

                        if (enemyFairy.Spells[2] != "Empty Slot" && EnemySpells[i, 2].Mana > 0)
                        {
                            attacks.Add(new Attack(i, j, EnemySpells[i, 2]));
                        }
                    }

                    j++;
                }

                i++;
            }

            var choiceAttack = new Attack();
            var newNumber    = randomizer.Next(10);

            if (newNumber < 4)
            {
                var damage = 0.0;
                foreach (var attack in attacks)
                {
                    if (DataOfModels.OffensiveSpells[attack.Spell.Name].Damage * enemy.ActiveFairies[attack.Forward].LevelCoefficient > damage)
                    {
                        damage       = DataOfModels.OffensiveSpells[attack.Spell.Name].Damage * enemy.ActiveFairies[attack.Forward].LevelCoefficient;
                        choiceAttack = attack;
                    }
                }
            }
            else if (newNumber >= 4 && newNumber < 7)
            {
                var maxHP = 0.0;
                foreach (var attack in attacks)
                {
                    if (player.ActiveFairies[attack.Victim].HealthPoint > maxHP)
                    {
                        maxHP        = player.ActiveFairies[attack.Victim].HealthPoint;
                        choiceAttack = attack;
                    }
                }
            }
            else if (newNumber >= 7 && newNumber < 9)
            {
                var minHP = 30.0;
                foreach (var attack in attacks)
                {
                    if (player.ActiveFairies[attack.Victim].HealthPoint < minHP)
                    {
                        minHP        = player.ActiveFairies[attack.Victim].HealthPoint;
                        choiceAttack = attack;
                    }
                }
            }
            else
            {
                choiceAttack = attacks[randomizer.Next(attacks.Count)];
            }

            if (choiceAttack.WasChoice)
            {
                EventAggregator.OnEnemyAttack(choiceAttack.Forward, choiceAttack.Victim, choiceAttack.Spell.Name, "Player");
                return(true);
            }

            return(false);
        }