Beispiel #1
0
        private void LeaveFreeze()
        {
            if (!TimeFreezeStarted)
            {
                return;
            }
            TimeFreezeStarted = false;
            Time.timeScale    = PreviousTimeScale;
            if (TimeStampDiff > 0 && PlayerGhostManager.Instance.EnabledGhostCnt <= MaxGhostNum)
            {
                TimeStateManager.Instance.Rewind(TimeStampDiff, false);
                PlayerGhostManager.Instance.VerifyAndConfirmCurrentGhost();
                PlayerController.Instance.ResetAllTimeStat();
                PlayerController.Instance.RebuildTimeRegister();

                GameObject timeCastFXInstance = Instantiate(TimeCastFXGO, PlayerController.Instance.transform.position, Quaternion.identity);
                timeCastFXInstance.GetComponent <LightCastFX>().PostSpawn();
                ManagedTimeUtilities.RegisterEntireGO(timeCastFXInstance);
            }
            else
            {
                PlayerGhostManager.Instance.DestroyCurrentGhost();
                PlayerController.Instance.RebuildTimeRegister();
                TimeStateManager.Instance.BackToNow();
            }
        }
 private void Update()
 {
     remainNxtTime -= Time.deltaTime;
     if (remainNxtTime <= 0f)
     {
         GameObject go = Instantiate(BulletPrefab, BulletSpawnPoint.position, Quaternion.identity);
         ManagedTimeUtilities.RegisterEntireGO(go);
         go.GetComponent <Rigidbody2D>().velocity = new Vector2(ShootLeft ? -BulletVelocity : BulletVelocity, 0f);
         remainNxtTime = ShootInterval;
     }
 }
        IEnumerator AsyncLoadScene(string sceneName)
        {
            Time.timeScale = 1f;//Sometimes scene will be reloaded from a freeze state
            if (TimeStateManager.Instance != null)
            {
                TimeStateManager.Instance.UnregisterAll();
            }
            yield return(SceneManager.LoadSceneAsync(sceneName));

            if (SoundManager.Instance == null)
            {
                Instantiate(SoundManagerPrefab, Vector3.zero, Quaternion.identity);
            }
            else
            {
                SoundManager.Instance.ClearAllSFX();
            }

            Instantiate(TimeStateManagerPrefab, Vector3.zero, Quaternion.identity);
            TimeSelectionHelperInt = TimeStateManager.Instance.GetComponent <TimeSelectionHelper>();
            Instantiate(GhostManagerPrefab, Vector3.zero, Quaternion.identity);

            GameObject go = GameObject.Find("/SceneRoot");

            if (go == null)
            {
                Log.Error("No Scene Root in Scene!");
                yield break;
            }
            CurrentSceneRoot = go.GetComponent <SceneRoot>();
            CurrentSceneRoot.RegisterAllSceneElementForTime();

            if (CurrentSceneRoot.PlayerSpawnPoint != null)
            {
                Instantiate(PlayerPrefab, CurrentSceneRoot.PlayerSpawnPoint.position, Quaternion.identity);
                ManagedTimeUtilities.RegisterEntireGO(PlayerController.Instance.gameObject);
            }

            Instantiate(FXManagerPrefab, Vector3.zero, Quaternion.identity);
            TimeStateManager.Instance.BeginRecord();
            GameStateNow = GameState.Running;
            yield return(null);

            Instantiate(PauseMenuPrefab, Vector3.zero, Quaternion.identity);
        }
Beispiel #4
0
 public void DestroyCurrentGhost()
 {
     ManagedTimeUtilities.RealDestroyGO(CurrentGhost);
 }
Beispiel #5
0
 public void CreateNewGhost()
 {
     CurrentGhost = Instantiate(GhostPrefab);
     CloneInHierachy(PlayerController.Instance.transform, CurrentGhost.transform);
     ManagedTimeUtilities.RegisterEntireGO(CurrentGhost);
 }