示例#1
0
        private IEnumerator StolePizzaAnimationRoutine(DroneGameObject drone, GameObject enemy)
        {
            CoroutineManager.StopCoroutine(_droneReleasePizzaRoutine);

            var pizza = _level.GetPizzaFromPool();

            pizza.SetScaleXY(1, 1);
            pizza.SetXY(enemy.x, enemy.y);
            pizza.alpha   = 1;
            pizza.visible = true;

            int firstAirplaneIndex = _level.FirstAirplaneIndex;

            _level.SetChildIndex(pizza, firstAirplaneIndex - 1);

            //Animate pizza

            float fromX = enemy.x;
            float fromY = enemy.y;

            float offsetX = 0;
            float offsetY = -25;

            int time     = 0;
            int duration = 450;

            while (time < duration && !drone.Destroyed)
            {
                pizza.x = Easing.Ease(Easing.Equation.CubicEaseOut, time, fromX, drone.x + offsetX - fromX, duration);
                pizza.y = Easing.Ease(Easing.Equation.CubicEaseOut, time, fromY, drone.y + offsetY - fromY, duration);

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

            pizza.parent = drone;
            pizza.SetXY(offsetX, offsetY);

            _droneReleasePizzaRoutine =
                CoroutineManager.StartCoroutine(DroneReleasePizzaRoutine(drone, (Sprite)pizza), this);
        }
示例#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);
        }