private PlayerSpawnController getPlayerSpawnController()
    {
        if (playerSpawnController == null)
        {
            GameObject gObj = GameObject.Find("NetworkController");
            playerSpawnController = (PlayerSpawnController)gObj.GetComponent<PlayerSpawnController>();

        }
        return playerSpawnController;
    }
Exemple #2
0
    public Transform[] spawnPoints;                                     // Location of the available spawnpoints

    void Awake()
    {
        spawnguy = this;                                        // Set the static reference
//		tag = "PlayerSpawner";			// Set an object with this script to the PlayerSpawner tag

        // THIS IS AN EASY WAY TO CHANGE WHICH GUY IS USED IN THE ENTIRE GAME
//		GuyPrefab =  (GameObject)Resources.Load("GuyCharacterPrefab_Physics_Resource") as GameObject;
//		GuyPrefab =  (GameObject)Resources.Load("GuyCharacterPrefab_Pixel_Resource") as GameObject;

        if (spawnPoints.Length == 0)                    // If there are no spawn points added to the array, the object itself becomes the default spawnpoint
        {
            spawnPoints = new Transform[] { gameObject.transform }
        }
        ;
    }

    void Start()
    {
        if (GameController.control.LoadingFile())         // If loading from file - spawn at saved position and reset trigger
        {
            GameController.control.GuyLocation = Instantiate(GuyPrefab, new Vector3(GameController.control.LoadedX, GameController.control.LoadedY, 0), transform.rotation) as GameObject;
            GameController.control.SetLoadingFile(false);
        }
        else                                                                  // This spawns the character usually when switching scenes
        {
            if (GameController.control.RememberIndex() >= spawnPoints.Length) // If the index is too high for the number of spawn points - error and set to default spawn index = 0;
            {
                print("ERROR in navigateRoom.cs object - Looking for Index (" + GameController.control.RememberIndex() + "). Array max index = (" + ((int)(spawnPoints.Length) - 1) + ")");
                GameController.control.SetRememberIndex(0);
            }

            Vector3 spawnPosition = spawnPoints[GameController.control.RememberIndex()].position;
            spawnPosition.z = 0;
            GameController.control.GuyLocation = Instantiate(GuyPrefab, spawnPosition, Quaternion.identity) as GameObject;

            GameController.control.SetRememberIndex(0);
        }
    }
}
Exemple #3
0
    // Start is called before the first frame update
    void Start()
    {
        Instance = this;
        PossibleNavMeshPoints = NavMesh.CalculateTriangulation().vertices;
        _playerSpawn          = FindObjectOfType <PlayerSpawnController>();
        _uiControllers        = FindObjectOfType <Canvas>().GetComponentsInChildren <IUiController>();
        _npcSpawns            = FindObjectsOfType <SpawnBaseController <INpc> >();

        // notify manager that player have been already spawned
        _playerSpawn.OnSpawn.AddListener((c) =>
        {
            PlayerController = (IPlayerController)c;
            PlayerController.OnDie.AddListener((ch) => _deathPopup.SetActive(true));
            SpawnNpcs();

            // start job of UI controllers
            StartAllUi();
        });

        // spawn player
        _playerSpawn.Spawn();
    }
Exemple #4
0
 void Awake()
 {
     player = GameObject.FindWithTag("Player");
     playerSpawnCTRL = GameObject.FindGameObjectWithTag("BidaSpawnCTRL").GetComponent<PlayerSpawnController>();
 }