// Start is called before the first frame update
    void Start()
    {
        switch (SceneManager.GetActiveScene().buildIndex)
        {
        case 0:
            _currentScene = SCENES.MENU;
            break;

        case 1:
            _currentScene = SCENES.GAME;
            break;

        default:
            _currentScene = SCENES.NULL;
            break;
        }
        if (_currentScene == SCENES.GAME)
        {
            _spawnManager.StartSpawning();
            _mainCamera  = Camera.main;
            _audioSource = GetComponent <AudioSource>();
            if (_audioSource == null)
            {
                Debug.LogError("GameManager::Start() AudioSource is null");
            }
            else
            {
                _audioSource.clip = _music[0];
                _audioSource.Play();
            }
        }
    }
Exemple #2
0
    public void Load(SCENES sceneIndex, bool activeCanvas)
    {
        sceneLoaderCanvas.gameObject.SetActive(true);
        sceneLoaderPanel.gameObject.SetActive(activeCanvas);

        StartCoroutine(LoadAsync(sceneIndex));
    }
Exemple #3
0
    public void changeScene(SCENES sceneToLoad)
    {
        //string oldScene = currentScene;
        switch (sceneToLoad)
        {
        case SCENES.FARM:
            StartCoroutine(fadeOutToNewScene("Farm"));
            break;

        case SCENES.OVERWORLD:
            StartCoroutine(fadeOutToNewScene("Overworld"));
            break;

        case SCENES.LAB:
            StartCoroutine(fadeOutToNewScene("Laboratory"));
            break;

        case SCENES.VICTORY:
            StartCoroutine(fadeOutToNewScene("Victory"));
            break;

        case SCENES.LOSS:
            StartCoroutine(fadeOutToNewScene("GameOver"));
            break;

        case SCENES.MAIN_MENU:
            StartCoroutine(fadeOutToNewScene("MainMenu"));
            break;

        default:
            print("Invalid scene name");
            break;
        }
    }
Exemple #4
0
 /** 初期化*/
 private void init()
 {
     //シーンの切り替えが必要か?
     if (nextScene == SCENES.SC_NONE)
         return; // init()を出る
     // シーンの切り替えが必要
     nowScene = nextScene;
     nextScene = SCENES.SC_NONE;
 }
 // Use this for initialization
 void Start()
 {
     me = this;
     textScene.enabled = isDebug;
     nowScene          = SCENES.SC_NONE;
     nextScene         = SCENES.SC_TITLE;
     iScore            = 0;
     // ハイスコアを読み込む
     if (PlayerPrefs.HasKey("HighScore"))
     {
         iHighScore = PlayerPrefs.GetInt("HighScore");
     }
 }
    /** シーンの切り替え処理*/
    void changeScene()
    {
        if (nextScene != SCENES.SC_NONE)
        {
            nowScene  = nextScene;
            nextScene = SCENES.SC_NONE;

            switch (nowScene)
            {
            case SCENES.SC_TITLE:
                textScene.text = "TITLE";
                sceneObjects[(int)SCENES.SC_TITLE].SetActive(true);
                sceneObjects[(int)SCENES.SC_GAMEOVER].SetActive(false);
                textHighScore.enabled = true;
                // ゲームオブジェクトを全て削除
                removeAllGameObjects();
                break;

            case SCENES.SC_GAME:
                textScene.text = "GAME";
                sceneObjects[(int)SCENES.SC_TITLE].SetActive(false);
                // ゲームパラメーターを初期化
                iScore   = 0;
                gameTime = 0f;
                textHighScore.enabled = false;
                break;

            case SCENES.SC_GAMEOVER:
                textScene.text = "GAMEOVER";
                sceneObjects[(int)SCENES.SC_GAMEOVER].SetActive(true);
                textHighScore.enabled = true;

                // ゲームの挙動を停止
                sceneObjects[(int)SCENES.SC_GAME].BroadcastMessage("StopGame");

                // ハイスコアの更新
                if (iScore > iHighScore)
                {
                    iHighScore = iScore;
                    // ハイスコアを書き込む
                    PlayerPrefs.SetInt("HighScore", iHighScore);
                }

                break;
            }

            // ハイスコアの代入
            string sc = "00000" + iHighScore;
            textHighScore.text = "HighScore:" + sc.Substring(sc.Length - 6, 6);
        }
    }
Exemple #7
0
    private IEnumerator LoadAsync(SCENES sceneIndex)
    {
        AsyncOperation op = SceneManager.LoadSceneAsync((int)sceneIndex);

        while (!op.isDone)
        {
            float progress = Mathf.Clamp01(op.progress / .9f);

            if (slider != null)
            {
                slider.value = progress;
            }
            if (textProgress != null)
            {
                textProgress.text = (int)(progress * 100.0f) + "%";
            }

            yield return(null);
        }
    }
    /** 更新処理*/
    void updateScene()
    {
        /** スコア表示*/
        string sc = "00000" + iScore;

        textScore.text = "Score:" + sc.Substring(sc.Length - 6, 6);

        /** シーン別処理*/
        switch (nowScene)
        {
        case SCENES.SC_TITLE:
            // タイトルの切り替え
            if (Input.GetMouseButtonDown(0))
            {
                nextScene = SCENES.SC_GAME;
            }
            break;

        case SCENES.SC_GAME:
            updateGame();
            /** 切り替えチェック*/
            if (isDebug)
            {
                if (Input.GetMouseButtonDown(1))
                {
                    nextScene = SCENES.SC_GAMEOVER;
                }
            }

            break;

        case SCENES.SC_GAMEOVER:
            // シーンの切り替え
            if (Input.GetMouseButtonDown(0))
            {
                nextScene = SCENES.SC_TITLE;
            }
            break;
        }
    }
Exemple #9
0
        /**初期化*/
        private void init()
        {
            //シーンの切り替えが必要か?
            if (nextScene == SCENES.SC_NONE)
                return;//init()を出る
            //シーンの切り替えが必要
            nowScene = nextScene;
            nextScene = SCENES.SC_NONE;

            switch (nowScene)
            {
                //起動
                case SCENES.SC_BOOT:
                    for (int i = 0; i < CHR_MAX; i++)
                    {
                        type[i] = CHRTYPE.CHRTYPE_NONE;
                        labels[i] = new Label();
                        labels[i].Visible = false;
                        labels[i].AutoSize = true;
                        Controls.Add(labels[i]);
                    }
                    nextScene = SCENES.SC_TITLE;
                    break;

                //ゲーム開始時の初期化
                case SCENES.SC_GAME:
                    type[0] = CHRTYPE.CHRTYPE_PLAYER;
                    vx[0] = 0;
                    vy[0] = 0;
                    labels[0].Text = "(のヮの)";
                    labels[0].Visible = true;
                    px[0] = (ClientSize.Width - labels[0].Width) / 2;
                    py[0] = (ClientSize.Height - labels[0].Height) / 2;
                    labels[0].Left = (int)px[0];
                    labels[0].Top = (int)py[0];

                    //敵の初期化
                    for (int i = 1; i < 1 + ENEMY_MAX; i++)
                    {
                        type[i] = CHRTYPE.CHRTYPE_ENEMY;
                        vx[i] = (float)(rand.NextDouble()
                            * (2 * ENEMY_SPEED) - ENEMY_SPEED);
                        vy[i] = (float)(rand.NextDouble()
                            * (2 * ENEMY_SPEED) - ENEMY_SPEED);

                        labels[i].Text = "(~~__~~)";
                        px[i] = rand.Next(ClientSize.Width - labels[i].Width);
                        py[i] = rand.Next(ClientSize.Height - labels[i].Height);
                    }
                    //アイテムの初期化
                    for (int i = 1+ENEMY_MAX;i < CHR_MAX;  i++)
                    {
                        type[i] = CHRTYPE.CHRTYPE_ITME;
                        vx[i] = (float)(rand.NextDouble()
                            * (2 * ITEM_SPEED) - ITEM_SPEED);
                        vy[i] = (float)(rand.NextDouble()
                            * (2 * ITEM_SPEED) - ITEM_SPEED);
                        labels[i].Text = "☆";
                        px[i] = rand.Next(ClientSize.Width - labels[i].Width);
                        py[i] = rand.Next(ClientSize.Height - labels[i].Height);
                    }

                    //アイテムの残り数を設定
                    iTtmeCount = ITEM_MAX;

                        break;
            }
        }
Exemple #10
0
        /**アイテムの更新処理**/
        private void updateItem(int i)
        {
            constantMove(i);
            if (hitPlayer(i))
            {
                //アイテムを消す
                type[i] = CHRTYPE.CHRTYPE_NONE;
                //クリアチェック
                iTtmeCount--;
                if(iTtmeCount<=0)
                {
                    //アイテムを全部とった
                    nextScene = SCENES.SC_CLEAR;
                }

            }
        }
Exemple #11
0
 /**敵の更新処理**/
 private void updateEnemy(int i)
 {
     constantMove(i);
     if(hitPlayer(i))
     {
         nextScene = SCENES.SC_GANEOVER;
     }
 }
Exemple #12
0
        /**更新処理*/
        private void update()
        {
            switch(nowScene)
            {
                case SCENES.SC_TITLE:
                    if((Control.MouseButtons & MouseButtons.Left)
                        == MouseButtons.Left)
                    {
                        //左クリックされた
                        nextScene = SCENES.SC_GAME;
                    }
                    break;

                case SCENES.SC_GAME:
                    updateGame();
                    break;
                case SCENES.SC_GANEOVER:
                case SCENES.SC_CLEAR:
                    if ((Control.MouseButtons & MouseButtons.Left)
                        == MouseButtons.Left)
                    {
                        //左クリックされた
                        nextScene = SCENES.SC_TITLE;
                    }
                    break;

            }
        }
Exemple #13
0
 public static void SceneMove(SCENES NextScene)
 {
     // FadeManagerを呼び出す
     FadeManager.Instance.Load((int)NextScene);
 }
Exemple #14
0
 /// <summary>
 /// シーン遷移関数
 /// ゲームシーンとの行き来は別
 /// TODO:フェード処理はまだいれていないので後で入れる
 /// </summary>
 /// <param name="nextSceneGameObject"></param>
 public void ChangeScene(SCENES nextScene)
 {
     scenes[(int)currentScene].SetActive(false);
     scenes[(int)nextScene].SetActive(true);
     currentScene = nextScene;
 }
Exemple #15
0
 public void Load(SCENES sceneIndex)
 {
     Load(sceneIndex, true);
 }
    IEnumerator ILoad()
    {
        // Create Player1
        player      = Instantiate(player);
        player.name = "alucard";

        // PUT THIS IN ANOTHER FUNCTION, put thing to load in a list and pass that to the Load function
        // Load where to go
        AsyncOperation a = SceneManager.LoadSceneAsync(SETTINGS.currentScene, LoadSceneMode.Additive);

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

        // Set Scene Active
        _nextScene = SceneManager.GetSceneByName(SETTINGS.currentScene);
        SceneManager.SetActiveScene(_nextScene);

        // Move Player(s) to Scene at SpawnPoint
        _spawnPosition = SCENES.SpawnPointLookUp(SETTINGS.currentScene, SETTINGS.spawnPointIndex);
        player.transform.SetPositionAndRotation(_spawnPosition, _rotation);
        SceneManager.MoveGameObjectToScene(player.gameObject, _nextScene);

        // Unload Previous Scene
        SceneManager.UnloadSceneAsync("SceneStartMenu");

        // if(!newgame)
        // {
        //  SAVELOAD.Load(filename);

        //  SETTINGS.saveFileName = filename;

        //  player = Instantiate(player);
        //  player.name = "alucard";
        //  AsyncOperation a = SceneManager.LoadSceneAsync(SETTINGS.currentScene, LoadSceneMode.Additive);
        //  while (!a.isDone)
        //  {
        //      yield return null;
        //  }

        //  _nextScene = SceneManager.GetSceneByName(SETTINGS.currentScene);
        //  SceneManager.SetActiveScene(_nextScene);

        //  _spawnPosition = SCENES.SpawnPointLookUp(SETTINGS.currentScene, SETTINGS.spawnPointIndex);
        //  player.transform.SetPositionAndRotation(_spawnPosition, _rotation);
        //  SceneManager.MoveGameObjectToScene(player.gameObject, _nextScene);
        //  SceneManager.UnloadSceneAsync("SceneStartMenu");
        // }
        // else
        // {


        //  SETTINGS.saveFileName = filename;

        //  player = Instantiate(player);
        //  player.name = "alucard";
        //  AsyncOperation a = SceneManager.LoadSceneAsync("SceneStage", LoadSceneMode.Additive);
        //  while (!a.isDone)
        //  {
        //      yield return null;
        //  }
        //  _nextScene = SceneManager.GetSceneByName(SCENES.Stage.sceneName);
        //  SceneManager.SetActiveScene(_nextScene);
        //  player.transform.SetPositionAndRotation(_spawnPosition, _rotation);
        //  SceneManager.MoveGameObjectToScene(player.gameObject, _nextScene);
        //  SceneManager.UnloadSceneAsync("SceneStartMenu");
        // }
    }
Exemple #17
0
 static public void SceneMove(SCENES NextScene)
 {
     SceneManager.LoadScene((int)NextScene);
 }
Exemple #18
0
 public void LoadScene(SCENES sceneToLoad)
 {
     SceneManager.LoadScene((int)sceneToLoad);
 }
 static public void SceneMove(SCENES NextScene)
 {
     // FadeManagerを呼び出す
     FadeManager.instance.LoadScene((int)NextScene, 1.0f);
 }
 static public void SceneMove(SCENES NextScene)
 {
     FadeManager.Instance.LoadScene((int)NextScene, 1.0f);
 }