Exemple #1
0
        public void Move(GSPlay play, Direction moveDir)
        {
            if (npcState != NPCState.Idle) return;
            direction = moveDir;

            //check for collision

            if (moveDir == Direction.North && !play.CheckCollide(gridX, gridY - 1)) gridY--;
            if (moveDir == Direction.South && !play.CheckCollide(gridX, gridY + 1)) gridY++;
            if (moveDir == Direction.East && !play.CheckCollide(gridX + 1, gridY)) gridX++;
            if (moveDir == Direction.West && !play.CheckCollide(gridX - 1, gridY)) gridX--;

            npcState = NPCState.Walk;
            UpdateTarget(); // <- do this
        }
 public static void SwitchToTitle()
 {
     currentGameState = new GSTitle();
     playState = null;
 }
 public static void SwitchToQuit()
 {
     currentGameState = new GSQuit();
     playState = null;
 }
 public static void SwitchToPlay()
 {
     if (playState == null) { playState = new GSPlay(); }
     currentGameState = playState;
 }