Пример #1
0
        public void TestAdd()
        {
            //Arrange
            CustomMaths maths = new CustomMaths(6, 5);

            //Act
            int result = maths.Add();

            //Assert
            Assert.AreEqual <int>(11, result);
        }
Пример #2
0
    private void KillNeighbours(Enemy enemy)
    {
        EnemyKilled?.Invoke();
        // remove the enemy reference from the grid array
        activeEnemies[enemy.Index.x, enemy.Index.y] = null;

        // enable firing for the closest enemy to the player in the collumn
        for (int y = 0; y < settings.Levels[settings.CurrentLevel].GridRows; y++)
        {
            if (activeEnemies[enemy.Index.x, y] != null)
            {
                activeEnemies[enemy.Index.x, y].CurrentlyShooting = true;
                break;
            }
        }

        matchedEnemies.Add(enemy);

        int remainingNeighbours = 0;

        foreach (Enemy matched in matchedEnemies)
        {
            remainingNeighbours += GetNeighbours(matched).Count();
        }

        if (remainingNeighbours <= 0)
        {
            // adding fibonacci points
            PointManager.Instance.AddScore(matchedEnemies.Count * CustomMaths.CalculateFibonacci(matchedEnemies.Count) * 10);
            matchedEnemies.Clear();

            if (ActiveEnemies() <= 0)
            {
                SetState?.Invoke(GameState.NextLevel);
            }

            SetActiveCollums();
            return;
        }

        // get all valid neighbours and destroy them
        foreach (Enemy neighbour in GetNeighbours(enemy))
        {
            neighbour.Die();
        }

        SetActiveCollums();
    }