Пример #1
0
    /// <summary>
    /// 処理の流れ: 場所をサーチ→曲線描画or→引っ張るアクション→助走→テレポート
    /// </summary>
    private void Update()
    {
        if (state == GameState.Reslut)
        {
            time += Time.deltaTime;
            if (time <= 5)
            {
                return;
            }
            if (!resultSceneMove)
            {
                input.ResultViveInputtrigger(viveDevice, ref resultSceneMove, ref time);
                return;
            }
            SceneLoadManager.Instance.LoadScene("Stage");
            return;
        }

        if (state == GameState.Title)
        {
            bool changeSwich = false;
            changeSwich = input.TitleViveInputTrigger(viveDevice);

            if (changeSwich)
            {
                MainManager.Instance.TitleLogoEraseLoad();
            }

            return;
        }

        if (!anchorSwith)
        {
            anchor.SetActive(false);
            gunSetAnchor.SetActive(true);
        }

        input.ViveInputMenuButton(viveDevice, ref map, ref mapSwith, ref mapAlphaTime, goleMapSwitch, ref arrowCursor, ref arrowAngleSwitch);

        if (mapSwith)
        {
            if (mapAlphaTime >= 1)
            {
                map.GetComponent <Renderer>().material.color = new Color(0, 0, 0, mapAlphaTime);
                mapAlphaTime += Time.deltaTime;
            }
        }

        if (arrowAngleSwitch)
        {
            playerMap.MapArrowAngle(map.transform, ref arrowCursor, gole);
        }

        // ギミックが入っていた時にviveコントローラーのパッドを押せば起動する
        if (gimmickIn)
        {
            input.ViveInputTouchpad(viveDevice, ref gimmckScript);
            gimmickIn = false;
            return;
        }

        if (otakaraIn)
        {
            otakaraSwich = input.ViveInputOtakaraGet(viveDevice, otakara, viveRightController.transform.position, ref memoryPosition);
        }

        // ここでviveのトリガー判定をしている
        isTrigger = input.ViveRockInputTrigger(viveDevice, viveRightController.transform.position, ref memoryPosition, ref pullBody, ref anchorSwith);

        // テレポート移動(ここに書いたのはこの後入力できないようにするため)
        if (trigger)
        {
            if (player.transform.position == finishPosition)
            {
                trigger = false;
                return;
            }

            particle.SetActive(true);

            //DOFとBlurを適用させる
            postProcess.profile = postMove;

            time += Time.deltaTime;

            viveDevice.TriggerHapticPulse(date.vibration);

            player.transform.position = runaway.Runaway(player.transform.position, finishPosition, date.moveSpeed, time);

            particle.transform.position = displayPosition;
            particle.transform.LookAt(player.transform.position);

            if (player.transform.position != finishPosition)
            {
                return;
            }

            pullBody.SetActive(false);

            particle.SetActive(false);



            hibana.gameObject.SetActive(false);

            efSwitch = false;

            line.startWidth = 0.2f;

            trigger   = false;
            isTrigger = false;
            particle.SetActive(false);
            postProcess.profile = def;
            time = 0;
            return;
        }


        // ここで場所をサーチする
        if (!isTrigger && !otakaraSwich)
        {
            SearchRay();
        }

        drawLine.OnDrawLine(displayPosition, date.hight, viveRightController.transform.position, date.maxDis);

        float dis = Vector3.Distance(pullBody.transform.position, viveRightController.transform.position);

        //Debug.Log(line.material);
        // サーチした場所が設定した値より遠い場合処理を止める
        dis = Vector3.Distance(displayPosition, viveRightController.transform.position);
        if (dis > date.maxDis || date.minDis > dis && !trigger && !isTrigger && !otakaraSwich || moveStop)
        {
            //line.GetComponent<MeshRenderer>().material = banLineMt;
            //lineMt = banLineMt;
            line.material = banLineMt;

            if (cursor != banCurcor)
            {
                pointCursor.SetActive(false);
                banCurcor.SetActive(true);
                cursor = banCurcor;
            }
            return;
        }

        //lineMt = nomalLineMt;
        //line.GetComponent<MeshRenderer>().material = nomalLineMt;
        line.material = nomalLineMt;
        if (cursor != pointCursor)
        {
            banCurcor.SetActive(false);
            pointCursor.SetActive(true);
            cursor = pointCursor;
        }

        // もしトリガーを引いていなかったら曲線を出す
        if (!trigger && !isTrigger && !otakaraSwich && !moveStop)
        {
            gunTrigger.transform.rotation = Quaternion.AngleAxis(0, new Vector3(1, 0, 0));
            if (line.startWidth <= 0.2f)
            {
                line.startWidth = 0.2f;
            }
            return;
        }

        // 縄表示
        drawLine.SetRope(anchor.transform.position, date.hight, viveRightController.transform.position, dis);
        //lineMt = wireMt;
        //line.GetComponent<MeshRenderer>().material = wireMt;
        line.material   = wireMt;
        line.startWidth = 0.05f;
        if (displayPosition != anchor.transform.position)
        {
            if (!anchorSwith)
            {
                anchorSwith = true;
            }
            gunTrigger.transform.rotation = Quaternion.AngleAxis(30, new Vector3(1, 0, 0));
            gunSetAnchor.SetActive(false);
            anchor.SetActive(true);
            anchor.transform.position = anchorAction.AnchorMove(viveRightController.transform.position, displayPosition, time);
            time += Time.deltaTime * 3;

            if (efSwitch && !otakaraIn)
            {
                hibana.Stop();
                hibana.time = 0;
                efSwitch    = false;
            }

            return;
        }

        if (!efSwitch && !otakaraIn)
        {
            hibana.gameObject.transform.position = anchor.transform.position;
            hibana.gameObject.SetActive(true);
            hibana.Play();
            efSwitch = true;
        }

        time = 0;

        if (trigger)
        {
            return;
        }

        // 引っ張るアクションをしている

        pullBody.SetActive(true);
    }