Example #1
0
 public void BackLobby()
 {
     MyPV.RPC("RPCBackLobby", PhotonTargets.AllBuffered);
     NowLacePhase = LacePhase.End;
     //ロビーBGM
     SoundManager.Instance.PlayBGM(2);
 }
Example #2
0
    //レースのフェーズをReadyに出来るかチェック。
    public void CheckLacePhaseShiftToReady()
    {
        //開始人数になったら準備開始。
        if (LacePlayStartNum == LacePlayerList.Count)
        {
            //レースの段階を準備に進める。
            NowLacePhase = LacePhase.Ready;

            //レース中フラグを立てる。
            IsLaceFlag = true;
        }
    }
Example #3
0
    //レースの準備。
    private void LaceReady()
    {
        for (int i = 0; i < LacePlayStartNum; i++)
        {
            if (LacePlayerList[i].NetID == PhotonNetwork.player.ID)
            {
                //自キャラでのみ車を作成。
                UseLaceCar = PhotonNetwork.Instantiate(this.LaceCarPrefab.name,
                                                       LaceStartPos[i].position,
                                                       LaceStartPos[i].rotation,
                                                       0);

                //車のハンドブレーキを引く。
                UseLaceCar.GetComponent <SimpleCarController>().ChangeRunFlag();

                //kmテキストに速度表示テキストを設定。
                UseLaceCar.GetComponent <Km>().SetCarSpeedText(CarSpeedText);

                //速度テキストを表示。
                CarSpeedText.gameObject.SetActive(true);

                //ミニマップの表示。
                LaceMiniMap.SetActive(true);

                //ミニマップのカメラのターゲットを設定。
                LaceMiniMap.GetComponent <MiniMap>().ChangeTarget(UseLaceCar.transform);

                ////カウントダウン開始。
                //CountDownTimeText.gameObject.SetActive(true);
                CountDownTimeText.GetComponent <CountDownTime>().CountDownStart(3.0f, "00");
                Anim.SetActive(true);
                Anim.GetComponent <Animator>().Play("countDown");
                //直前のBGMを停止
                SoundManager.Instance.StopBGM();
                //カウントダウンのSE
                SoundManager.Instance.PlaySE(1);

                MainCamera.GetComponent <NoboCamera>().enabled   = false;
                MainCamera.GetComponent <ExampleClass>().enabled = true;
                MainCamera.GetComponent <ExampleClass>().SetTarget(UseLaceCar.GetComponent <SimpleCarController>().GetLaceCameraTrans());

                PhotonView player = PhotonView.Find(LacePlayerList[i].ID);
                player.GetComponent <NoboCharacterController>().PhotonDestroy();
            }
        }
        //レース段階を開始に進める。
        NowLacePhase = LacePhase.Start;
    }
Example #4
0
    //各数値の初期化。
    public void LaceUseVariableReset()
    {
        if (LacePlayerList.Count > 0)
        {
            LacePlayerList.Clear();
        }

        if (Goal.Count > 0)
        {
            Goal.Clear();
        }

        IsLaceFlag = false;

        NowLacePhase = LacePhase.None;

        LaceTimeText.GetComponent <GameTime>().ResetGameTime();
    }
Example #5
0
    // Update is called once per frame
    void Update()
    {
        UpdateReservationPlayerNameText();

        switch (NowLacePhase)
        {
        case LacePhase.None:
            if (GoalPlyerNum <= 0 && IsLaceFlag == true)
            {
                //LaceUseVariableReset();
                MyPV.RPC("LaceUseVariableReset", PhotonTargets.AllBuffered);
            }
            break;

        case LacePhase.Ready:
            LaceReady();
            break;

        case LacePhase.Start:
            //カウントダウンが終わったら。
            if (Anim.GetComponent <Animator>().GetCurrentAnimatorStateInfo(0).normalizedTime > 1.0f)
            {
                //車のハンドブレーキを降ろす。
                UseLaceCar.GetComponent <SimpleCarController>().ChangeRunFlag();
                //レース開始。
                NowLacePhase = LacePhase.Game;

                //レースBGMを鳴らす
                SoundManager.Instance.PlayBGM(3);

                //カウントダウンテキストを非表示。
                CountDownTimeText.gameObject.SetActive(false);
                Anim.SetActive(false);

                //レース時間テキストを表示。
                LaceTimeText.gameObject.SetActive(true);
            }
            break;

        case LacePhase.Game:

            //プレイヤーが一人ゴールした。
            if (GoalPlyerNum == 1)
            {
                CountDownTimeText.gameObject.SetActive(true);

                //カウントダウン開始。
                CountDownTimeText.GetComponent <CountDownTime>().CountDownStart(CountDownTime, "00");

                NowLacePhase = LacePhase.Goal;
            }
            break;

        case LacePhase.Goal:
            //全員ゴールが出来た。
            if (GoalPlyerNum == LacePlayStartNum)
            {
                for (int i = 0; i < LacePlayerList.Count; i++)
                {
                    if (LacePlayerList[i].NetID == UseLaceCar.GetComponent <PhotonView>().ownerId)
                    {
                        UseLaceCar.transform.position = PodiumPos[i].position;
                        //カウントダウン開始。
                        CountDownTimeText.gameObject.SetActive(false);
                        NowLacePhase = LacePhase.Result;
                        SoundManager.Instance.PlaySE(2);
                    }
                }
                NowLacePhase = LacePhase.Result;
                return;
            }

            //カウントダウンが終了した時点で全員がゴールしていなくてもレースを終わらせる。
            if (CountDownTimeText.GetComponent <CountDownTime>().GetCountDownEnd() == true)
            {
                //カウントダウンを非表示。
                CountDownTimeText.gameObject.SetActive(false);

                //レースの順位分ループを回す。
                for (int j = 0; j < LacePlayerList.Count;)
                {
                    for (int i = 0; i < LacePlayerList.Count; i++)
                    {
                        if (LacePlayerList[i].NetID == PhotonNetwork.player.ID)
                        {
                            ////リザルトで表示する赤い帯の位置を設定。
                            //LaceResultTransparentPanel.GetComponent<RectTransform>().transform.position =
                            //    new Vector3(400.0f,
                            //    LaceResultTransparentPanel.GetComponent<RectTransform>().transform.position.y - 50.0f * j,
                            //    0.0f);

                            //ゴールしている時の処理。
                            if (LacePlayerList[i].isGoal == true)
                            {
                                UseLaceCar.transform.position = PodiumPos[j].position;
                            }
                            //ゴールしていない
                            else
                            {
                                //ゴールしていないプレイヤーのリザルト情報を設定。
                                MyPV.RPC("RPCAddLaceResult", PhotonTargets.All, UseLaceCar.GetComponent <PhotonView>().ownerId,
                                         "--:--:--", UseLaceCar.GetComponent <PhotonView>().owner.NickName, false);
                                UseLaceCar.GetComponent <SimpleCarController>().ChangeRunFlag();
                                NowLacePhase = LacePhase.Result;
                                return;
                            }
                        }
                    }
                    j++;
                }
            }
            break;

        case LacePhase.Result:
            //レース時間テキスト非表示。
            LaceTimeText.gameObject.SetActive(false);
            //リザルトを表示。
            LaceResultPanel.SetActive(true);
            //ミニマップを非表示。
            LaceMiniMap.SetActive(false);
            //lobbyに戻るボタンを表示。
            BackLobbyButton.gameObject.SetActive(true);
            break;

        case LacePhase.End:

            //レースに使うテキスト群を非表示。
            SetActiveCollection(false);

            //車を削除。
            if (UseLaceCar != null)
            {
                PhotonNetwork.Destroy(UseLaceCar);
                UseLaceCar = null;
            }

            //レース用のカメラから普通のカメラに戻す。
            MainCamera.GetComponent <NoboCamera>().enabled   = true;
            MainCamera.GetComponent <ExampleClass>().enabled = false;
            MainCamera.GetComponent <ExampleClass>().SetTarget(null);

            //lobbyに戻るボタンを非表示。
            BackLobbyButton.gameObject.SetActive(false);

            //レースフェーズを初期化。
            NowLacePhase = LacePhase.None;

            //PhotonNetwork上にプレイヤーを生成し、メインカメラのターゲットを切り替え。
            MainCamera.GetComponent <NoboCamera>().ChangeTarget(GameManager.GetComponent <GameManager>().PhotonInstantiatePlayer(ReturnLobbyPos.position, Quaternion.identity, 0).transform);
            break;

        default:
            break;
        }
    }