예제 #1
0
 public void MovePlayer(int dest)           //function to move player
 {
     wump.move(map.getAdjacent(wump.room)); //move wump at start of turn
     view.transform.position = new Vector3(9, 2, 0);
     player.room             = dest;
     int[] temp = map.getAdjacent(dest);
     for (int i = 0; i < temp.Length; i++)
     {
         doors[i].GetComponent <Door>().doorNum = temp[i];
     }
     CheckRoom();        //check if stepped in hazards
     Warnings();         //show warnings
     currentNum.text = "Current Room: " + player.room;
 }
예제 #2
0
    public void MovePlayer(int dest)                                 //function to move player
    {
        if (map.isAdjacent(player.room, dest))                       //check adjacent
        {
            wump.move(map.getAdjacent(wump.room));                   //move wump at start of turn
            rooms[player.room].GetComponent <Room>().player = false; //move player
            rooms[dest].GetComponent <Room>().player        = true;
            player.room = dest;
            CheckRoom();    //check if stepped in hazards
            Warnings();     //show warnings
        }

        else
        {
            StartCoroutine(Announce("Please choose an adjacent room"));
        }
    }
예제 #3
0
        //update on the character's status
        public static void Update(ref bool play, ref Map cave, ref Player player, ref Wumpus wumpus,
                                  ref SuperBats bats, ref Pit pitA, ref Pit pitB)
        {
            //wumpus logic
            if (wumpus.Awake)
            {
                wumpus.move(cave);

                if (wumpus.Room == player.Room)
                {
                    player.Alive = false;
                    play         = false;
                }
            }

            //player logic
            if (player.Alive)
            {
                bool turn = true;
                //continues checking input until it is valid
                while (turn)
                {
                    //gets input
                    String move = Console.ReadLine();

                    //parses input
                    //if the player chose to move
                    if (string.Compare(move, 0, "M", 0, 1, true) == 0)
                    {
                        //prompts for room number
                        Console.WriteLine("Tunnels connect to " + cave.Rooms[cave.Cloc[0]].Adj[0] + " " + cave.Rooms[cave.Cloc[0]].Adj[1] +
                                          " " + cave.Rooms[cave.Cloc[0]].Adj[2]);
                        Console.WriteLine("What room would you like to move to?");
                        move = Console.ReadLine();

                        //parses the room number
                        int room;
                        int.TryParse(move, out room);
                        bool valid = true;

                        //checks input against the adjacent rooms
                        for (int i = 0; i < 3; i++)
                        {
                            if (room == cave.Rooms[cave.Cloc[0]].Adj[i])
                            {
                                player.move(ref cave, room);
                                break;
                            }
                            else if (i == 2)
                            {
                                Console.WriteLine("Not possible");
                                Console.WriteLine("Please (S)hoot or (M)ove");
                                valid = false;
                            }
                        }
                        if (!valid)
                        {
                            continue;
                        }
                    }
                    else if (string.Compare(move, 0, "S", 0, 1, true) == 0)
                    {
                        player.shoot(ref cave, ref wumpus);
                    }
                    else
                    {
                        //invalid input, ask for reentry of input
                        Console.WriteLine("Invalid Input");
                        Console.WriteLine("Please (S)hoot or (M)ove");
                        continue;
                    }
                    turn = false;
                }
            }
            else
            {
                Console.WriteLine("The Wumpus ate you! Game Over!");
            }
        }