Ejemplo n.º 1
0
        protected override void Draw(GameTime gameTime)
        {
            List <int> tiles = new List <int>();

            spriteBatch.Begin();

            //foreach (DrawableTile tile in drawableTiles) {
            //  tile.Draw(spriteBatch);
            //}
            foreach (Character character in players)
            {
                character.Draw(spriteBatch, Statics.checkAmountResults(tiles, character.currentPos()));
                tiles.Add(character.currentPos());
            }
            foreach (SideTracker sidetracker in sideTrackers)
            {
                sidetracker.Draw(spriteBatch, players);
            }
            rollButton.Draw(spriteBatch);
            currentPlayerIcon.Draw(spriteBatch);
            diceImage.Draw(spriteBatch);
            spriteBatch.End();
            base.Draw(gameTime);
        }
Ejemplo n.º 2
0
 public BackgroundMap(Texture2D texture, GraphicsDeviceManager graphics)
 {
     this.texture = texture;
     this.pos     = Statics.getOffsetForMap(texture, graphics);
 }
Ejemplo n.º 3
0
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            //oldKeyboardState = newKeyboardState;
            //newKeyboardState = Keyboard.GetState();
            oldMouseState = mouseState;
            mouseState    = Mouse.GetState();
            spriteBatch.Begin();
            GraphicsDevice.Clear(Color.Gray);
            map.Draw(spriteBatch);

            //Statics.debugTiles(oldKeyboardState, newKeyboardState, spriteBatch, players);
            //Statics.debugSpecificChar(oldKeyboardState, newKeyboardState, spriteBatch, players[playerOnTurn], players);

            //foreach (Character character in players) {
            //	character.DrawBorders(spriteBatch, Statics.getOtherPositions(players, character));
            //}

            if (players[playerOnTurn].stepsleft > 0)
            {
                players[playerOnTurn].DrawBorders(spriteBatch, Statics.getOtherPositions(players, players[playerOnTurn]));
                //players[playerOnTurn].Update(spriteBatch, Statics.getOtherPositions(players, players[playerOnTurn]));
                //players[playerOnTurn].DrawBorders(spriteBatch, Statics.getOtherPositions(players, players[playerOnTurn]));
                players[playerOnTurn].Update(oldMouseState, mouseState, Statics.getOtherPositions(players, players[playerOnTurn]), players);
                //Statics.debugSpecificChar(oldKeyboardState, newKeyboardState, spriteBatch, players[playerOnTurn], players);
            }
            else
            {
                rollButton.Update(Content.Load <Texture2D>("rollbutton.png"));
                var tempPlayer = playerOnTurn + 1;
                if (tempPlayer == players.Count)
                {
                    tempPlayer = 0;
                }
                currentPlayerIcon.Update(players[tempPlayer].texture);
                if (rollButton.isClicked(oldMouseState, mouseState))
                {
                    playerOnTurn++;
                    if (playerOnTurn == players.Count)
                    {
                        playerOnTurn = 0;
                    }
                    players[playerOnTurn].setSteps(new Random().Next(1, 6));
                    players[playerOnTurn].setOldPos();
                    rollButton.Update(Content.Load <Texture2D>("rollbutton1.png"));
                }
            }
            int truesteps = 0;

            if ((int)players[playerOnTurn].stepsleft < players[playerOnTurn].stepsleft)
            {
                truesteps = (int)players[playerOnTurn].stepsleft + 1;
            }
            else
            {
                truesteps = (int)players[playerOnTurn].stepsleft;
            }

            diceImage.Update(truesteps);
            foreach (SideTracker sidetracker in sideTrackers)
            {
                sidetracker.Update(players);
            }

            //Console.WriteLine(players[playerOnTurn].stepsleft);
            //DeathChecker
            List <Character> toRemove = new List <Character>();

            foreach (Character player in players)
            {
                if (player.alive != true)
                {
                    toRemove.Add(player);
                }
            }
            foreach (Character player in toRemove)
            {
                players.Remove(player);
            }
            if (players.Count == 1)
            {
                Console.WriteLine(players[0].name + " has won");
                Console.Write("Press Enter to exit");
                Console.ReadLine();
                Exit();
            }
            base.Update(gameTime);
            spriteBatch.End();
        }