Ejemplo n.º 1
0
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    void Update()
    {
        if (count.GetCountEnd())
        {
            if (!carSetting.automaticGear && activeControl)
            {
                if (Input.GetKeyDown("page up"))
                {
                    ShiftUp();
                }
                if (Input.GetKeyDown("page down"))
                {
                    ShiftDown();
                }
            }
        }
    }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        if (!pauseM.GetFlag())
        {
            if (Camera.main != null)
            {
                Pos = PosParent.transform.position;
                Pos = new Vector3(Pos.x, Pos.y + 4.5f, Pos.z);                                 // グレの位置を車両の近くに設定

                cameraPos = Camera.main.transform.position;                                    // カメラの位置

                cursorPosition = Input.mousePosition;                                          // 画面上のカーソルの位置

                cursorPosition.z = Vector3.Distance(cameraPos, this.transform.position) + 20f; // z座標にメインカメラから車の距離を入れる

                cursorPosition3d = Camera.main.ScreenToWorldPoint(cursorPosition);             // 3Dの座標になおす
                throwDirection   = cursorPosition3d - this.transform.position;                 // 玉を飛ばす方向

                throwDirection.y += 2.0f;                                                      // グレの飛ぶ高さを指定



                // インターバルをつける
                if (BombStock != 0 && countDown.GetCountEnd())
                {
                    if (Input.GetMouseButtonDown(0))                                                     // マウスの左クリックを押したとき
                    {
                        rb_ball = Instantiate(ball, Pos, transform.rotation).GetComponent <Rigidbody>(); // 玉を生成
                        rb_ball.transform.parent = PosParent.transform;                                  // 車両をグレネードの親に設定

                        // 点滅フラグをONにする
                        isBlink = true;
                    }
                    if (Input.GetMouseButtonUp(0))
                    {
                        // 点滅フラグをOFFにする
                        isBlink = false;

                        BombStock--;

                        if (rb_ball != null)
                        {
                            rb_ball.isKinematic = false;
                            rb_ball.AddForce(throwDirection + carRigid.velocity, ForceMode.Impulse); // カーソルの方向に力を一度加える
                            // ボムを投げる効果音
                            audioSource.PlayOneShot(clip[0]);
                        }
                    }
                }


                if (BOMBMAX > BombStock)
                {
                    if (count >= INTERVAL)
                    {
                        BombStock++;
                        // ボム回復効果音
                        audioSource.PlayOneShot(clip[1]);
                        count = 0f;
                    }
                }


                count += Time.deltaTime;
            }
        }
    }