Beispiel #1
0
 internal void DrawOnShiftInterface(ShiftInterface shiftInterface)
 {
     Particles.ForEach(p => shiftInterface.drawOnOverlay(p));
     Projectiles.ForEach(p => shiftInterface.drawOnOverlay(p));
     Collectables.ForEach(c => shiftInterface.drawOnOverlay(c));
     Enemies.ForEach(e => shiftInterface.drawOnOverlay(e));
     shiftInterface.drawOnOverlay(MainPlayer);
 }
Beispiel #2
0
 internal void DrawMinimap(Camera camera)
 {
     Map.DrawMap(camera);
     Particles.ForEach(p => camera.DrawMinimap(p));
     Projectiles.ForEach(p => camera.DrawMinimap(p));
     Collectables.ForEach(c => camera.DrawMinimap(c));
     Enemies.ForEach(e => camera.DrawMinimap(e));
     camera.DrawMinimap(MainPlayer);
 }
Beispiel #3
0
 internal void DrawObjects(Camera camera)
 {
     Map.DrawTiles(camera);
     Particles.ForEach(p => camera.Draw(p));
     Projectiles.ForEach(p => camera.Draw(p));
     Collectables.ForEach(c => camera.Draw(c));
     Enemies.ForEach(e => camera.Draw(e));
     camera.Draw(MainPlayer);
 }
        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;
            }
        }
Beispiel #5
0
        internal void Update(float deltaTime)
        {
            //Update the FarseerPhysics physics
            PhysicsWorld.Step(deltaTime);

            Projectiles.ForEach(p => p.Update(deltaTime));
            Particles.ForEach(p => p.Update(deltaTime));
            Collectables.ForEach(c => c.Update(deltaTime));
            Enemies.ForEach(e => e.Update(deltaTime));

            MainPlayer.Update(deltaTime);
            Map.Update(deltaTime);
            EnemyDirector.Update(deltaTime);

            MainCamera.Update(deltaTime);

            Cull(Projectiles);
            Cull(Particles);
            Cull(Collectables);
            Cull(Enemies);
        }
Beispiel #6
0
        internal void ClearGame()
        {
            Projectiles.ForEach(p => p.WasCleared());
            Projectiles.Clear();

            Particles.ForEach(p => p.WasCleared());
            Particles.Clear();

            Collectables.ForEach(c => c.WasCleared());
            Collectables.Clear();

            Enemies.ForEach(e => e.WasCleared());
            Enemies.Clear();

            Map.ClearGame();

            EnemyDirector.ClearGame();

            MainPlayer.WasCleared();
            MainPlayer = null;

            MainCamera = null;
        }