Esempio n. 1
0
    // Use this for initialization
    void Start()
    {
        player = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerControl>();
        player.gameSceneControl = this;

        levelControl = new LevelControl();
        levelControl.gameSceneControl = this;
        levelControl.player           = player;
        levelControl.oniGroupPrefab   = oniGroupPrefab;
        levelControl.Create();

        resultControl = new ResultControl();

        gameUIControl = GameUIControl.Instance;
        scoreControl  = gameUIControl.scoreControl;

        result.oniDefeatNum    = 0;
        result.evaluationCount = new int[(int)Evaluation.Num];
        result.rank            = 0;
        result.score           = 0;
        result.scoreMax        = 0;

        for (int i = 0; i < result.evaluationCount.Length; i++)
        {
            result.evaluationCount[i] = 0;
        }

        fadeControl = FadeControl.Instance;
        fadeControl.Fade(3.0f, new Color(0, 0, 0, 1.0f), new Color(0, 0, 0, 0));

        nextState = State.Start;
    }
Esempio n. 2
0
    IEnumerator EndSequence()
    {
        fade.Fade();
        yield return(new WaitForSeconds(2));

        SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
    }
Esempio n. 3
0
 void OnCollisionEnter2D(Collision2D other)
 {
     if (other.gameObject.CompareTag("Bounds"))
     {
         speed = -speed;
     }
     if (other.gameObject.CompareTag("Player"))
     {
         text.SetActive(true);
         fade.Fade();
         SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
     }
 }
Esempio n. 4
0
    // Use this for initialization
    void Start()
    {
        // set player uncontrollable
        PlayerControl player = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerControl>();

        player.IsPlayable = false;

        fadeControl = FadeControl.Instance;
        fadeControl.Fade(FadeTime, new Color(0, 0, 0, 1.0f), new Color(0, 0, 0, 0));

        startAudio = GetComponent <AudioSource>();

        nextState = State.Title;
    }
Esempio n. 5
0
 public void newGame()
 {
     fade.Fade();
     soundManager.PlaySound("Thunder");
     StartCoroutine(Play());
 }
Esempio n. 6
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.P))
        {
            Debug.Break();
        }

        preStateTimer = timer;
        timer        += Time.deltaTime;

        switch (state)
        {
        case State.Start:
        {
            if (timer > StartTime)
            {
                gameUIControl.SetStartVisible(false);
                nextState = State.Game;
            }
            break;
        }

        case State.Game:
        {
            levelControl.OniAppearControl();

            if (oniGroupComplite >= oniGroupAppearMax)
            {
                nextState = State.WaitOniVanish;
            }

            if (oniGroupComplite >= ScoreHideNum && backupOniDefeatNum == -1)
            {
                backupOniDefeatNum = result.oniDefeatNum;
            }

            break;
        }

        case State.WaitOniVanish:
        {
            if (GameObject.FindGameObjectsWithTag("OniGroup").Length == 0 && player.GetSpeedRate() > 0.5f)
            {
                nextState = State.LastRun;
            }

            break;
        }

        case State.LastRun:
        {
            if (timer > 2.0f)
            {
                nextState = State.WaitPlayerStop;
            }

            break;
        }

        case State.WaitPlayerStop:
        {
            if (player.IsStopped)
            {
                scoreControl.SetScoreForce(backupOniDefeatNum);
                scoreControl.SetScore(result.oniDefeatNum);
                nextState = State.Goal;
            }
            break;
        }

        case State.Goal:
        {
            if (oniEmitter.oniNum == 0)
            {
                nextState = State.WaitOniFall;
            }

            break;
        }

        case State.WaitOniFall:
        {
            if (!scoreControl.IsActive && timer > 1.5f)
            {
                nextState = State.ResultDefeat;
            }

            break;
        }

        case State.ResultDefeat:
        {
            if (timer >= 0.4f && preStateTimer < 0.4f)
            {
                GetComponent <AudioSource>().PlayOneShot(evaluationSound);
            }
            if (timer > 0.5f)
            {
                nextState = State.ResultEvaluation;
            }

            break;
        }

        case State.ResultEvaluation:
        {
            if (timer >= 0.4f && preStateTimer < 0.4f)
            {
                GetComponent <AudioSource>().PlayOneShot(evaluationSound);
            }
            if (timer > 2.0f)
            {
                nextState = State.ResultTotal;
            }

            break;
        }

        case State.ResultTotal:
        {
            if (timer >= 0.4f && preStateTimer < 0.4f)
            {
                GetComponent <AudioSource>().PlayOneShot(evaluationSound);
            }
            if (timer > 2.0f)
            {
                nextState = State.GameOver;
            }

            break;
        }

        case State.GameOver:
        {
            if (Input.GetMouseButton(0))
            {
                fadeControl.Fade(1.0f, new Color(0, 0, 0, 0), new Color(0, 0, 0, 1.0f));
                GetComponent <AudioSource>().PlayOneShot(returnSound);
                nextState = State.GotoTitle;
            }
            break;
        }

        case State.GotoTitle:
        {
            if (fadeControl.IsActive)
            {
                UnityEngine.SceneManagement.SceneManager.LoadScene("TitleScene");
            }

            break;
        }
        }

        if (nextState != State.None)
        {
            switch (nextState)
            {
            case State.Start:
            {
                gameUIControl.SetStartVisible(true);
                break;
            }

            case State.WaitPlayerStop:
            {
                player.Stop();
                int totalRank = resultControl.GetTotalRank();
                if (totalRank > 0)
                {
                    var oniHill         = Instantiate <GameObject>(OniHillPrefab[totalRank]);
                    var oniHillPosition = player.transform.position;
                    oniHillPosition.x         += player.DistanceToStop();
                    oniHillPosition.x         += GoalStopDistance;
                    oniHillPosition.y          = 0.0f;
                    oniHill.transform.position = oniHillPosition;
                }

                break;
            }

            case State.Goal:
            {
                var go = Instantiate <GameObject>(oniEmitterPrefab);
                oniEmitter = go.GetComponent <OniEmitterControl>();
                var emitterPosition = oniEmitter.transform.position;

                emitterPosition.x  = player.transform.position.x;
                emitterPosition.x += player.DistanceToStop();
                emitterPosition.x += GameSceneControl.GoalStopDistance;

                oniEmitter.transform.position = emitterPosition;

                int oniNum = 0;
                switch (resultControl.GetTotalRank())
                {
                // bad rank
                case 0: oniNum = Mathf.Min(result.oniDefeatNum, 10); break;

                // normal rank
                case 1: oniNum = 6; break;

                // good rank
                case 2: oniNum = 10; break;

                // excellent rank
                case 3: oniNum = 20; break;
                }
                oniEmitter.oniNum = oniNum;
                if (oniNum == 0)
                {
                    oniEmitter.isEnableHitSound = false;
                }
                break;
            }

            case State.ResultDefeat:
            {
                oniEmitter.isEnableHitSound = false;
                gameUIControl.DisplayDefeatRank(true);
                break;
            }

            case State.ResultEvaluation:
            {
                gameUIControl.DisplayEvaluationRank(true);
                break;
            }

            case State.ResultTotal:
            {
                gameUIControl.DisplayDefeatRank(false);
                gameUIControl.DisplayEvaluationRank(false);

                gameUIControl.DisplayTotalRank(true);
                break;
            }

            case State.GameOver:
            {
                gameUIControl.SetReturnVisible(true);
                break;
            }
            }

            state         = nextState;
            nextState     = State.None;
            timer         = 0.0f;
            preStateTimer = -1.0f;
        }
    }
Esempio n. 7
0
    // Update is called once per frame
    void Update()
    {
        timer += Time.deltaTime;

        switch (state)
        {
        case State.Title:
        {
            if (Input.GetMouseButton(0))
            {
                nextState = State.WaitSoundEffectEnd;
            }

            break;
        }

        case State.WaitSoundEffectEnd:
        {
            // Scale Animation for start image.
            float rate  = timer / TitleAnimationTime;
            float scale = Mathf.Lerp(2.0f, 1.0f, rate);

            startImage.rectTransform.localScale = Vector3.one * scale;

            // Check whether start audio is over
            if (!startAudio.isPlaying || startAudio.time >= startAudio.clip.length)
            {
                nextState = State.WaitFade;
            }

            break;
        }

        case State.WaitFade:
        {
            if (!fadeControl.IsActive)
            {
                nextState = State.LoadGameScene;
            }

            break;
        }
        }

        if (nextState != State.None)
        {
            switch (nextState)
            {
            case State.WaitSoundEffectEnd:
            {
                startAudio.Play();
                break;
            }

            case State.WaitFade:
            {
                fadeControl.Fade(FadeTime, new Color(0, 0, 0, 0), new Color(0, 0, 0, 1.0f));
                break;
            }

            case State.LoadGameScene:
            {
                SceneManager.LoadScene("GameScene");
                break;
            }
            }

            state     = nextState;
            nextState = State.None;
            timer     = 0;
        }
    }