Exemplo n.º 1
0
        public void AddScreen(GameScreen screen)
        {
            screen.ScreenManager = this;

             if (IsInitialized)
             {
            screen.LoadContent();
             }

             Screens.Add(screen);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Removes a screen from the screen manager. You should normally
        /// use GameScreen.ExitScreen instead of calling this directly, so
        /// the screen can gradually transition off rather than just being
        /// instantly removed.
        /// </summary>
        public void RemoveScreen(GameScreen screen)
        {
            // If we have a graphics device, tell the screen to unload content.
             if (IsInitialized)
             {
            screen.UnloadContent();
             }

             Screens.Remove(screen);
             ScreensToUpdate.Remove(screen);
        }
Exemplo n.º 3
0
        public void CheckCollisions(ScreenManager ScreenManager, GameScreen playScreen)
        {
            // arrow on mob collision
            if (arrowList.Count > 0 && MobList.Count > 0)
            {
                foreach (Arrow arrow in arrowList)
                {
                    foreach (Entity mob in MobList)
                    {
                        if (arrow.IsAlive && mob.IsAlive && ((Mobile)arrow.GetComponent("Mobile")).BoundingBox.Intersects(((Mobile)mob.GetComponent("Mobile")).BoundingBox))
                        {
                            arrow.IsAlive = false;
                            mob.DoAction("TakeDamage", new SingleIntArgs(GameUtil.arrowDmg));
                            if (!mob.IsAlive)
                                Score++;
                            continue;
                        }
                    }
                }
                CleanArrowList();
                CleanMobList();
            }

            // mob on player collision
            if (MobList.Count > 0)
            {
                foreach (Entity mob in MobList)
                {
                    if (mob.IsAlive)
                    {
                        if (((Mobile)mob.GetComponent("Mobile")).BoundingBox.Intersects(((Mobile)player.GetComponent("Mobile")).BoundingBox))
                        {
                            mob.IsAlive = false;
                            player.DoAction("TakeDamage", new SingleIntArgs(((Mobile)mob.GetComponent("Mobile")).CollisionDamage));
                            if (!player.IsAlive)
                            {
                                ScreenManager.AddScreen(new GameOverScreen(Score));
                                ScreenManager.RemoveScreen(playScreen);  // back to title screen
                            }
                        }
                    }
                }
                CleanMobList();
            }
        }