Example #1
0
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
            graphics.PreferredBackBufferHeight = GameUtil.windowHeight;
            graphics.PreferredBackBufferWidth = GameUtil.windowWidth;
            this.IsMouseVisible = true;

            screenManager = new ScreenManager(this, graphics);
            Components.Add(screenManager);
            screenManager.AddScreen(new TitleScreen());
        }
Example #2
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();
            }
        }