示例#1
0
    override public void OnCameraExit()
    {
        if (BulletTime.isEditing)
        {
            BulletTime.SampleAnimation(localAnimation, (localAnimation.cachedState != null)? localAnimation.cachedState.length: 0, true);
            BulletTime.SampleAnimation(localAnimation2, (localAnimation2.cachedState != null) ? localAnimation2.cachedState.length : 0, true);
        }

        if (audio != null)
        {
            foreach (var a in audio)
            {
                if (a && a.loop)
                {
                    a.Stop();
                }
            }
        }

        foreach (ParticleSystem ps in fx)
        {
            if (ps && (ps.loop || stopFxOnExit))
            {
                ps.Stop();
                ps.Clear();
            }
        }

        inside = false;
    }
示例#2
0
 // Start is called before the first frame update
 void Start()
 {
     gameObject.transform.position = GameController.instance.lastCheckpointPos;
     animator      = GetComponent <Animator>();
     rb            = GetComponent <Rigidbody2D>();
     spiritToggler = this.gameObject.GetComponent <BulletTime>();
 }
 private void _StartBulletTime(TextMeshProUGUI button)
 {
     Time.timeScale      = Values.TIMESCALE_BULLET_TIME;
     Time.fixedDeltaTime = 0.02f * Time.timeScale;
     bulletTimeStatus    = BulletTime.ENABLED;
     StartCoroutine(_BulletTimeLoop(button));
 }
示例#4
0
    virtual public void OnCameraStay(float timeInTrigger, float normalizedTimeInTrigger)
    {
        if (!camera)
        {
            return;
        }

        if (BulletTime.allowCameraTriggers && !cameraActive)
        {
            ActivateCamera();
        }
        else if (!BulletTime.allowCameraTriggers && cameraActive)
        {
            DeactivateCamera();
        }

        if (!BulletTime.allowCameraTriggers)
        {
            return;
        }

        camera.gameObject.SendMessage("OnCameraStay", normalizedTimeInTrigger, SendMessageOptions.DontRequireReceiver);

        if (BulletTime.isEditing)
        {
            BulletTime.SampleAnimation(localCameraAnimation, timeInTrigger, true);
            ApplyTweaks();
        }
    }
示例#5
0
    IEnumerator Start()
    {
        _rb             = GetComponent <Rigidbody2D>();
        _animator       = GetComponent <Animator>();
        _spriteRenderer = GetComponent <SpriteRenderer>();
        _babyCatcher    = gameObject.transform.Find("BabyCatcher").GetComponent <BabyCatcher>();
        _exitPoints     = gameObject.transform.Find("ExitPoints").gameObject;

        _exitN = _exitPoints.transform.Find("up-arrow").gameObject.GetComponent <SpriteRenderer>();
        _exitS = _exitPoints.transform.Find("down-arrow").gameObject.GetComponent <SpriteRenderer>();
        _exitW = _exitPoints.transform.Find("left-arrow").gameObject.GetComponent <SpriteRenderer>();
        _exitE = _exitPoints.transform.Find("right-arrow").gameObject.GetComponent <SpriteRenderer>();

        // Debug.Log($"EXIT POINTS {_exitN} {_exitS}");
        if (_type == Spirit.Type.Large)
        {
            _exitPoints.transform.Find("down-arrow").gameObject.SetActive(false);
            _exitPoints.transform.Find("left-arrow").gameObject.SetActive(false);
            _exitPoints.transform.Find("right-arrow").gameObject.SetActive(false);
        }
        else if (_type == Spirit.Type.small)
        {
            _exitPoints.transform.Find("right-arrow").gameObject.SetActive(false);
            _exitPoints.transform.Find("left-arrow").gameObject.SetActive(false);
            _exitPoints.transform.Find("up-arrow").gameObject.SetActive(false);
        }
        yield return(null); // just to make sure everybody is instancied

        bulletTime = FindObjectOfType <BulletTime>();
    }
示例#6
0
    // Update is called once per frame
    void Update()
    {
        var r   = BulletTime.Noise1D(BulletTime.time * frequency + _noiseSeed) * 2f - 1f;
        var a   = ((Mathf.Abs(r) > 0.25)?Mathf.Pow(r, 1f + pullToRest) * Mathf.Sign(r): r) * maxAngle;
        var rot = (Mathf.Abs(a) > Mathf.Epsilon)? Quaternion.AngleAxis(a, aroundAxis): Quaternion.identity;

        transform.localRotation = _initialLocalRotation * rot;
    }
    void Start()
    {
        //	Full speed.
        Time.timeScale = playbackSpeedInFramesPerSecond / BulletTime.frameRate;

        onRestart();
        BulletTime.addRestartListener(onRestart);
    }
示例#8
0
    void Awake()
    {
        startBulletTimeEvent = new UnityEvent();
        stopBulletTimeEvent  = new UnityEvent();

        if (instance == null)
        {
            instance = this;
        }
    }
    static public void SetLightGroup(LightGroup defaultLightGroup)
    {
        var lightGroups = Object.FindObjectsOfType(typeof(LightGroup)) as LightGroup[];
        var lightGroup  = defaultLightGroup;

        if (lightGroup)
        {
            BulletTime.DisableLightGroups(lightGroups);
            BulletTime.SetActiveLightGroup(lightGroup);
        }
    }
示例#10
0
 private void Start()
 {
     m_doubleSwap            = GetComponent <PlayerDoubleSwap>();
     m_bOriginalSwapDamageOn = swapDamageOn;
     if (SwapAnimator != null)
     {
         SwapAnimatorSpr         = SwapAnimator.GetComponent <SpriteRenderer>();
         SwapAnimatorSpr.enabled = false;
     }
     bulletTime = GetComponent <BulletTime>();
     lr         = GetComponent <LineRenderer>();
 }
示例#11
0
    void Update()
    {
        //float t = BulletTime.time;
        float t   = Time.time;
        float rnd = mid + BulletTime.Noise1D(t * frequency) * range;

        _rnd = rnd.ToString();
        if (propBlock != null)
        {
            propBlock.Clear();
            propBlock.AddFloat("_Intensity", rnd);
            GetComponent <Renderer>().SetPropertyBlock(propBlock);
        }
    }
示例#12
0
 static protected void GUITimeRange(string name, ref float minValue, ref float maxValue, float minLimit, float maxLimit)
 {
     EditorGUILayout.BeginHorizontal();
     EditorGUILayout.LabelField(name, GUILayout.Width(50));
     EditorGUILayout.LabelField(minLimit.ToString(), GUILayout.Width(40));
     minValue = BulletTime.MakeDescreetTime(minValue, BulletTime.frameRate);
     maxValue = BulletTime.MakeDescreetTime(maxValue, BulletTime.frameRate);
     minLimit = BulletTime.MakeDescreetTime(minLimit, BulletTime.frameRate);
     maxLimit = BulletTime.MakeDescreetTime(maxLimit, BulletTime.frameRate);
     EditorGUILayout.MinMaxSlider(ref minValue, ref maxValue, minLimit, maxLimit);
     EditorGUILayout.LabelField(maxLimit.ToString(), GUILayout.Width(50));
     minValue = BulletTime.MakeDescreetTime(minValue, BulletTime.frameRate);
     maxValue = BulletTime.MakeDescreetTime(maxValue, BulletTime.frameRate);
     EditorGUILayout.EndHorizontal();
 }
    private IEnumerator _StopBulletTimeWithDelay()
    {
        while (true)
        {
            Time.timeScale += Values.TIMESCALE_GRADUAL_DELTA;
            yield return(new WaitForSeconds(Values.LOAD_SHORT_PAUSE));

            if (Time.timeScale > 0.9f)
            {
                Time.timeScale      = Values.TIMESCALE_STANDARD;
                Time.fixedDeltaTime = 0.02f * Time.timeScale;
                bulletTimeStatus    = BulletTime.DISABLED;
                yield break;
            }
        }
    }
示例#14
0
    void SampleAnimation()
    {
        if (!BulletTime.isEditing)
        {
            return;
        }

        BulletTime.SampleAnimation(m_AnimatedObjects, true);
        foreach (var seq in m_Sequencers)
        {
            if (seq)
            {
                seq.Update();
            }
        }
    }
    private IEnumerator _StartBulletTimeWithDelay(TextMeshProUGUI button)
    {
        while (true)
        {
            Time.timeScale -= Values.TIMESCALE_GRADUAL_DELTA;
            yield return(new WaitForSeconds(Values.LOAD_SHORT_PAUSE));

            if (Time.timeScale < 0.6f)
            {
                Time.timeScale      = Values.TIMESCALE_BULLET_TIME;
                Time.fixedDeltaTime = 0.02f * Time.timeScale;
                bulletTimeStatus    = BulletTime.ENABLED;
                StartCoroutine(_BulletTimeLoop(button));
                yield break;
            }
        }
    }
示例#16
0
    private bool isEnemyShooting = true;                          // flag allows or not to shoot spawning enemy


    void Awake()
    {
        if (instance == null)
            instance = this;
        else if (instance != this)
            Destroy(gameObject);

        DontDestroyOnLoad(gameObject);

        nextGoldenScore = goldenScore;                            // initial first golden Score
        scoreText.text = "0";

        hierarchyGuard = new GameObject("HierarchyGuard").transform;

        // Get references
        bulletTime = GetComponent<BulletTime>();
        medalAwardingFor = GetComponent<MedalAwardingFor>();
        pause = GetComponent<Pause>();
    }
示例#17
0
    void Refresh(float startTime)
    {
        m_AnimatedObjects = BulletTime.CollectAnimatedObjects();
        m_MaxTime         = BulletTime.GetAnimationLength(m_AnimatedObjects);

        m_CurrentScene     = EditorApplication.currentScene;
        m_Sequencers       = Object.FindObjectsOfType(typeof(SplineCameraSequencer)) as SplineCameraSequencer[];
        m_SplineAnimators  = Object.FindObjectsOfType(typeof(SplineAnimator)) as SplineAnimator[];
        m_ImportantObjects = Object.FindObjectsOfType(typeof(ImportantObject)) as ImportantObject[];

        foreach (var sa in m_SplineAnimators)
        {
            sa.Invalidate();
        }

        foreach (var seq in m_Sequencers)
        {
            seq.Invalidate();
        }

        float maxSplineTime = 0.0f;

        if (m_Sequencers != null)
        {
            foreach (var seq in m_Sequencers)
            {
                maxSplineTime = Mathf.Max(seq.timeLength, maxSplineTime);
            }
        }

        if (maxSplineTime < Mathf.Epsilon)
        {
            foreach (var sa in m_SplineAnimators)
            {
                maxSplineTime = Mathf.Max(sa.timeLength, maxSplineTime);
            }
        }

        m_MaxTime = Mathf.Max(m_MaxTime, maxSplineTime);

        BulletTime.time = startTime; BulletTime.deltaTime = m_MaxTime;
    }
示例#18
0
    public override void Init()
    {
        LevelSetting _levelSet = FindObjectOfType <LevelSetting>();

        if (_levelSet != null)
        {
            active = _levelSet.DashOpen;
        }
        else
        {
            active = true;
        }
        m_bulletTime = GetComponent <BulletTime>();
        lr           = GetComponent <LineRenderer> ();
        amin         = GetComponent <Animator>();
        m_stateMgr   = GetComponent <PlayerStateManager>();
        charge       = maxCharge;

        //Rewired------------------------------------------------------------
        rPlayer = ReInput.players.GetPlayer(0);
    }
示例#19
0
    void Update()
    {
        if (requestDemoRestart)
        {
            requestDemoRestart = false;
            Debug.Log("Restart demo");
            BulletTime.Restart();
        }

        if (BulletTime.isEditing)
        {
            var sameLength   = Mathf.Approximately(prevSplineTimeLength, spline.timeLength);
            var samePosition = Vector3.Distance(transform.position, prevPosition) <= Mathf.Epsilon;
            if (spline != prevSpline || !sameLength || !samePosition)
            {
                UpdatePositionOnSpline();
            }

            if (camera)
            {
                cameraAnimation = camera.GetComponent <Animation>();
                // local animations must be disabled or not played automatically
                if (cameraAnimation && cameraAnimation.enabled && cameraAnimation.playAutomatically)
                {
                    cameraAnimation = null;
                }
                if (cameraAnimation && !cameraAnimation.clip)
                {
                    cameraAnimation = null;
                }

                if (localCameraAnimation.animation != cameraAnimation)
                {
                    localCameraAnimation.Reset(cameraAnimation);
                }

                localAudioListener = FindAudioListener(camera.gameObject);
            }
        }
    }
    void Start()
    {
        if (!Application.isPlaying)
        {
            return;
        }

        if (!System.IO.Directory.Exists(CaptureDir))
        {
            System.IO.Directory.CreateDirectory(CaptureDir);
        }

        Application.runInBackground = true;

        BulletTime.Refresh();

        timeToCapture         = BulletTime.duration;
        Time.captureFramerate = (int)BulletTime.frameRate;

        Debug.Log("CAPTURE STARTED. Time length " + timeToCapture + ". Frames to capture " + framesToCapture);
        frameNumber = 0;
    }
示例#21
0
    private BulletTime bulletTime;             // reference to BulletTime script


    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else if (instance != this)
        {
            Destroy(gameObject);
        }

        DontDestroyOnLoad(gameObject);
        DontDestroyOnLoad(lifesText);
        DontDestroyOnLoad(scoreText);

        SpawnPlayer();
        nextGoldenScore = goldenScore;           //  initial first golden Score
        GetGUIReferences();                      // ger references to GUI components
        //lifesText.text = "Lifes: " + lifes;
        scoreText.text = "Score: 0";

        bulletTime = GetComponent <BulletTime>();

        hierarchyGuard = new GameObject("HierarchyGuard").transform;

        if (isEnemySpawn)
        {
            StartCoroutine(RandomObjectSpawner(enemies, enemyPosition, enemySpawnTime));
        }

        if (isPickUpSpawn)
        {
            StartCoroutine(RandomObjectSpawner(pickUps, pickUpPosition, pickUpTime));          // spawn random objects
            StartCoroutine(RandomObjectSpawner(fuelSpawn, pickUpPosition, fuelSpawnTime));     // spawn every  time fuel
            StartCoroutine(RandomObjectSpawner(ammo, pickUpPosition, fuelSpawnTime));          // spawn every  time ammo
        }
    }
    protected void ToggleBulletTime(string toggleStatus, TextMeshProUGUI button)
    {
        switch (toggleStatus)
        {
        case GameStrings.START_BULLET_TIME_IMMEDIATE:
            _StartBulletTime(button);
            break;

        case GameStrings.START_BULLET_TIME:
            StartCoroutine(_StartBulletTimeWithDelay(button));
            break;

        case GameStrings.STOP_BULLET_TIME:
            StartCoroutine(_StopBulletTimeWithDelay());
            break;

        case GameStrings.STOP_BULLET_TIME_IMMEDIATE:
            Time.timeScale   = Values.TIMESCALE_STANDARD;
            bulletTimeStatus = BulletTime.DISABLED;
            break;
        }

        SendMessage("__OnBulletTimeChange", toggleStatus, SendMessageOptions.DontRequireReceiver);
    }
示例#23
0
    override public void OnCameraStay(float timeInTrigger, float normalizedTimeInTrigger)
    {
#if UNITY_EDITOR
        if (BulletTime.isEditing)
        {
            var t = (localAnimation.cachedState != null)? Mathf.Repeat(timeInTrigger, localAnimation.cachedState.length): timeInTrigger;
            BulletTime.SampleAnimation(localAnimation, t, true);
            //t = (localAnimation2.cachedState != null) ? Mathf.Repeat(timeInTrigger, localAnimation2.cachedState.length) : timeInTrigger;
            t = timeInTrigger;
            BulletTime.SampleAnimation(localAnimation2, t, true);

            updateTimeInTrigger = timeInTrigger;
        }
#endif

        if (Application.isPlaying && BulletTime.timeJump)
        {
            //;;Debug.Log("Animation Time Jump " + timeInTrigger);
            if (target != null && target.GetComponent <Animation>() != null)
            {
                foreach (AnimationState state in target.GetComponent <Animation>())
                {
                    //if (state.enabled && state.weight > 0)
                    state.time = timeInTrigger;
                }
            }
            if (target2 != null && target2.GetComponent <Animation>() != null)
            {
                foreach (AnimationState state in target2.GetComponent <Animation>())
                {
                    //if (state.enabled && state.weight > 0)
                    state.time = timeInTrigger;
                }
            }
        }
    }
示例#24
0
    void Update()
    {
        if (!spline)
        {
            return;
        }

        EvaluateTimeLength();

        var splineAnimatorT = ConvertFrameToWarpedTime(BulletTime.frame, BulletTime.frameFraction, ref cacheWarpedTimeFrameNumber, ref cacheWarpedTime) + offSet + _additionalOffSet;
        var splineT         = ConvertWarpedTimeToSplineNormalizedParameter(splineAnimatorT);

        Vector3 newPos = spline.GetPositionOnSpline(splineT);

        newPos += _offs;
        newPos += Vector3.up * (offSetUp + _additionalOffSetUp);

        Quaternion qRot = spline.GetOrientationOnSpline(splineT);
        Vector3    tang = qRot * Vector3.right;

        float totalSway  = sway + _additionalSway;
        float swayNoise  = SwayNoise(swayFrequency);
        float swayAngle  = swayNoise * swayLeanAmplitude * Mathf.Min(totalSway, 1.0f);
        float swayOffSet = swayNoise * totalSway;

        newPos += (offSetSideways + _additionalOffSetSideways + swayOffSet) * tang;

        var splineTMinusEpsilon = ConvertWarpedTimeToSplineNormalizedParameter(splineAnimatorT - 0.01f);

        Quaternion qPast = spline.GetOrientationOnSpline(splineTMinusEpsilon);
        float      yrot  = qPast.eulerAngles.y;

        yrot = yrot - qRot.eulerAngles.y;

        yrot = yrot % 360;
        if (yrot > 180)
        {
            yrot = yrot - 360;
        }
        if (yrot < -180)
        {
            yrot = 360 + yrot;
        }

        var leanAngle = Mathf.Clamp(coolness * (yrot % 180) + swayAngle, -maxLeanAngle, maxLeanAngle);

        leanAngle = Mathf.Clamp(leanAngle + additionalLean % 180, -maxLeanAngle, maxLeanAngle);

        var realDeltaTime = (Time.timeScale < Mathf.Epsilon) ? (Time.deltaTime / Time.timeScale) : 0.1f;

        //	Keffo: Changed this to prevent the 'swimming' when scrubbing, seems to work.
        //	Original: _currLeanAngle = Mathf.Lerp(_currLeanAngle, leanAngle, BulletTime.isEditing ? 1.0f : 0.15f * 30f * realDeltaTime);
        if (BulletTime.isEditing || BulletTime.paused)
        {
            _currLeanAngle = leanAngle;
        }
        else
        {
            _currLeanAngle = Mathf.Lerp(_currLeanAngle, leanAngle, 0.15f * 30f * realDeltaTime);
        }

        Quaternion r = Quaternion.Euler(0.0f, 0.0f, _currLeanAngle);


        Vector3 steadyCamPos = newPos;

        if (!debug)
        {
            if (originOfLean)
            {
                var delta = originOfLean.transform.position - transform.position;
                delta  = Quaternion.Inverse(qRot) * delta;
                newPos = newPos + delta - r * delta;
            }

            transform.position = newPos;            //Vector3.Lerp(transform.position, newPos, BulletTime.deltaTime * 5.0f);
            transform.rotation = qRot * r;
        }

        if (leanAngle < -leanAngleToTriggerFx)
        {
            if (rightFx && !rightFx.IsAlive())
            {
                rightFx.Stop(true); rightFx.Play(true);
                var ra = BulletTime.RandomFromArray(rightAudio) as AudioSource;
                if (ra && ra.enabled == true)
                {
                    ra.Play();
                }
            }
        }
        if (leanAngle > leanAngleToTriggerFx)
        {
            if (leftFx && !leftFx.IsAlive())
            {
                leftFx.Stop(true); leftFx.Play(true);
                var la = BulletTime.RandomFromArray(leftAudio) as AudioSource;
                if (la && la.enabled == true)
                {
                    la.Play();
                }
            }
        }

        if (steadyCamRoot && !debug)
        {
            steadyCamRoot.transform.position = steadyCamPos;
            steadyCamRoot.transform.rotation = qRot;
        }

        if (onboardCamRoot)
        {
            if (legacyOnboardCamera)
            {
                onboardCamRoot.transform.position = newPos;
                onboardCamRoot.transform.rotation = qRot * r;
            }
            else
            {
                var frameXform = (originOfLean) ? originOfLean.transform : transform;
                onboardCamRoot.transform.position = frameXform.position;
                onboardCamRoot.transform.rotation = frameXform.rotation;
            }
        }
    }
示例#25
0
    void Awake()
    {
        if (instance == null)
            instance = this;
        else if (instance != this)
            Destroy(gameObject);

        DontDestroyOnLoad(gameObject);

        nextGoldenScore = goldenScore;                            // initial first golden Score
        scoreText.text = "0";

        hierarchyGuard = new GameObject("HierarchyGuard").transform;

        // Get references
        bulletTime = GetComponent<BulletTime>();
        medalAwardingFor = GetComponent<MedalAwardingFor>();
        pause = GetComponent<Pause>();
    }
    void LateUpdate()
    {
        SaveTransforms(movesFrom, movesTo);

        if (lookAt)
        {
            GetComponent <Camera>().transform.LookAt(lookAt, Vector3.up);
        }

        const float filmWidthInMM  = 36f;
        const float filmHeightInMM = filmWidthInMM / 1.5f;

        GetComponent <Camera>().fieldOfView = 2.0f * Mathf.Atan2(filmHeightInMM, 2f * focalLength) * Mathf.Rad2Deg;

        if (letterBox)
        {
            var targetAspect     = aspectHeight / Mathf.Max(aspectWidth, 1e-3f);
            var totalPixelWidth  = GetComponent <Camera>().pixelWidth / GetComponent <Camera>().rect.width;
            var totalPixelHeight = GetComponent <Camera>().pixelHeight / GetComponent <Camera>().rect.height;
            var pixelRect        = GetComponent <Camera>().pixelRect;
            pixelRect.height = pixelRect.width * targetAspect;
            if (totalPixelHeight <= pixelRect.height)
            {
                pixelRect.height = totalPixelHeight;
                pixelRect.width  = (pixelRect.height / targetAspect);
                pixelRect.x      = Mathf.Round((totalPixelWidth - pixelRect.width) * 0.5f);
                pixelRect.width  = Mathf.Round(pixelRect.width);
            }
            else
            {
                pixelRect.width = totalPixelWidth;
                pixelRect.x     = 0;
            }
            pixelRect.y      = Mathf.Round((totalPixelHeight - pixelRect.height) * 0.5f);
            pixelRect.height = Mathf.Round(pixelRect.height);
            GetComponent <Camera>().pixelRect = pixelRect;
        }
        else
        {
            GetComponent <Camera>().rect = new Rect(0, 0, 1, 1);
        }

        if (!BulletTime.isEditing)
        {
            if (lookAt)
            {
                GetComponent <Camera>().transform.localRotation *= _externalRotation;
            }
            else
            {
                GetComponent <Camera>().transform.localRotation = _initialLocalRot * _externalRotation;
            }
        }

        if ((!BulletTime.isEditing || lookAt) && jitter > 0f && Time.timeScale > 0f)
        {
            var x = BulletTime.Noise1D(BulletTime.time * jitterFrequency * 0.33f) * 2f - 1f;
            var y = BulletTime.Noise1D((BulletTime.time + 1f) * jitterFrequency * 0.33f) * 2f - 1f;
            var n = new Vector2(x, y);
            n *= (GetComponent <Camera>().fieldOfView / 70f); // normalize jitter from 70 FOV angle
            n *= jitter * 0.2f;                               //0.25f;
            var q = Quaternion.Euler(n.x, n.y, 0.0f);
            GetComponent <Camera>().transform.localRotation *= q;
        }

        RestoreTransforms(movesFrom, movesTo);
    }
示例#27
0
    // Start is called before the first frame update


    private void Awake()
    {
        bulletTime = GameObject.FindGameObjectWithTag("player").GetComponent <BulletTime>();
    }
    public void Sample(int frame, float frameFraction, int frameCount, WrapMode wrapMode)
    {
        if (BulletTime.paused && !BulletTime.isEditing)
        {
            if (m_ActiveTrigger)
            {
                m_ActiveTrigger.OnCameraExit();
                m_ActiveTrigger = null;
            }
            return;
        }

        if (wrapMode == WrapMode.Loop)
        {
            frame %= frameCount;
        }
        else if (wrapMode == WrapMode.PingPong)
        {
            frame = (int)Mathf.PingPong((float)frame, (float)frameCount);
        }

        var lastTrigger = m_ActiveTrigger;

        m_ActiveTrigger = null;

        int triggerIndex = -1;

        if (wrapMode == WrapMode.Loop && triggers.Length > 0)
        {
            triggerIndex    = triggers.Length - 1;
            m_ActiveTrigger = triggers[triggerIndex];
        }

        for (int q = 0; q < triggers.Length; ++q)
        {
            if (frame >= triggers[q].splineAnimatorFrame || m_ActiveTrigger == null)
            {
                triggerIndex = q;
            }
        }

        int triggerLengthInFrames = 0;

        if (triggerIndex >= 0)
        {
            m_ActiveTrigger = triggers[triggerIndex];
            var nextTriggerIndex = (triggerIndex + 1) % triggers.Length;
            triggerLengthInFrames = triggers[nextTriggerIndex].splineAnimatorFrame - triggers[triggerIndex].splineAnimatorFrame;

            if (triggerLengthInFrames < 0)             // wrap
            {
                triggerLengthInFrames = frameCount + triggerLengthInFrames;
            }
        }


        if (lastTrigger != m_ActiveTrigger)
        {
            if (lastTrigger)
            {
                lastTrigger.OnCameraExit();
            }
            m_ActiveTrigger.OnCameraEnter();

            var lightGroup = m_ActiveTrigger.lightGroup;
            if (!lightGroup)
            {
                lightGroup = defaultLightGroup;
            }
            if (lightGroup)
            {
                BulletTime.SetActiveLightGroup(lightGroup);
            }
        }
        if (m_ActiveTrigger)
        {
            var timeInTrigger = BulletTime.MakeFrameTimeDbl(frame - m_ActiveTrigger.splineAnimatorFrame, BulletTime.frameRate, frameFraction);
            if (timeInTrigger < 0)
            {
                timeInTrigger = BulletTime.MakeFrameTimeDbl(frameCount, BulletTime.frameRate) + timeInTrigger;
            }

            double normalizedTimeInTrigger = 0;
            if (triggerLengthInFrames > 0)
            {
                normalizedTimeInTrigger = timeInTrigger / BulletTime.MakeFrameTimeDbl(triggerLengthInFrames, BulletTime.frameRate);
            }

            m_ActiveTrigger.OnCameraStay((float)timeInTrigger, Mathf.Clamp((float)normalizedTimeInTrigger, 0f, 1f));
        }

        if (BulletTime.isEditing)
        {
            var lightGroup = m_ActiveTrigger.lightGroup;
            if (!lightGroup)
            {
                lightGroup = defaultLightGroup;
            }
            if (lightGroup)
            {
                SetLightGroup(lightGroup);
            }
        }
    }
示例#29
0
 void Start()
 {
     genNewOrientation();
     BulletTime.addRestartListener(genNewOrientation);
 }
示例#30
0
 private void Start()
 {
     player       = ReInput.players.GetPlayer(0);
     m_bulletTime = GetComponent <BulletTime>();
 }
示例#31
0
    void Awake()
    {
        if (instance == null)
            instance = this;
        else if (instance != this)
            Destroy(gameObject);

        DontDestroyOnLoad(gameObject);
        DontDestroyOnLoad(lifesText);
        DontDestroyOnLoad(scoreText);

        SpawnPlayer();
        nextGoldenScore = goldenScore;           //  initial first golden Score
        GetGUIReferences();                      // ger references to GUI components
        //lifesText.text = "Lifes: " + lifes;
        scoreText.text = "Score: 0";

        bulletTime = GetComponent<BulletTime>();

        hierarchyGuard = new GameObject("HierarchyGuard").transform;

        if (isEnemySpawn)
            StartCoroutine(RandomObjectSpawner(enemies, enemyPosition, enemySpawnTime));

        if (isPickUpSpawn)
        {
            StartCoroutine(RandomObjectSpawner(pickUps, pickUpPosition, pickUpTime));          // spawn random objects
            StartCoroutine(RandomObjectSpawner(fuelSpawn, pickUpPosition, fuelSpawnTime));     // spawn every  time fuel
            StartCoroutine(RandomObjectSpawner(ammo, pickUpPosition, fuelSpawnTime));          // spawn every  time ammo
        }
    }