Beispiel #1
0
        /// <summary>
        /// Have the player respawn at the last checkpoint.
        /// </summary>
        public void Respawn()
        {
            ResetManager.Reset();

            playerSprite.enabled = true;
            player.Physics.Enable();

            try {
                Vector3 position = TransitionManager.GetCurrentSpawnPosition();
                if (position != Vector3.positiveInfinity)
                {
                    player.Physics.Position = position;
                }

                player.Physics.Velocity = Vector2.zero;

                bool   facingRight = TransitionManager.GetCurrentSpawnFacing();
                Facing facing      = facingRight ? Facing.Right : Facing.Left;
                player.SetFacing(facing);
            } catch (UnityException e) {
                Debug.Log(e);
            }

            StartCoroutine(_WaitToEnableControls());
        }
Beispiel #2
0
        //-------------------------------------------------------------------------
        // Unity API
        //-------------------------------------------------------------------------
        protected override void Awake()
        {
            base.Awake();
            player = FindObjectOfType <PlayerCharacter>();
            mouse  = GetComponentInChildren <Mouse>(true);

            resets  = ResetManager.Instance;
            sounds  = AudioManager.Instance;
            dialogs = DialogManager.Instance;

            Physics2D.gravity = new Vector2(0, -gravity);

            string currentSpawn = TransitionManager.GetCurrentSpawnName();

            if (currentSpawn == null || currentSpawn == "")
            {
                if (initialSpawn == null)
                {
                    if (player != null)
                    {
                        TransitionManager.RegisterSpawn("SCENE_START", GameObject.FindGameObjectWithTag("Player").transform.position, true);
                        TransitionManager.SetCurrentSpawn("SCENE_START");
                    }
                }
                else
                {
                    TransitionManager.SetCurrentSpawn(initialSpawn.name);
                }
            }

            // Set the current scene in the transition manager;
            // Set vsync to monitor refresh rate.
            if (!initialized)
            {
                QualitySettings.vSyncCount = 1;
                TransitionManager.SetCurrentScene(SceneManager.GetActiveScene().name);
                initialized = true;
            }

            Journey.SetNarrator(QuestSettings.Narrator);
            Journey.SetQuest(QuestSettings.MainQuest);
            Journey.Begin();
        }
Beispiel #3
0
        /// <summary>
        /// Deactivate the vCam if the player leaves its trigger collider.
        /// </summary>
        /// <param name="col">The collider that's intersecting the vCam collider</param>
        public void PullTriggerExit2D(Collider2D col)
        {
            if (col.gameObject.CompareTag("Player"))
            {
                if (TargettingCamera.target == cameraSettings.transform)
                {
                    // Don't reset if you're turning the vCam off.
                    // TODO: this is breaking either the boss battle OR the start of
                    // scenes the player's in.
                    if (gameObject.activeInHierarchy)
                    {
                        if (!GameManager.Player.IsDead())
                        {
                            ResetManager.Reset();
                        }
                    }

                    if (!GameManager.Player.IsDead())
                    {
                        Deactivate();
                    }
                }
            }
        }
Beispiel #4
0
 private void ResetScene()
 {
     ResetManager.Reset();
     player.Respawn();
     TargettingCamera.ClearTarget();
 }