public void PlayerMove(int room, ref Game1.State currentGameState) { //update player pos to room player.pos = room; if (Pits.Contains(room)) { currentGameState = Game1.State.Fell; //update state } else if (Bats.Contains(room)) { currentGameState = Game1.State.Superbat; //update state //generate new room for player to be carried to int newRoom = -1; do { newRoom = randomGenerator.Next(1, 20); } while (newRoom == room); player.pos = newRoom; } else if (wump.pos == room) //if u ran into the wumpus! { //check if already awake if (wump.awake) { currentGameState = Game1.State.WumpWin; } else //wump was sleeping { wump.awake = true; //wumpus used awaken! WumpusMove(); //EndTurn(); } } }
public MenuScreen(Rectangle window, Game1.State State) { this.State = State; this.window = window; lineHeight = 56; target = 0;//markerad är den första font = Settings.FontStandard; setAlignment(); Title = null; TargetColor = Color.White; }
public ActionItem(String name, Game1.State action) : base(name) { this.Name = name; this.Action = action; }
public void ShootArrow(ref int[] rooms, int numRooms, ref Game1.State currentGameState) { if (player.arrows > 0) { bool wumpAwoken = !wump.awake; //if wumpus was awaken this turn to ensure we perform WumpusMove before EndTurn wump.awake = true; //awaken wumpus player.arrows--; int currentArrowLocation = player.pos; int[] arrowTravellingRooms = new int[6]; //keeps track of rooms arrow will actualy travel through arrowTravellingRooms[0] = currentArrowLocation; int count = 0; Console.WriteLine("Arrow went through rooms: "); for (int i = 0; i < numRooms; i++) { int arrowRoom = rooms[i]; count++; if (getAdjacentRooms(currentArrowLocation).Contains(arrowRoom)) { int originalArrowLocation = currentArrowLocation; currentArrowLocation = arrowRoom; if (count >= 2) //check to ensure no crooked arrows { while (currentArrowLocation == arrowTravellingRooms[count - 2]) //if crooked { currentArrowLocation = getAdjacentRooms(originalArrowLocation)[randomGenerator.Next(0, 2)]; } } arrowTravellingRooms[count] = currentArrowLocation; Console.Write("" + arrowTravellingRooms[count] + " "); if (CheckWumpusHit(arrowRoom)) { currentGameState = Game1.State.PlayerWin; } else if (CheckPlayerHit(currentArrowLocation)) //lose condition { currentGameState = Game1.State.PlayerHit; } } else //pick adjacent room at random { if (count >= 2) //check to ensure no crooked arrows { int originalArrowLocation = currentArrowLocation; do { currentArrowLocation = getAdjacentRooms(originalArrowLocation)[randomGenerator.Next(0, 2)]; } while (currentArrowLocation == arrowTravellingRooms[count - 2]); } else { currentArrowLocation = getAdjacentRooms(currentArrowLocation)[randomGenerator.Next(0, 2)]; } arrowTravellingRooms[count] = currentArrowLocation; Console.Write("" + arrowTravellingRooms[count] + " "); if (CheckWumpusHit(currentArrowLocation))//win condition { currentGameState = Game1.State.PlayerWin; } //check if player hit else if (CheckPlayerHit(currentArrowLocation)) //lose condition { currentGameState = Game1.State.PlayerHit; } } } rooms = arrowTravellingRooms; //pass current arrow path //Console.WriteLine("\n" + player.arrows + " arrows left."); if (wumpAwoken && !(currentGameState == Game1.State.PlayerHit || currentGameState == Game1.State.PlayerWin || currentGameState == Game1.State.WumpWin)) { WumpusMove(); } } else //if out of arrows then wumpus wins { currentGameState = Game1.State.WumpWin; } }
public Buttons_Access(int x, int y, int width, int height, Game1.State newState, string text) : base(x, y, width, height) { this.newState = newState; this.text = text; }