private IEnumerator PlayCoinsExplosionRoutine(Stork stork) { int time = 0; int duration = 1200; yield return(null); _cartoonCoinsExplosion.SetActive(true); stork.AddChild(_cartoonCoinsExplosion); _cartoonCoinsExplosion.SetXY(0, 0); _cartoonCoinsExplosion.alpha = 1f; SpriteTweener.TweenAlpha(_cartoonCoinsExplosion, 1, 0, duration - 500, null, 500); while (time < duration) { float fFrame = Mathf.Map(time, 0, duration, 0, _cartoonCoinsExplosion.frameCount - 1); int frame = Mathf.Round(fFrame) % _cartoonCoinsExplosion.frameCount; _cartoonCoinsExplosion.SetFrame(frame); time += Time.deltaTime; yield return(null); } yield return(new WaitForMilliSeconds(200)); stork.RemoveChild(_cartoonCoinsExplosion); _cartoonCoinsExplosion.SetActive(false); }
private IEnumerator LockingCrossHairOnEnemy() { _state = HunterState.LOCKING_CROSSHAIR_ON_ENEMY; _crossHair.visible = true; SpriteTweener.TweenAlpha(_hunterFollowRangeCone, 0, 0.4f, 500); //Seeking target do { var crossHairWorldPos = TransformPoint(_crossHair.Pos.x, _crossHair.Pos.y); var distance = _enemy.Pos - crossHairWorldPos; var distanceNorm = distance.Normalized; var nextPos = distanceNorm * _sightSpeed * Time.delta; _crossHair.Translate(nextPos.x, nextPos.y); if (!IsEnemyInRange()) { _lostLockOnEnemyOutOfRangeRoutine = _lostLockOnEnemyOutOfRangeRoutine = CoroutineManager.StartCoroutine(LostLockOnEnemyOutOfRangeRoutine(_enemy), this); } yield return(null); } while (_state == HunterState.LOCKING_CROSSHAIR_ON_ENEMY); }
private IEnumerator ShowSmokeOnStork00Routine(Stork stork) { int time = 0; int duration = 1500; yield return(null); _smoke00.visible = true; stork.AddChild(_smoke00); _smoke00.SetXY(0, 0); _smoke00.alpha = 1f; SpriteTweener.TweenAlpha(_smoke00, 1, 0, duration - 500, null, 500); while (time < duration) { float fFrame = Mathf.Map(time, 0, duration, 0, _smoke00.frameCount - 1); int frame = Mathf.Round(fFrame) % _smoke00.frameCount; _smoke00.SetFrame(frame); time += Time.deltaTime; yield return(null); } yield return(new WaitForMilliSeconds(200)); stork.RemoveChild(_smoke00); _smoke00.visible = false; }
public void FadeInOut(GameObject parent, int duration = 1400, OnTransition onTransition = null, OnFinished onFinished = null, CenterMode centerMode = CenterMode.Min) { parent.AddChild(this); if (centerMode == CenterMode.Center) { SetXY(-width * 0.5f, -height * 0.5f); } else { SetXY(0, 0); } SetActive(true); SpriteTweener.TweenAlpha(this, 0, 1, duration / 2, o => { onTransition?.Invoke(); SpriteTweener.TweenAlpha(this, 1, 0, duration / 2, go => { onFinished?.Invoke(); SetActive(false); this.parent.RemoveChild(this); }); }); //CoroutineManager.StartCoroutine(instance.FadeInOutRoutine(time, onFinished)); }
private IEnumerator EndLevelRoutine() { SpriteTweener.TweenAlpha(_crossHair, 1, 0, 400); SpriteTweener.TweenAlpha(_hunterFollowRangeCone, _hunterFollowRangeCone.alpha, 0, 400); yield return(null); }
private IEnumerator EnemyDetectedRoutine() { _state = HunterState.ENEMY_DETECTED; SpriteTweener.TweenAlpha(_crossHair, 0, 1, 400); SoundManager.Instance.SetFxVolume(4, 0.5f); yield return(new WaitForMilliSeconds(500)); //Start Lock enemy _lockingCrossHairOnEnemy = CoroutineManager.StartCoroutine(LockingCrossHairOnEnemy(), this); }
private void FadeInOut() { visible = true; _isFading = true; _offSetAnimTimer = 0; SpriteTweener.TweenAlpha(this.EasyDraw, 0, 1, _fadeInOutDuration / 2, go => { SpriteTweener.TweenAlpha(this.EasyDraw, 1, 0, _fadeInOutDuration / 2, go2 => { _offSetAnimTimer = 0; _isFading = false; visible = false; }); }); }
private IEnumerator ChasingRoutine(GameObject target) { _state = DroneState.CHASING_ENEMY; var chasingMoveRoutine = ChasingMovementRoutine(target); _iesDebug.Add(chasingMoveRoutine); SpriteTweener.TweenAlpha(_droneFollowRangeCone, 0, 0.4f, 500); yield return(chasingMoveRoutine); SpriteTweener.TweenAlpha(_droneFollowRangeCone, 0.4f, 0, 500); _iesDebug.Remove(chasingMoveRoutine); _iesDebug.Remove(_chasingRoutine); }
IEnumerator DroneReleasePizzaRoutine(DroneGameObject drone, Sprite pizza) { while (drone.State == DroneGameObject.DroneState.HIT_ENEMY || drone.State == DroneGameObject.DroneState.RETURN_TO_START_POINT_AFTER_HIT) { yield return(null); } int duration = 1000; SpriteTweener.TweenAlpha(pizza, 1, 0, duration); yield return(new WaitForMilliSeconds(duration)); pizza.visible = false; pizza.alpha = 1; pizza.parent = _level; }
private IEnumerator LostLockOnEnemyOutOfRangeRoutine(GameObject enemy) { _state = HunterState.LOST_LOCK_ON_ENEMY; SpriteTweener.TweenAlpha(_hunterFollowRangeCone, 0.4f, 0, 500); SpriteTweener.TweenAlpha(_crossHair, 1, 0, 400); //Only get points when evading the first time if (_lostLockOnEnemyCounter == 0) { LocalEvents.Instance.Raise(new LevelLocalEvent(_enemy, (GameObject)this, null, LevelLocalEvent.EventType.STORK_GET_POINTS_EVADE_HUNTER)); } _lostLockOnEnemyCounter++; yield return(new WaitForMilliSeconds(1000)); //Return to scanning state _scanningForEnemyRoutine = CoroutineManager.StartCoroutine(ScanningForEnemy(HunterState.SCANNING, true), this); }
public bool ActivateNextDeliveryPoint() { var lastDeliveryPoint = _deliveryPoints[_currentDeliveryPoint]; SpriteTweener.TweenAlpha(lastDeliveryPoint, 1, 0, 600, go => { go.SetActive(false); }); if (_currentDeliveryPoint >= _deliveryPoints.Length - 1) { return(false); } _currentDeliveryPoint++; var nextDeliveryPoint = _deliveryPoints[_currentDeliveryPoint]; nextDeliveryPoint.SetActive(true); SpriteTweener.TweenAlpha(nextDeliveryPoint, 0, 1, 600); return(true); }