コード例 #1
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;
        }
コード例 #2
0
        /// <summary>
        /// A coroutine used to go through every snake body part and trigger its Eat MMFeedbacks
        /// </summary>
        protected virtual IEnumerator EatCo()
        {
            int   total = _snakeBodyParts.Count;
            float feedbacksIntensity = 0f;
            float part = 1 / (float)total;

            for (int i = 0; i < total; i++)
            {
                if (i >= _snakeBodyParts.Count)
                {
                    yield break;
                }
                yield return(MMCoroutine.WaitForFrames(BodyPartsOffset / 2));

                feedbacksIntensity = 1 - i * part;
                if (i == total - 1)
                {
                    if ((i < MaxAmountOfBodyParts - 1) && (_snakeBodyParts.Count > i))
                    {
                        if (_snakeBodyParts[i] != null)
                        {
                            _snakeBodyParts[i].New();
                        }
                    }
                }
                else
                {
                    _snakeBodyParts[i].Eat(feedbacksIntensity);
                }
            }
        }
コード例 #3
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);
        }
コード例 #4
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;
                }
            }
        }
コード例 #5
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();
        }
コード例 #6
0
        /// <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);
        }
コード例 #7
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();
        }
コード例 #8
0
ファイル: ButtonActivated.cs プロジェクト: leonidas192/Iseng
        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;
            }
        }
コード例 #9
0
        /// <summary>
        /// Triggers an attack, turning the damage area on and then off
        /// </summary>
        /// <returns>The weapon attack.</returns>
        protected virtual IEnumerator MeleeWeaponAttack()
        {
            if (_attackInProgress)
            {
                yield break;
            }

            _attackInProgress = true;
            yield return(new WaitForSeconds(InitialDelay));

            EnableDamageArea();
            yield return(MMCoroutine.WaitForFrames(1));

            HandleMiss();
            yield return(new WaitForSeconds(ActiveDuration));

            DisableDamageArea();
            _attackInProgress = false;
        }
コード例 #10
0
        /// <summary>
        /// A coroutine used to teleport the snake to the other side of the screen
        /// </summary>
        /// <returns></returns>
        protected virtual IEnumerator TeleportCo()
        {
            TeleportFeedback?.PlayFeedbacks();

            TeleportOnceFeedback?.PlayFeedbacks();

            yield return(MMCoroutine.WaitForFrames(BodyPartsOffset));

            int   total = _snakeBodyParts.Count;
            float feedbacksIntensity = 0f;
            float part = 1 / (float)total;

            for (int i = 0; i < total; i++)
            {
                yield return(MMCoroutine.WaitForFrames(BodyPartsOffset / 2));

                feedbacksIntensity = 1 - i * part;
                TeleportFeedback?.PlayFeedbacks(this.transform.position, feedbacksIntensity);
            }
        }
コード例 #11
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;
        }
コード例 #12
0
        /// <summary>
        /// Automatically adds items and equips a weapon if needed
        /// </summary>
        /// <returns></returns>
        protected virtual IEnumerator AutoAddAndEquip()
        {
            yield return(MMCoroutine.WaitForFrames(1));

            if (_autoAdded)
            {
                yield break;
            }

            foreach (InventoryItemsToAdd item in AutoAddItemsMainInventory)
            {
                MainInventory?.AddItem(item.Item, item.Quantity);
            }
            foreach (InventoryItemsToAdd item in AutoAddItemsHotbar)
            {
                HotbarInventory?.AddItem(item.Item, item.Quantity);
            }
            if (AutoEquipWeapon != null)
            {
                MainInventory.AddItem(AutoEquipWeapon, 1);
                EquipWeapon(AutoEquipWeapon.ItemID);
            }
            _autoAdded = true;
        }
コード例 #13
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());
        }
コード例 #14
0
        /// <summary>
        /// Activates this part's collider
        /// </summary>
        /// <returns></returns>
        protected virtual IEnumerator ActivateCollider()
        {
            yield return(MMCoroutine.WaitFor(1f));

            _collider2D.enabled = true;
        }