Exemplo n.º 1
0
 public void LoadMenu()
 {
     AudioManager.instance.StopSceneMusic(1);
     Time.timeScale = 1f;
     lvlChanger.SetActive(true);
     lvlChanger.FadeToLevel(0);
 }
Exemplo n.º 2
0
 public void SceneLoad()
 {
     if (lvlC != null)
     {
         lvlC.FadeToLevel(sceneName);
     }
     else
     {
         SceneManager.LoadScene(sceneName);
     }
 }
Exemplo n.º 3
0
  private void Update()
  {
      if (playerHealth.isDead)
      {
          GameOver();
      }

      // Pause Menu
      if (Input.GetKeyDown(KeyCode.Escape))
      {
          if (m_CurrentState == GameState.Playing)
          {
              m_CurrentState = GameState.Paused;
          }
          else
          {
              m_CurrentState = GameState.Playing;
          }
      }

      // State machine
      switch (m_CurrentState)
      {
      case GameState.Playing:
      {
          break;
      }

      case GameState.Paused:
      {
          Pause();
          break;
      }

      default:
      {
          break;
      }
      }

      if (treasure != null && treasure.gameEnd)
      {
          if (!endingGame)
          {
              EndGame();
          }
          else if (endCutScene.state != PlayState.Playing)
          {
              levelChanger.FadeToLevel();
          }
      }
  }
Exemplo n.º 4
0
 // destroys the player if their health goes below 0
 private void CheckDeath()
 {
     if (health <= 0)
     {
         FindObjectOfType <AudioManager>().Play("PlayerDeath");
         FindObjectOfType <AudioManager>().Play("GameOver");
         health = 0;
         levelChanger.FadeToLevel(2);
     }
     else
     {
         FindObjectOfType <AudioManager>().Play("PlayerHit");
     }
 }
Exemplo n.º 5
0
    /**
     * Prepare the next level to load by stopping the current music, loading the next music and starting the new Scene.
     */
    private void LoadLevel(string value, int levelNumber)
    {
        if (levelNumber == 4)
        {
            print("Level Number is: " + levelNumber);
            print("Attempting to load: " + SceneManager.GetSceneByName("Scene/GameComplete").buildIndex);
            levelChanger.FadeToLevel(5);
        }


        gameManager.currentLevel = levelNumber;
        // Calling the FadeOut script. The SceneManager.LoadScene is called there.
        levelChanger.FadeToLevel(levelNumber);
    }
Exemplo n.º 6
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKeyUp(KeyCode.Space))
     {
         lcScript.FadeToLevel("Level1");
     }
 }
 private void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.CompareTag("Player"))
     {
         levelChanger.FadeToLevel((SceneManager.GetActiveScene().buildIndex + 1) % SceneManager.sceneCountInBuildSettings);
     }
 }
Exemplo n.º 8
0
        public void LevelSwitch(string sceneName)
        {
            LevelChanger levelChanger = FindObjectOfType <LevelChanger>();

            levelChanger.FadeToLevel(1);
            LoadingSceneScript.gSceneName = sceneName;
        }
Exemplo n.º 9
0
    void OnTriggerEnter2D(Collider2D col)
    {
        if (col.tag == "Player")
        {
            player = col.gameObject.GetComponent <Player>();

            if (GameManager.instance.currentSceneIndex == 2)
            {
                AudioManager.instance.StopSceneMusic(1);
                AudioManager.instance.PlaySceneMusic(0);
                player.Freeze();
                WinScreen.SetActive(true);
            }
            else
            {
                lvlChanger.FadeToLevel(2);

                // Conservando los stats del jugador para el próximo nivel
                GameManager.instance.playerMaxHp  = player.maxHp;
                GameManager.instance.playerHp     = player.hp;
                GameManager.instance.playerDamage = player.damage;
                GameManager.instance.playerSpeed  = player.speed;
            }
        }
    }
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.CompareTag("Player"))
     {
         ScriptCalled.FadeToLevel(levelIndex);
     }
 }
Exemplo n.º 11
0
    private IEnumerator Start()
    {
        quaternion   = Quaternion.AngleAxis(3, Time.deltaTime * 0.5f * Vector3.up);
        text.text    = "Loading";
        LevelChanger = gameObject.AddComponent <LevelChanger>();

        GameManager.SetGameState(GameState.Loading);
        yield return(new WaitForSeconds(3f));

        if (string.IsNullOrEmpty(nextLevel))
        {
            LevelChanger.FadeToLevel("MainMenu", Animator);
            yield break;
        }

        var loading = LevelChanger.Load(nextLevel);

        while (!loading.isDone)
        {
            yield return(null);
        }

        nextLevel = null;
        SceneManager.UnloadSceneAsync("LoadingScene");
    }
Exemplo n.º 12
0
 void OnTriggerEnter2D(Collider2D shit)
 {
     if (shit.gameObject.tag == "Player")
     {
         fadeOut.FadeToLevel(3);
     }
 }
Exemplo n.º 13
0
    private void OnInedibleItemPickup()
    {
        GlobalData.Lives--;

        if (GlobalData.Lives < 0)
        {
            if (PlayGamesScript.SuccessAuth)
            {
                PlayGamesScript.AddScoreToLeaderboard(GPGSIds.leaderboard_score, GlobalData.Score);
            }
            else
            {
                PlayGamesScript.Auth();
            }

            //AdRequest
            if (!m_AdWasShown)
            {
                m_AdPopup.Open();
                OnPause();
            }
            else
            {
                LevelChanger.FadeToLevel(GameLevels.THE_END);
            }
        }
        else
        {
            m_TextLives.text = $"Lives: {GlobalData.Lives}";
        }
    }
Exemplo n.º 14
0
        private void Update()
        {
            if (leftHandDevices.Count <= 0 && leftHandDevices.Count <= 0)
            {
                return;
            }

            bool menuPressed;

            #region Controller Inputs
            if (leftHandDevices[0].TryGetFeatureValue(CommonUsages.menuButton, out menuPressed) && menuPressed && !menuPressedLastFrame)
            {
                menuPressedLastFrame = true;

                if (currentSceneName != "MainMenu" && menuPressed)
                {
                    if (Time.timeScale != 1)
                    {
                        Time.timeScale = 1;
                    }
                    Debug.Log("Going home!");
                    levelChanger.FadeToLevel("MainMenu");
                }
                else if (currentSceneName == "MainMenu" && menuPressed && menuControl != null)
                {
                    menuControl.ResetMenu.Invoke();
                }
            }
            else if (leftHandDevices[0].TryGetFeatureValue(CommonUsages.menuButton, out menuPressed) && !menuPressed && menuPressedLastFrame)
            {
                menuPressedLastFrame = false; // Reset menu pressed last frame back to false once menu button is no longer pressed
            }
            #endregion
        }
Exemplo n.º 15
0
 private void NextScene()
 {
     if (sceneCounter == 0)
     {
         cutscene1.SetActive(false);
         cutscene2.SetActive(true);
         sceneCounter += 1;
     }
     else if (sceneCounter == 1)
     {
         cutscene2.SetActive(false);
         cutscene3.SetActive(true);
         sceneCounter += 1;
     }
     else if (sceneCounter == 2)
     {
         cutscene3.SetActive(false);
         cutscene4.SetActive(true);
         sceneCounter += 1;
     }
     else if (sceneCounter == 3)
     {
         cutscene4.SetActive(false);
         cutscene5.SetActive(true);
         sceneCounter += 1;
     }
     else if (sceneCounter == 4)
     {
         lcScript.FadeToLevel("Instructions");
     }
 }
Exemplo n.º 16
0
    // Update is called once per frame
    void Update()
    {
        if (isSkullActive)
        {
            if (player.playerHasMap)
            {
                SkullTextPrefab.SetActive(true);

                if (Input.GetKey(KeyCode.E))
                {
                    SkullContinue();
                    levelChanger.FadeToLevel();
                }
            }
            else
            {
                GetMapText.SetActive(true);
            }
        }
        else
        {
            SkullTextPrefab.SetActive(false);
            GetMapText.SetActive(false);
        }
    }
Exemplo n.º 17
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.CompareTag("Player"))
     {
         levelChanger.FadeToLevel(levelIndex);
     }
 }
Exemplo n.º 18
0
    public void LevelSwitch(string sceneName)
    {
        LevelChanger levelChanger = FindObjectOfType <LevelChanger>();

        levelChanger.FadeToLevel(1);
        //LoadingSceneScript.gSceneName = "Wuyan_guochang1";
    }
Exemplo n.º 19
0
    /// <summary>
    /// 切换关卡场景
    /// </summary>
    public void LevelSwitch(int sceneID)
    {
        LevelChanger levelChanger = FindObjectOfType <LevelChanger>();

        levelChanger.FadeToLevel(1);
        LoadingSceneScript.gSceneNumber = sceneID;
    }
 // Update is called once per frame
 void Update()
 {
     if (Input.GetMouseButtonDown(0))
     {
         levelChanger.FadeToLevel(1);
     }
 }
Exemplo n.º 21
0
    IEnumerator Transition()
    {
        yield return(new WaitForSeconds(2f));

        LevelChanger.FadeToLevel(0);
        SceneManager.LoadScene("EncounterField");
    }
Exemplo n.º 22
0
    void Update()
    {
        Ray  ray      = Camera.main.ScreenPointToRay(Input.mousePosition);
        bool hitPause = Physics.Raycast(ray, Mathf.Infinity, pauseMenuLayer);

        if (Input.GetMouseButtonDown(0) && !hitPause && !PausePanel.activeInHierarchy)  //TODO: need to change to touchpad?
        {
            if (index < 5)
            {
                NextDialogue();  // 完成bubble text上的東西後才呼叫
            }
            else if (index >= 7 && index < 12)
            {
                image[0].GetComponentInChildren <Text>().text = "1+1";
                image[1].GetComponentInChildren <Text>().text = "4+1";
                image[2].GetComponentInChildren <Text>().text = "6\n+\n3";
                image[3].GetComponentInChildren <Text>().text = "3\n+\n4";
                image[4].GetComponentInChildren <Text>().text = "5";
                image[5].GetComponentInChildren <Text>().text = "10";
                image[6].GetComponentInChildren <Text>().text = "1";
                image[7].GetComponentInChildren <Text>().text = "8";

                NextDialogue();
            }

            if (index == 12)
            {
                PlayerPrefs.SetString("PipeGyroTutorialComplete", "true");
                StartCoroutine(KickPlayerOut(5)); //Kick the player out after 5 sec

                // StartCoroutine(ChangeBool());

                if (Input.GetMouseButtonDown(0) && boolean)
                {
                    boolean = false;
                    if (lc)
                    {
                        lc.FadeToLevel(4);
                    }
                    else
                    {
                        SceneManager.LoadScene(4);
                    }
                }
            }
        }
    }
    public void BossDeath()
    {
        LevelChanger levelChanger = GameObject.Find("LevelChanger").GetComponent <LevelChanger>();

        levelChanger.GoToScene("Credits"); //Change this text to the name of the epilogue scene
        levelChanger.FadeToLevel("Credits");
        DestroyMob();
    }
Exemplo n.º 24
0
    // Start the game - load game scene
    public void PlayAgain()
    {
        // Fade out music
        StartCoroutine(FadeMusicOut(music));

        // Load the next level
        levelChanger.FadeToLevel(0);
    }
Exemplo n.º 25
0
 private void OnCollisionEnter2D(Collision2D collisionInfo)
 {
     if (collisionInfo.collider.tag == "Player" && !hasFadeBegan)
     {
         hasFadeBegan = true;
         levelChanger.FadeToLevel(levelChanger.currentLevelIndex.value);
     }
 }
 void OnTriggerEnter2D(Collider2D shit)
 {
     if (shit.gameObject.tag == "Player")
     {
         fadeOut.FadeToLevel(2);
         GameMaster.maxLives = 1;
     }
 }
Exemplo n.º 27
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.CompareTag("Player") && !other.isTrigger)
     {
         playerStorage.initialValue = playerPosition;
         levelChanger.FadeToLevel(sceneToLoad);
     }
 }
Exemplo n.º 28
0
 public void HandleRewardBasedVideoFailedToLoad(object sender, AdFailedToLoadEventArgs args)
 {
     MonoBehaviour.print(
         "HandleRewardBasedVideoFailedToLoad event received with message: "
         + args.Message);
     OnPause();
     LevelChanger.FadeToLevel(2); //load the end scene
 }
Exemplo n.º 29
0
 private void OnTriggerEnter2D(Collider2D col)
 {
     if (col.CompareTag("Player"))
     {
         playerpc.lastDoor = doorLetter;
         playerpc.walking  = true;
         lc.FadeToLevel(level);
     }
 }
Exemplo n.º 30
0
    // Update is called once per frame
    void /*Late*/ Update()
    {
        // If the map building is complete
        if (map.MapGenerationCompleted() && !playerSpawned)
        {
            // Position the player
            playerSpawned = map.PositionPlayerInEmptyCube(player);
            playerController.SetPlayerRotation();

            // Initialse the quests
            questManager.InitQuests();

            // Record the start of the games map grid cubes
            GameDataManager.instance.RecordGridCubes(map.GridCubeArray(), true);

            // Spawn the initial monsters
            monsterManager.SpawnMonsters();

            Debug.Log("GC - INIT - COMPLETE");
        }

        // If the player needs health spawn it
        if (playerController.CurrentHealth() <= playerController.MaxHealth() / 2 && !healthSpawned)
        {
            // Spawn player health
            SpawnHealth();
            healthSpawned = true;
        }

        // If the player is dead -- needs adding to
        if (playerController.CurrentHealth() <= 0 && !playerController.PlayerDead())
        {
            // Disable the player controller
            playerController.enabled = false;

            // Record the end of the games map grid cubes
            GameDataManager.instance.RecordGridCubes(map.GridCubeArray(), false);
            GameDataManager.instance.SetQuestStatsIncomplete(questManager.QuestIndex());

            // Push the data
            GameDataManager.instance.PushData();
            Debug.Log("PLAYER DIED - GAME OVER");

            // Load the scene
            DontDestroyOnLoad(GameDataManager.instance);
            DontDestroyOnLoad(Controls.instance);

            // Load the next level
            levelChanger.FadeToLevel(SceneManager.GetActiveScene().buildIndex + 1);

            // Player is dead
            playerController.PlayerDead(true);
        }

        // Increase the game time
        GameDataManager.instance.IncreaseGameTime();
    }