Exemplo n.º 1
0
        /// <summary>
        /// Looks for the level start position and if it's inside the room, makes this room the current one
        /// </summary>
        protected virtual void HandleLevelStartDetection()
        {
            if (!_initialized)
            {
                Initialization();
            }

            if (AutoDetectFirstRoomOnStart)
            {
                if (LevelManager.Instance != null)
                {
                    if (RoomBounds.Contains(LevelManager.Instance.Players[0].transform.position))
                    {
                        MMCameraEvent.Trigger(MMCameraEventTypes.ResetPriorities);
                        MMCinemachineBrainEvent.Trigger(MMCinemachineBrainEventTypes.ChangeBlendDuration, 0f);

                        MMSpriteMaskEvent.Trigger(MMSpriteMaskEvent.MMSpriteMaskEventTypes.MoveToNewPosition,
                                                  RoomColliderCenter,
                                                  RoomColliderSize,
                                                  0f, MMTween.MMTweenCurve.LinearTween);

                        PlayerEntersRoom();
                        VirtualCamera.Priority = 10;
                        VirtualCamera.enabled  = true;
                    }
                    else
                    {
                        VirtualCamera.Priority = 0;
                        VirtualCamera.enabled  = false;
                    }
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Describes the events happening once the initial fade in is complete
        /// </summary>
        protected virtual void AfterFadeOut(GameObject collider)
        {
            TeleportCollider(collider);

            if (AddToDestinationIgnoreList)
            {
                Destination.AddToIgnoreList(collider.transform);
            }

            if (CameraMode == CameraModes.CinemachinePriority)
            {
                MMCameraEvent.Trigger(MMCameraEventTypes.ResetPriorities);
                MMCinemachineBrainEvent.Trigger(MMCinemachineBrainEventTypes.ChangeBlendDuration, DelayBetweenFades);
            }

            if (CurrentRoom != null)
            {
                CurrentRoom.PlayerExitsRoom();
            }

            if (TargetRoom != null)
            {
                TargetRoom.PlayerEntersRoom();
                TargetRoom.VirtualCamera.Priority = 10;
                MMSpriteMaskEvent.Trigger(MoveMaskMethod, (Vector2)TargetRoom.RoomColliderCenter, TargetRoom.RoomColliderSize, MoveMaskDuration, MoveMaskCurve);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Describes the events happening after the pause between the fade in and the fade out
 /// </summary>
 protected virtual void AfterFadePause(GameObject collider)
 {
     if (TeleportCamera)
     {
         MMCameraEvent.Trigger(MMCameraEventTypes.StartFollowing, collider.MMGetComponentNoAlloc <Character>());
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// On Start we grab our dependencies and initialize spawn
        /// </summary>
        protected virtual void Start()
        {
            BoundsCollider = _collider;
            InstantiatePlayableCharacters();

            MMCameraEvent.Trigger(MMCameraEventTypes.SetConfiner, null, BoundsCollider);

            if (Players == null || Players.Count == 0)
            {
                return;
            }

            Initialization();

            // we handle the spawn of the character(s)
            if (Players.Count == 1)
            {
                SpawnSingleCharacter();
            }
            else
            {
                SpawnMultipleCharacters();
            }

            CheckpointAssignment();

            // we trigger a level start event
            TopDownEngineEvent.Trigger(TopDownEngineEventTypes.LevelStart, null);
            MMGameEvent.Trigger("Load");

            MMCameraEvent.Trigger(MMCameraEventTypes.SetTargetCharacter, Players[0]);
            MMCameraEvent.Trigger(MMCameraEventTypes.StartFollowing);
            MMGameEvent.Trigger("CameraBound");
        }
Exemplo n.º 5
0
 /// <summary>
 /// Describes the events happening before the initial fade in
 /// </summary>
 /// <param name="collider"></param>
 protected virtual void BeforeFadeIn(GameObject collider)
 {
     ActivateZone();
     if (TeleportCamera)
     {
         MMCameraEvent.Trigger(MMCameraEventTypes.StopFollowing, collider.MMGetComponentNoAlloc <Character>());
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// Coroutine that kills the player, stops the camera, resets the points.
        /// </summary>
        /// <returns>The player co.</returns>
        protected virtual IEnumerator SoloModeRestart()
        {
            if ((PlayerPrefabs.Count() <= 0) && (SceneCharacters.Count <= 0))
            {
                yield break;
            }

            // if we've setup our game manager to use lives (meaning our max lives is more than zero)
            if (GameManager.Instance.MaximumLives > 0)
            {
                // we lose a life
                GameManager.Instance.LoseLife();
                // if we're out of lives, we check if we have an exit scene, and move there
                if (GameManager.Instance.CurrentLives <= 0)
                {
                    TopDownEngineEvent.Trigger(TopDownEngineEventTypes.GameOver, null);
                    if ((GameManager.Instance.GameOverScene != null) && (GameManager.Instance.GameOverScene != ""))
                    {
                        LoadingSceneManager.LoadScene(GameManager.Instance.GameOverScene);
                    }
                }
            }

            MMCameraEvent.Trigger(MMCameraEventTypes.StopFollowing);

            MMFadeInEvent.Trigger(OutroFadeDuration, FadeCurve, FaderID, true, Players[0].transform.position);
            yield return(new WaitForSeconds(OutroFadeDuration));

            yield return(new WaitForSeconds(RespawnDelay));

            GUIManager.Instance.SetPauseScreen(false);
            GUIManager.Instance.SetDeathScreen(false);
            MMFadeOutEvent.Trigger(OutroFadeDuration, FadeCurve, FaderID, true, Players[0].transform.position);


            MMCameraEvent.Trigger(MMCameraEventTypes.StartFollowing);

            if (CurrentCheckpoint == null)
            {
                CurrentCheckpoint = InitialSpawnPoint;
            }

            if (Players[0] == null)
            {
                InstantiatePlayableCharacters();
            }

            if (CurrentCheckpoint != null)
            {
                CurrentCheckpoint.SpawnPlayer(Players[0]);
            }
            _started = DateTime.UtcNow;

            // we send a new points event for the GameManager to catch (and other classes that may listen to it too)
            TopDownEnginePointEvent.Trigger(PointsMethods.Set, 0);
            TopDownEngineEvent.Trigger(TopDownEngineEventTypes.RespawnComplete, Players[0]);
            yield break;
        }
Exemplo n.º 7
0
        /// <summary>
        /// Describes the events happening after the pause between the fade in and the fade out
        /// </summary>
        protected virtual void AfterDelayBetweenFades(GameObject collider)
        {
            MMCameraEvent.Trigger(MMCameraEventTypes.StartFollowing);

            if (TriggerFade)
            {
                MMFadeOutEvent.Trigger(FadeInDuration, FadeTween, FaderID, false, LevelManager.Instance.Players[0].transform.position);
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Describes the events happening before the initial fade in
        /// </summary>
        /// <param name="collider"></param>
        protected virtual void SequenceStart(GameObject collider)
        {
            ActivateZone();

            if (CameraMode == CameraModes.TeleportCamera)
            {
                MMCameraEvent.Trigger(MMCameraEventTypes.StopFollowing);
            }

            if (FreezeTime)
            {
                MMTimeScaleEvent.Trigger(MMTimeScaleMethods.For, 0f, 0f, false, 0f, true);
            }

            if (FreezeCharacter && (_player != null))
            {
                _player.Freeze();
            }
        }