예제 #1
0
 public virtual void OnSpawn(SpawnPoint spawnPoint)
 {
 }
예제 #2
0
 public void SpawnPlayer(SpawnPoint spawnPoint, bool reset = true, bool nextFrame = true)
 {
     StartCoroutine(SpawnPlayerCo(spawnPoint, reset, nextFrame));
 }
예제 #3
0
 public SpawnPoint GetSpawnPoint(string name)
 {
     return(SpawnPoint.Find(name));
 }
예제 #4
0
        IEnumerator SpawnPlayerCo(SpawnPoint spawnPoint, bool reset, bool nextFrame)
        {
            if (nextFrame)
            {
                yield return(null);
            }

            Profiler.BeginSample("SpawnPlayerCo");

            lastPlayerSpawnPoint = spawnPoint;

            if (!playerPrefab)
            {
                Debug.LogError("Missing player prefab");
                yield break;
            }

            if (!playerController)
            {
                playerController = Instantiate(playerPrefab);
            }

            if (!playerCamera)
            {
                playerCamera = Instantiate(playerCameraPrefab);
            }

            for (var i = GameAgent.GetEnumerator(); i.MoveNext();)
            {
                if (i.Current)
                {
                    i.Current.OnBeforeSpawnPlayer(reset);
                }
            }

            var camera          = spawnPoint.camera ? spawnPoint.camera : defaultCamera;
            var cameraTransform = camera.transform;

            cameraTransform.parent =
                playerCamera.eyeTransform ? playerCamera.eyeTransform : playerCamera.transform;

            cameraTransform.localPosition = Vector3.zero;
            cameraTransform.localRotation = Quaternion.identity;
            cameraTransform.localScale    = Vector3.one;

            playerCamera.camera           = camera;
            playerController.playerCamera = playerCamera;

            if (audioTransformsUpdater != null)
            {
                audioTransformsUpdater(playerController.transform, camera.transform);
            }

            spawnPoint.Spawn(playerController, reset);

            for (var i = GameAgent.GetEnumerator(); i.MoveNext();)
            {
                if (i.Current)
                {
                    i.Current.OnAfterSpawnPlayer(spawnPoint, reset);
                }
            }

            Profiler.EndSample();
        }
예제 #5
0
 public virtual void OnSpawn(SpawnPoint spawnPoint, bool reset)
 {
 }
예제 #6
0
 public virtual void OnAfterSpawnPlayer(SpawnPoint point, bool reset)
 {
 }