Esempio n. 1
0
        public void CheckIfCanSpawn()
        {
            int     lastEnemyDistance = 0;
            Vector2 spawnPoint        = GameState.Instance.GetVar <Vector2>("spawn_point");
            Penguin penguin           = GameState.Instance.GetVar <Penguin>("penguin");

            spawnPoint.X = penguin.GetPosition().X + GameState.Instance.GetCurrentScene().GetWindowWidth();

            if (LastSpawnedEnemy != null)
            {
                lastEnemyDistance = (int)spawnPoint.X - (int)LastSpawnedEnemy.GetPosition().X;
            }

            double spawnChance = this.SpawnRandom.NextDouble();

            if (LastSpawnedEnemy == null || lastEnemyDistance >= MAX_ENEMY_DISTANCE || (lastEnemyDistance >= MIN_ENEMY_DISTANCE && spawnChance < SPAWN_RATE))
            {
                double walrusChance = this.SpawnRandom.NextDouble();

                if (walrusChance < WALRUS_RATE)
                {
                    Walrus walrus = new Walrus(spawnPoint);
                    GameState.Instance.GetCurrentScene().AddEntity(walrus);
                    LastSpawnedEnemy = walrus;
                }
                else
                {
                    spawnPoint.Y = spawnPoint.Y - 90;
                    Seagull seagull = new Seagull(spawnPoint);
                    GameState.Instance.GetCurrentScene().AddEntity(seagull);
                    LastSpawnedEnemy = seagull;
                }
            }
        }
        public void Test()
        {
            var gary = new Walrus();
            var can  = new CannedWalrusFood();
            var food = new WalrusFood();
            var mock = new Mock <IOpensCans>();

            mock.Setup(m => m.Open(can)).Returns(food);
            var opensCans = mock.Object;
            var subject   = new FeedsWalrus(opensCans);

            subject.Feed(gary, can);

            Assert.True(gary.HasEaten(food));
        }
 public void Feed(Walrus gary, CannedWalrusFood can)
 {
     gary.AddToStomach(_opensCans.Open(can));
 }
 public void I_Have_A_Walrus()
 {
     _walrus = new Walrus();
 }