示例#1
0
        public void addDeadPlayer(Player p)
        {
            foreach (Player t in deadPlayers)
            {
                if(p.getRow() - 2 == t.getRow() && p.getCol() == t.getCol())
                {
                    p.setThrower(true);
                    p.addPartner(t);
                    t.setThrower(true);
                    t.addPartner(p);
                }
                else if(p.getRow() + 2 == t.getRow() && p.getCol() == t.getCol())
                {
                    p.setThrower(true);
                    p.addPartner(t);
                    t.setThrower(true);
                    t.addPartner(p);
                }
                else if(p.getRow() == t.getRow() && p.getCol() - 2 == t.getCol())
                {
                    p.setThrower(true);
                    p.addPartner(t);
                    t.setThrower(true);
                    t.addPartner(p);
                }
                else if (p.getRow() == t.getRow() && p.getCol() + 2 == t.getCol())
                {
                    p.setThrower(true);
                    p.addPartner(t);
                    t.setThrower(true);
                    t.addPartner(p);
                }
            }

            deadPlayers.Add(p);
        }
示例#2
0
 public void addPartner(Player p)
 {
     partner.Add(p);
 }
示例#3
0
 public void DrawPlayer(Player player)
 {
     Vector2 drawPosition = ApplyTransformations(player.Position);
     player.Draw(spriteRenderer, drawPosition);
 }
示例#4
0
        protected void PlayingGame(GameTime gametime, MouseState mouse, KeyboardState keyboard)
        {
            turnString.SetValue(currentPlayer.getTurnsLeft());
            cameraDirection = Vector2.Zero;

            if (keyboard.IsKeyDown(Keys.Left) == true)
            {
                cameraDirection.X = -1;
            }
            else if (keyboard.IsKeyDown(Keys.Right) == true)
            {
                cameraDirection.X = 1;
            }

            if (keyboard.IsKeyDown(Keys.Up) == true)
            {
                cameraDirection.Y = -1;
            }
            else if (keyboard.IsKeyDown(Keys.Down) == true)
            {
                cameraDirection.Y = 1;
            }

            camera.Translate(cameraDirection, gametime, grid.getLevelRows(), grid.getLevelCols());

            if (mouse.LeftButton == ButtonState.Pressed && oldMouse.LeftButton == ButtonState.Released)
            {
                //if is a valid tile
                if (grid.mouseClicked(camera.TransformMouse(new Vector2( mouse.X, mouse.Y))))
                {
                    if (currentPlayer.isBridge())
                    {
                        currentPlayer = new Player();
                        currentPlayer.Position = grid.getSpawnPoint();
                        currentPlayer.setPosition(grid.getSpawnRow(), grid.getSpawnCol());
                        camera.Position = grid.getCameraCenter();
                        grid.setCurrentPlayer(currentPlayer);
                        grid.decreaseTileLevels();
                        gameTurns--;
                        if (gameTurns <= 0)
                            state =  GameState.gameover;
                    }
                    else {
                        currentPlayer.decrementTurnsLeft();
                        if (currentPlayer.getTurnsLeft() <= 0)
                        {
                            grid.addDeadPlayer(currentPlayer);
                            currentPlayer = new Player();
                            currentPlayer.Position = grid.getSpawnPoint();
                            currentPlayer.setPosition(grid.getSpawnRow(), grid.getSpawnCol());
                            camera.Position = grid.getCameraCenter();
                            grid.setCurrentPlayer(currentPlayer);
                            grid.decreaseTileLevels();
                            gameTurns--;
                            if (gameTurns <= 0)
                                state = GameState.gameover;
                        }
                    }
                }
            }
            else if (keyboard.IsKeyDown(Keys.Space) && oldKeyboard.IsKeyUp(Keys.Space))
            {

                    grid.addDeadPlayer(currentPlayer);
                    int passedTurns = currentPlayer.getTurnsLeft();
                    currentPlayer = new Player();
                    currentPlayer.Position=grid.getSpawnPoint();
                    currentPlayer.setPosition(grid.getSpawnRow(), grid.getSpawnCol());
                    camera.Position = grid.getCameraCenter();
                    grid.setCurrentPlayer(currentPlayer);
                    grid.decreaseTileLevels();
                    currentPlayer.addTurnsLeft(passedTurns);
                    gameTurns--;
                    if (gameTurns <= 0)
                        state = GameState.gameover;

            }

            if (grid.isWin())
            {
                currentLevel++;
                if (currentLevel < levels.Count)
                {
                    gameTurns = C.gameTurns;
                    grid.unloadLevel();
                    grid.initJewels(frameImageManager);
                    grid.LoadLevel(levels[currentLevel]);
                    frameImageManager.resetFrameImages();
                    currentBackground = TextureRefs.background;
                    currentFrame = TextureRefs.frame;

                }
                else
                {
                    state = GameState.victory;
                }

            }
            else if (grid.isCloseWin())
            {
                currentBackground = TextureRefs.backgroundGood;
                currentFrame = TextureRefs.frameGood;
            }
        }
示例#5
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here

            this.IsMouseVisible = true;
            state = GameState.title;
            currentPlayer = new Player();

            frameImageManager = new FrameImageManager();

            base.Initialize();
            camera = new Camera2D(spriteBatch);
            grid = new Grid(C.xMarginLeft, C.yMargin, C.tileWidth, C.tileHeight, camera);
            grid.setCurrentPlayer(currentPlayer);
            grid.initJewels(frameImageManager);
            turnString = new TurnString(TextureRefs.turnsTexture, 0, C.turnsX, C.turnsY);
        }
示例#6
0
 public void setCurrentPlayer(Player player)
 {
     currentPlayer = player;
 }