Ejemplo n.º 1
0
    public void Init(SpeedrunManager _speedRun)
    {
        if (initialCheckpoint == null)
        {
            Debug.LogError("An initial checkpoint should always be setted", initialCheckpoint);
            return;
        }

        if (_speedRun.GetIsActive())
        {
            for (int i = 0; i < checkpointContainer.childCount; i++)
            {
                checkpointContainer.GetChild(i).gameObject.SetActive(false);
            }

            activeCheckpoint = initialCheckpoint;
        }
        else
        {
            for (int i = 0; i < checkpointContainer.childCount; i++)
            {
                CheckpointBase _current = checkpointContainer.GetChild(i).GetComponent <CheckpointBase>();
                checkpoints.Add(_current);
                _current.Init();
                _current.ActivateCheckpoint += HandleActivateCheckpoint;
            }

            activeCheckpoint = initialCheckpoint;
            activeCheckpoint.Enable();
        }
    }
Ejemplo n.º 2
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.layer == LayerMask.NameToLayer("Player") || other.gameObject.layer == LayerMask.NameToLayer("PlayerImmunity"))
        {
            Time.timeScale = 0f;

            if (GameManager.Exist())
            {
                if (GameManager.instance.GetLevelsManager().GetMode())
                {
                    OptionsManager     optionsMng     = GameManager.instance.GetOptionsManager();
                    SpeedrunManager    speedRunMng    = LevelManager.instance.GetSpeedrunManager();
                    dreamloLeaderBoard leaderBoardMng = GameManager.instance.GetLeaderboard();
                    leaderBoardMng.AddScore(optionsMng.GetUserName(), speedRunMng.GetTimer());
                }

                GameManager.instance.GetSoundManager().StopMusic();
            }
            PlayerInputManager.SetCanReadInput(false);
            LevelManager.instance.GetUIGameplayManager().ToggleMenu(MenuType.EndGame);

            LevelManager.OnPlayerEndLevel?.Invoke();
            soundCtrl.PlayClip();
        }
    }
Ejemplo n.º 3
0
 /// <summary>
 /// Funzioen che gestisce l'evento OnGameUnPause
 /// </summary>
 public void GameUnPause()
 {
     pause          = false;
     Time.timeScale = 1f;
     PlayerInputManager.SetCanReadGameplayInput(true);
     if (SpeedrunManager.ResumeTimer != null)
     {
         SpeedrunManager.ResumeTimer();
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Funzioen che gestisce l'evento OnGamePause
 /// </summary>
 public void GamePause()
 {
     pause          = true;
     Time.timeScale = 0f;
     PlayerInputManager.SetCanReadGameplayInput(false);
     if (SpeedrunManager.PauseTimer != null)
     {
         SpeedrunManager.PauseTimer();
     }
 }
Ejemplo n.º 5
0
    private void HandleOnCountdownEnd()
    {
        PlayerInputManager.SetCanReadInput(true);
        lvl.GetPlayer().GetHealthController().SetCanLoseHealth(true);
        ui.ToggleMenu(MenuType.Game);

        if (SpeedrunManager.StartTimer != null)
        {
            SpeedrunManager.StartTimer();
        }
    }
Ejemplo n.º 6
0
    private void HandleDeathAnimationEnd()
    {
        ResetLife();
        ResetStunHit();
        graphics.Disable();

        if (tempRespawnTime == -1)
        {
            respawnTime = defaultRespawnTime;
        }
        else
        {
            respawnTime = tempRespawnTime;
        }

        if (SpeedrunManager.StopForSeconds != null)
        {
            SpeedrunManager.StopForSeconds(speedrunBonusTime);
        }

        deathCoroutine = StartCoroutine(DeathCoroutine());
    }
Ejemplo n.º 7
0
    /// <summary>
    /// Funzione che manda il nemico in stato Morte
    /// </summary>
    public void Die(float _respawnTime = -1)
    {
        if (_respawnTime == -1)
        {
            respawnTime = defaultRespawnTime;
        }
        else
        {
            respawnTime = _respawnTime;
        }

        stunHitGot = 0;

        if (SpeedrunManager.StopForSeconds != null)
        {
            SpeedrunManager.StopForSeconds(speedrunBonusTime);
        }

        if (enemySM.GoToDeath != null)
        {
            enemySM.GoToDeath();
        }
    }
Ejemplo n.º 8
0
        public override void Enable()
        {
            if (GameManager.Exist())
            {
                nameText.text = GameManager.instance.GetOptionsManager().GetUserName();
            }

            SpeedrunManager speedrunMng = LevelManager.instance.GetSpeedrunManager();

            if (speedrunMng.GetIsActive())
            {
                speedRunPanel.SetActive(true);
                normalPanel.SetActive(false);
                speedRunTimerText.text = "Time: " + speedrunMng.GetTimer().ToString("0.00");
            }
            else
            {
                normalPanel.SetActive(true);
                speedRunPanel.SetActive(false);
                tokenText.text = "Tokens: " + LevelManager.instance.GetTokenManager().GetTokensCount().ToString();
            }

            base.Enable();
        }
Ejemplo n.º 9
0
    public override void Enter()
    {
        player = context.player;

        PlayerVFXController.OnDeathVFXEnd += HandleDeathVFXEnd;
        player.GetVFXController().PlayDeathVFX();
        player.GetSoundController().Death();

        timerForRespawn = false;
        respawnTimer    = 0f;
        player.StopImmunityCoroutine();
        PlayerInputManager.Rumble(1f, 1f, 0.5f);
        player.ChangeGraphics(context.player.GetPlayerGraphic());

        player.GetAnimatorController().SetAnimatorController(null);
        player.GetAnimatorController().ResetAnimator();

        PlayerShotController shotCtrl = context.player.GetShotController();

        shotCtrl.ChangeShotType(shotCtrl.GetPlayerDefaultShotSetting());

        player.GetActualGraphic().GetModel().transform.localScale = new Vector3(1, 1, 1);
        player.GetActualGraphic().Disable();
        player.GetCollisionController().OnStickyEnd();
        player.GetCollisionController().GetPlayerCollider().enabled = false;
        player.GetCollisionController().GetCollisionInfo().ResetAll();
        player.GetMovementController().SetCanMove(false);
        shotCtrl.SetCanShoot(false);
        shotCtrl.SetCanUseCrossair(false);
        shotCtrl.SetCanAim(false);

        if (SpeedrunManager.StopTimer != null)
        {
            SpeedrunManager.StopTimer();
        }
    }
Ejemplo n.º 10
0
    public void Init(SpeedrunManager _speedRun)
    {
        if (!tokenContainer)
        {
            return;
        }
        for (int i = 0; i < tokenContainer.childCount; i++)
        {
            BaseToken _current = tokenContainer.GetChild(i).GetComponent <BaseToken>();

            if (_speedRun.GetIsActive())
            {
                _current.gameObject.SetActive(false);
            }
            else
            {
                _current.Init();
                tokens.Add(_current);
                _current.GetToken += HandleGetToken;
            }
        }

        tokenCounter = 0;
    }
Ejemplo n.º 11
0
    /// <summary>
    /// Inizializzazione elementi del livello (verrà chiamata dalla SM)
    /// </summary>
    public void Init(UI_ManagerBase _uiManager, bool _speedrunMode)
    {
        instance  = this;
        pause     = false;
        uiManager = _uiManager.GetGameplayManager();

        //Init
        poolMng = GetComponent <PoolManager>();
        if (poolMng != null)
        {
            poolMng.Init();
        }

        stickyMng = GetComponent <StickyObjectManager>();
        if (stickyMng != null)
        {
            stickyMng.Init();
        }

        enemyMng = GetComponent <EnemyManager>();
        if (enemyMng != null)
        {
            enemyMng.Init();
        }

        platformMng = GetComponent <PlatformManager>();
        if (platformMng != null)
        {
            platformMng.Init(uiManager.GetGameplayManager());
        }

        speedMng = GetComponent <SpeedrunManager>();
        if (speedMng != null)
        {
            speedMng.Init(_speedrunMode);
        }

        checkpointMng = GetComponent <CheckpointManager>();
        if (checkpointMng != null)
        {
            checkpointMng.Init(speedMng);
        }

        poopCtrl = FindObjectOfType <PoopController>();
        if (poopCtrl != null)
        {
            poopCtrl.Init();
        }

        tokenMng = GetComponent <TokenManager>();
        if (tokenMng != null)
        {
            tokenMng.Init(speedMng);
        }

        player = FindObjectOfType <Player>();
        if (player != null)
        {
            player.Init(enemyMng, platformMng, tokenMng);
        }

        tutorialMng = GetComponent <TutorialManager>();
        if (tutorialMng != null)
        {
            tutorialMng.Init(enemyMng, player);
        }

        cameraMng = GetComponent <CameraManager>();
        if (cameraMng != null)
        {
            cameraMng.Init();
        }

        doorsMng = GetComponent <DoorsButtonsManager>();
        if (doorsMng != null)
        {
            doorsMng.Init();
        }

        videoStream = FindObjectOfType <StreamVideo>();

        //Setup
        enemyMng.EnemiesSetup();

        //Iscrizione Eventi
        PlayerInputManager.OnPausePressed += HandlePlayerPauseButtonPressed;
        player.OnPlayerDeath += HandlePlayerDeath;
        OnGamePause          += GamePause;
        OnGameUnPause        += GameUnPause;
    }