Пример #1
0
 // Update is called once per frame
 void Update()
 {
     if (gameMode != GameMode.play &&
         xBox.ButtonDown(XBox.Str.Start))
     {
         Time.timeScale = 1f;
         PlayGame();
     }
     //プレイ中にできること
     else if (gameMode == GameMode.play && !playerScript.stopPlayer)
     {
         //ポーズ画面の表示
         if ((xBox.ButtonDown(XBox.Str.Start)))
         {
             playerScript.stopPlayer = true;
             pauseUi.gameObject.SetActive(true);
             ChangePouseMode();
         }
     }
     //ポース中にできること
     else if (gameMode == GameMode.pause)
     {
         PauseMode();
     }
     else if (gameMode == GameMode.Help)
     {
         Time.timeScale = 0f;
         if ((xBox.ButtonDown(XBox.Str.A)))
         {
             ChangePouseMode();
         }
     }
 }
Пример #2
0
    void Update()
    {
        if (!ngFlag)
        {
            if (scrollFlag)
            {
                renbanMovie.titleUi.transform.localPosition = Vector3.MoveTowards(renbanMovie.titleUi.transform.localPosition, new Vector3(0f, 540f, 0f), 2160f * Time.deltaTime);
            }

            if (renbanMovie.titleUi.transform.localPosition == new Vector3(0f, 540f, 0f))
            {
                selectFlag = true;
                scrollFlag = false;
            }

            //スタートボタン
            if (xBox.ButtonDown(XBox.Str.Start) ||
                xBox.ButtonDown(XBox.Str.A))
            {
                if (!scrollFlag)
                {
                    audioC.SeSoundPlay(AudioController.Se.Enter);
                }

                if (!selectFlag && !scrollFlag)
                {
                    scrollFlag = true;
                }
                else if (selectFlag)
                {
                    if (tutorialChoice)
                    {
                        choiceStage = 0;
                    }
                    GameController.stageNumber = (GameController.StageNumber)Enum.ToObject(typeof(GameController.StageNumber), choiceStage);
                    //ステージへ
                    LoadScene.sceneName = "Stage";
                    StartCoroutine(Load(audioC.clip));
                }
            }
            ChangeStage();
        }

        // ステージアイコンの描画処理---------------------------------------------------------
        if (choiceOkStage > 2)
        {
            Kazan.enabled = true;
            Mori.transform.localPosition   = new Vector3(-600f, -810f, 0f);
            Sabaku.transform.localPosition = new Vector3(0f, -810f, 0f);
        }
        else
        {
            Kazan.enabled = false;
            Mori.transform.localPosition   = new Vector3(-300f, -810f, 0f);
            Sabaku.transform.localPosition = new Vector3(300f, -810f, 0f);
        }
        if (choiceOkStage > 1)
        {
            Sabaku.enabled = true;
        }
        else
        {
            Sabaku.enabled = false;
            Mori.transform.localPosition = new Vector3(0f, -810f, 0f);
        }
        //----------------------------------------------------------------------------------

        // カーソルの移動
        if (tutorialChoice)
        {
            ChoicepositonUpdate(Tutorial);
        }
        else
        {
            if (choiceStage == 1)
            {
                ChoicepositonUpdate(Mori);
            }
            else if (choiceStage == 2)
            {
                ChoicepositonUpdate(Sabaku);
            }
            else if (choiceStage >= 3)
            {
                ChoicepositonUpdate(Kazan);
            }
        }
    }
Пример #3
0
    void Update()
    {
        if (!heightLock && playerScript.playerLife != 0)
        {
            // カメラの切り替え
            if (!playerScript.stopPlayer)
            {
                if (playerScript.cableScript.chilledBlock == null && !playerScript.cableScript.cableLock && (xBox.Button(XBox.Str.LB)))
                {
                    lookOnFlag = true;
                }
                else
                {
                    lookOnFlag = false;
                }
            }


            //FPSとTPSでカメラの高さを変更する
            transform.position = player.transform.position + (lookOnFlag ? new Vector3(0f, 1.15f, 0f) - transform.forward * 0.15f : new Vector3(0f, 1.5f, 0f));     // カメラを自機に追従させる
            if (gameController.gameMode == GameController.GameMode.play)
            {
                rotateCameraAngle();

                if (playerScript.cableScript.chilledBlock == null && !playerScript.cableScript.cableLock &&
                    xBox.ButtonDown(XBox.Str.LB) && playerScript.cableFlag && !playerScript.stopPlayer)
                {
                    mainCamera.transform.LookAt(playerScript.cableScript.cablePosition.transform.position);
                }

                float cameraDistance;

                //FPS時の処理
                if (lookOnFlag)
                {
                    RaycastHit hit;
                    cameraMaxDistance = Mathf.MoveTowards(cameraMaxDistance, FPS_MAX_DISTANCE, 60f * Time.deltaTime);

                    if (cameraMaxDistance != FPS_MAX_DISTANCE &&
                        Physics.SphereCast(this.transform.position, 0.02f, -transform.forward, out hit, cameraMaxDistance, layerMask))
                    {
                        cameraMaxDistance = hit.distance;
                    }
                    else
                    {
                        mainCamera.transform.position = player.transform.position + (Vector3.up * 1.15f) + -player.transform.forward * (cameraMaxDistance - 0.15f);
                    }
                    mainCamera.transform.eulerAngles = new Vector3(transform.eulerAngles.x, transform.eulerAngles.y, mainCamera.transform.eulerAngles.z);
                }
                //TPS時の処理
                else
                {
                    //TPS時
                    RaycastHit hit;
                    cameraMaxDistance = Mathf.MoveTowards(cameraMaxDistance, TPS_MAX_DISTANCE, 60f * Time.deltaTime);
                    if (Physics.SphereCast(this.transform.position, 0.02f, -transform.forward, out hit, cameraMaxDistance, layerMask))
                    {
                        cameraMaxDistance = hit.distance;
                    }
                    cameraDistance = cameraMaxDistance;
                    //tpsに移行が終わってる時
                    //カメラの向きと場所の変更
                    mainCamera.transform.position = transform.position + -transform.forward * cameraDistance;

                    mainCamera.transform.LookAt(transform.position);
                }
            }
        }
    }
Пример #4
0
    // Update is called once per frame
    void Update()
    {
        if (Time.timeScale == 0)
        {
            return;
        }

        //ケーブルが伸び切るかオブジェクトに当たった時
        if (usbRange == MAX_SCALE && flag)
        {
            //フラグをfalseにする
            flag = false;
        }

        //ケーブルが縮み切った時
        if (!flag && usbRange == MIN_SCALE)
        {
            bool cFlag = false;
            //子オブジェクトにCableBlockがなければケーブルを消去する
            foreach (Transform child in cablePosition.transform)
            {
                if (child.gameObject.tag == "CableMoveBlock")
                {
                    cableFlag = true;
                    cFlag     = true;
                }
            }
            if (!cFlag)
            {
                DestoryCable();
            }
        }

        //USBが縮んでいるとき
        if (!flag)
        {
            bool downFlag = false;
            foreach (Transform child in cablePosition.transform)
            {
                //子オブジェクトのケーブルブロックを探す
                if (child.gameObject.name == "CableMoveBlock")
                {
                    foreach (Transform child2 in child.transform)
                    {
                        //子オブジェクトのケーブルグラウンドを探す
                        if (child2.gameObject.tag == "CableGround")
                        {
                            float range = 0.5f;
                            //下にブロックが行っても大丈夫な状態ならケーブルの角度を変更する
                            if (Physics.Raycast(child2.transform.position + new Vector3(0f, range, 0f) + (transform.forward * range), -Vector3.up, 0.5f, blockMask + LayerMask.GetMask("Enemy")))
                            {
                                downFlag = true;
                            }
                        }
                    }
                }
            }
            if (chilledBlock != null)
            {
                //USBコードを正面を向けるようにする
                targetAngleRotateY(transform.gameObject, cablePositionDefault.transform.eulerAngles, CABLE_ROTATE_SPEED);
                if (!downFlag)
                {
                    targetAngleRotateX(transform.gameObject, cablePositionDefault.transform.eulerAngles, CABLE_ROTATE_SPEED);
                }
            }
        }
        //USBハブも正面に向ける
        if (!cableLock)
        {
            targetAngleRotateY(cablePosition, transform.eulerAngles, USB_ROTATE_SPEED);
        }

        //ケーブルの長さ変更
        if (!cableFlag)
        {
            //USBケーブルの長さ変更
            usbRange += SPEED * Time.deltaTime * BoolToInt(flag);
            //最大値や最小値を超えないように
            usbRange = Mathf.Clamp(usbRange, MIN_SCALE, MAX_SCALE);
        }

        if (flag)
        {
            RaycastHit hit;
            //レイを飛ばしてCableBlockがあるなら
            if (Physics.Raycast(transform.position, transform.forward,
                                out hit, MAX_SCALE, cableMask))
            {
                GameObject hitOb = hit.collider.transform.parent.gameObject;

                foreach (Transform child in hitOb.transform)
                {
                    //子オブジェクトのケーブルブロックを探す
                    if (child.gameObject.tag == "CablePositon")
                    {
                        //角度の変更
                        transform.LookAt(child.transform.position);

                        //USBの角度の適応
                        cablePosition.transform.eulerAngles = transform.eulerAngles;
                        //ケーブルがUsbBoxに当たった時(通り過ぎた時)
                        if ((cablePosition.transform.position - (transform.position +
                                                                 transform.forward * usbRange)).magnitude >
                            (cablePosition.transform.position - child.transform.position).magnitude)
                        {
                            if (!AboutFloat(transform.eulerAngles.y, child.transform.eulerAngles.y, 90f))
                            {
                                DestoryFlag();
                                UsbRangeNormal();
                                break;
                            }

                            gameController.SeSoundLoad(AudioController.Se.Player_UsbSet);
                            //USBの角度変更
                            transform.eulerAngles = child.eulerAngles;
                            //場所変更
                            cablePosition.transform.position = child.transform.position;
                            //Usbを指すための角度変更
                            cablePosition.transform.eulerAngles = child.eulerAngles;

                            if (hitOb.tag == "CableMoveBlock")
                            {
                                cableMoveBlock       = hitOb.gameObject.GetComponent <CableMoveBlock>();
                                playerMove.cableFlag = false;
                                //子オブジェクトに設定
                                hitOb.transform.parent = cablePosition.transform;
                                flag = false;
                                //hitOb.GetComponent<Rigidbody>().constraints = RigidbodyConstraints.FreezeAll;
                                foreach (Transform child2 in hitOb.transform)
                                {
                                    child2.gameObject.layer = LayerMask.NameToLayer("Default");
                                }
                                hitOb.layer  = LayerMask.NameToLayer("Default");
                                chilledBlock = hitOb;
                                //リジッドボディの削除
                                Destroy(hitOb.GetComponent <Rigidbody>());
                            }
                            else if (hitOb.tag == "CableSwitchBlock" || hitOb.tag == "ReloadBlock")
                            {
                                buttonUi.SetActive(true);
                                childPort       = hitOb;
                                portBlockScript = childPort.GetComponent <PortBlock>();
                                ChildGimmickSearch(gimmickParent.transform, portBlockScript.portName);
                                cableFlag        = true;
                                cableLockPositon = cablePosition.transform.position;
                                cableLock        = true;
                                flag             = false;
                            }
                        }
                        else
                        {
                            //USBを伸ばす
                            UsbRangeNormal();
                        }
                    }
                }
            }
            else
            {
                UsbRangeNormal();
            }
        }
        else
        {
            UsbRangeNormal();
        }


        //ケーブルを持っているときの上移動
        if (chilledBlock != null)
        {
            foreach (Transform child in cablePosition.transform)
            {
                //子オブジェクトのケーブルブロックを探す
                if (child.gameObject.name == "PortBlock")
                {
                    BlockUpDown(child.gameObject);
                }
            }
        }

        //スイッチに当たっているとき
        if (cableLock)
        {
            //電源を入れる処理---------------------------------------
            if (xBox.ButtonDown(XBox.Str.A))
            {
                //電源の切り替え
                pawerFlag = !pawerFlag;
                //時間のリセット
                timer = 0f;
            }

            if (pawerFlag)
            {
                PortBlock pB = childPort.GetComponent <PortBlock>();

                //変更する処理
                if (TimerCount(pB.Timer, ref timer))
                {
                    ElectricCreate(childPort);

                    gameController.SeSoundLoad(AudioController.Se.Player_UsbPower);
                    if (childPort.name == "ReloadPort")
                    {
                        playerCharacter.GetComponent <PlayerMove>().Reload();
                    }

                    for (int i = 0; i < childGimmick.Count; i++)
                    {
                        if (childGimmick[i].GetComponent <SwitchFlag>() != null)
                        {
                            SwitchFlag sF = childGimmick[i].GetComponent <SwitchFlag>();
                            sF.flag = !sF.flag;
                        }

                        if (childGimmick[i].GetComponent <SwitchBomb>() != null)
                        {
                            SwitchBomb sB = childGimmick[i].GetComponent <SwitchBomb>();
                            //入っていればカウントを進め時間が来れば発射する
                            if (sB.bulletNum > 0)
                            {
                                sB.bulletNum--;
                                //生成
                                GameObject bulletOb = Instantiate(sB.bullet);

                                //場所と角度の設定
                                foreach (Transform child in childGimmick[i].transform)
                                {
                                    if (child.transform.name == "BulletPositon")
                                    {
                                        bulletOb.transform.position    = child.transform.position;
                                        bulletOb.transform.eulerAngles = child.transform.eulerAngles;
                                    }
                                }
                            }
                        }
                    }
                    pawerFlag = false;
                }
            }
            for (int i = 0; i < childGimmick.Count; i++)
            {
                //扇風機を回転させる処理-------------------------------------------------------
                if (childGimmick[i].name == "Wind")
                {
                    //場所と角度の設定
                    foreach (Transform child in childGimmick[i].transform)
                    {
                        //扇風機の羽の部分
                        if (child.transform.tag == "Wing")
                        {
                            Vector3 angle  = child.gameObject.transform.eulerAngles;
                            Vector2 rotate = new Vector2(Input.GetAxis((XBox.AxisStr.LeftButtonUp).ToString()), Input.GetAxis((XBox.AxisStr.LeftButtonRight).ToString())).normalized * 30f * Time.deltaTime;
                            angle += new Vector3(rotate.x, rotate.y, 0F);
                            if (angle.x > 0 && angle.x < 90)
                            {
                                angle.x = 0f;
                            }
                            if (angle.x < -90)
                            {
                                angle.x = -90f;
                            }
                            child.gameObject.transform.eulerAngles = angle;
                            //場所と角度の設定
                        }
                    }
                }
            }
            UsbRangeNormal();
            cablePosition.transform.position = cableLockPositon;
            //ケーブルの長さを算出し、限界の長さを超えていたら消去
            if ((cableLockPositon - transform.position).magnitude > MAX_SCALE)
            {
                DestoryFlag();
                usbRange = MAX_SCALE;
            }

            //大きく動いたらケーブルを離す
            if (Mathf.Abs(xBox.AxisGet(XBox.AxisStr.LeftJoyRight)) > 0.8f ||
                Mathf.Abs(xBox.AxisGet(XBox.AxisStr.LeftJoyUp)) > 0.8f)
            {
                DestoryFlag();
            }
        }

        //ケーブルの向きの更新
        transform.LookAt(cablePosition.transform.position);
        //ケーブルの長さの更新
        ScaleChange(Vector3.Distance(cablePosition.transform.position, transform.position));

        //ケーブルを手放す処理
        if (chilledBlock != null && usbRange == MIN_SCALE)
        {
            if (playerMove.isGround ||
                !cableMoveBlock.isGround)
            {
                blockTimer = 0f;
            }
            else
            {
                if (TimerCount(BLOCK_TIMER_MAX, ref blockTimer))
                {
                    DestoryFlag();
                    blockTimer = 0f;
                }
            }
        }
    }
Пример #5
0
    //ケーブルの処理
    void CableMove()
    {
        if (isGround)
        {
            if ((xBox.ButtonDown(XBox.Str.RB)))
            {
                //ケーブルの発射
                if (!cable.activeSelf)
                {
                    if (cameraScript.lookOnFlag)
                    {
                        cableFlag = true;
                        cable.SetActive(true);
                        cableUsb.SetActive(true);
                        RaycastHit hit;
                        if (CameraRay(out hit, 15f, cameraScript.layerMask))
                        {
                            //ケーブルが何かに当たるなら当たった場所に向く
                            cable.transform.LookAt(hit.point);
                        }
                        else
                        {
                            //そうでなければ大体向いている方向に打つ
                            cable.transform.eulerAngles = cameraObject.transform.eulerAngles;
                        }
                        cable.GetComponent <Cable>().DefaultLoad();
                    }
                }
                else
                {
                    cable.GetComponent <Cable>().DestoryFlag();
                }
            }
            else if (xBox.ButtonDown(XBox.AxisStr.BackTrigger, false))
            {
                // 弾の発射
                if (!cable.activeSelf && cameraScript.lookOnFlag && bullets > 0)
                {
                    gameController.SeSoundLoad(AudioController.Se.Player_Gun);
                    bullets--;
                    bulletRect.sizeDelta      = new Vector2(250 * bullets, 1095);
                    emptyBulletRect.sizeDelta = new Vector2(250 * (BULLETS_MAX - bullets), 1095);
                    GameObject go = Instantiate(playerBullet);
                    go.tag = "PlayerBullet";
                    go.transform.position = muzzle.position;
                    RaycastHit hit;

                    if (CameraRay(out hit, 25f, cameraScript.layerMask))
                    {
                        //ケーブルが何かに当たるなら当たった場所に向く
                        muzzle.transform.LookAt(hit.point);
                    }
                    else
                    {
                        //そうでなければ大体向いている方向に打つ
                        muzzle.transform.eulerAngles = cameraObject.transform.eulerAngles;
                    }
                    go.GetComponent <Rigidbody>().velocity += muzzle.forward * 20f;  // 銃口の方向に飛ばす
                }
            }
        }
    }