Пример #1
0
    // Update is called once per frame
    void Update()
    {
        switch (state)
        {
        case (PLAYER_STATE.STOP):
        {
            //スタートするまでの待機
            time += Time.deltaTime;


            //スタートする時のUI
            //スタート時間になったので状態を走る状態にする。
            if (time >= startWaitTime)
            {
                startRenderer.enabled = false;
                time  = 0;
                state = PLAYER_STATE.RUN;
                GetComponent <Animator>().SetBool("bRun", true);
                smog.Play();                    //走る時の煙エフェクトON
            }
            else if (time >= startWaitTime - 1) //スタートまで1秒前
            {
                startUi.transform.localScale = new Vector3(1, 1, 0.5f);
                startRenderer.sharedMaterial.SetTextureOffset("_MainTex", new Vector2(0, 0));
                if ((int)time != seCheckTimeOld)
                {
                    se.SePlay("pon");
                }
            }
            else if (time >= startWaitTime - 2)       //スタートまで2秒前
            {
                startUi.transform.localScale = new Vector3(time / 10 + 0.5f, startUi.transform.localScale.y, time / 10 + 0.5f);
                startRenderer.sharedMaterial.SetTextureOffset("_MainTex", new Vector2(0, -0.25f));
                if ((int)time != seCheckTimeOld)
                {
                    se.SePlay("pi");
                }
            }
            else if (time >= startWaitTime - 3)
            {
                                                     //スタートまで3秒前
                {
                    startUi.transform.localScale = new Vector3(time / 10 + 0.5f, startUi.transform.localScale.y, time / 10 + 0.5f);
                    startRenderer.sharedMaterial.SetTextureOffset("_MainTex", new Vector2(0, -0.50f));
                    if ((int)time != seCheckTimeOld)
                    {
                        se.SePlay("pi");
                    }
                }
            }
            else if (time >= startWaitTime - 4)
            {
                                                     //スタートまで4秒前
                {
                    startRenderer.enabled        = true;
                    startUi.transform.localScale = new Vector3(time / 10 + 0.5f, startUi.transform.localScale.y, time / 10 + 0.5f);
                    startRenderer.sharedMaterial.SetTextureOffset("_MainTex", new Vector2(0, -0.75f));
                    if ((int)time != seCheckTimeOld)
                    {
                        se.SePlay("pi");
                    }
                }
            }
            seCheckTimeOld = (int)time;
            break;
        }

        case (PLAYER_STATE.RUN):
        {
            //スピードの変更
            changeAccel();
            //横の移動量決定
            velocity = new Vector3(speed / 60 * 4, velocity.y, 0);

            //壁に当たってる間は止まる。
            if (bHitWall)
            {
                velocity.x = 0.0f;
                time      += Time.deltaTime;
                if (time > 1)
                {
                    time     = 0;
                    speed    = speedMin;
                    bHitWall = false;
                }
            }
            break;
        }

        default:
        {
            break;
        }
        }
    }
Пример #2
0
    // Update is called once per frame
    void Update()
    {
        if (!isLocalPlayer)
        {
            return;
        }

        ////順位判定
        if (Player2 == null)
        {
            Player2 = GameObject.Find("vsPlayer");
        }
        else
        {
            Distance = transform.position.x - Player2.transform.position.x;
        }



        rankText.text = rank.ToString() + "位";


        switch (state)
        {
        case (PLAYER_STATE.STOP):
        {
            //スタート時間になったので状態を走る状態にする。
            if (hostTimerScript.GetTime() >= startWaitTime)
            {
                startRenderer.enabled = false;
                smog.Play();
                time  = 0;
                state = PLAYER_STATE.RUN;
                GetComponent <Animator>().SetBool("bRun", true);
            }
            //スタートする時のUI
            //スタート時間になったので状態を走る状態にする。
            else if (hostTimerScript.GetTime() >= startWaitTime - 1)         //スタートまで1秒前
            {
                startUi.transform.localScale = new Vector3(1, 1, 0.5f);
                startRenderer.sharedMaterial.SetTextureOffset("_MainTex", new Vector2(0, 0));
                if ((int)time != seCheckTimeOld)
                {
                    se.SePlay("pon");
                }
            }
            else if (hostTimerScript.GetTime() >= startWaitTime - 2)         //スタートまで2秒前
            {
                startUi.transform.localScale = new Vector3(time / 10 + 0.5f, startUi.transform.localScale.y, time / 10 + 0.5f);
                startRenderer.sharedMaterial.SetTextureOffset("_MainTex", new Vector2(0, -0.25f));
                if ((int)time != seCheckTimeOld)
                {
                    se.SePlay("pi");
                }
            }
            else if (hostTimerScript.GetTime() >= startWaitTime - 3)         //スタートまで3秒前
            {
                startUi.transform.localScale = new Vector3(time / 10 + 0.5f, startUi.transform.localScale.y, time / 10 + 0.5f);
                startRenderer.sharedMaterial.SetTextureOffset("_MainTex", new Vector2(0, -0.50f));
                if ((int)time != seCheckTimeOld)
                {
                    se.SePlay("pi");
                }
            }
            else if (hostTimerScript.GetTime() >= startWaitTime - 4)         //スタートまで4秒前
            {
                startRenderer.enabled        = true;
                startUi.transform.localScale = new Vector3(time / 10 + 0.5f, startUi.transform.localScale.y, time / 10 + 0.5f);
                startRenderer.sharedMaterial.SetTextureOffset("_MainTex", new Vector2(0, -0.75f));
                if ((int)time != seCheckTimeOld)
                {
                    se.SePlay("pi");
                }
            }

            seCheckTimeOld = (int)time;

            break;
        }

        case (PLAYER_STATE.RUN):
        {
            //スピードの変更
            changeAccel();

            //横の移動量決定
            velocity = new Vector3(speed / 60 * 4, velocity.y, 0);

            //壁に当たってる間は止まる。
            if (bHitWall)
            {
                velocity.x = 0.0f;
                time      += Time.deltaTime;
                if (time > 1)
                {
                    time     = 0;
                    speed    = speedMin;
                    bHitWall = false;
                }
            }

            //順位判定
            if (Distance >= 0)
            {
                rank = 1;
            }
            else
            {
                rank = 2;
            }

            break;
        }

        default:
        {
            break;
        }
        }
    }