コード例 #1
0
ファイル: GameManager.cs プロジェクト: JLSaake/Night-Light
    // Update is called once per frame
    void Update()
    {
        if (playerInstance != null)
        {
            overheadCamera.transform.position = new Vector3(playerInstance.transform.position.x,
                                                            overheadCamera.transform.position.y,
                                                            playerInstance.transform.position.z);
            overheadCamera.transform.rotation = overheadCameraStart;
            overheadCamera.transform.Rotate(new Vector3(playerInstance.transform.eulerAngles.z,
                                                        playerInstance.transform.eulerAngles.x,
                                                        -playerInstance.transform.eulerAngles.y));
        }

        if (Input.GetButtonDown("Pause") && gamePaused && uiManager.InPauseMain())
        {
            UnpauseGame();
        }
        else
        if (gameActive)
        {
            if (Input.GetButtonDown("Pause"))
            {
                PauseGame();
            }

            if ((Input.GetButtonDown("Fire2")) && (playerInstance != null) && (Scoring.GetLight() > 0))
            {
                PlayerProjectile projectile = Instantiate(projectilePrefab) as PlayerProjectile;
                projectile.FireProjectile(playerInstance);
            }
            if (prevLight != Scoring.GetLight())
            {
                prevLight = Scoring.GetLight();
                if (Scoring.GetLight() <= 0)
                {
                    playerInstance.setWalkSpeed(slowWalk);
                }
                else
                {
                    playerInstance.setWalkSpeed(fastWalk);
                }
            }
            //Debug.Log("Time Remaining: " + Mathf.Round(maxTime - timer.GetElapsedTime()) + " seconds");
            //Debug.Log("Ghosts Remaining: " + Ghost.GhostCountGet());
            //TODO: UI updating (light, time, and ghosts remaining goes here)

            if (Ghost.GhostCountGet() <= 0)
            {
                playerInstance.setMove(false);
                Debug.Log("You Win!");
                gameActive = false;
                timer.PauseTime();
                playerInstance.FreeCursor();
                levelManager.LoadLevel("06Win");
            }

            uiManager.UpdateNumbers(Scoring.GetLight(), (maxTime - timer.GetElapsedTime()), Ghost.GhostCountGet());
        }

        if (timer.GetElapsedTime() > maxTime && !outOfTime)
        {
            playerInstance.setMove(false);
            outOfTime  = true;
            gameActive = false;
            Debug.Log("GameOver");
            playerInstance.FreeCursor();
            levelManager.LoadLevel("05Lose");
        }
    }