Exemplo n.º 1
0
        /// <summary>
        /// Двигаемся к золоту
        /// </summary>
        /// <param name="moveRate"></param>
        protected virtual void MoveToGold(MoveRate moveRate)
        {
            //TODO: исключить те, что супер далеко или те у которых уже полно пиратов других и своих
            var tilesWithGold = Board.AllTiles(x => x.Type != TileType.Water && x.Coins > 0).ToList();

            //Исключаем, те, что уже у моих пиратов
            tilesWithGold.RemoveAll(t => MyPirates.Count(e => e.Position.Position == t.Position) >= t.Coins);

            if (!tilesWithGold.Any())
            {
                return;
            }

            //Исключаем золото уже у чужого пирата
            tilesWithGold.RemoveAll(t => AllEnemies.Count(e => e.Position.Position == t.Position) >= t.Coins);

            if (!tilesWithGold.Any())
            {
                return;
            }

            //Ищем минимальное растояние до золота до хода и после хода
            var distBefore     = tilesWithGold.Select(t => new Tuple <int, Tile>(Distance(moveRate.Move.From.Position, t.Position), t)).ToList();
            var distAfter      = tilesWithGold.Select(t => new Tuple <int, Tile>(Distance(moveRate.Move.To.Position, t.Position), t)).ToList();
            var minMovesBefore = distBefore.Select(t => t.Item1).Min();
            var minMovesAfter  = distAfter.Select(t => t.Item1).Min();

            if (minMovesAfter >= minMovesBefore)
            {
                return;
            }

            moveRate.AddRate("MoveToGold", (Coef.MoveToGold * DistanceCoef(minMovesAfter)));
        }
Exemplo n.º 2
0
        public void TestBulkAttackReal()
        {
            var game    = CreateGame();
            var empOnes = game.GameManager.CurrentNode.GetEmptyNeighborhoodTiles(game.GameManager.Hero, false);

            Assert.Greater(empOnes.Count, 1);
            var enemies = AllEnemies.Where(i => i.PowerKind == EnemyPowerKind.Champion).ToList();

            enemies[0].Stats.GetStat(EntityStatKind.Health).Value.Nominal *= 10;//make sure wont' die
            float en1Health = enemies[0].Stats.Health;
            float en2Health = enemies[1].Stats.Health;

            for (int i = 0; i < 2; i++)
            {
                game.GameManager.CurrentNode.SetTile(enemies[i], empOnes[i].point);
            }
            var ab = game.GameManager.Hero.GetPassiveAbility(Roguelike.Abilities.AbilityKind.BulkAttack);

            MaximizeAbility(ab, game.Hero);

            game.Hero.RecalculateStatFactors(false);
            var sb = game.Hero.GetTotalValue(EntityStatKind.ChanceToBulkAttack);

            for (int i = 0; i < 20; i++)
            {
                //hit only 1st enemy
                game.GameManager.InteractHeroWith(enemies[0]);
                GotoNextHeroTurn();
            }

            Assert.Greater(en1Health, enemies[0].Stats.Health);

            //2nd shall be hit by an ability
            Assert.Greater(en2Health, enemies[1].Stats.Health);
        }
Exemplo n.º 3
0
        public void TestPoisonPotionConsume()
        {
            var game = CreateGame();
            var hero = game.Hero;

            hero.SetChanceToExperienceEffect(EffectType.Poisoned, 100);

            //make enemy poisonus
            var enemy        = AllEnemies.First();
            var poisonAttack = enemy.Stats.GetStat(EntityStatKind.PoisonAttack);

            poisonAttack.Value.Nominal = 10;

            game.Hero.OnMeleeHitBy(enemy);
            var le1 = game.Hero.GetFirstLastingEffect(EffectType.Poisoned);

            Assert.NotNull(le1);

            var pot = Helper.AddTile <Potion>();

            pot.SetKind(PotionKind.Antidote);
            AddItemToInv(pot);
            hero.Consume(pot);

            le1 = game.Hero.GetFirstLastingEffect(EffectType.Poisoned);
            Assert.Null(le1);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Отнимаем золото
        /// </summary>
        /// <param name="moveRate"></param>
        protected void MoveToOccupiedGold(MoveRate moveRate)
        {
            var tilesWithGold = Board.AllTiles(x => x.Type != TileType.Water && x.Coins > 0).ToList();

            if (!tilesWithGold.Any())
            {
                return;
            }

            //Исключаем свободное золото
            tilesWithGold.RemoveAll(t => AllEnemies.Count(e => e.Position.Position == t.Position) < t.Coins);

            if (!tilesWithGold.Any())
            {
                return;
            }

            //Ищем минимальное растояние до золота до хода и после хода
            var distBefore     = tilesWithGold.Select(t => new Tuple <int, Tile>(Distance(moveRate.Move.From.Position, t.Position), t)).ToList();
            var distAfter      = tilesWithGold.Select(t => new Tuple <int, Tile>(Distance(moveRate.Move.To.Position, t.Position), t)).ToList();
            var minMovesBefore = distBefore.Select(t => t.Item1).Min();
            var minMovesAfter  = distAfter.Select(t => t.Item1).Min();

            if (minMovesAfter >= minMovesBefore)
            {
                return;
            }

            moveRate.AddRate("MoveToOccupiedGold", (Coef.MoveToOccupiedGold * DistanceCoef(minMovesAfter)));
        }
Exemplo n.º 5
0
        public void ManaScrollTest()
        {
            var game = CreateGame();
            var hero = game.Hero;

            var enemy = AllEnemies.First();

            enemy.Symbol = EnemySymbols.SnakeSymbol;
            enemy.SetSpecialAttackStat();

            var scroll = PrepareScroll(hero, SpellKind.ManaShield, enemy);
            var spell  = game.GameManager.SpellManager.ApplyPassiveSpell(hero, scroll);

            Assert.NotNull(spell);

            var heroHealth = game.Hero.Stats.Health;

            game.Hero.OnMelleeHitBy(enemy);                      //PoisonBallSpell work on mana shields!
            Assert.AreEqual(game.Hero.Stats.Health, heroHealth); //mana shield

            GotoSpellEffectEnd(spell);

            heroHealth = game.Hero.Stats.Health;
            game.Hero.OnMelleeHitBy(enemy);
            Assert.Less(game.Hero.Stats.Health, heroHealth);//mana shield gone
        }
Exemplo n.º 6
0
    private void Summon()
    {
        AllEnemies gameEnemies = QuestManager.instance.gameEnemies;

        GameObject[] enemies = gameEnemies.orcPrefabs;
        switch (enemyType)
        {
        case EnemyType.Orc:
            enemies = gameEnemies.orcPrefabs;
            break;

        case EnemyType.Dreg:
            enemies = gameEnemies.dregPrefabs;
            break;

        case EnemyType.SkeletonSoldier:
            enemies = gameEnemies.skeletonPrefabs;
            break;
        }
        for (int i = 0; i < spawnLocations.Length; i++)
        {
            GameObject newEnemy = gameEnemies.SpawnRandomEnemy(enemies, level, spawnLocations[i]);
            spawnedEnemies.Add(newEnemy);
        }
        StartCoroutine(CheckEnemies());
    }
Exemplo n.º 7
0
    private void OnEnable()
    {
        if (AllEnemies == null)
        {
            AllEnemies = new List <EnemyUnit>();
        }

        AllEnemies.Add(this);

        WorldManager.Instance.EnemiesSpawned++;
    }
Exemplo n.º 8
0
 private void ECTorpedoAttack(sortie_battle.torpedo api)
 {
     if (api == null)
     {
         return;
     }
     AllFriends.ZipEach(api.api_fdam.Skip(1), Delegates.SetDamage);
     AllEnemies.ZipEach(api.api_edam.Skip(1), Delegates.SetDamage);
     AllFriends.ZipEach(api.api_fydam.Skip(1), Delegates.SetGiveDamage);
     AllEnemies.ZipEach(api.api_eydam.Skip(1), Delegates.SetGiveDamage);
 }
Exemplo n.º 9
0
 private void TorpedoAttack(sortie_battle.torpedo api)
 {
     if (api == null)
     {
         return;
     }
     NightOrTorpedo.ArrayZip(api.api_fdam, 1, Delegates.SetDamage);
     AllEnemies.ZipEach(api.api_edam.Skip(1), Delegates.SetDamage);
     NightOrTorpedo.ArrayZip(api.api_fydam, 1, Delegates.SetGiveDamage);
     AllEnemies.ZipEach(api.api_eydam.Skip(1), Delegates.SetGiveDamage);
 }
Exemplo n.º 10
0
 private void SupportAttack(sortie_battle.support api)
 {
     if (api == null)
     {
         return;
     }
     AirBattle(api.api_support_airatack, true);
     if (api.api_support_hourai != null)
     {
         AllEnemies.ZipEach(api.api_support_hourai.api_damage.Skip(1), Delegates.SetDamage);
     }
 }
Exemplo n.º 11
0
        /// <summary>
        /// Ход под удар
        /// </summary>
        /// <param name="moveRate"></param>
        protected virtual void MoveUnderAtack(MoveRate moveRate)
        {
            //Не боимся слазить с корабля стоя на нем
            if (moveRate.Move.From.Position == MyShip.Position)
            {
                return;
            }

            if (AllEnemies.Any(e => Distance(e.Position.Position, moveRate.Move.To.Position) == 1))
            {
                moveRate.AddApplyToAllRate("MoveUnderAtack", Coef.MoveUnderAtack);
            }
        }
Exemplo n.º 12
0
        public void TestBleeding()
        {
            var game = CreateGame(true, 1);

            Assert.AreEqual(AllEnemies.Count, 1);
            int actionCounter = 0;

            game.GameManager.EventsManager.ActionAppended += (object sender, Roguelike.Events.GameEvent e) =>
            {
                if (e is LivingEntityAction)
                {
                    var lea = e as LivingEntityAction;
                    if (lea.Kind == LivingEntityActionKind.ExperiencedEffect)
                    {
                        if (lea.Info.Contains(EffectType.Bleeding.ToDescription()))
                        {
                            actionCounter++;
                        }
                    }
                }
            };

            var enemy = AllEnemies.First();

            Assert.True(enemy.Revealed);
            var enemyHealthStat = enemy.Stats.GetStat(EntityStatKind.Health);

            enemyHealthStat.Value.Nominal = 150;
            enemy.SetIsWounded(true);//make sure will bleed
            var enemyHealth = enemy.Stats.Health;

            var wpn = game.GameManager.LootGenerator.GetLootByTileName <Weapon>("rusty_sword");

            SetHeroEquipment(wpn);

            enemy.OnMelleeHitBy(game.Hero);
            var le1 = enemy.LastingEffects.Where(i => i.Type == EffectType.Bleeding).FirstOrDefault();

            Assert.NotNull(le1);
            Assert.Greater(enemyHealth, enemy.Stats.Health);

            //var value = game.Hero.Stats.GetStat(EntityStatKind.Defense).Value;
            var turns = le1.PendingTurns;

            for (int i = 0; i < turns; i++)
            {
                game.GameManager.SkipHeroTurn();
                GotoNextHeroTurn();
            }
            Assert.AreEqual(actionCounter, 3);
        }
Exemplo n.º 13
0
    public List <Quest> completedQuests = new List <Quest>(); //check here if its been added

    private void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else if (instance != null)
        {
            Destroy(gameObject);
        }

        gameEnemies = GetComponent <AllEnemies>();
        quests      = GetComponent <Quests>();
    }
Exemplo n.º 14
0
        protected override void InitBadPixels()
        {
            base.InitBadPixels();

            // boss
            boss = new Boss();
            Add(boss);

            for (int i = 0; i < 412; i++)
            {
                RedGuard bp = RedGuard.Create(); // Cloaky();
                bp.PositionAndTarget = new Vector2(RandomMath.RandomBetween(123f, 720f), RandomMath.RandomBetween(9f, 290f));
                //bp.TargetSpeed = 18.0f; // TODO
                Add(bp);
                AllEnemies.Add(bp);
                FindWalkableGround(bp);
            }

            for (int i = 0; i < 36; i++)
            {
                Servant s = Servant.Create();
                s.PositionAndTarget = new Vector2(RandomMath.RandomBetween(140f, 720f), RandomMath.RandomBetween(9f, 290f));
                Add(s);
                FindWalkableGround(s);
            }

            // servants at local hero's castle
            for (int i = 0; i < 3; i++)
            {
                Servant s = Servant.Create();
                s.AvoidingKnights.ChaseRange = 4f;
                s.AvoidingHero.ChaseRange    = 4f;
                s.PositionAndTarget          = new Vector2(RandomMath.RandomBetween(0f, 20f), RandomMath.RandomBetween(32f, 90f));
                Add(s);
                FindWalkableGround(s);
            }

            for (int i = 0; i < 14; i++) // XIV companions!
            {
                Knight cp = Knight.Create();
                cp.PositionAndTarget = new Vector2(KnightsStartingPositions[2 * i] + DEBUG_SHIFT_POS_RIGHT, KnightsStartingPositions[2 * i + 1]);
                //bp.TargetSpeed = 18.0f; // TODO
                Add(cp);
                hero.Knights.Add(cp);
                FindWalkableGround(cp);
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// Creates a new bosses and minions
        /// </summary>
        /// <param name="lvl"> The current level number </param>
        private void CreateNewEnemies(int lvl)
        {
            // Linearly finds the maximum of minions
            int maxMinions = (int)(-0.1f * lvl + 6);
            // Linearly finds the maximum of bosses
            int maxBosses = (int)(0.5f * lvl);

            // Maximum amount of Minions
            maxMinions = rnd.Next(maxMinions);

            // Maximum amount of Minions
            maxBosses = rnd.Next(maxBosses);

            // Checks the maximum enemies total
            int maxEnemiesTotal = Math.Min(maxMinions + maxBosses,
                                           (row) * (col) / 2);

            // Cycles through all the enemies
            for (int n = 0; n < maxEnemiesTotal; n++)
            {
                // Gets a new random position
                Position pos = GetRandomPosition();

                if (maxMinions > 0)
                {
                    // Adds the new minion to the list
                    AllEnemies.Add(new Minion(Room, Player, pos));

                    // Puts it on the board
                    Room[pos] = Piece.Enemy;

                    // Decrements one from maxMinions
                    maxMinions--;
                }
                else if (maxBosses > 0)
                {
                    // Adds the new Boss to the list
                    AllEnemies.Add(new Boss(Room, Player, pos));

                    // Puts it on the board
                    Room[pos] = Piece.Boss;

                    // Decrements one from maxBosses
                    maxBosses--;
                }
            }
        }
Exemplo n.º 16
0
        public void TestWandMastering()//ChanceToElementalBulkAttack()
        {
            var   game = CreateGame();
            float originalStatValue = 0;
            var   destExtraStat     = SetWeapon(AbilityKind.WandsMastering, game.Hero, out originalStatValue);
            var   weapon            = game.Hero.GetActiveWeapon();

            var empOnes = game.GameManager.CurrentNode.GetEmptyNeighborhoodTiles(game.GameManager.Hero, false);

            Assert.Greater(empOnes.Count, 1);
            var enemies = AllEnemies.Where(i => i.PowerKind == EnemyPowerKind.Champion).ToList();

            enemies[0].Stats.GetStat(EntityStatKind.Health).Value.Nominal *= 10;//make sure wont' die
            float en1Health = enemies[0].Stats.Health;
            float en2Health = enemies[1].Stats.Health;

            for (int i = 0; i < 2; i++)
            {
                game.GameManager.CurrentNode.SetTile(enemies[i], empOnes[i].point);
            }
            var ab = game.GameManager.Hero.GetPassiveAbility(Roguelike.Abilities.AbilityKind.WandsMastering);

            for (int i = 0; i < 5; i++)
            {
                ab.IncreaseLevel(game.Hero);
            }

            game.Hero.RecalculateStatFactors(false);
            //var sb = game.Hero.GetTotalValue(EntityStatKind.ChanceToBulkAttack);

            for (int i = 0; i < 20; i++)
            {
                weapon.SpellSource.Count = 20;
                //hit only 1st enemy
                var spell = weapon.SpellSource.CreateSpell(game.Hero);
                Assert.True(game.GameManager.SpellManager.ApplyAttackPolicy(game.Hero, enemies[0], weapon.SpellSource));
                GotoNextHeroTurn();
            }

            Assert.Greater(en1Health, enemies[0].Stats.Health);

            //2nd shall be hit by an ability
            Assert.Greater(en2Health, enemies[1].Stats.Health);
        }
Exemplo n.º 17
0
        public void Update(GameTime gameTime)
        {
            Player.Update(gameTime);
            Collectables.ForEach(c => c.Update(gameTime));

            List <Collectable> collected = Collectables.FindAll(c => c.HasCollidedWithPlayer);

            foreach (var item in collected)
            {
                AllTheSpritesWithinTheScene.Remove(item);
                Collectables.Remove(item);
            }



            var spawnPointsWithinTheViewport   = AllSpawnPoints.FindAll(c => Helper.CurrentGame.GraphicsDevice.Viewport.Bounds.Contains(c.SpritePosition - new Vector2(Camera.CamPos.X, Camera.CamPos.Y)));
            var despawnPointsWithinTheViewport = AllDespawnPoints.FindAll(c => Helper.CurrentGame.GraphicsDevice.Viewport.Bounds.Contains(c.SpritePosition - new Vector2(Camera.CamPos.X, Camera.CamPos.Y)));

            if (spawnPointsWithinTheViewport.Count > 0 && despawnPointsWithinTheViewport.Count > 0)
            {
                if (!AllEnemies.Peek().IsVisible)
                {
                    AllEnemies.Peek().IsVisible         = true;
                    AllEnemies.Peek().SpritePosition    = spawnPointsWithinTheViewport.ElementAt(Helper.random.Next(spawnPointsWithinTheViewport.Count)).SpritePosition;
                    AllEnemies.Peek().TargetDestination = despawnPointsWithinTheViewport.ElementAt(Helper.random.Next(despawnPointsWithinTheViewport.Count)).SpritePosition;
                }
            }

            if (AllEnemies.Peek().IsVisible)
            {
                AllEnemies.Peek().Update(gameTime);
                if (AllEnemies.Peek().TargetReached)
                {
                    AllEnemies.Enqueue(AllEnemies.Dequeue());
                }
            }


            if (Collectables.Count <= 0)
            {
                Gameover = true;
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// Уход от удара
        /// </summary>
        /// <param name="moveRate"></param>
        protected override void MoveFromAtack(MoveRate moveRate)
        {
            //Не боимся слазить с корабля стоя на нем
            if (moveRate.Move.From.Position == MyShip.Position)
            {
                return;
            }

            if (AllEnemies.Any(e => Distance(e.Position.Position, moveRate.Move.From.Position) == 1) &&
                AllEnemies.All(e => Distance(e.Position.Position, moveRate.Move.To.Position) != 1))
            {
                moveRate.AddRate("MoveFromAtack", Coef.MoveFromAtack
                                 * (moveRate.Move.WithCoins ? 1.3 : 1)
                                 * (GoldOnPosition(moveRate.Move.To.Position) > 0 ? 1.2 : 1)
                                 * (Distance(moveRate.Move.From.Position, MyShip.Position) > Distance(moveRate.Move.To.Position, MyShip.Position) ? 1.1 : 1)
                                 * (Distance(moveRate.Move.From.Position, MyShip.Position) < Distance(moveRate.Move.To.Position, MyShip.Position) ? 0.9 : 1)
                                 );
                moveRate.AddApplyToAllRate("MoveFromAtackToAll", Coef.MoveFromAtackToAll);
            }
        }
Exemplo n.º 19
0
        public void RageScrollTest()
        {
            var game = CreateGame();
            var hero = game.Hero;

            hero.UseAttackVariation = false;
            var enemy = AllEnemies.First();

            Func <float> hitEnemy = () =>
            {
                var enemyHealth = enemy.Stats.Health;
                enemy.OnMelleeHitBy(game.Hero);
                var lastEnemyHealthDiff = enemyHealth - enemy.Stats.Health;
                return(lastEnemyHealthDiff);
            };
            var healthDiff = hitEnemy();

            var emp = CurrentNode.GetClosestEmpty(hero);

            CurrentNode.SetTile(enemy, emp.point);

            var scroll = new Scroll(SpellKind.Rage);

            hero.Inventory.Add(scroll);
            var attackPrev = hero.GetCurrentValue(EntityStatKind.MeleeAttack);
            var spell      = game.GameManager.SpellManager.ApplyPassiveSpell(hero, scroll);

            Assert.NotNull(spell);
            Assert.Greater(hero.GetCurrentValue(EntityStatKind.MeleeAttack), attackPrev);

            var healthDiffRage = hitEnemy();

            Assert.Greater(healthDiffRage, healthDiff);//rage in work

            GotoSpellEffectEnd(spell);
            Assert.AreEqual(hero.GetCurrentValue(EntityStatKind.MeleeAttack), attackPrev);
            var healthDiffAfterRage = hitEnemy();
            var delta = Math.Abs(healthDiffAfterRage - healthDiff);

            Assert.Less(delta, 0.001);//rage was over
        }
Exemplo n.º 20
0
        public void TestPoisoned()
        {
            var game       = CreateGame();
            var healthStat = game.Hero.Stats.GetStat(EntityStatKind.Health);
            var health     = healthStat.Value.CurrentValue;

            Assert.Greater(game.Hero.GetChanceToExperienceEffect(EffectType.Poisoned), 0);
            game.Hero.SetChanceToExperienceEffect(EffectType.Poisoned, 100);

            //make enemy poisonus
            var enemy        = AllEnemies.First();
            var poisonAttack = enemy.Stats.GetStat(EntityStatKind.PoisonAttack);

            poisonAttack.Value.Nominal = 10;

            game.Hero.OnMelleeHitBy(enemy);
            var le1 = game.Hero.GetFirstLastingEffect(EffectType.Poisoned);

            Assert.NotNull(le1);

            Assert.Less(healthStat.Value.CurrentValue, health);
            var turns = le1.PendingTurns;

            for (int i = 0; i < turns; i++)
            {
                game.GameManager.SkipHeroTurn();
                GotoNextHeroTurn();
                Assert.Less(healthStat.Value.CurrentValue, health);
                health = healthStat.Value.CurrentValue;
            }

            health = healthStat.Value.CurrentValue;

            for (int i = 0; i < 5; i++)
            {
                game.GameManager.SkipHeroTurn();
                GotoNextHeroTurn();
                Assert.AreEqual(healthStat.Value.CurrentValue, health);
            }
        }
Exemplo n.º 21
0
        /// <summary>
        /// Ход под удар
        /// </summary>
        /// <param name="moveRate"></param>
        protected override void MoveUnderAtack(MoveRate moveRate)
        {
            //Не боимся слазить с корабля стоя на нем
            if (moveRate.Move.From.Position == MyShip.Position)
            {
                return;
            }

            var myAtakers = AllEnemies.Count(p => Distance(p.Position.Position, moveRate.Move.To.Position) == 1);

            if (myAtakers == 0)
            {
                return;
            }

            var myDefence = MyPirates.Count(p => Distance(p.Position.Position, moveRate.Move.To.Position) == 1) - 1;

            if (myDefence < myAtakers)
            {
                moveRate.AddApplyToAllRate("MoveUnderAtack", Coef.MoveUnderAtack);
            }
        }
Exemplo n.º 22
0
        public void NonPlainEnemyUsesEffects()
        {
            var game = CreateGame(numEnemies: 1, numberOfRooms: 1);
            var hero = game.Hero;

            var spellAttackDone = false;

            game.GameManager.EventsManager.ActionAppended += (object sender, Roguelike.Events.GameEvent e) =>
            {
                if (e is LivingEntityAction lea)
                {
                    if (lea.Info.Contains("Ball"))
                    {
                        spellAttackDone = true;
                    }
                }
            };

            hero.Stats.SetNominal(Roguelike.Attributes.EntityStatKind.Health, 255);
            var enemy = AllEnemies.First();

            enemy.SetNonPlain(true);
            Assert.NotNull(enemy.ActiveManaPoweredSpellSource);
            var closeHero = game.Level.GetClosestEmpty(hero);

            game.Level.SetTile(enemy, closeHero.point);
            var enemyMana = enemy.Stats.Mana;

            for (int i = 0; i < 10; i++)
            {
                game.GameManager.EnemiesManager.AttackIfPossible(enemy, hero);//TODO
                if (enemy.Stats.Mana < enemyMana)
                {
                    break;
                }
            }
            Assert.True(spellAttackDone);
        }
Exemplo n.º 23
0
        public void DziewannaScrollTest()
        {
            var game = CreateGame(numEnemies: 1);
            var hero = game.Hero;

            Enemy enemy  = AllEnemies.First();
            var   scroll = PrepareScroll(hero, SpellKind.Dziewanna, enemy);

            var enHealth = enemy.Stats.Health;
            var apples   = game.GameManager.CurrentNode.GetTiles <Food>().Where(i => i.Kind == FoodKind.Apple && i.EffectType == Roguelike.Effects.EffectType.Poisoned);

            Assert.AreEqual(apples.Count(), 0);
            game.GameManager.SpellManager.ApplyPassiveSpell(hero, scroll);
            Assert.True(!game.GameManager.HeroTurn);
            apples = game.GameManager.CurrentNode.GetTiles <Food>().Where(i => i.Kind == FoodKind.Apple);
            var applesCount = apples.Count();

            Assert.Greater(applesCount, 0);

            for (int i = 0; i < 10; i++)
            {
                GotoNextHeroTurn();
                if (enemy.HasLastingEffect(Roguelike.Effects.EffectType.Poisoned)
                    //|| enemy.HasLastingEffect(Roguelike.Effects.EffectType.ConsumedRawFood)
                    )
                {
                    break;
                }
            }
            Assert.True(
                enemy.HasLastingEffect(Roguelike.Effects.EffectType.Poisoned)
                //|| enemy.HasLastingEffect(Roguelike.Effects.EffectType.ConsumedRawFood)
                );
            var applesAfter = game.GameManager.CurrentNode.GetTiles <Food>().Where(i => i.Kind == FoodKind.Apple && i.EffectType == Roguelike.Effects.EffectType.Poisoned).ToList();

            Assert.Greater(applesCount, applesAfter.Count);
            Assert.Greater(enHealth, enemy.Stats.Health);
        }
Exemplo n.º 24
0
        public void TransformScrollTest()
        {
            var game = CreateGame();
            var hero = game.Hero;

            Enemy        enemy = AllEnemies.First();
            PassiveSpell spell;
            var          scroll = PrepareScroll(hero, SpellKind.Transform, enemy);

            Assert.True(game.GameManager.EnemiesManager.ShallChaseTarget(enemy, game.Hero));
            spell = game.GameManager.SpellManager.ApplyPassiveSpell(hero, scroll);
            Assert.NotNull(spell);

            Assert.True(!game.GameManager.HeroTurn);
            var le = game.Hero.LastingEffectsSet.GetByType(Roguelike.Effects.EffectType.Transform);

            Assert.NotNull(le);
            Assert.False(game.GameManager.EnemiesManager.ShallChaseTarget(enemy, game.Hero));

            GotoSpellEffectEnd(spell);

            Assert.True(game.GameManager.EnemiesManager.ShallChaseTarget(enemy, game.Hero));
        }
Exemplo n.º 25
0
        public void EnemyAttackTest()
        {
            var game = CreateGame();
            var hero = game.Hero;

            var enemy = AllEnemies.Cast <Enemy>().First();

            enemy.PrefferedFightStyle          = PrefferedFightStyle.Magic;//use spells
            enemy.ActiveManaPoweredSpellSource = new Scroll(SpellKind.FireBall);

            var mana = enemy.Stats.Mana;

            Assert.True(game.GameManager.HeroTurn);
            TryToMoveHero();

            var emptyHeroNeib = game.Level.GetEmptyNeighborhoodPoint(game.Hero, EmptyNeighborhoodCallContext.Move);
            var set           = game.Level.SetTile(enemy, emptyHeroNeib.Item1);

            Assert.True(set);

            GotoNextHeroTurn(game);
            var heroHealth = hero.Stats.Health;

            //if (heroHealth == hero.Stats.Health)
            {
                for (int i = 0; i < 10; i++)
                {
                    game.GameManager.EnemiesManager.AttackIfPossible(enemy as Enemy, hero);//TODO
                    if (enemy.Stats.Mana < mana)
                    {
                        break;
                    }
                }
            }
            Assert.Greater(heroHealth, hero.Stats.Health);
            Assert.Greater(mana, enemy.Stats.Mana);//used mana
        }
Exemplo n.º 26
0
 private void Start()
 {
     _allEnemies = _allEnemiesParent.GetComponent <AllEnemies>();
     player      = playerTransform.gameObject.GetComponent <Player>();
 }
Exemplo n.º 27
0
        public void NightBattle(sortie_battle api)
        {
            if (api.api_friendly_info != null)
            {
                var friend = api.api_friendly_info;
                FriendFleet = friend.api_ship_id
                              .Select((x, i) => new ShipInBattle
                {
                    Index      = i + 1,
                    ShipInfo   = Staff.Current.MasterData.ShipInfo[x],
                    Level      = friend.api_ship_lv[i],
                    Equipments = friend.api_Slot[i].Select(y => Staff.Current.MasterData.EquipInfo[y]).Where(y => y != null).Select(y => new EquipInBattle(y)).ToArray(),
                    Firepower  = friend.api_Param[i][0],
                    Torpedo    = friend.api_Param[i][1],
                    AA         = friend.api_Param[i][2],
                    Armor      = friend.api_Param[i][3]
                }).ToArray();
                SetHPs(FriendFleet, friend.api_nowhps, friend.api_maxhps);
                var fleet1 = Fleet1;
                Fleet1      = FriendFleet;
                FriendNight = new NightCombat(this, api.api_friendly_battle, FriendFleet, AllEnemies.ToArray());
                Fleet1      = fleet1;
            }

            if (api.api_active_deck != null)
            {
                Night = new NightCombat(this, api, NightOrTorpedo, api.api_active_deck[1] == 1 ? EnemyFleet : EnemyFleet2);
            }
            else
            {
                Night = new NightCombat(this, api, NightOrTorpedo, EnemyFleet);
            }
            EndApplyBattle();
        }
Exemplo n.º 28
0
 private void OnDisable()
 {
     AllEnemies.Remove(this);
 }
Exemplo n.º 29
0
 private void Construct(AllEnemies allEnemies)
 {
     _allEnemies = allEnemies;
 }
Exemplo n.º 30
0
 private void RevealAllEnemies(Roguelike.RoguelikeGame game)
 {
     AllEnemies.ForEach(i => i.Revealed = true);
 }