예제 #1
0
        /// <summary>
        /// Waits for 2 seconds, then kills the ball object after having played the MMFeedbacks
        /// </summary>
        /// <returns></returns>
        protected virtual IEnumerator ProgrammedDeath()
        {
            yield return(MMCoroutine.WaitFor(LifeSpan));

            DeathFeedback?.PlayFeedbacks();
            this.gameObject.SetActive(false);
        }
예제 #2
0
        /// <summary>
        /// Resets the whole scene
        /// </summary>
        /// <returns></returns>
        protected virtual IEnumerator ResetSceneCo()
        {
            yield return(MMCoroutine.WaitFor(DelayBeforeReset));


            CountPoints();

            yield return(MMCoroutine.WaitFor(DelayForPoints));

            ResetFeedback?.PlayFeedbacks();

            yield return(MMCoroutine.WaitFor(0.1f));

            // we reset the ball's position and forces
            BowlingBallRb.MovePosition(_initialBallPosition);
            BowlingBallRb.transform.localRotation = _initialBallRotation;
            BowlingBallRb.velocity        = Vector3.zero;
            BowlingBallRb.angularVelocity = Vector3.zero;

            yield return(MMCoroutine.WaitForFrames(1));

            BowlingBallRb.transform.position = _initialBallPosition;

            // we make our launcher rotate again
            BowlingBallLauncherWiggler.RotationActive = true;

            foreach (StrikePin pin in _strikePins)
            {
                pin.ResetPin();
            }

            _ballThrown = false;
        }
예제 #3
0
        protected virtual IEnumerator ReloadSequence()
        {
            if (DetachLeftHand)
            {
                BoundWeaponIK.AttachLeftHand = false;
            }
            if (DetachRightHand)
            {
                BoundWeaponIK.AttachRightHand = false;
            }
            if (DisableAimWeaponModelAtTargetDuringReload)
            {
                foreach (WeaponModel model in WeaponModels)
                {
                    model.AimWeaponModelAtTarget = false;
                }
            }
            yield return(MMCoroutine.WaitFor(_reloadDuration));

            if (DetachLeftHand)
            {
                BoundWeaponIK.AttachLeftHand = true;
            }
            if (DetachRightHand)
            {
                BoundWeaponIK.AttachRightHand = true;
            }
            if (DisableAimWeaponModelAtTargetDuringReload)
            {
                foreach (WeaponModel model in WeaponModels)
                {
                    model.AimWeaponModelAtTarget = true;
                }
            }
        }
예제 #4
0
        /// <summary>
        /// Moves the food to another spot
        /// </summary>
        /// <returns></returns>
        protected virtual IEnumerator MoveFood()
        {
            Model.SetActive(false);
            yield return(MMCoroutine.WaitFor(OffDelay));

            Model.SetActive(true);
            this.transform.position = Spawner.DetermineSpawnPosition();
            AppearFeedback?.PlayFeedbacks();
        }
        /// <summary>
        /// A coroutine used to hide the instructions after a while
        /// </summary>
        /// <returns></returns>
        protected virtual IEnumerator DisappearCo()
        {
            yield return(MMCoroutine.WaitFor(DisappearDelay));

            StartCoroutine(MMFade.FadeCanvasGroup(_canvasGroup, DisappearDuration, 0f, true));
            yield return(MMCoroutine.WaitFor(DisappearDuration + 0.1f));

            this.gameObject.SetActive(false);
        }
예제 #6
0
        /// <summary>
        /// A coroutine used to spawn loot after a delay
        /// </summary>
        /// <returns></returns>
        protected virtual IEnumerator SpawnLootCo()
        {
            yield return(MMCoroutine.WaitFor(Delay));

            int randomQuantity = Random.Range((int)Quantity.x, (int)Quantity.y);

            for (int i = 0; i < randomQuantity; i++)
            {
                SpawnOneLoot();
            }
            LootFeedback?.PlayFeedbacks();
        }
예제 #7
0
        protected virtual IEnumerator TriggerButtonActionCo()
        {
            if (AutoActivationDelay <= 0f)
            {
                TriggerButtonAction();
                yield break;
            }
            else
            {
                AutoActivationInProgress = true;
                AutoActivationStartedAt  = Time.time;
                yield return(MMCoroutine.WaitFor(AutoActivationDelay));

                AutoActivationInProgress = false;
                TriggerButtonAction();
                yield break;
            }
        }
예제 #8
0
        /// <summary>
        /// A coroutine used to move to each stored target to attack them
        /// </summary>
        /// <returns></returns>
        protected virtual IEnumerator AttackCoroutine()
        {
            float intervalDuration = AttackDuration / _targets.Count;

            // we play our initial attack feedback
            AttackFeedback?.PlayFeedbacks();

            int enemyCounter = 0;

            foreach (Vector3 destination in _targets)
            {
                // for each new enemy, we play an attack feedback
                IndividualAttackFeedback?.PlayFeedbacks();
                MMTween.MoveTransform(this, this.transform, this.transform.position, destination, null, 0f, intervalDuration, AttackCurve);
                _lookAtTarget = destination;
                yield return(MMCoroutine.WaitFor(intervalDuration - enemyCounter * IntervalDecrement));

                enemyCounter++;
            }

            MMTween.MoveTransform(this, this.transform, this.transform.position, _initialPosition, null, 0f, intervalDuration, AttackCurve);
            _lookAtTarget = _initialLookAtTarget;
        }
예제 #9
0
        /// <summary>
        /// A countdown used to reset the scene after a max delay
        /// </summary>
        /// <returns></returns>
        protected virtual IEnumerator ResetCountdown()
        {
            yield return(MMCoroutine.WaitFor(MaxDurationBeforeReset));

            StartCoroutine(ResetSceneCo());
        }
        /// <summary>
        /// Activates this part's collider
        /// </summary>
        /// <returns></returns>
        protected virtual IEnumerator ActivateCollider()
        {
            yield return(MMCoroutine.WaitFor(1f));

            _collider2D.enabled = true;
        }