Пример #1
0
        public void Init()
        {
            if (initPlayer2 == false && _twoplayer == true)
            {
                Objects.Add(GetPlayer2());
                initPlayer2 = true;
            }

            if (initdone == false)
            {
                Objects.Add(GetPlayer());
                Objects.Add(GetEnemy());
                initdone = true;
            }

            if (initdone2 == true) //make sure only strong enemy spawn at the start of game
            {
                Enemy spawnedEnemy = SpawnMoreEnemy();
                Objects.Add(spawnedEnemy);
                SpawnedEnemies.Add(spawnedEnemy);
            }

            if (initdone2 == false)
            {
                Frame inventory = new Frame("inventory", "Inventory", new Location(10, 10), 150, 150);
                inventory.AddButton(Color.DarkRed, Color.Red, inventory.Close);
                GuiEnvironment.GetRenderer().RegisterFrame(inventory);

                Frame help = new Frame("help", "Help and Controls", new Location(250, 10), 150, 250);
                help.AddButton(Color.DarkRed, Color.Red, help.Close);
                help.AddButton(Color.DarkBlue, Color.RoyalBlue, inventory.Toggle);
                GuiEnvironment.GetRenderer().RegisterFrame(help);
                initdone2 = true;
            }
        }
Пример #2
0
        /// <summary>
        /// Get the current renderer to draw the game
        /// </summary>
        public void Draw()
        {
            GuiEnvironment.GetRenderer().RenderWindow();

            MetaHandler.ShowPanels(); // IA - Make the panel visible

            // IA - Single Player Mode only.
            if (_gameStates.Peek() == GameState.SinglePlayerMode)
            {
                MetaHandler.DisplayHungerInformation();                             // IA - Show the hunger level progress bar and messages
                MetaHandler.DisplayTimer();                                         // IA - Make the timer visible
                MetaHandler.DisplayGameLevel();                                     // IA - Display the game level
                MetaHandler.DisplayAmmunitionLevel(_player.Weapon);                 // IA - Display info about amminutions (type and amount)
                MetaHandler.DisplayEnemiesInfo(SpawnedEnemies, EnemiesToBeRemoved); // IA - Display how many enemies have been destroyed.
                MetaHandler.DrawFoodField(GetPlayer().Inventory);
            }

            // IA - Only display the worth of minerals while the game runs.
            if (_gameStates.Peek() == GameState.SinglePlayerMode)
            {
                MetaHandler.DisplayRate(GetPlayer().Inventory.GetTotalValue(), GetPlayer().Inventory);
            }

            // IA - Two Players Mode only.
            if (_gameStates.Peek() == GameState.TwoPlayerMode)
            {
                MetaHandler.DisplayTwoPlayersInstructions();
                MetaHandler.DisplaySinglePlayerWeaponInfo(_player, "Player 1", 15);
                MetaHandler.DisplaySinglePlayerWeaponInfo(_player2, "Player 2", 85);
                MetaHandler.DisplayRate(_player.Inventory.GetTotalValue(), _player.Inventory, "PLAYER 1", -190, Color.Wheat);
                MetaHandler.DisplayRate(_player2.Inventory.GetTotalValue(), _player2.Inventory, "PLAYER 2", 10, Color.Yellow);
            }
        }
Пример #3
0
 protected QuestionWidget(IValue value, QuestionStatement statement, GuiEnvironment guiEnvironment)
     : base(guiEnvironment)
 {
     this.Statement = statement;
     this.Value     = value;
     this.Dependencies.UnionWith(statement.GetDependencies());
 }
Пример #4
0
 /// <summary>
 /// Gets the current game GuiEnvironment - constructs a
 /// <see cref="T:Escapade.gui.GuiEnvironment"/> object if a current one doesn't exist
 /// </summary>
 /// <returns>The GuiEnvironment</returns>
 public static GuiEnvironment GetEnvironment()
 {
     if (_environment == null)
     {
         _environment = GuiEnvironment.GetEnvironment();
     }
     return(_environment);
 }
Пример #5
0
        public FormWidget CreateFormWidget(FormStatement structureNode)
        {
            var interpreter = new Interpreter();
            var environment = new GuiEnvironment();
            var form        = interpreter.Visit(structureNode, environment);

            return((FormWidget)form);
        }
Пример #6
0
        protected Widget(GuiEnvironment environment)
        {
            this.Environment  = environment;
            this.Controls     = new List <Control>();
            this.Dependencies = new SortedSet <string>();

            this.Environment.RegisterObserver(this);
            this.isVisible = true;
        }
Пример #7
0
 public DatePickerWidget(
     DateValue value,
     QuestionStatement statement,
     GuiEnvironment guiEnvironment,
     WidgetStyle style)
     : base(value, statement, guiEnvironment)
 {
     this.CreateControls(statement, style);
 }
Пример #8
0
 public CheckBoxWidget(
     BooleanValue value,
     QuestionStatement statement,
     GuiEnvironment guiEnvironment,
     WidgetStyle style)
     : base(value, statement, guiEnvironment)
 {
     this.CreateControls(statement, style);
 }
Пример #9
0
 public TextFieldWidget(
     IValue value,
     QuestionStatement statement,
     GuiEnvironment guiEnvironment,
     WidgetStyle style)
     : base(value, statement, guiEnvironment)
 {
     this.CreateControls(statement, style);
 }
Пример #10
0
 public ValidatedTextFieldWidget(
     IValue value,
     IValidator <string> validator,
     QuestionStatement statement,
     GuiEnvironment guiEnvironment,
     WidgetStyle style)
     : base(value, statement, guiEnvironment, style)
 {
     this.validator = validator;
 }
Пример #11
0
 public FormWidget(
     FormStatement statement,
     GuiEnvironment guiEnvironment,
     IList <Widget> controls)
     : base(guiEnvironment)
 {
     this.Statement = statement;
     foreach (var control in controls)
     {
         this.AddControls(control.Controls);
     }
 }
Пример #12
0
        public VisibilityWidget(
            IfStatement statement,
            GuiEnvironment guiEnvironment,
            IList <Widget> ifControls,
            IList <Widget> elseControls)
            : base(guiEnvironment)
        {
            this.Statement    = statement;
            this.IfControls   = ifControls;
            this.ElseControls = elseControls;
            this.AddToControls(ifControls);
            this.AddToControls(elseControls);

            this.Dependencies.UnionWith(statement.GetDependencies());
            this.EvaluateVisibility();
        }
Пример #13
0
        public void RunApplication(FormStatement structureNode)
        {
            var interpreter = new Interpreter();
            var env         = new GuiEnvironment();
            var form        = interpreter.Visit(structureNode, env);
            var window      = new Window();
            var view        = new ListView();

            foreach (var control in form.Controls)
            {
                view.Items.Add(control);
            }

            window.Content = view;
            var application = new Application();

            application.Run(window);
        }
Пример #14
0
        /// <summary>
        /// Initialisation stage 3 - initialise objects dependent on stage 1 + 2
        /// </summary>
        public void PostInit()
        {
            Frame         helpFrame = GuiEnvironment.GetRenderer().GetFrame("help");
            List <string> helpList  = new List <string>();

            helpList.Add("~ Frame help ~");
            helpList.Add("- The red button closes a frame.");
            helpList.Add("- The blue button toggles the");
            helpList.Add("inventory frame");
            helpList.Add(" ");
            helpList.Add("~ Mouse Controls ~");
            helpList.Add("B, LShift+B(P1), P, P+J(P2): Buy Weapon");
            helpList.Add("F(P1), K(P2): On rock tile - dig rock");
            helpList.Add("G(P1), L(P2): On air - place rock");
            helpList.Add("V(P1), O(P2): Shoot ");
            helpList.Add("~ Keyboard controls ~");
            helpList.Add("E - Generate new minerals");
            helpList.Add("M - Generate a new map(removed)");
            helpList.Add("H - Toggle this frame");
            helpList.Add("Q - Toggle inventory frame");
            helpList.Add("Esc - Quit game");

            helpFrame.Content = helpList;
        }
Пример #15
0
        /// <summary>
        /// Update the game based on events, objects and other things
        /// </summary>
        public void Update()
        {
            randomhit++;

            //spawn rate - jeremy
            if (randomhit >= 200)
            {
                Init();
                randomhit = 0;
            }

            // JY- detect projectile hits, projectile and enemies will be deleted
            foreach (Entity e in Objects)
            {
                if (e is Projectile)
                {
                    if (_twoplayer)
                    {
                        if (_player.PlayerHitbyProjectile((Projectile)e))
                        {
                            _gameStates.Push(GameState.PlayerTwoWins);
                            ControlGameState();
                        }
                        else if (_player2.PlayerHitbyProjectile((Projectile)e))
                        {
                            _gameStates.Push(GameState.PlayerOneWins);
                            ControlGameState();
                        }
                    }
                    else
                    {
                        if (_player.PlayerHitbyProjectile((Projectile)e))
                        {
                            _gameStates.Push(GameState.SinglePlayerEndGame);
                            ControlGameState();
                        }
                    }

                    if (SpawnedEnemies.Count > 0)
                    {
                        foreach (Enemy _e in SpawnedEnemies)
                        {
                            if (((Projectile)e).CheckObjectHit(_world, _e))
                            {
                                ProjectilesToBeRemoved.Add((Projectile)e);
                            }

                            if (_e.CheckHit((Projectile)e))
                            {
                                EnemiesToBeRemoved.Add(_e);
                            }
                        }
                    }
                    else
                    if (((Projectile)e).CheckObjectHit(_world, _enemy))
                    {
                        ProjectilesToBeRemoved.Add((Projectile)e);
                    }
                }
                //JY- detect enemies hitting players
                else if (e is Enemy)
                {
                    if (_twoplayer)
                    {
                        if (_player.PlayerHitbyEnemy((Enemy)e))
                        {
                            _gameStates.Push(GameState.PlayerTwoWins);
                            //_player.PlayerHitbyEnemy((Enemy)e) = !_player.PlayerHitbyEnemy((Enemy)e);
                            ControlGameState();
                        }
                        else if (_player2.PlayerHitbyEnemy((Enemy)e))
                        {
                            _gameStates.Push(GameState.PlayerOneWins);
                            ControlGameState();
                        }
                    }
                    else
                    {
                        if (_player.PlayerHitbyEnemy((Enemy)e))
                        {
                            _gameStates.Push(GameState.SinglePlayerEndGame);
                            ControlGameState();
                        }
                    }
                }
            }

            foreach (Projectile p in ProjectilesToBeRemoved)
            {
                Objects.Remove(p);
            }

            foreach (Enemy en in EnemiesToBeRemoved)
            {
                if (SpawnedEnemies.Contains(en))
                {
                    SpawnedEnemies.Remove(en);
                }

                Objects.Remove(en);
            }

            foreach (Entity obj in Objects)
            {
                obj.Update();
            }


            //PLAYER 1 MINE/BUILD ROCKS INPUT
            //mine rocks/minerals right
            // IA - Rewritten the mining logic for the single player
            if (SwinGame.KeyDown(KeyCode.FKey))
            {
                int x = _player.Location.X;
                int y = _player.Location.Y;
                if (SwinGame.KeyReleased(KeyCode.DKey))
                {
                    x += 1;
                }
                else if (SwinGame.KeyReleased(KeyCode.SKey))
                {
                    y += 1;
                }
                else if (SwinGame.KeyReleased(KeyCode.AKey))
                {
                    x -= 1;
                }
                else if (SwinGame.KeyReleased(KeyCode.WKey))
                {
                    y -= 1;
                }

                try
                {
                    if (_world.Map[x, y].Type == TileType.Rock && x != 0 && y != 0 && x != 52 && y != 36)
                    {
                        _world.Map[x, y].Type = TileType.Air;
                        if (_world.Map[x, y].Mineral != null)
                        {
                            GetPlayer().Inventory.AddItem(_world.Map[x, y].Mineral);
                        }
                    }
                }
                catch (Exception e)
                {
                    // IA - in case of an exception, force the reassignment of x and y using the player's location.
                    x = _player.Location.X;
                    y = _player.Location.Y;
                }
            }

            //build rock right
            if (SwinGame.KeyDown(KeyCode.DKey) && SwinGame.KeyDown(KeyCode.GKey))
            {
                //GetEnvironment ().HandleGuiEvent (GuiEvent.MouseRight, new Location (_player.Location.X+1, _player.Location.Y));
                GetEnvironment();
                int   x = (_player.Location.X + 1);
                int   y = (_player.Location.Y);
                Frame f = GuiEnvironment.GetRenderer().GetActiveFrame(new Location(x, y));
                if (f == null)
                {
                    Tile tile = _world.Map[x, y];
                    if (tile.Type == TileType.Air)
                    {
                        _world.Map[x, y] = new Tile(TileType.Rock);
                    }
                }
            }

            //build rock left
            if (SwinGame.KeyDown(KeyCode.AKey) && SwinGame.KeyDown(KeyCode.GKey))
            {
                //GetEnvironment ().HandleGuiEvent (GuiEvent.MouseRight, new Location (_player.Location.X+1, _player.Location.Y));
                GetEnvironment();
                int   x = (_player.Location.X - 1);
                int   y = (_player.Location.Y);
                Frame f = GuiEnvironment.GetRenderer().GetActiveFrame(new Location(x, y));
                if (f == null)
                {
                    Tile tile = _world.Map[x, y];
                    if (tile.Type == TileType.Air)
                    {
                        _world.Map[x, y] = new Tile(TileType.Rock);
                    }
                }
            }

            //build rock up
            if (SwinGame.KeyDown(KeyCode.WKey) && SwinGame.KeyDown(KeyCode.GKey))
            {
                //GetEnvironment ().HandleGuiEvent (GuiEvent.MouseRight, new Location (_player.Location.X+1, _player.Location.Y));
                GetEnvironment();
                int   x = (_player.Location.X);
                int   y = (_player.Location.Y - 1);
                Frame f = GuiEnvironment.GetRenderer().GetActiveFrame(new Location(x, y));
                if (f == null)
                {
                    Tile tile = _world.Map[x, y];
                    if (tile.Type == TileType.Air)
                    {
                        _world.Map[x, y] = new Tile(TileType.Rock);
                    }
                }
            }

            //build rock down
            if (SwinGame.KeyDown(KeyCode.SKey) && SwinGame.KeyDown(KeyCode.GKey))
            {
                //GetEnvironment ().HandleGuiEvent (GuiEvent.MouseRight, new Location (_player.Location.X+1, _player.Location.Y));
                GetEnvironment();
                int   x = (_player.Location.X);
                int   y = (_player.Location.Y + 1);
                Frame f = GuiEnvironment.GetRenderer().GetActiveFrame(new Location(x, y));
                if (f == null)
                {
                    Tile tile = _world.Map[x, y];
                    if (tile.Type == TileType.Air)
                    {
                        _world.Map[x, y] = new Tile(TileType.Rock);
                    }
                }
            }

            if (_twoplayer == true)
            {
                //PLAYER 2 MINE/BUILD ROCKS INPUT
                //mine rocks/minerals right
                if (SwinGame.KeyDown(KeyCode.KKey))
                {
                    int i = _player2.Location.X;
                    int j = _player2.Location.Y;
                    if (SwinGame.KeyReleased(KeyCode.RightKey))
                    {
                        i += 1;
                    }
                    else if (SwinGame.KeyReleased(KeyCode.DownKey))
                    {
                        j += 1;
                    }
                    else if (SwinGame.KeyReleased(KeyCode.LeftKey))
                    {
                        i -= 1;
                    }
                    else if (SwinGame.KeyReleased(KeyCode.UpKey))
                    {
                        j -= 1;
                    }

                    try
                    {
                        if (_world.Map[i, j].Type == TileType.Rock && i != 0 && j != 0 && i != 52 && j != 36)
                        {
                            _world.Map[i, j].Type = TileType.Air;
                            if (_world.Map[i, j].Mineral != null)
                            {
                                _player2.Inventory.AddItem(_world.Map[i, j].Mineral);
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        // IA - in case of an exception, force the reassignment of x and y using the player's location.
                        i = _player2.Location.X;
                        j = _player2.Location.Y;
                    }
                }

                //build rock right
                if (SwinGame.KeyDown(KeyCode.RightKey) && SwinGame.KeyDown(KeyCode.LKey))
                {
                    //GetEnvironment ().HandleGuiEvent (GuiEvent.MouseRight, new Location (_player.Location.X+1, _player.Location.Y));
                    GetEnvironment();
                    int   x = (_player2.Location.X + 1);
                    int   y = (_player2.Location.Y);
                    Frame f = GuiEnvironment.GetRenderer().GetActiveFrame(new Location(x, y));
                    if (f == null)
                    {
                        Tile tile = _world.Map[x, y];
                        if (tile.Type == TileType.Air)
                        {
                            _world.Map[x, y] = new Tile(TileType.Rock);
                        }
                    }
                }

                //build rock left
                if (SwinGame.KeyDown(KeyCode.LeftKey) && SwinGame.KeyDown(KeyCode.LKey))
                {
                    //GetEnvironment ().HandleGuiEvent (GuiEvent.MouseRight, new Location (_player.Location.X+1, _player.Location.Y));
                    GetEnvironment();
                    int   x = (_player2.Location.X - 1);
                    int   y = (_player2.Location.Y);
                    Frame f = GuiEnvironment.GetRenderer().GetActiveFrame(new Location(x, y));
                    if (f == null)
                    {
                        Tile tile = _world.Map[x, y];
                        if (tile.Type == TileType.Air)
                        {
                            _world.Map[x, y] = new Tile(TileType.Rock);
                        }
                    }
                }

                //build rock up
                if (SwinGame.KeyDown(KeyCode.UpKey) && SwinGame.KeyDown(KeyCode.LKey))
                {
                    //GetEnvironment ().HandleGuiEvent (GuiEvent.MouseRight, new Location (_player.Location.X+1, _player.Location.Y));
                    GetEnvironment();
                    int   x = (_player2.Location.X);
                    int   y = (_player2.Location.Y - 1);
                    Frame f = GuiEnvironment.GetRenderer().GetActiveFrame(new Location(x, y));
                    if (f == null)
                    {
                        Tile tile = _world.Map[x, y];
                        if (tile.Type == TileType.Air)
                        {
                            _world.Map[x, y] = new Tile(TileType.Rock);
                        }
                    }
                }

                //build rock down
                if (SwinGame.KeyDown(KeyCode.DownKey) && SwinGame.KeyDown(KeyCode.LKey))
                {
                    //GetEnvironment ().HandleGuiEvent (GuiEvent.MouseRight, new Location (_player.Location.X+1, _player.Location.Y));
                    GetEnvironment();
                    int   x = (_player2.Location.X);
                    int   y = (_player2.Location.Y + 1);
                    Frame f = GuiEnvironment.GetRenderer().GetActiveFrame(new Location(x, y));
                    if (f == null)
                    {
                        Tile tile = _world.Map[x, y];
                        if (tile.Type == TileType.Air)
                        {
                            _world.Map[x, y] = new Tile(TileType.Rock);
                        }
                    }
                }
            }

            if (SwinGame.KeyDown(KeyCode.EscapeKey))
            {
                Environment.Exit(0);
            }

            //PLAYER 1 KEY MOVEMENT/WEAPON INPUT
            //changes player input using keyboard - jeremy
            //Allowed player to attack,
            //else if if used so that the player can spam attack and move at the same time - Jonathan

            // buy weapon
            if (SwinGame.KeyDown(KeyCode.VKey) && SwinGame.KeyDown(KeyCode.WKey))
            {
                if (_player.Weapon != null && _player.Weapon.Ammunition > 0)
                {
                    _player.DeployWeapon(AttackDirection.Up);
                    Objects.Add(_player.Weapon.Projectile);
                }
            }
            else if (SwinGame.KeyDown(KeyCode.WKey) && _world.Map[_player.Location.X, _player.Location.Y - 1].Type != TileType.Rock && _player.Location.Y - 1 != 0)
            {
                _player.Location.Y -= 1;
            }

            if (SwinGame.KeyDown(KeyCode.VKey) && SwinGame.KeyDown(KeyCode.SKey))
            {
                if (_player.Weapon != null && _player.Weapon.Ammunition > 0)
                {
                    _player.DeployWeapon(AttackDirection.Down);
                    Objects.Add(_player.Weapon.Projectile);
                }
            }
            else if (SwinGame.KeyDown(KeyCode.SKey) && _world.Map[_player.Location.X, _player.Location.Y + 1].Type != TileType.Rock && _player.Location.Y + 1 != 36)
            {
                _player.Location.Y += 1;
            }

            if (SwinGame.KeyDown(KeyCode.VKey) && SwinGame.KeyDown(KeyCode.AKey))
            {
                if (_player.Weapon != null && _player.Weapon.Ammunition > 0)
                {
                    _player.DeployWeapon(AttackDirection.Left);
                    Objects.Add(_player.Weapon.Projectile);
                }
            }
            else if (SwinGame.KeyDown(KeyCode.AKey) && _world.Map[_player.Location.X - 1, _player.Location.Y].Type != TileType.Rock && _player.Location.X - 1 != 0)
            {
                _player.Location.X -= 1;
            }

            if (SwinGame.KeyDown(KeyCode.VKey) && SwinGame.KeyDown(KeyCode.DKey))
            {
                if (_player.Weapon != null && _player.Weapon.Ammunition > 0)
                {
                    _player.DeployWeapon(AttackDirection.Right);
                    Objects.Add(_player.Weapon.Projectile);
                }
            }
            else if (SwinGame.KeyDown(KeyCode.DKey) && _world.Map[_player.Location.X + 1, _player.Location.Y].Type != TileType.Rock && _player.Location.X + 1 != 52)
            {
                _player.Location.X += 1;
            }

            if (SwinGame.KeyTyped(KeyCode.BKey) && !SwinGame.KeyDown(KeyCode.LeftShiftKey))
            {
                if (GetPlayer().Inventory.GetMineralPoints() >= 20)
                {
                    if (_player.Weapon == null)
                    {
                        _player.BuyWeapon(_player.Location, WeaponType.Normal);
                    }
                    if (_player.Weapon.Type == WeaponType.Super)
                    {
                        _player.BuyWeapon(_player.Location, WeaponType.Normal);
                    }
                    _player.Weapon.Ammunition += 30;
                    // Objects.Add(_player.Weapon);
                    _player.Inventory.DeductMineralPoints(WeaponType.Normal);
                }
            }

            if (SwinGame.KeyTyped(KeyCode.BKey) && SwinGame.KeyDown(KeyCode.LeftShiftKey))
            {
                if (GetPlayer().Inventory.GetMineralPoints() >= 30)
                {
                    if (_player.Weapon == null)
                    {
                        _player.BuyWeapon(_player.Location, WeaponType.Super);
                    }
                    if (_player.Weapon.Type == WeaponType.Normal)
                    {
                        _player.BuyWeapon(_player.Location, WeaponType.Super);
                    }
                    _player.Weapon.Ammunition += 30;
                    // Objects.Add(_player.Weapon);
                    _player.Inventory.DeductMineralPoints(WeaponType.Super);
                }
            }

            if (_twoplayer == true)
            {
                //PLAYER 2 MOVEMENT/WEAPON KEY INPUT
                if (SwinGame.KeyDown(KeyCode.OKey) && SwinGame.KeyDown(KeyCode.UpKey))
                {
                    if (_player2.Weapon != null && _player2.Weapon.Ammunition > 0)
                    {
                        _player2.DeployWeapon(AttackDirection.Up);
                        Objects.Add(_player2.Weapon.Projectile);
                    }
                }
                else if (SwinGame.KeyDown(KeyCode.UpKey) && _world.Map[_player2.Location.X, _player2.Location.Y - 1].Type != TileType.Rock && _player2.Location.Y - 1 != 0)
                {
                    _player2.Location.Y -= 1;
                }

                if (SwinGame.KeyDown(KeyCode.OKey) && SwinGame.KeyDown(KeyCode.DownKey))
                {
                    if (_player2.Weapon != null && _player2.Weapon.Ammunition > 0)
                    {
                        _player2.DeployWeapon(AttackDirection.Down);
                        Objects.Add(_player2.Weapon.Projectile);
                    }
                }
                else if (SwinGame.KeyDown(KeyCode.DownKey) && _world.Map[_player2.Location.X, _player2.Location.Y + 1].Type != TileType.Rock && _player2.Location.Y + 1 != 36)
                {
                    _player2.Location.Y += 1;
                }

                if (SwinGame.KeyDown(KeyCode.OKey) && SwinGame.KeyDown(KeyCode.LeftKey))
                {
                    if (_player2.Weapon != null && _player2.Weapon.Ammunition > 0)
                    {
                        _player2.DeployWeapon(AttackDirection.Left);
                        Objects.Add(_player2.Weapon.Projectile);
                    }
                }
                else if (SwinGame.KeyDown(KeyCode.LeftKey) && _world.Map[_player2.Location.X - 1, _player2.Location.Y].Type != TileType.Rock && _player2.Location.X - 1 != 0)
                {
                    _player2.Location.X -= 1;
                }

                if (SwinGame.KeyDown(KeyCode.OKey) && SwinGame.KeyDown(KeyCode.RightKey))
                {
                    if (_player2.Weapon != null && _player2.Weapon.Ammunition > 0)
                    {
                        _player2.DeployWeapon(AttackDirection.Right);
                        Objects.Add(_player2.Weapon.Projectile);
                    }
                }
                else if (SwinGame.KeyDown(KeyCode.RightKey) && _world.Map[_player2.Location.X + 1, _player2.Location.Y].Type != TileType.Rock && _player2.Location.X + 1 != 52)
                {
                    _player2.Location.X += 1;
                }

                // Player 2 buys a weapon
                if (SwinGame.KeyTyped(KeyCode.PKey) && !SwinGame.KeyDown(KeyCode.JKey))
                {
                    if (_player2.Inventory.GetMineralPoints() >= 20)
                    {
                        if (_player2.Weapon == null)
                        {
                            _player2.BuyWeapon(_player.Location, WeaponType.Normal);
                        }
                        if (_player2.Weapon.Type == WeaponType.Super)
                        {
                            _player2.BuyWeapon(_player.Location, WeaponType.Normal);
                        }
                        _player2.Weapon.Ammunition += 20;
                        // Objects.Add(_player.Weapon);
                        _player2.Inventory.DeductMineralPoints(WeaponType.Normal);
                    }
                }


                if (SwinGame.KeyTyped(KeyCode.PKey) && SwinGame.KeyDown(KeyCode.JKey))
                {
                    if (_player2.Inventory.GetMineralPoints() >= 30)
                    {
                        if (_player2.Weapon == null)
                        {
                            _player2.BuyWeapon(_player.Location, WeaponType.Super);
                        }
                        if (_player2.Weapon.Type == WeaponType.Normal)
                        {
                            _player2.BuyWeapon(_player.Location, WeaponType.Super);
                        }
                        _player2.Weapon.Ammunition += 40;
                        // Objects.Add(_player.Weapon);
                        _player2.Inventory.DeductMineralPoints(WeaponType.Super);
                    }
                }
            }

            // Accept the spawning of minerals on demand - Useful for demonstration purposes only (to make it easier to collect mineral points, buy food, weapons, etc.)
            // if (SwinGame.KeyTyped(KeyCode.EKey))
            // {
            // GetWorld().PutMinerals();
            // }

            // IA - After computing everything, determine when/if the level should be increased.
            ControlLevels();
            MetaHandler.DisplayFoodExchange(GetPlayer().Inventory);

            // IA - End the game when the player's energy level reaches 0.
            if (MetaHandler.GetEnergyLevel() == 0)
            {
                EndGame("you_died");
            }
        }