Example #1
0
        public override void Update(GameTime gameTime)
        {
            chest.Image.Rect    = new Rectangle((int)Math.Round(BaseGame.game.ScreenWidth / 2.4), BaseGame.game.ScreenHeight / 2, BaseGame.game.ScreenWidth / 6, BaseGame.game.ScreenHeight / 3);
            itemBook.Image.Rect = new Rectangle((int)Math.Round(BaseGame.game.ScreenWidth / 2.2), (int)Math.Round(BaseGame.game.ScreenHeight / 1.8), BaseGame.game.ScreenWidth / 13, BaseGame.game.ScreenHeight / 9);
            if (!itemBook.IsTaken)
            {
                itemBook.IsVisible = chest.IsOpen;
            }

            crate.Image.Rect          = new Rectangle((int)Math.Round(BaseGame.game.ScreenWidth / 1.6), (int)Math.Round(BaseGame.game.ScreenHeight / 2.2), BaseGame.game.ScreenWidth / 7, BaseGame.game.ScreenHeight / 4);
            itemGoldBlocks.Image.Rect = new Rectangle((int)Math.Round(BaseGame.game.ScreenWidth / 1.5), (int)Math.Round(BaseGame.game.ScreenHeight / 1.7), BaseGame.game.ScreenWidth / 13, BaseGame.game.ScreenHeight / 9);
            if (!itemGoldBlocks.IsTaken)
            {
                itemGoldBlocks.IsVisible = crate.IsOpen;
            }

            fileScene.Update(gameTime);

            State["chest_open"] = chest.IsOpen;
            State["book_taken"] = itemBook.IsTaken;

            State["crate_open"]        = crate.IsOpen;
            State["gold_blocks_taken"] = itemGoldBlocks.IsTaken;

            base.Update(gameTime);
        }
Example #2
0
        public override void Update(GameTime gameTime)
        {
            MouseState newMouseState = Mouse.GetState();

            State["grid"] = JArray.FromObject(grid);

            fileScene.Update(gameTime);

            // update the blocks size
            blockWidth  = BaseGame.game.ScreenWidth / 8;
            blockHeight = (int)Math.Round(BaseGame.game.ScreenHeight / 4.5);

            // update the grid offset
            gridOffX = (int)Math.Round(BaseGame.game.ScreenWidth / 3.5);
            gridOffY = (int)Math.Round(BaseGame.game.ScreenHeight / 5.7);

            // edit grid
            int mouseRow = (int)Math.Floor((float)(newMouseState.Y - gridOffY) / blockHeight);
            int mouseCol = (int)Math.Floor((float)(newMouseState.X - gridOffX) / blockWidth);

            if (mouseRow >= 0 && mouseRow < grid.GetLength(0))
            {
                if (mouseCol >= 0 && mouseCol < grid.GetLength(1))
                {
                    int tile = grid[mouseRow, mouseCol];
                    BaseGame.game.ShowSpecialCursor = true;
                    if (tile == 0)
                    {
                        BaseGame.game.CursorToShow = Assets.AddCursor;
                    }
                    else if (tile == 1)
                    {
                        BaseGame.game.CursorToShow = Assets.RemoveCursor;
                    }

                    if (newMouseState.LeftButton == ButtonState.Pressed && oldMouseState.LeftButton == ButtonState.Released)
                    {
                        if (tile == 0)
                        {
                            if (BaseGame.game.Inventory.SelectedBlock >= 0 && BaseGame.game.Inventory.SelectedBlock < BaseGame.game.Inventory.Items.Count)
                            {
                                if (BaseGame.game.Inventory.Items.ElementAt(BaseGame.game.Inventory.SelectedBlock).Key.Id == "gold_block")
                                {
                                    if (BaseGame.game.Inventory.Items.ElementAt(BaseGame.game.Inventory.SelectedBlock).Value >= 1)
                                    {
                                        grid[mouseRow, mouseCol] = 1;
                                        BaseGame.game.Inventory.RemoveItem(BaseGame.game.Inventory.Items.ElementAt(BaseGame.game.Inventory.SelectedBlock).Key, 1);
                                    }
                                }
                            }
                        }
                        else if (tile == 1)
                        {
                            grid[mouseRow, mouseCol] = 0;
                            BaseGame.game.Inventory.AddItem("gold_block", 1);
                        }
                    }
                }
            }

            // verify if the grid is filled correctly
            if (grid[0, 0] == 1 && grid[1, 0] == 1 && grid[2, 0] == 1 && grid[2, 1] == 1 && grid[0, 2] == 1 && grid[1, 2] == 1 && grid[2, 2] == 1)
            {
                objCompleted = true;
                BaseGame.game.Player.ScenesState[BaseGame.game.Player.Level] = BaseGame.game.Scenes.Find(item => item.Identifier == BaseGame.game.Player.Level).State;
                BaseGame.game.Player.Level = "cage_4";
                BaseGame.game.ChangeScene("cage_4");
                DataManager.WriteFile("player.json", BaseGame.game.Player);
                BaseGame.game.ShowSpecialCursor = false;
            }

            oldMouseState = newMouseState;

            base.Update(gameTime);
        }
Example #3
0
        public override void Update(GameTime gameTime)
        {
            fileScene.Update(gameTime);

            base.Update(gameTime);
        }