/// <summary>
        /// Describes the events happening once the initial fade in is complete
        /// </summary>
        protected virtual void AfterFadeOut(Collider2D 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.RoomCollider.bounds.center + TargetRoom.RoomCollider.offset, TargetRoom.RoomCollider.bounds.size, MoveMaskDuration, MoveMaskCurve);
            }

            AfterFadeOutFeedback?.PlayFeedbacks();
        }
        /// <summary>
        /// Initialization
        /// </summary>
        public virtual void Start()
        {
            if (Players == null || Players.Count == 0)
            {
                return;
            }

            Initialization();

            CorgiEngineEvent.Trigger(CorgiEngineEventTypes.SpawnCharacterStarts);

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

            LevelGUIStart();
            CheckpointAssignment();

            // we trigger a level start event
            CorgiEngineEvent.Trigger(CorgiEngineEventTypes.LevelStart);
            MMGameEvent.Trigger("Load");

            MMCameraEvent.Trigger(MMCameraEventTypes.SetConfiner, null, BoundsCollider);
            MMCameraEvent.Trigger(MMCameraEventTypes.SetTargetCharacter, Players[0]);
            MMCameraEvent.Trigger(MMCameraEventTypes.StartFollowing);
        }
示例#3
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 (_roomCollider2D.bounds.Contains(LevelManager.Instance.Players[0].transform.position))
                    {
                        MMCameraEvent.Trigger(MMCameraEventTypes.ResetPriorities);
                        MMCinemachineBrainEvent.Trigger(MMCinemachineBrainEventTypes.ChangeBlendDuration, 0f);
                        VirtualCamera.Priority = 10;

                        MMSpriteMaskEvent.Trigger(MMSpriteMaskEvent.MMSpriteMaskEventTypes.MoveToNewPosition,
                                                  (Vector2)_roomCollider2D.bounds.center + _roomCollider2D.offset,
                                                  _roomCollider2D.bounds.size,
                                                  0f, MMTween.MMTweenCurve.LinearTween);

                        PlayerEntersRoom();
                    }
                }
            }
        }
示例#4
0
        /// <summary>
        /// Acts on MMCameraEvents when caught
        /// </summary>
        /// <param name="cameraEvent"></param>
        public virtual void OnMMEvent(MMCameraEvent cameraEvent)
        {
            switch (cameraEvent.EventType)
            {
            case MMCameraEventTypes.StartFollowing:
                StartFollowing();
                break;

            case MMCameraEventTypes.StopFollowing:
                StopFollowing();
                break;
            }
        }
        /// <summary>
        /// Describes the events happening after the pause between the fade in and the fade out
        /// </summary>
        protected virtual void AfterDelayBetweenFades(Collider2D collider)
        {
            if (CameraMode == CameraModes.TeleportCamera)
            {
                if (LevelManager.Instance.LevelCameraController != null)
                {
                    LevelManager.Instance.LevelCameraController.TeleportCameraToTarget();
                }
                MMCameraEvent.Trigger(MMCameraEventTypes.StartFollowing);
            }

            AfterDelayBetweenFadesFeedback?.PlayFeedbacks();

            if (TriggerFade)
            {
                MMFadeOutEvent.Trigger(FadeInDuration, FadeTween, FaderID, false, LevelManager.Instance.Players[0].transform.position);
            }
        }
        /// <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)
                {
                    CorgiEngineEvent.Trigger(CorgiEngineEventTypes.GameOver);
                    if ((GameManager.Instance.GameOverScene != null) && (GameManager.Instance.GameOverScene != ""))
                    {
                        LoadingSceneManager.LoadScene(GameManager.Instance.GameOverScene);
                    }
                }
            }

            MMCameraEvent.Trigger(MMCameraEventTypes.StopFollowing);

            yield return(new WaitForSeconds(RespawnDelay));

            MMCameraEvent.Trigger(MMCameraEventTypes.StartFollowing);

            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)
            CorgiEnginePointsEvent.Trigger(PointsMethods.Set, 0);
            // we trigger a respawn event
            ResetLevelBoundsToOriginalBounds();
            CorgiEngineEvent.Trigger(CorgiEngineEventTypes.Respawn);
        }
        /// <summary>
        /// Describes the events happening before the initial fade in
        /// </summary>
        /// <param name="collider"></param>
        protected virtual void SequenceStart(Collider2D 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();
            }

            SequenceStartFeedback?.PlayFeedbacks();
        }