Exemple #1
0
 static void Main(string[] args)
 {
     using (MinerGame game = new MinerGame())
     {
         game.Run();
     }
 }
Exemple #2
0
 public GameObject(MinerGame game, int posX, int posY)
     : this(game)
 {
     this.PosX = posX;
     this.PosY = posY;
     this.Position = new Vector2(posX * Field.FieldWidth, posY * Field.FieldHeight);
 }
Exemple #3
0
        public GameScene(MinerGame game)
            : base(game)
        {
            font = game.Content.Load<SpriteFont>(FONT_ASSET);

            GenerateLevel(this.Game.GameState.CurrentLevel);
        }
Exemple #4
0
 public Fuel(MinerGame game, int amount, int posX, int posY)
     : base(game, posX, posY)
 {
     this.Amount = amount;
     this.sprite = game.Content.Load<Texture2D>(ASSET_NAME);
     this.LifeTime = 30000;
     this.RemainingLifeTime = this.LifeTime;
 }
 public Indestructibility(MinerGame game, int posX, int posY)
     : base(game, posX, posY)
 {
     this.sprite = game.Content.Load<Texture2D>(ASSET_NAME);
     this.TotalUsageTime = 10000;
     this.RemainingUsageTime = this.TotalUsageTime;
     this.LifeTime = 20000;
     this.RemainingLifeTime = this.LifeTime;
 }
Exemple #6
0
 public Laser(MinerGame minerGame, int x, int y)
     : base(minerGame, x, y)
 {
     this.sprite = minerGame.Content.Load<Texture2D>(ASSET_NAME);
     this.TotalUsageTime = 15000;
     this.RemainingUsageTime = this.TotalUsageTime;
     this.LifeTime = 15000;
     this.RemainingLifeTime = this.LifeTime;
 }
Exemple #7
0
 public Bullet(MinerGame game, Vector2 position, ShootDirection dir)
     : base(game, position)
 {
     this.Width = width;
     this.Height = height;
     this.sprite = game.Content.Load<Texture2D>(ASSET_NAME);
     int one = (dir == ShootDirection.right) ? 1 : -1;
     velocity.X = one * 250.0f;
 }
Exemple #8
0
 public Field(MinerGame game, int posX, int posY)
     : base(game, posX, posY)
 {
     this.sprite = game.Content.Load<Texture2D>(ASSET_NAME);
     this.Position = new Vector2(posX * FieldWidth, posY * FieldHeight);
     this.IsRevealed = false;
     this.IsEmpty = false;
     this.IsDigged = false;
 }
Exemple #9
0
 /// <summary>
 /// Konstruktor
 /// </summary>
 /// <param name="game">Referencja do obiektu gry.</param>
 /// <param name="posX">Pozycja X na mapie.</param>
 /// <param name="posY">Pozycja Y na mapie.</param>
 public DoubleJump(MinerGame game, int posX, int posY)
     : base(game, posX, posY)
 {
     this.sprite = game.Content.Load<Texture2D>(ASSET_NAME);
     this.TotalUsageTime = 15000;
     this.RemainingUsageTime = this.TotalUsageTime;
     this.Used = false;
     this.LifeTime = 15000;
     this.RemainingLifeTime = this.LifeTime;
 }
Exemple #10
0
 public Laser(MinerGame game)
 {
     this.field = new Field();
     this.sprite = game.Content.Load<Texture2D>(ASSET_NAME);
     this.TotalUsageTime = 15000;
     this.RemainingUsageTime = this.TotalUsageTime;
     this.LifeTime = 15000;
     this.RemainingLifeTime = this.LifeTime;
     this.game = game;
 }
Exemple #11
0
 public Miner(MinerGame game)
     : base(game)
 {
     this.Suit = new Nanosuit();
     this.ExpToNextLevel = 100;
     this.Width -= 10.0f;
     this.Height -= 10.0f;
     this.sprite = game.Content.Load<Texture2D>(ASSET_NAME);
     this.JumpImpulse = JUMP_SPEED;
     LastMoveDirection = ShootDirection.right;
     this.currentBonus = new Laser(this.game);
 }
Exemple #12
0
 public Enemy(MinerGame game, Vector2 position, float speed, int jumpOnHitPoints, int laserHitPoints, int expGained, string assetName)
     : base(game, position)
 {
     this.speed = speed;
     this.JumpOnHitPoints = jumpOnHitPoints;
     this.LaserHitPoints = laserHitPoints;
     this.ExprienceGained = expGained;
     this.sprite = game.Content.Load<Texture2D>(assetName);
     this.LastMoveDirection = (new Random().Next() % 2 == 0) ? Direction.left : Direction.right;
     this.Width -= 10.0f;
     this.Height -= 10.0f;
 }
Exemple #13
0
        public StartMenu(MinerGame game)
            : base(game)
        {
            PlayerName = "";

            font = this.Game.Content.Load<SpriteFont>(FONT_ASSET);

            MenuItems.Add(new MenuItem(this, new Rectangle(Game.GraphicsDevice.Viewport.Width / 2 - MENU_ITEM_WIDTH / 2,
                    Game.GraphicsDevice.Viewport.Height / 2 - 150, MENU_ITEM_WIDTH, MENU_ITEM_HEIGHT), LABEL_TITLE, null));

            MenuItems[currentlySelected].Selected = false;
        }
        public HighScoreMenu(MinerGame game, MenuScene previous)
            : base(game, previous)
        {
            this.HighScores = HighScores.GetInstance();
            HighScores.HighScoreList.Add(new Result() { PlayerName = "asd", Score = 10 });
            Rectangle labelRec = new Rectangle(Game.GraphicsDevice.Viewport.Width / 2 - MENU_ITEM_WIDTH / 2,
                Game.GraphicsDevice.Viewport.Height / 2 - 300, MENU_ITEM_WIDTH, MENU_ITEM_HEIGHT);

            label = new MenuItem(this, labelRec, LABEL_BEST_SCORES, null);

            scoresList = new ListMenuItem(this, new Vector2(label.Boundaries.Left, label.Boundaries.Bottom + 50), this.HighScores);
            scoresList = new ListMenuItem(this, new Rectangle(labelRec.X, labelRec.Y + labelRec.Height + 50, labelRec.Width, labelRec.Height * 2), this.HighScores);
        }
Exemple #15
0
        public Stage(MinerGame game, StageLevel level, Vector2 size, IEnumerable <GameObject> objects)
            : base(game)
        {
            Level = level;
            Size  = size;

            CollisionSolver = new CollisionSolver(this, game);

            GameObjects = objects.ToList();
            Game.Components.Add(CollisionSolver);

            foreach (var o in GameObjects)
            {
                Game.Components.Add(o);
            }

            Player = (Player)Game.Components.Single(o => o is Player);
        }
Exemple #16
0
        public SettingsMenu(MinerGame game, MenuScene previous)
            : base(game, previous)
        {
            int start = 50;
            int pos = start;
            label = new MenuItem(this, new Rectangle(LEFT_MARGIN, pos, MENU_ITEM_WIDTH, MENU_ITEM_HEIGHT), LABEL_CONTROLS, null);
            pos += MENU_ITEM_HEIGHT + GAP * 2;
            MenuItems.Add(new MenuItem(this, new Rectangle(LEFT_MARGIN, pos, MENU_ITEM_WIDTH, MENU_ITEM_HEIGHT),
                String.Format("{0}: {1}", KEY_UP, this.Game.Settings.Controls.Up.ToString()), (menu) =>
                    {
                        ChangeKey();
                    }));
            pos += MENU_ITEM_HEIGHT + GAP;
            MenuItems.Add(new MenuItem(this, new Rectangle(LEFT_MARGIN, pos, MENU_ITEM_WIDTH, MENU_ITEM_HEIGHT),
                String.Format("{0}: {1}", KEY_DOWN, this.Game.Settings.Controls.Down.ToString()), (menu) =>
                    {
                        ChangeKey();
                    }));
            pos += MENU_ITEM_HEIGHT + GAP;
            MenuItems.Add(new MenuItem(this, new Rectangle(LEFT_MARGIN, pos, MENU_ITEM_WIDTH, MENU_ITEM_HEIGHT),
                String.Format("{0}: {1}", KEY_LEFT, this.Game.Settings.Controls.Left.ToString()), (menu) =>
                    {
                        ChangeKey();
                    }));
            pos += MENU_ITEM_HEIGHT + GAP;
            MenuItems.Add(new MenuItem(this, new Rectangle(LEFT_MARGIN, pos, MENU_ITEM_WIDTH, MENU_ITEM_HEIGHT),
                String.Format("{0}: {1}", KEY_RIGHT, this.Game.Settings.Controls.Right.ToString()), (menu) =>
                    {
                        ChangeKey();
                    }));
            pos += MENU_ITEM_HEIGHT + GAP;
            MenuItems.Add(new MenuItem(this, new Rectangle(LEFT_MARGIN, pos, MENU_ITEM_WIDTH, MENU_ITEM_HEIGHT),
                String.Format("{0}: {1}", KEY_ACTION, this.Game.Settings.Controls.Action.ToString()), (menu) =>
                    {
                        ChangeKey();
                    }));

            MenuItems[currentlySelected].Selected = true;
        }
        public DifficultyMenu(MinerGame game, MenuScene previous)
            : base(game, previous)
        {
            MenuItems.Add(new MenuItem(this, new Rectangle(Game.GraphicsDevice.Viewport.Width / 2 - MENU_ITEM_WIDTH / 2,
                    Game.GraphicsDevice.Viewport.Height / 2 - 300, MENU_ITEM_WIDTH, MENU_ITEM_HEIGHT), EASY, (menu) =>
                    {
                        // Following line protects new menu from instantly reading previous key as pressed.
                        GameScene newScene = new GameScene(this.Game)
                        {
                            OldKeyState = this.CurrentKeyState
                        };
                        menu.Game.GameState.Difficulty = DifficultyLevel.Easy;
                        MenuManager.GetInstance().CurrentMenu = newScene;

                    }));
            MenuItems.Add(new MenuItem(this, new Rectangle(Game.GraphicsDevice.Viewport.Width / 2 - MENU_ITEM_WIDTH / 2,
                    Game.GraphicsDevice.Viewport.Height / 2 - 150, MENU_ITEM_WIDTH, MENU_ITEM_HEIGHT), MEDIUM, (menu) =>
                    {
                        // Following line protects new menu from instantly reading previous key as pressed.
                        GameScene newScene = new GameScene(this.Game)
                        {
                            OldKeyState = this.CurrentKeyState
                        };
                        menu.Game.GameState.Difficulty = DifficultyLevel.Medium;
                        MenuManager.GetInstance().CurrentMenu = newScene;
                    }));
            MenuItems.Add(new MenuItem(this, new Rectangle(Game.GraphicsDevice.Viewport.Width / 2 - MENU_ITEM_WIDTH / 2,
                    Game.GraphicsDevice.Viewport.Height / 2, MENU_ITEM_WIDTH, MENU_ITEM_HEIGHT), HARD, (menu) =>
                    {
                        // Following line protects new menu from instantly reading previous key as pressed.
                        GameScene newScene = new GameScene(this.Game)
                        {
                            OldKeyState = this.CurrentKeyState
                        };
                        menu.Game.GameState.Difficulty = DifficultyLevel.Hard;
                        MenuManager.GetInstance().CurrentMenu = newScene;
                    }));
            MenuItems[currentlySelected].Selected = true;
        }
Exemple #18
0
 public PauseMenu(MinerGame game)
     : this(game, null)
 {
 }
Exemple #19
0
 public GameObject(MinerGame game, Vector2 position)
     : this(game)
 {
     this.Position = position;
 }
Exemple #20
0
 public SolidRock(MinerGame game, int posX, int posY)
     : base(game, posX, posY)
 {
     this.sprite = game.Content.Load<Texture2D>(ASSET_NAME);
 }
Exemple #21
0
 public Enemy(MinerGame game, int posX, int posY, float speed, int jumpOnHitPoints, int laserHitPoints, int expGained, string assetName)
     : this(game, new Vector2(posX * Field.FieldWidth, posY * Field.FieldHeight), speed, jumpOnHitPoints, laserHitPoints, expGained, assetName)
 {
 }
Exemple #22
0
 /// <summary>
 /// Konstruktor przypisujący pole na mapie.
 /// </summary>
 /// <param name="game">Referencja na obiekt gry.</param>
 /// <param name="posX">Pozycja poziomo (X)</param>
 /// <param name="posY">Pozycja pionowo (Y)</param>
 public BonusItem(MinerGame game, int posX, int posY)
     : base(game, posX, posY)
 {
     this.field = game.GameState.Map.Fields[posX][posY];
 }
Exemple #23
0
 /// <summary>
 /// Tworzy bonus losowego typu.
 /// </summary>
 /// <param name="minerGame">Referencja do obiektu gry.</param>
 /// <param name="x">Pozycja X na mapie</param>
 /// <param name="y">Pozycja Y na mapie</param>
 /// <returns>Bonus losowego typu</returns>
 public static BonusItem CreateRandomBonus(MinerGame minerGame, int x, int y)
 {
     Random rand = new Random();
     switch (rand.Next(6))
     {
         case 0:
             return new Fuel(minerGame, 35, x, y);
         case 1:
             return new DoubleJump(minerGame, x, y);
         case 2:
             return new Indestructibility(minerGame, x, y);
         case 3:
             return new KeyLocalizer(minerGame, x, y);
         case 4:
             return new Laser(minerGame, x, y);
         case 5:
             return new MoreEnemies(minerGame, x, y);
         default:
             return null;
     }
 }
Exemple #24
0
 public Ufolowca(MinerGame game, Vector2 position)
     : base(game, position, SPEED, JUMP_ON_HITS, LASER_HITS, EXP_GAINED, ASSET_NAME)
 {
     timeToSwitch = rand.Next(MAX_MOVE_SWITCH_TIME);
     JumpImpulse = JUMP_SPEED;
 }
Exemple #25
0
 public MenuScene(MinerGame game, MenuScene previous)
     : this(game)
 {
     previousMenu = previous;
 }
Exemple #26
0
 public Key(MinerGame minerGame, int x, int y)
     : base(minerGame, x, y)
 {
     this.sprite = game.Content.Load<Texture2D>(ASSET_NAME);
 }
Exemple #27
0
 public Field(MinerGame game, int posX, int posY, bool isEmpty)
     : this(game, posX, posY)
 {
     this.IsEmpty = isEmpty;
 }
Exemple #28
0
 public Kosmojopek(MinerGame game, Vector2 position)
     : base(game, position, SPEED, JUMP_ON_HITS, LASER_HITS, EXP_GAINED, ASSET_NAME)
 {
     timeToSwitch = rand.Next(MAX_MOVE_SWITCH_TIME);
 }
Exemple #29
0
        public PauseMenu(MinerGame game, MenuScene previous)
            : base(game, previous)
        {
            int start = -400;
            int pos = start;
            MenuItems.Add(new MenuItem(this, new Rectangle(Game.GraphicsDevice.Viewport.Width / 2 - MENU_ITEM_WIDTH / 2,
                    Game.GraphicsDevice.Viewport.Height / 2 + pos, MENU_ITEM_WIDTH, MENU_ITEM_HEIGHT), RESUME, (menu) =>
                    {
                        this.GoBack();
                    }));
            pos += MENU_ITEM_HEIGHT + GAP;
            MenuItems.Add(new MenuItem(this, new Rectangle(Game.GraphicsDevice.Viewport.Width / 2 - MENU_ITEM_WIDTH / 2,
                    Game.GraphicsDevice.Viewport.Height / 2 + pos, MENU_ITEM_WIDTH, MENU_ITEM_HEIGHT), SAVE_GAME, (menu) =>
                    {
                        using (FileStream fs = new FileStream("save1.xml", FileMode.Create))
                        {
                            XmlSerializer xml = new XmlSerializer(typeof(GameState));
                            xml.Serialize(fs, this.Game.GameState);
                        }
                    }));
            pos += MENU_ITEM_HEIGHT + GAP;
            MenuItems.Add(new MenuItem(this, new Rectangle(Game.GraphicsDevice.Viewport.Width / 2 - MENU_ITEM_WIDTH / 2,
                    Game.GraphicsDevice.Viewport.Height / 2 + pos, MENU_ITEM_WIDTH, MENU_ITEM_HEIGHT), LOAD_GAME, (menu) =>
                    {
                        System.Windows.Forms.OpenFileDialog openFile = new System.Windows.Forms.OpenFileDialog();

                        if (openFile.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                        {
                            try
                            {
                                this.Game.Content.Unload();

                                using (Stream stream = openFile.OpenFile())
                                {
                                    XmlSerializer xml = new XmlSerializer(typeof(GameState));
                                    this.Game.GameState = (GameState)xml.Deserialize(stream);
                                    this.Game.GameState.Miner.Suit = new Nanosuit();
                                    stream.Close();
                                }

                                this.Game.GameState.Miner.game = this.Game;

                                foreach (var item in this.Game.GameState.Enemies)
                                {
                                    item.game = this.Game;
                                }

                                foreach (var item in this.Game.GameState.Bullets)
                                {
                                    item.game = this.Game;
                                }

                                this.Game.Content.Load<SpriteFont>("general");
                                this.Game.Content.Load<Texture2D>(Kosmojopek.ASSET_NAME);
                                this.Game.Content.Load<Texture2D>(Ufolowca.ASSET_NAME);
                                this.Game.Content.Load<Texture2D>(WladcaLaserowejDzidy.ASSET_NAME);
                                //this.Content.Load<Texture2D>(PoteznySultan.ASSET_NAME);
                                this.Game.Content.Load<Texture2D>(Miner.ASSET_NAME);
                                //this.Content.Load<Texture2D>(CosmicMatter.ASSET_NAME);
                                this.Game.Content.Load<Texture2D>(DoubleJump.ASSET_NAME);
                                this.Game.Content.Load<Texture2D>(Field.ASSET_NAME);
                                this.Game.Content.Load<Texture2D>(Fuel.ASSET_NAME);
                                this.Game.Content.Load<Texture2D>(Indestructibility.ASSET_NAME);
                                this.Game.Content.Load<Texture2D>(Key.ASSET_NAME);
                                this.Game.Content.Load<Texture2D>(KeyLocalizer.ASSET_NAME);
                                this.Game.Content.Load<Texture2D>(Laser.ASSET_NAME);
                                this.Game.Content.Load<Texture2D>(MoreEnemies.ASSET_NAME);
                                this.Game.Content.Load<Texture2D>(SolidRock.ASSET_NAME);
                                this.Game.Content.Load<Texture2D>(SpaceGate.ASSET_NAME);
                                this.Game.Content.Load<Texture2D>(TitanRock.ASSET_NAME);
                                this.Game.Content.Load<Texture2D>(Bullet.ASSET_NAME);

                                this.Game.GameState.Miner.LoadContent();

                                foreach (var item in this.Game.GameState.Enemies)
                                {
                                    item.LoadContent();
                                }

                                foreach (var item in this.Game.GameState.Bullets)
                                {
                                    item.LoadContent();
                                }

                                foreach (var item in this.Game.GameState.Map.Fields)
                                {
                                    foreach (var field in item)
                                    {
                                        field.game = this.Game;
                                        field.LoadContent();
                                    }
                                }

                                GameScene newScene = new GameScene(this.Game)
                                {
                                    OldKeyState = this.CurrentKeyState
                                };
                                MenuManager.GetInstance().CurrentMenu = newScene;
                            }
                            catch (Exception exc)
                            {
                                System.Windows.Forms.MessageBox.Show(ERROR_READING_FILE + exc.Message);
                            }
                        }
                    }));
            pos += MENU_ITEM_HEIGHT + GAP;
            MenuItems.Add(new MenuItem(this, new Rectangle(Game.GraphicsDevice.Viewport.Width / 2 - MENU_ITEM_WIDTH / 2,
                    Game.GraphicsDevice.Viewport.Height / 2 + pos, MENU_ITEM_WIDTH, MENU_ITEM_HEIGHT), INSTRUCTIONS, (menu) =>
                    {

                    }));
            pos += MENU_ITEM_HEIGHT + GAP;
            MenuItems.Add(new MenuItem(this, new Rectangle(Game.GraphicsDevice.Viewport.Width / 2 - MENU_ITEM_WIDTH / 2,
                    Game.GraphicsDevice.Viewport.Height / 2 + pos, MENU_ITEM_WIDTH, MENU_ITEM_HEIGHT), SETTINGS, (menu) =>
                    {
                        SettingsMenu newMenu = new SettingsMenu(this.Game, this)
                        {
                            OldKeyState = this.CurrentKeyState
                        };
                        MenuManager.GetInstance().CurrentMenu = newMenu;
                    }));
            pos += MENU_ITEM_HEIGHT + GAP;
            MenuItems.Add(new MenuItem(this, new Rectangle(Game.GraphicsDevice.Viewport.Width / 2 - MENU_ITEM_WIDTH / 2,
                    Game.GraphicsDevice.Viewport.Height / 2 + pos, MENU_ITEM_WIDTH, MENU_ITEM_HEIGHT), EXIT_MAIN_MENU, (menu) =>
                    {
                        MainMenu newMenu = new MainMenu(this.Game)
                        {
                            OldKeyState = this.CurrentKeyState
                        };
                        MenuManager.GetInstance().CurrentMenu = newMenu;
                    }));
            pos += MENU_ITEM_HEIGHT + GAP;
            MenuItems.Add(new MenuItem(this, new Rectangle(Game.GraphicsDevice.Viewport.Width / 2 - MENU_ITEM_WIDTH / 2,
                    Game.GraphicsDevice.Viewport.Height / 2 + pos, MENU_ITEM_WIDTH, MENU_ITEM_HEIGHT), EXIT_GAME, (menu) =>
                    {
                        menu.Game.ExitGame();
                    }));
            MenuItems[currentlySelected].Selected = true;
        }
 public HighScoreMenu(MinerGame game)
     : this(game, null)
 {
 }
Exemple #31
0
 public GameObject(MinerGame game)
     : this()
 {
     this.game = game;
 }