예제 #1
0
    private IEnumerator WarnCorotinue()
    {
        WaitForFixedUpdate wait = new WaitForFixedUpdate();
        float timer             = warningTime;

        boxCollider.enabled = false;
        warningObject.SetActive(true);

        while (timer > 0)
        {
            timer -= Time.fixedDeltaTime;
            yield return(wait);
        }

        boxCollider.enabled = true;
        animatorTrigger.TakeEffect();
        targetAnimator.TakeEffect();
        timer = time;
        while (timer > 0)
        {
            timer -= Time.fixedDeltaTime;
            yield return(wait);
        }
        warningObject.SetActive(false);
        boxCollider.enabled = false;
        ObjectPool.RecycleObject(this.gameObject);
    }
예제 #2
0
    IEnumerator DoDrop()
    {
        mDropActive = true;

        WaitForFixedUpdate wait = new WaitForFixedUpdate();

        while (mDropActive)
        {
            yield return(wait);

            float   moveY = dropSpeed * Time.fixedDeltaTime;
            Vector3 pos   = transform.position;

            RaycastHit hit;
            if (Physics.SphereCast(collider.bounds.center, mRadius, Vector3.down, out hit, moveY, dropLayerMask))
            {
                pos         = hit.point + hit.normal * mRadius;
                mDropActive = false;

                Invoke("Release", destroyDelay);
                Invoke("DoBlinkers", destroyStartBlinkDelay);
            }
            else
            {
                pos.y -= moveY;
            }

            transform.position = pos;
        }
    }
예제 #3
0
    private IEnumerator Fade(float duration, float targetVolume)
    {
        if (_fadeVolumeProcess != null)
        {
            StopCoroutine(_fadeVolumeProcess);
        }

        _currentVolume = _audioSource.volume;

        float _deltaVolume = targetVolume - _currentVolume;

        if (_audioSource.volume == 0)
        {
            _audioSource.Play();
        }

        var waitForFixedUpdate = new WaitForFixedUpdate();

        while (_currentVolume != targetVolume)
        {
            _audioSource.volume += _deltaVolume * Time.fixedDeltaTime / duration;

            if (_audioSource.volume == 0)
            {
                _audioSource.Stop();
            }

            yield return(waitForFixedUpdate);
        }
    }
예제 #4
0
    private IEnumerator MoveCorotinue()
    {
        WaitForFixedUpdate wait = new WaitForFixedUpdate();

        float timer = time;

        Vector2 movement = transform.right * speed * Time.fixedDeltaTime;
        Vector2 position = transform.position;

        while (timer > 0)
        {
            transform.position = position;
            position          += movement;
            timer -= Time.fixedDeltaTime;
            yield return(wait);
        }

        for (int i = 0; i < wave; i++)
        {
            CreateBarrage();
            timer = waveInterval;

            while (timer > 0)
            {
                timer -= Time.fixedDeltaTime;
                yield return(wait);
            }
        }

        ObjectPool.RecycleObject(this.gameObject);
    }
예제 #5
0
    private IEnumerator Movement()
    {
        statButton.transform.SetAsLastSibling();
        WaitForFixedUpdate fx = new WaitForFixedUpdate();

        if (statButton.transform.position.x > 0)
        {
            // closes the stat button

            while (statButton.transform.position.x > closedPos.position.x)
            {
                statButton.transform.Translate(Vector3.left * mSpeed * Time.deltaTime);
                yield return(fx);
            }
        }
        else
        {
            // opens the stat button

            while (statButton.transform.position.x < openedPos.position.x)
            {
                statButton.transform.Translate(Vector3.right * mSpeed * Time.deltaTime);
                yield return(fx);
            }
        }
    }
    private IEnumerator Hover()
    {
        WaitForFixedUpdate wait = new WaitForFixedUpdate();
        float   hoverDeltaTime  = 0;
        Vector2 shakeVector     = Vector2.right * (Random.Range(0, 2) == 1 ? 1 : -1);

        if (currentSoundState == 1)
        {
            currentSoundState = 2;
            theAwesomeSound.Play(SoundId.CatStrike);
            //Debug.Log("Played it!");
        }

        while (true)
        {
            if (distanceVector[0] > 0)
            {
                catSprite.flipX = false;
            }
            else if (distanceVector[0] < 0)
            {
                catSprite.flipX = true;
            }
            catRigidbody.MovePosition(locationOnRadius + (Vector2.up * 0.15f * Mathf.Sin(10 * hoverDeltaTime)) + (shakeVector * 0.1f * Mathf.Sin(hoverDeltaTime * 0.37f)));
            yield return(wait);

            hoverDeltaTime += Time.deltaTime;
            //Debug.Log("In coroutine");
        }
    }
    IEnumerator GenerateLevel()
    {
        WaitForSeconds     startup  = new WaitForSeconds(1);
        WaitForFixedUpdate interval = new WaitForFixedUpdate();

        yield return(startup);

        //place start room
        PlaceStartRoom();
        yield return(interval);

        //random intteration
        int interations = Random.Range((int)iterationRange.x, (int)iterationRange.y);

        for (int i = 0; i < interations; i++)
        {
            //place random room from list
            PlaceRoom();
            yield return(interval);
        }

        //place end room
        PlaceEndRoom();
        yield return(interval);

        //level generator finished
        Debug.Log("level generator finished");

        //place player
        player = Instantiate(playerPrefab) as PlayerController;
        player.transform.position = startRoom.playerStart.position;
        player.transform.rotation = startRoom.playerStart.rotation;
    }
예제 #8
0
        private IEnumerator Record()
        {
            YieldInstruction _fupd = new WaitForFixedUpdate();

            _rawData.Clear();
            Vector3 projected;
            float   angle;
            float   targetAngle;

            while (true)
            {
                projected   = Vector3.ProjectOnPlane(_playerCar.Transform.up, Vector3.forward);
                angle       = Vector3.Angle(projected, Vector3.up);
                targetAngle = ((Vector3.Angle(Vector3.right, projected) > 90f) ? angle : 360f - angle);

                _rawData.Add(new Vector4(_playerCar.Transform.position.x,
                                         _playerCar.Transform.position.y, targetAngle, _playerCar.nitro.IsNitroPressed));

                if (_recordObjectController.IsFind)
                {
                    _recordObjectController.RecordObjectInFrame();
                }

                yield return(_fupd);
            }
        }
        private IEnumerator DoRebuildMeshEditor()
        {
            var waiter = new WaitForFixedUpdate();

            // skip a physics frame to allow part setup to complete
            yield return(waiter);

            while (!ApplicationLauncher.Ready)
            {
                yield return(waiter);
            }

            // don't voxelize until the part is placed
            while (EditorLogic.SelectedPart == part)
            {
                yield return(waiter);
            }

            // skip if not in the ship, OnEditorAttach will rebuild the mesh data
            if (!EditorLogic.SortedShipList.Contains(part))
            {
                yield break;
            }

            RebuildAllMeshData();
        }
예제 #10
0
        private IEnumerator CheckForStability()
        {
            var waitForFixedUpdate = new WaitForFixedUpdate();

            while (true)
            {
                if (CanStabalize)
                {
                    _velocitySamples.Enqueue(_rigidbody.velocity.magnitude);
                    if (_velocitySamples.Count > 10)
                    {
                        _velocitySamples.Dequeue();

                        if (MathUtils.Average(_velocitySamples) < _restabilizationThreshold &&
                            IntVector2.Distance(Position, transform.position) < .02f)
                        {
                            StartCoroutine(Stabilize());
                            break;
                        }
                    }
                }

                yield return(waitForFixedUpdate);
            }
        }
예제 #11
0
    private IEnumerator CooltimeWorks(int id)
    {
        WaitForFixedUpdate fixedUpdate = new WaitForFixedUpdate();
        // 2020.01.07 화요일 - 코드 추가
        int coolTimeID = mInfos[id].CoolTimeIndex;

        // 2020.01.07 화요일 - 코드 수정
        //mCoolTimeArr[mInfos[id].CoolTimeIndex] = mInfos[id].CoolTime;
        mCoolTimeArr[coolTimeID] = mInfos[id].CoolTime;
        mSkillArr[id - 1].SetVisible(true);

        // 2020.01.07 화요일 - 코드 수정
        //while (mCoolTimeArr[mInfos[id].CoolTimeIndex] > 0)
        while (coolTimeID > 0)
        {
            // 2020.01.07 화요일 - 코드 수정
            //mCoolTimeArr[mInfos[id].CoolTimeIndex] -= Time.fixedDeltaTime;
            mCoolTimeArr[coolTimeID] -= Time.fixedDeltaTime;
            // 2020.01.07 화요일 - 코드 수정
            //mSkillArr[id - 1].ShowCoolTime(mInfos[id].CoolTime, mCoolTimeArr[mInfos[id].CoolTimeIndex]);
            mSkillArr[id - 1].ShowCoolTime(mInfos[id].CoolTime, mCoolTimeArr[coolTimeID]);
            yield return(fixedUpdate);
        }
        mSkillArr[id - 1].SetVisible(false);
    }
예제 #12
0
 private void Start()
 {
     wfs   = new WaitForSeconds(holdTime);
     wffu  = new WaitForFixedUpdate();
     agent = GetComponent <NavMeshAgent>();
     StartCoroutine(Patrol());
 }
예제 #13
0
        /// <summary>
        /// Use with a coroutine
        /// </summary>
        public IEnumerator DoTilePulse(float minTile, float delay)
        {
            if (delay > 0.0f)
            {
                enabled = true;

                float curTime = 0.0f;
                float maxTile = Screen.height;
                WaitForFixedUpdate waitUpdate = new WaitForFixedUpdate();

                while (curTime < delay)
                {
                    curTime += Time.fixedDeltaTime;

                    float t = Mathf.Sin(Mathf.PI * (curTime / delay));
                    t *= t;

                    numTiles = maxTile + t * (minTile - maxTile);

                    yield return(waitUpdate);
                }

                enabled = false;
            }

            yield break;
        }
예제 #14
0
    private IEnumerator ContinuouslySteerToDest()
    {
        YieldInstruction wait = new WaitForFixedUpdate();

        // float stuckSensitivity = 1f;
        // float stuckTimer = 0f;
        // float timeTillStuck = 1f;
        // Vector3 stuckDest = Vector3.zero;
        // Vector3 lastPos = _transform.position;
        do
        {
            Debug.DrawLine(_transform.position, _currDest);
            // if ((lastPos - _transform.position).sqrMagnitude > stuckSensitivity * _characterMotor.MovementSpeed || _paused) {
            //  lastPos = _transform.position;
            //  stuckTimer = 0f;
            // } else {
            //  stuckTimer += Time.fixedDeltaTime;
            //  if (stuckTimer >= timeTillStuck) {
            //      stuckTimer = 0f;
            //      if (_nextFurniture != null) {
            //          _destList = RoomManager.g.PathToFurnitureFrom(_nextFurniture, _transform.position);
            //      }
            //      // stuckDest = _currDest;
            //      // _currDest = _transform.position + (_transform.position - _currDest);
            //      // yield return new WaitForSeconds(1f);
            //      // _currDest = stuckDest;
            //  }
            // }

            yield return(wait);
        } while ((_currDest - _transform.position).sqrMagnitude > _destinationSensitivity);
        _currDest = _transform.position;
        yield break;
    }
예제 #15
0
    IEnumerator Press(bool _down)
    {
        var eoff = new WaitForFixedUpdate();

        Vector3 a = readyPos;
        Vector3 b = pressedPos;

        if (!_down)
        {
            a = pressedPos;
            b = readyPos;
        }

        float dist = (a - b).magnitude;

        for (float t = 0; t < resetTime; t += Time.unscaledDeltaTime)
        {
            float it = Mathf.Clamp01(t / resetTime);
            transform.position = Vector3.Lerp(a, b, it);
            yield return(eoff);
        }

        transform.position = b;
        //yield return eoff;
        //yield break;
    }
예제 #16
0
        public IEnumerator Update(Action _action)
        {
            switch (updateType)
            {
            case UpdateType.FixedUpdate:
                WaitForFixedUpdate waitForFixedUpdate = new WaitForFixedUpdate();
                while (true)
                {
                    _action();
                    yield return(waitForFixedUpdate);
                }

            case UpdateType.Update:
                while (true)
                {
                    _action();
                    yield return(true);
                }

            case UpdateType.LateUpdate:
                WaitForEndOfFrame waitForEndOfFrame = new WaitForEndOfFrame();
                while (true)
                {
                    _action();
                    yield return(waitForEndOfFrame);
                }
            }
        }
예제 #17
0
    private IEnumerator HitCorotinue()
    {
        WaitForFixedUpdate wait = new WaitForFixedUpdate();

        float timer = warningTime;

        while (timer > 0)
        {
            timer -= Time.fixedDeltaTime;

            yield return(wait);
        }

        timer         = damageTime;
        readyToDamage = true;
        while (timer > 0)
        {
            timer -= Time.fixedDeltaTime;

            yield return(wait);
        }
        readyToDamage = false;

        var         obj   = ObjectPool.GetObject(bullet, "SkillBullets");
        SkillBullet skill = obj.GetComponent <SkillBullet>();

        skill.Source = Source;
        skill.Target = Target;

        skill.Launch(transform.position, transform.right);

        ObjectPool.RecycleObject(this.gameObject);
    }
    IEnumerator GenerateLevel()
    {
        WaitForSeconds     startUp  = new WaitForSeconds(2f);
        WaitForFixedUpdate interval = new WaitForFixedUpdate();

        yield return(startUp);

        PlaceStartRoom();

        yield return(interval);

        int iterations = UnityEngine.Random.Range((int)IterationRange.x, (int)IterationRange.y);

        for (int i = 0; i < iterations; i++)
        {
            PlaceRoom();
            PlaceCorridor();

            yield return(interval);
        }

        PlaceEndRoom();
        yield return(interval);

        PlacePlayerInStartRoom();

        //   yield return new WaitForSeconds(3f);
        //   ResetLevelGenerator();
    }
예제 #19
0
    /// <summary>
    ///     This function run all function to generate lever
    /// </summary>
    private IEnumerator GenerateLevel()
    {
        WaitForSeconds     startup  = new WaitForSeconds(1);
        WaitForFixedUpdate interval = new WaitForFixedUpdate();

        yield return(startup);

        // Place start room
        PlaceStartRoom();
        yield return(interval);

        // Random Iteration
        int iterations = Random.Range(iterationRange.x, iterationRange.y);

        for (int i = 0; i < iterations; i++)
        {
            // Place random room from list
            PlaceRoom();
            yield return(interval);
        }

        // Place end room
        PlaceEndRoom();
        yield return(interval);

        // Bake NavMesh
        _navMeshSurface.BuildNavMesh();

        // Level generation finished
        Debug.Log("Level generation finished");

        // Set player active
        player.SetActive(true);
    }
 private void Awake()
 {
     waitForEndOfFrame  = new WaitForEndOfFrame();
     waitForFixedUpdate = new WaitForFixedUpdate();
     StartCoroutine(WaitForEndOfFrame());
     StartCoroutine(WaitForFixedUpdate());
 }
        private System.Collections.IEnumerator UpdateRoutine()
        {
            var waitForFixed = new WaitForFixedUpdate();
            var waitForLate  = new WaitForEndOfFrame();

Restart:

            switch (_useUpdateSequence)
            {
            case UpdateSequence.None:
            case UpdateSequence.Update:
                yield return(null);

                break;

            case UpdateSequence.FixedUpdate:
                yield return(waitForFixed);

                break;

            case UpdateSequence.LateUpdate:
                yield return(waitForLate);

                break;
            }

            if (_useUpdateSequence != UpdateSequence.None && _stateMachine.Current != null)
            {
                _stateMachine.Current.UpdateMovement();
            }

            goto Restart;
        }
    void Start()
    {
        // ...............................................
        // Coroutine adaptor initialization
        CoRoutineUtils.StartCoroutine = StartCoroutine;
        WaitForFixedUpdate wait = new WaitForFixedUpdate();

        CoRoutineUtils.WaitForFixedUpdate = delegate() { return(wait); };
        CoRoutineUtils.WaitForSeconds     = delegate(double delay) { return(new WaitForSeconds((float)delay)); };

        Component[] windows = gameObject.GetComponents(typeof(BitWindow));
        BitWindow   window  = null;

        for (int i = 0; i < windows.Length; i++)
        {
            if (windows[i].name == "coloranimator_window")
            {
                window = (BitWindow)windows[i];
                break;
            }
        }

        if (window == null)
        {
            Debug.LogError("Main window not found.");
            return;
        }

        Debug.Log("Main window loaded. =)");

        BitHorizontalProgressBar animatorHorizontalprogressbar = window.FindControl <BitHorizontalProgressBar>("animator_horizontalprogressbar");

        CoRoutineUtils.StartCoroutine(animatorHorizontalprogressbar.AnimateProgress(animatorHorizontalprogressbar.MinValue, animatorHorizontalprogressbar.MaxValue, 5));
    }
예제 #23
0
    IEnumerator DoHurtForce(Vector3 normal)
    {
        mHurtActive = true;

        mCtrl.enabled      = false;
        rigidbody.velocity = Vector3.zero;
        rigidbody.drag     = 0.0f;

        WaitForFixedUpdate wait = new WaitForFixedUpdate();

        normal.x = Mathf.Sign(normal.x);
        normal.y = 0.0f;
        normal.z = 0.0f;

        while (mHurtActive)
        {
            yield return(wait);

            rigidbody.AddForce(normal * hurtForce);
        }

        mCtrl.enabled = true;
        mCtrl.ResetCollision();

        mHurtActive = false;
    }
예제 #24
0
    private IEnumerator IncreaseSizeThanMove()
    {
        _increasingSize = new Vector3(_growSpeed, _growSpeed, _growSpeed);

        var waitForFixedUpdate = new WaitForFixedUpdate();

        while (_currentStar.transform.localScale.x < _fullSize * 1.2f)
        {
            _currentStar.transform.localScale += _increasingSize;
            yield return(waitForFixedUpdate);
        }

        yield return(waitForFixedUpdate);

        while (_currentStar.transform.localScale.x > _fullSize)
        {
            _currentStar.transform.localScale -= _increasingSize;
            yield return(waitForFixedUpdate);
        }

        yield return(waitForFixedUpdate);

        _audio.Play();
        _needMove = true;
    }
예제 #25
0
    IEnumerator DoScan()
    {
        WaitForSeconds     idleWait   = new WaitForSeconds(scanWaitDelay);
        WaitForFixedUpdate updateWait = new WaitForFixedUpdate();

        Vector3 angles = point.localEulerAngles;

        float s = scanStart * degreeMax * 0.5f, e = -scanStart * degreeMax * 0.5f;

        angles.z = s;
        point.localEulerAngles = angles;

        while ((EntityState)state == EntityState.Normal)
        {
            yield return(idleWait);

            float curT = 0.0f;
            while (curT < scanAngleDelay)
            {
                yield return(updateWait);

                curT = Mathf.Clamp(curT + Time.fixedDeltaTime, 0.0f, scanAngleDelay);
                float rot = Holoville.HOTween.Core.Easing.Sine.EaseIn(curT, s, e - s, scanAngleDelay, 0.0f, 0.0f);
                angles.z = rot;
                point.localEulerAngles = angles;
            }

            float _s = s;
            s = e;
            e = _s;
        }
    }
예제 #26
0
    IEnumerator CheckWhetherMonsterHadReachedFinish(Vector3 position, float contactRadius)
    {
        var monsters = new Collider[20];
        var monstersHadReachedFinishAmount = 0;

        var iterationStep = new WaitForFixedUpdate();

        var layerMask = 1 << GetComponent <GameSystem>().layerMonster;

        while (true)
        {
            monstersHadReachedFinishAmount = Physics.OverlapSphereNonAlloc(position, contactRadius, monsters, layerMask);

            for (var i = 0; i < monstersHadReachedFinishAmount; ++i)
            {
                SendMessage("ApplyDamageToPlayer", monsters[i].GetComponent <MonsterComponent>().monsterParams.damage, SendMessageOptions.RequireReceiver);

                DestroyImmediate(monsters[i].gameObject);

                --aliveMonstersCount;

                if (aliveMonstersCount < 1 && spawnedMonstersCount >= monstersMaxCount)
                {
                    SendMessage("AllMonstersHaveDied", SendMessageOptions.RequireReceiver);
                }
            }

            yield return(iterationStep);
        }
    }
예제 #27
0
    IEnumerator DoMove()
    {
        if (startDelay > 0f)
        {
            yield return(new WaitForSeconds(startDelay));
        }

        var easeFunc = EaseManager.ToEaseFunction(tweenStyle);
        var wait     = new WaitForFixedUpdate();

        while (mCurTime < delay)
        {
            mCurTime += Time.fixedDeltaTime;
            if (mCurTime > delay)
            {
                mCurTime = delay;
            }

            if (isToggled)
            {
                float t = easeFunc(mCurTime, delay, 0f, 0f);
                targetBody.MovePosition(Vector2.Lerp(mStartPosition, mEndPosition, t));
            }
            else
            {
                float t = easeFunc(delay - mCurTime, delay, 0f, 0f);
                targetBody.MovePosition(Vector2.Lerp(mEndPosition, mStartPosition, t));
            }

            yield return(wait);
        }

        mRout = null;
    }
예제 #28
0
        IEnumerator Animate(bool value, float duration, EaseType easeType)
        {
            var waitForFixedUpdate = new WaitForFixedUpdate();
            var t = 0f;

            var currentSpeeds = new float[ParallaxLayers.Count];

            for (int i = 0; i < currentSpeeds.Length; i++)
            {
                currentSpeeds[i] = ParallaxLayers[i].Speed;
            }

            while (t <= 1.0f)
            {
                t += (ProCamera2D.UpdateType == UpdateType.LateUpdate ? Time.deltaTime : Time.fixedDeltaTime) / duration;

                for (int i = 0; i < ParallaxLayers.Count; i++)
                {
                    if (value)
                    {
                        ParallaxLayers[i].Speed = Utils.EaseFromTo(currentSpeeds[i], _initialSpeeds[i], t, easeType);
                    }
                    else
                    {
                        ParallaxLayers[i].Speed = Utils.EaseFromTo(currentSpeeds[i], 1, t, easeType);
                    }
                }

                yield return((ProCamera2D.UpdateType == UpdateType.FixedUpdate) ? waitForFixedUpdate : null);
            }
        }
예제 #29
0
    private IEnumerator AlphaAnim() //코루틴을 사용한 글자 깜빡거림
    {
        WaitForFixedUpdate fixedUpdate = new WaitForFixedUpdate();
        bool  bAscending = true;
        float halfTime   = mAlphaAnimPeriod / 2;
        Color color      = new Color(0, 0, 0, 1 / halfTime * Time.fixedDeltaTime);

        while (true)
        {
            yield return(fixedUpdate);

            if (bAscending)
            {
                mStartText.color += color;
                if (mStartText.color.a >= 1)
                {
                    bAscending = false;
                }
            }
            else
            {
                mStartText.color -= color;
                if (mStartText.color.a <= 0)
                {
                    bAscending = true;
                }
            }
        }
    }
    public IEnumerator UpdateForNewWeek()
    {
        Vector3 timelineArrowStart = timelineArrow.transform.localPosition;
        Vector3 timelineArrowEnd;

        if (GameController.week < regularSeasonPieces.Count)
        {
            timelineArrowEnd = regularSeasonPieces[GameController.week].transform.localPosition;
        }
        else
        {
            Debug.Log("It's probably the postseason.");
            timelineArrowEnd = postseasonPiece.transform.localPosition;
        }

        WaitForFixedUpdate waiter = new WaitForFixedUpdate();
        float timer    = 0f;
        float duration = 0.7f;

        while (timer < duration)
        {
            timer += Time.deltaTime;

            float step = timer / duration;

            timelineArrow.transform.localPosition = Vector3.Lerp(timelineArrowStart, timelineArrowEnd, step);

            yield return(waiter);
        }
    }