コード例 #1
0
ファイル: FieldItem.cs プロジェクト: mecha-rm/GDW_Y3-PJT
    // Update is called once per frame
    void Update()
    {
        // if there is a death space
        if (deathSpace != null)
        {
            // if the item box falls into the death space, it is returned to the object pool.
            if (deathSpace.InDeathSpace(transform.position) == true)
            {
                ItemManager.GetInstance().ReturnItem(this);
            }
        }
        // maybe check for the death space if it isn't set?

        // counts down to when this item should despawn
        if (useDespawnTimer)
        {
            despawnCountdown -= Time.deltaTime;

            // returns item to pool.
            if (despawnCountdown <= 0.0F)
            {
                despawnCountdown = 0.0F;
                ItemManager.GetInstance().ReturnItem(this);
            }
        }
    }
コード例 #2
0
    // Update is called once per frame
    void Update()
    {
        // the existing players
        List <PlayerObject> players = new List <PlayerObject>();

        if (p1 != null)
        {
            players.Add(p1);
        }

        if (p2 != null)
        {
            players.Add(p2);
        }

        if (p3 != null)
        {
            players.Add(p3);
        }

        if (p4 != null)
        {
            players.Add(p4);
        }


        // goes through with all the players
        foreach (PlayerObject px in players)
        {
            // player has been found.
            if (px.playerScore >= winScore)
            {
                // searches for game builder
                GameBuilder gb = FindObjectOfType <GameBuilder>();

                // if game builder exists, then tell it not to load the game again when it exists the scene.
                if (gb != null)
                {
                    gb.recentWinner = px.playerNumber; // saves the most recent winner.
                    gb.SetLoadGame(false);
                }


                SceneManager.LoadScene(nextScene);
            }

            // checks for death
            if (deathSpace.InDeathSpace(px.gameObject.transform.position))
            {
                px.Respawn();
            }
        }

        // if the game is timed.
        if (timedGame && countdownTimer != null)
        {
            // if the timer has hit zero, end the game.
            float currTime = countdownTimer.GetCurrentTimeValue();

            // checks to see if time has reached 0.
            if (currTime <= 0.0F)
            {
                // loads scene.
                SceneManager.LoadScene(nextScene);
            }
        }

        // player 1 has won
        // if (p1 != null)
        // {
        //     if (p1.playerScore >= winScore)
        //         SceneManager.LoadScene("EndScene");
        //
        //     // death calculation.
        //     if (deathSpace.InDeathSpace(p1.gameObject.transform.position))
        //         p1.Respawn();
        // }
        //
        // // player 2 has won
        // if (p2 != null)
        // {
        //     if (p2.playerScore >= winScore)
        //         SceneManager.LoadScene("EndScene");
        // }
        //
        // // player 3 has won
        // if (p3 != null)
        // {
        //     if (p3.playerScore >= winScore)
        //         SceneManager.LoadScene("EndScene");
        // }
        //
        // // player 4 has won
        // if (p4 != null)
        // {
        //     if (p4.playerScore >= winScore)
        //         SceneManager.LoadScene("EndScene");
        // }
    }