/// <summary>
        /// Places the player and all NPCs on the map randomly.
        /// </summary>
        private void CreateHumans()
        {
            Vector3 coords3D = new Vector3(PlayerSpawnCoordinates[0], PlayerSpawnCoordinates[1], 0);

            //  Place the player
            Player = Instantiate(playerPrefab.GetComponent <Player>(),
                                 coords3D,
                                 Quaternion.identity);
            // give the player a unique id
            Player.myID = 0;
            // Set player status to inactive. Will get avtivated when we leave the house
            Player.gameObject.SetActive(false);
            PlayerHouse playerHouseScript = playerHouse.GetComponent <PlayerHouse>();

            // Set the player inside the house
            playerHouseScript.NotifyPlayerIsClose(true);
            playerHouseScript.NotifyPlayerInside(true);
            // Set the player var of the house
            playerHouseScript.setPlayer(Player.gameObject);

            //  Place the NPCs in the grid
            for (int i = 1; i <= npcNumber; i++)
            {
                NPCs.Add(Instantiate(npcPrefab.GetComponent <NPC>(),
                                     randomGridForHumans.RandomCoords[i],
                                     Quaternion.identity));
                // give all npcs a unique id
                NPCs[i - 1].myID = i + 1;
            }

            //  Infect one
            NPCs[Mathf.RoundToInt(npcNumber / 2f)].SetInitialCondition(NPC.EXPOSED);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Places the player and all NPCs on the map
        /// </summary>
        private void CreateHumans()
        {
            // place player near their house
            Vector3 coords = new Vector2(-3.43f, -2.34f);

            //  Place the player
            Player = Instantiate(playerPrefab.GetComponent <Player>(),
                                 coords,
                                 Quaternion.identity);
            // give the player a unique id
            Player.myID = 0;
            // Set player status to inactive. Will get avtivated when we leave the house
            Player.gameObject.SetActive(false);

            PlayerHouse playerHouseScript = PlayerHouse.GetComponent <PlayerHouse>();

            // Set the player inside the house
            playerHouseScript.NotifyPlayerIsClose(true);
            playerHouseScript.NotifyPlayerInside(true);
            // Set the player var of the house
            playerHouseScript.setPlayer(Player.gameObject);


            //  Place the NPCs in the grid
            for (int i = 0; i < npcNumber; i++)
            {
                NPCs.Add(Instantiate(npcPrefab.GetComponent <NPC>(),
                                     randomGridForHumans.RandomCoords[i],
                                     Quaternion.identity));
                // give all npcs a unique id
                NPCs[i].myID = i + 1;
            }

            //  Infect one them.
            NPCs[Mathf.RoundToInt(npcNumber / 2f)].SetInitialCondition(NPC.EXPOSED);

            //  Place the NPC_AIs in the grid
            for (int i = 0; i < npcAINumber; i++)
            {
                NPC_AIs.Add(Instantiate(npcAIPrefab.GetComponent <NPC_AI>(),
                                        randomGridForHumans.RandomCoords[i],
                                        Quaternion.identity));
                // give all npcs with ai a unique id
                NPC_AIs[i].myID = npcNumber + 1 + i;
                // give them a unique layer so that they are allowed on bridges
                NPC_AIs[i].gameObject.layer = LayerMask.NameToLayer("NPC_AI");
            }
            //  Infect one them.
            NPC_AIs[Mathf.RoundToInt(npcAINumber / 2f)].SetInitialCondition(NPC.EXPOSED);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Places the player and all NPCs on the map randomly.
        /// </summary>
        private void CreateHumans()
        {
            Vector3 coords3D = new Vector3(PlayerSpawnCoordinates[0], PlayerSpawnCoordinates[1], 0);

            //  Place the player
            Player = Instantiate(playerPrefab.GetComponent <Player>(),
                                 coords3D,
                                 Quaternion.identity);
            // Activate player. Otherwise it does not show (i done really know why. Probably has smth todo with the house)
            Player.gameObject.SetActive(true);

            PlayerHouse playerHouseScript = playerHouse.GetComponent <PlayerHouse>();

            // Set the player var of the house
            playerHouseScript.setPlayer(Player.gameObject);
            // The player is not close and not at home
            // NOTE: Setting these explicitely is not really necessary, since they are already set for the house.
            playerHouseScript.NotifyPlayerIsClose(false);
            playerHouseScript.NotifyPlayerInside(false);

            // give the player a unique id
            Player.myID = npcNumber;

            //  Place the NPCs in the grid
            for (int i = 1; i <= npcNumber; i++)
            {
                NPCs.Add(Instantiate(npcPrefab.GetComponent <NPC>(),
                                     randomGridForHumans.RandomCoords[i],
                                     Quaternion.identity));
                // give all npcs a unique id
                NPCs[i - 1].myID = i - 1;
            }

            //  Infect one
            NPCs[Mathf.RoundToInt(npcNumber / 2f)].SetInitialCondition(NPC.EXPOSED);
        }