예제 #1
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);
                }
            }
        }
예제 #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
        /// <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;
        }
예제 #4
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);
            }
        }
예제 #5
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;
        }