Exemple #1
0
        public StorkManager(Stork pStork, Level pLevel) : base(false)
        {
            _stork = pStork;
            _level = pLevel;
            _map   = _level.Map;
            _stork.ColliderListener = this;

            _lastMarker = _level.GetChildren(false).Where(o => o is DeliveryPoint).LastOrDefault();
        }
Exemple #2
0
        public IEnumerator DropPizzaRoutine(Vector2 dropPoint, int delay = 400)
        {
            if (delay > 0)
            {
                yield return(new WaitForMilliSeconds(delay));
            }

            Console.WriteLine($"{this}: droppoint: {dropPoint}");

            //Get pizza game object
            var pizza = _level.GetPizzaFromPool();

            if (pizza == null)
            {
                yield break;
            }

            _level.SetChildIndex(pizza, _level.GetChildren(false).Count);
            pizza.visible = true;
            pizza.SetScaleXY(1, 1);
            var pizzaPos = _stork.Pos; // + _stork.Forward * 35;

            pizza.SetXY(pizzaPos.x, pizzaPos.y);

            var fromX = pizzaPos.x;
            var fromY = pizzaPos.y;

            var toX = dropPoint.x;
            var toY = dropPoint.y;

            int time     = 0;
            int duration = 1800;

            pizza.SetScaleXY(1, 1);

            var fromScaleX = pizza.scaleX;
            var fromScaleY = pizza.scaleY;

            int scaleTime = 0;

            bool hasChangedDepthFlag = false;

            while (time < duration)
            {
                pizza.x = Easing.Ease(Easing.Equation.Linear, time, fromX, toX - fromX, duration);
                pizza.y = Easing.Ease(Easing.Equation.Linear, time, fromY, toY - fromY, duration);

                float scaleX = 0;
                float scaleY = 0;

                if (scaleTime < 400)
                {
                    scaleX = Easing.Ease(Easing.Equation.CubicEaseOut, scaleTime, fromScaleX, 1.5f - fromScaleX,
                                         400);
                    scaleY = Easing.Ease(Easing.Equation.CubicEaseOut, scaleTime, fromScaleY, 1.5f - fromScaleY,
                                         400);
                }
                else
                {
                    scaleX = Easing.Ease(Easing.Equation.CubicEaseIn, scaleTime - 400, 1.5f, 0f - 1.5f, duration - 400);
                    scaleY = Easing.Ease(Easing.Equation.CubicEaseIn, scaleTime - 400, 1.5f, 0f - 1.5f, duration - 400);

                    if (!hasChangedDepthFlag && scaleX < 1)
                    {
                        hasChangedDepthFlag = true;
                        pizza.parent.SetChildIndex(pizza, _lastMarker.Index + 1);
                    }
                }

                pizza.SetScaleXY(scaleX, scaleY);

                time      += Time.deltaTime;
                scaleTime += Time.deltaTime;
                yield return(null);
            }

            ParticleManager.Instance.PlaySmallSmoke(_level, toX, toY, 1500, _lastMarker.Index + 1);
        }