Ejemplo n.º 1
0
 public void Dash()
 {
     dashPressed_ = true;
     CoroutineWrapper.DoAfterFrame(() => {
         dashPressed_ = false;
     });
 }
Ejemplo n.º 2
0
        private void FixedUpdate()
        {
            if (!enabled_)
            {
                return;
            }

            int  resultCount = GetRaycastPositions().Sum(pos => CollisionsAtPosition(pos));
            bool isOffGround = resultCount <= 0;

            if (checkDeath_ && isOffGround)
            {
                enabled_ = false;

                GameNotifications.OnBattlePlayerFellOffGround.Invoke(Player_);

                Player_.InputController.DisableInput(BattlePlayerInputController.PriorityKey.OffGround);
                Player_.InputController.CancelAnyAnimatedMovements();
                Player_.Rigidbody.constraints = RigidbodyConstraints.None;
                Player_.Rigidbody.drag        = 0.0f;
                dustParticleSystem_.SetEmissionRateOverDistance(0.0f);
                coroutine_ = CoroutineWrapper.DoAfterDelay(kDeathDelay, () => {
                    Player_.Health.Kill();
                });
            }
        }
Ejemplo n.º 3
0
        private void SetDepthOfFieldEnabledInternal(bool enabled, bool animate)
        {
            if (depthOfFieldCoroutine_ != null)
            {
                depthOfFieldCoroutine_.Cancel();
                depthOfFieldCoroutine_ = null;
            }

            DepthOfFieldModel.Settings settings = postProcessingProfile_.depthOfField.settings;
            if (!animate)
            {
                settings.focalLength = enabled ? kMaxFocalLength : kMinFocalLength;
                postProcessingProfile_.depthOfField.settings = settings;
                postProcessingProfile_.depthOfField.enabled  = enabled;
            }
            else
            {
                postProcessingProfile_.depthOfField.enabled = true;
                float start = enabled ? kMinFocalLength : kMaxFocalLength;
                float end   = enabled ? kMaxFocalLength : kMinFocalLength;
                depthOfFieldCoroutine_ = CoroutineWrapper.DoEaseFor(kDepthOfFieldAnimationDuration, EaseType.CubicEaseOut, (float p) => {
                    settings.focalLength = Mathf.Lerp(start, end, p);
                    postProcessingProfile_.depthOfField.settings = settings;
                }, () => {
                    postProcessingProfile_.depthOfField.enabled = enabled;
                });
            }
        }
Ejemplo n.º 4
0
    public static CoroutineWaiter GetAwaiter(this IEnumerator coroutine)
    {
        var awaiter = new CoroutineWaiter();

        runer.StartCoroutine(CoroutineWrapper.WaitReturnNull(awaiter, coroutine));
        return(awaiter);
    }
Ejemplo n.º 5
0
        // PRAGMA MARK - IRecycleSetupSubscriber Implementation
        public void OnRecycleSetup()
        {
            float segmentSize     = 1.0f / kSegments;
            float halfSegmentSize = segmentSize / 2.0f;

            for (float x = -0.5f + halfSegmentSize; x <= 0.5f; x += segmentSize)
            {
                for (float y = -0.5f + halfSegmentSize; y <= 0.5f; y += segmentSize)
                {
                    for (float z = -0.5f + halfSegmentSize; z <= 0.5f; z += segmentSize)
                    {
                        GameObject partObject = ObjectPoolManager.Create(partPrefab_, parent: this.gameObject);
                        partObject.transform.localScale    = new Vector3(segmentSize, segmentSize, segmentSize);
                        partObject.transform.localPosition = new Vector3(x, y, z);
                    }
                }
            }

            if (InGameConstants.BattlePlayerPartsFade)
            {
                coroutine_ = CoroutineWrapper.DoAfterDelay(GameConstants.Instance.BattlePlayerPartFadeDuration, () => {
                    ObjectPoolManager.Recycle(this);
                });
            }
        }
Ejemplo n.º 6
0
        private void AnimateToState(BGMState state)
        {
            if (coroutine_ != null)
            {
                coroutine_.Cancel();
                coroutine_ = null;
            }

            float oldVolume = backgroundMusicAudioSource_.volume;
            float newVolume = 0.0f;

            switch (state)
            {
            case BGMState.Normal:
                newVolume = 1.0f;
                break;

            case BGMState.Muted:
                newVolume = kBGMMutedVolume;
                break;
            }

            coroutine_ = CoroutineWrapper.DoEaseFor(kBGMStateTransitionDuration, EaseType.SineEaseInOut, (float p) => {
                backgroundMusicAudioSource_.volume = Mathf.Lerp(oldVolume, newVolume, p);
            });
        }
Ejemplo n.º 7
0
 /// <summary>
 /// 弹框提示信息,分两类
 /// ----第一类:两行内容的=== title:标题, content:内容----
 /// 第二类:一行内容的=== title为空,     content:内容----
 /// </summary>
 /// <param name="title"></param>
 /// <param name="content"></param>
 public void ShowPopup(string title, string content)
 {
     if (string.IsNullOrEmpty(title) && content != null)
     {
         ContentTextSingle.text = content;
         SingleTipGo.SetActive(true);
         if (content.Length < 14)
         {
             ContentTextSingle.alignment = TextAnchor.MiddleCenter;
         }
         else
         {
             ContentTextSingle.alignment = TextAnchor.MiddleLeft;
         }
     }
     else
     {
         TitleText.text        = title;
         ContentTextTwice.text = content;
         TwiceTipGo.SetActive(true);
         if (content.Length < 14)
         {
             ContentTextTwice.alignment = TextAnchor.MiddleCenter;
         }
         else
         {
             ContentTextTwice.alignment = TextAnchor.MiddleLeft;
         }
     }
     CoroutineWrapper.EXES(4f, () => { Hide(); });
 }
Ejemplo n.º 8
0
        // PRAGMA MARK - IRecycleSetupSubscriber Implementation
        void IRecycleSetupSubscriber.OnRecycleSetup()
        {
            dispersing_ = false;

            CancelCoroutines();
            renderer_.material.SetFloat("_DissolveFactor", 0.0f);
            coroutines_.Add(CoroutineWrapper.DoEaseFor(kInDuration * 0.6f, EaseType.CubicEaseOut, (float percentage) => {
                float scale = Mathf.Lerp(0.0f, kFinalScale, percentage);
                this.transform.localScale = new Vector3(scale, scale, scale);

                float emissionGain = Mathf.Lerp(0.0f, kMaxEmissionGain, percentage);
                renderer_.material.SetFloat("_EmissionGain", emissionGain);
            }, () => {
                coroutines_.Add(CoroutineWrapper.DoEaseFor(kInDuration * 0.4f, EaseType.CubicEaseOut, (float percentage2) => {
                    float newScale            = Mathf.Lerp(kFinalScale, kHeldScale, percentage2);
                    this.transform.localScale = new Vector3(newScale, newScale, newScale);

                    float newEmissionGain = Mathf.Lerp(kMaxEmissionGain, kHeldEmissionGain, percentage2);
                    renderer_.material.SetFloat("_EmissionGain", newEmissionGain);
                }, () => {
                    CancelCoroutines();
                    StartHeldLooping();
                }));
            }));
        }
Ejemplo n.º 9
0
        // PRAGMA MARK - Public Interface
        public void Init(string title, GameObject detailPrefab, Action allPlayersReadyCallback)
        {
            titleText_.Text = title;

            ObjectPoolManager.Create(detailPrefab, parent: detailContainer_);

            views_.Clear();
            allPlayersReadyCallback_ = allPlayersReadyCallback;

            foreach (Player player in RegisteredPlayers.AllPlayers.Where(p => !p.IsAI))
            {
                var view = ObjectPoolManager.Create <InstructionPlayerReadyView>(GamePrefabs.Instance.InstructionPlayerReadyViewPrefab, parent: playersReadyContainer_);
                view.Init(player);
                view.OnReady += CheckIfAllPlayersReady;

                views_.Add(view);
            }

            transition_.AnimateIn(() => {
                // NOTE (darren): don't allow players to ready up until transition is finished
                foreach (var view in views_)
                {
                    view.StartChecking();
                }

                CoroutineWrapper.DoAfterDelay(kNoPlayersCheckDuration, () => {
                    // NOTE (darren): if all AI players then this will pass inspection
                    CheckIfAllPlayersReady();
                });
            });
        }
Ejemplo n.º 10
0
 private void RespawnDummyPlayer(RecyclablePrefab unused)
 {
     CleanupDummyPlayer(recycle: false);
     CoroutineWrapper.DoAfterDelay(3.0f, () => {
         SpawnDummyPlayer();
     });
 }
Ejemplo n.º 11
0
        void ITransition.Animate(TransitionType transitionType, float delay, Action <ITransition> callback)
        {
            CurrentTransitionType_ = transitionType;

            EaseType easeType   = (transitionType == TransitionType.In) ? inEaseType_ : outEaseType_;
            T        startValue = (transitionType == TransitionType.In) ? GetOutValue() : GetInValue();

            if (currentCoroutine_ != null)
            {
                currentCoroutine_.Cancel();
                currentCoroutine_ = null;

                // If interrupted - start from current value
                startValue = GetCurrentValue();
            }

            T endValue = (transitionType == TransitionType.In) ? GetInValue() : GetOutValue();

            SetValue(startValue, endValue, 0.0f);
            currentCoroutine_ = CoroutineWrapper.DoAfterDelay(baseDelay_ + delay, () => {
                currentCoroutine_ = CoroutineWrapper.DoEaseFor(duration_, easeType, (float p) => {
                    SetValue(startValue, endValue, p);
                }, () => {
                    currentCoroutine_ = null;
                    callback.Invoke(this);
                });
            });
        }
Ejemplo n.º 12
0
        private IEnumerator MoveToPosition(Vector3 position)
        {
            // NOTE (darren): why do we need to wait a frame?
            // if we generate a position that is too close + we are already
            // there, then we can actually set coroutine_ to the DoAfterDelay
            // which will get overridden by the first coroutine_ when the method returns...
            // therefore we lose the reference to the DoAfterDelay :O
            yield return(null);

            Vector2 xzPosition = position.Vector2XZValue();

            while (true)
            {
                Vector2 currentXZPosition = stateMachine_.Player.transform.position.Vector2XZValue();
                if (Vector2.Distance(currentXZPosition, xzPosition) <= kGoodEnoughDistance)
                {
                    break;
                }

                stateMachine_.InputState.LerpMovementVectorTowards(xzPosition - currentXZPosition);
                yield return(null);
            }

            coroutine_ = CoroutineWrapper.DoEveryFrameForDelay(UnityEngine.Random.Range(kIdleDelayMin, kIdleDelayMax), () => {
                stateMachine_.InputState.LerpMovementVectorTowards(Vector2.zero);
            }, () => {
                MoveToRandomNearbyPosition();
            });
        }
Ejemplo n.º 13
0
        private void MoveToRandomNearbyPosition()
        {
            Vector3 nearbyPosition = GenerateRandomNearbyPosition();

            // TODO (darren): validate nearby position with nav-mesh
            coroutine_ = CoroutineWrapper.StartCoroutine(MoveToPosition(nearbyPosition));
        }
Ejemplo n.º 14
0
 public void AnimateAlpha(float alpha, float duration)
 {
     CancelAnimation();
     animateCoroutine_ = CoroutineWrapper.DoEaseFor(duration, EaseType.QuinticEaseIn, (float p) => {
         SetAlpha(Mathf.Lerp(alpha, 0.0f, p));
     });
 }
Ejemplo n.º 15
0
        public static CoroutineWrapper StartCoroutineAsync(IEnumerator coroutine, MonoBehaviour host)
        {
            var wrapper = new CoroutineWrapper();

            RunOnUnityScheduler(() => { host.StartCoroutine(wrapper.Run(coroutine)); });
            return(wrapper);
        }
Ejemplo n.º 16
0
        public static CoroutineWrapper StartCancelableCoroutineAsync(IEnumerator coroutine, MonoBehaviour host, CancellationToken cancellationToken)
        {
            var wrapper = new CoroutineWrapper(cancellationToken);

            RunOnUnityScheduler(() => { host.StartCoroutine(wrapper.Run(coroutine)); });
            return(wrapper);
        }
 private void KeepBeakOpenFor(float duration)
 {
     keepBeakOpen_ = true;
     CoroutineWrapper.DoAfterDelay(duration, () => {
         keepBeakOpen_ = false;
     });
 }
        private IEnumerator AutoTapCoroutine()
        {
            yield return(new WaitForSeconds(GameConstants.kDooberAutoTapDelay));

            this._autoTapCoroutine = null;
            this.HandleTap();
        }
Ejemplo n.º 19
0
        protected override void OnStateEntered()
        {
            if (!PlayerScores.HasPendingScores)
            {
                HandleScoringFinished();
                return;
            }

            InGameConstants.AllowChargingLasers = false;
            InGameConstants.EnableQuacking      = true;

            GameModesProgressionNextUnlockView.ShowIfPossible();
            ActionHintTrackerUtil.ShowIfNecessary(HintKey.CelebrateAction, HintKey.ReflectAction);
            celebrateActionAccumulator_.BeginAccumulating();

            if (InGameConstants.ZoomInOnSurvivors)
            {
                BattleCamera.Instance.SetSurvivingPlayersAsTransformsOfInterest();
            }

            if (InGameConstants.ShowScoringView)
            {
                CoroutineWrapper.DoAfterDelay(kShowDelay, () => {
                    InGamePlayerScoringView.Show(HandleScoringFinished);
                });
            }
            else
            {
                CoroutineWrapper.DoAfterDelay(kShowDelay + 2.0f, () => {
                    HandleScoringFinished();
                });
            }
        }
Ejemplo n.º 20
0
    private void Awake()
    {
        wrapper = new CoroutineWrapper(this);

        TestBoss.OnBossAwaken  += TestBoss_OnBossAwaken;
        TestBoss.OnBossRemoved += TestBoss_OnBossRemoved;
    }
Ejemplo n.º 21
0
 private void CancelAnimation()
 {
     if (animateCoroutine_ != null)
     {
         animateCoroutine_.Cancel();
         animateCoroutine_ = null;
     }
 }
Ejemplo n.º 22
0
 private void CleanupSelectorAnimationCoroutine()
 {
     if (selectorAnimationCoroutine_ != null)
     {
         selectorAnimationCoroutine_.Cancel();
         selectorAnimationCoroutine_ = null;
     }
 }
Ejemplo n.º 23
0
        public static SimpleCoroutineAwaiter <object> GetAwaiter(this IEnumerator coroutine)
        {
            var awaiter    = new SimpleCoroutineAwaiter <object>();
            var enumerator = new CoroutineWrapper <object>(coroutine, awaiter).Run();

            RunOnUnityScheduler(() => RunCoroutine(enumerator));
            return(awaiter);
        }
Ejemplo n.º 24
0
 // PRAGMA MARK - IRecycleSetupSubscriber Implementation
 public void OnRecycleSetup()
 {
     coroutine_ = CoroutineWrapper.DoEaseFor(duration_, EaseType.CubicEaseOut, (float percentage) => {
         light_.intensity = Mathf.Lerp(kLightIntensity, 0.0f, percentage);
     }, () => {
         ObjectPoolManager.Recycle(this);
     });
 }
Ejemplo n.º 25
0
 private void CancelReflectCoroutine()
 {
     if (reflectCoroutine_ != null)
     {
         reflectCoroutine_.Cancel();
         reflectCoroutine_ = null;
     }
 }
Ejemplo n.º 26
0
 protected override void OnStateExited()
 {
     StateMachine_.InputState.CancelTargetMovementVector();
     if (coroutine_ != null)
     {
         coroutine_.Cancel();
         coroutine_ = null;
     }
 }
Ejemplo n.º 27
0
 public void Show(string rTextTip, float rTimeLength = 3.0f)
 {
     if (mCoroutineWrapper != null)
     {
         CoroutineManager.Instance.Stop(mCoroutineWrapper);
         mCoroutineWrapper = null;
     }
     mCoroutineWrapper = CoroutineManager.Instance.StartWrapper(StartAnim(rTextTip, rTimeLength));
 }
Ejemplo n.º 28
0
 protected override void OnStateUpdated()
 {
     if (coroutine_ == null && InGameConstants.IsAllowedToChargeLasers(StateMachine_.Player))
     {
         coroutine_ = CoroutineWrapper.DoAfterDelay(GetRandomCheckAttackDelay(), () => {
             StateMachine_.SwitchState(AIStateMachine.State.Attack);
         });
     }
 }
Ejemplo n.º 29
0
 public void showtoast(string content)
 {
     toastObj.text = content;
     toastObj.gameObject.SetActive(true);
     CoroutineWrapper.EXES(1.5f, () =>
     {
         toastObj.gameObject.SetActive(false);
     });
 }
Ejemplo n.º 30
0
    /// <summary>
    /// 根据状态码执行
    /// </summary>
    /// <param name="status"></param>
    public void PopupInfo(string status)
    {
        isHit = false;
        Debug.Log(status);
        switch (status)
        {
        case "200":
            PP.ShowPopup("请求成功", "密码修改成功,请重新登录");
            gameObject.SetActive(false);
            CoroutineWrapper.EXES(1f, () =>
            {
                mainUISet.lastpagename = mainUISet.UIname.main;
                mainUISet.lastpageid   = 0;
                mainui.LogOut();
            });
            break;

        case "300":
            PP.ShowPopup("意见提交成功", "意见提交成功,我们会尽快查看!");
            break;

        case "500":
            PP.ShowPopup("请求失败", "请求失败,请稍后再试!");
            break;

        case "Error":
            PP.ShowPopup("请求失败", "请稍候重试");
            break;

        case "null":
            PP.ShowPopup("格式错误", "昵称不可为空");
            break;

        case "1002":
            PP.ShowPopup("号码出错", "号码已存在,请更换手机号再试");
            break;

        case "1004":
            PP.ShowPopup("验证码错误", "请输入正确的验证码");
            break;

        case "1007":
            PP.ShowPopup("", "密码修改成功,请重新登录");
            gameObject.SetActive(false);
            CoroutineWrapper.EXES(1f, () =>
            {
                mainUISet.lastpagename = mainUISet.UIname.main;
                mainUISet.lastpageid   = 0;
                mainui.LogOut();
            });
            break;

        default:
            PP.ShowPopup("请求失败", "请稍候重试");
            break;
        }
    }