Ejemplo n.º 1
0
    public void Search()
    {
        if (monster.playerRecentlySeen && !wait)
        {
            monster.movement.GoToDestination(monster.playerLastPos);

            if (Vector3.Distance(monster.transform.position, monster.playerLastPos) <= 0.3f)
            {
                wait = true;
                StartCoroutine(Wait(monster.waitingTime));
                nodeManager.astarPath.theList.Clear();
                monster.playerRecentlySeen = false;
                doneSearching = false;
            }
        }
        else if (!monster.playerRecentlySeen)
        {
            Navigation.Room playerRoom = GameManager.instance.GetPlayer().roomAgent.GetRecentRoom();
            //If the player is in a room after chase, search the interest nodes in that room
            if (!playerRoom.isWorld)
            {
                SearchNearbyX(playerRoom, monster.playerLost);
            }
            else
            {
                monster.playerLost = false;
                Debug.Log("Must have been the wind..");
            }
        }
    }
Ejemplo n.º 2
0
    private void SearchNearbyX(Navigation.Room room, bool condition)
    {
        // Make the list of room nodes in a random order when first initialized
        if (roomNodes.Count == 0 && !doneSearching)
        {
            List <Navigation.Node> nodesInRoom = room.interestNodes;
            while (nodesInRoom.Count > 0)
            {
                int rng = Random.Range(0, nodesInRoom.Count);
                roomNodes.Add(nodesInRoom[rng]);
                nodesInRoom.RemoveAt(rng);
            }
        }

        // Stop searching in the room if it has finished searching all the nodes
        else if (roomNodes.Count == 0 && doneSearching)
        {
            condition = false;
            Debug.Log("Must have been the wind..");
        }

        // Only search a new node if the player isn't seen/chased and if it has reached the last node
        if (nodeManager.end == true && monster.seesPlayer == false && !nodeManager.atStairs)
        {
            nodeManager.SetGoalDestination(roomNodes[0]);
            nodeManager.end = false;
            roomNodes.RemoveAt(0);
        }
    }
Ejemplo n.º 3
0
 public void SetSoundSource(Vector3 dest, Navigation.Room room)
 {
     if (!monster.heardSound)
     {
         monster.heardSound = true;
         soundSource        = dest;
         soundSourceRoom    = room;
     }
 }
Ejemplo n.º 4
0
    /// <summary>
    /// Try searching a random room
    /// </summary>
    /// <returns>False if no accessible rooms were found, True otherwise.</returns>
    public bool SearchRandomRoom()
    {
        List <Navigation.Room> shuffledRooms = GetShuffledRooms();
        bool success = false;

        while (!success && shuffledRooms.Count > 0)
        {
            Navigation.Room room = shuffledRooms[0];    // Get the topmost room
            shuffledRooms.RemoveAt(0);                  // Pop the room to not search it again
            success = SearchRoom(room);                 // Try searching the room
        }                                               // If we failed, try the next room in the list

        return(success);                                // If all searches failed, this will return false
    }
Ejemplo n.º 5
0
    /// <summary>
    /// Start searching all the interest points in a room.
    /// </summary>
    /// <param name="room">The room to search</param>
    /// <returns>True if at least one of the interest points are accessible, False otherwise.</returns>
    public bool SearchRoom(Navigation.Room room)
    {
        SetRoom(room);

        return(TryNextRoomNode());
    }
Ejemplo n.º 6
0
 /// <summary>
 /// Set a room for the monster to explore next.
 /// </summary>
 /// <param name="room">The room to explore next.</param>
 public void SetRoom(Navigation.Room room)
 {
     currentRoom = room;
     roomNodes   = nodeManager.CreateStack(nodeManager.ShuffleInterestNodes(currentRoom));
 }