Exemplo n.º 1
0
        public void SpawnEgg()
        {
            const float SPAWN_DISTANCE = 10f;

            _eggSpawned = true;

            Vector2 direction = -1f * DirectionHelper.GetFacingFromDirection(_animDirection);

            if (_animDirection == AnimationDirection.Left ||
                _animDirection == AnimationDirection.Right)
            {
                direction.Y += (float)GameScreen.RandomNum.NextDouble() - 0.5f;
            }
            else if (_animDirection == AnimationDirection.Up ||
                     _animDirection == AnimationDirection.Down)
            {
                direction.X += (float)GameScreen.RandomNum.NextDouble() - 0.5f;
            }
            direction.Normalize();

            Vector2 spawn = Position + (SPAWN_DISTANCE * direction) + PHYSICS_OFFSET;

            EggEntity egg = GameScreen.AddEgg(spawn);

            egg.DynamicBody.ApplyLinearImpulse(direction);
        }