コード例 #1
0
    void reset(int scenarioIdx = -1)
    {
        if (scenario != null)
        {
            scenario.setActive(false);
        }

        if (crntWaypointSet != null)
        {
            crntWaypointSet.gameObject.SetActive(false);
        }


        if (scenarioIdx >= 0 && scenarioIdx < scenarios.Length)
        {
            scenario = scenarios[scenarioIdx];

            print(scenario.name);

            scenario.setActive(true);

            neck.lockValue = scenario.neckLockValue;
            filterManager.reset(scenario.filters);

            crosshair.SetActive(scenario.canShoot);

            VRStepBody.isKinematic = !scenario.isControlled;

            // if on rail
            if (!scenario.isControlled)
            {
                splineController.Duration          = scenario.trackDuration;
                splineController.OrientationMode   = scenario.trackOrientation;
                splineController.rotationLookAhead = scenario.rotationLookAhead;

                neck.reset();


                // if track is supplied, initialize with it
                if (scenario.track != null)
                {
                    splineController.init(scenario.track);
                }
                // otherwise, randomize
                else
                {
                    splineController.init(trackAlts [Random.Range(0, trackAlts.Length - 1)]);
                }
            }
            // else if controlled
            else
            {
                // stop spline controller
                splineController.stop();

                if (scenario.startingPosition != null)
                {
                    transform.TransferTo(scenario.startingPosition);
                }

                if (scenario.useWaypoints)
                {
                    crntWaypointSet = scenario.waypointSet;

                    if (crntWaypointSet == null)
                    {
                        crntWaypointSet = waypointAlts [Random.Range(0, waypointAlts.Length - 1)];
                    }

                    crntWaypointSet.reset();
                }

                // if not using VRStep
                if (!scenario.useVRStep)
                {
                    // disable VRStep
                    stepDetector.enabled  = false;
                    WIPController.enabled = false;
                }

                // if using VRStep
                else
                {
                    // enable VRStep
                    stepDetector.enabled  = true;
                    WIPController.enabled = true;
                }
            }
        }
        else
        {
            scenario = null;
        }
    }