Ejemplo n.º 1
0
 /// <summary>
 /// Basic constructor
 /// </summary>
 /// <param name="position">Position</param>
 /// <param name="x">Radius of the bounding box width</param>
 /// <param name="y">Radius of the bounding box height</param>
 /// <param name="points">Points obtained for killing the enemy</param>
 /// <param name="horizontalSpeed">Horizontal movement speed</param>
 /// <param name="verticalSpeed">Vertical movement speed</param>
 /// <param name="fallingSpeed">Falling speed</param>
 public Pickle(Vector2 position, float x, float y, int points, float horizontalSpeed,
     float verticalSpeed, float fallingSpeed)
     : base(position, x, y, points, horizontalSpeed, verticalSpeed, fallingSpeed)
 {
     artist = new DrawingComponent(SpriteDatabase.GetAnimation("Pickle Walk"), Color.White,
         new Vector2(SettingsManager.GetInstance().Scale, SettingsManager.GetInstance().Scale), 0.75f);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Basic constructor
        /// </summary>
        /// <param name="position">Position</param>
        /// <param name="x">Radius x</param>
        /// <param name="y">Radius y</param>
        public Lettuce(Vector2 position, float x, float y)
            : base(position, x, y)
        {
            artist = new DrawingComponent(SpriteDatabase.GetAnimation("Lettuce Bounce"), Color.White,
                new Vector2(SettingsManager.GetInstance().Scale, SettingsManager.GetInstance().Scale), 1);

            artists = new DrawingComponent[4];
            artists[0] = new DrawingComponent(SpriteDatabase.GetAnimation("Lettuce Left"), Color.White,
                new Vector2(SettingsManager.GetInstance().Scale, SettingsManager.GetInstance().Scale), 1);
            artists[1] = new DrawingComponent(SpriteDatabase.GetAnimation("Lettuce Middle Left"), Color.White,
                new Vector2(SettingsManager.GetInstance().Scale, SettingsManager.GetInstance().Scale), 1);
            artists[2] = new DrawingComponent(SpriteDatabase.GetAnimation("Lettuce Middle Right"), Color.White,
                new Vector2(SettingsManager.GetInstance().Scale, SettingsManager.GetInstance().Scale), 1);
            artists[3] = new DrawingComponent(SpriteDatabase.GetAnimation("Lettuce Right"), Color.White,
                new Vector2(SettingsManager.GetInstance().Scale, SettingsManager.GetInstance().Scale), 1);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Basic Constructor
 /// </summary>
 /// <param name="position">Position</param>
 /// <param name="x">Radius of the bounding box width</param>
 /// <param name="y">Radius of the bounding box height</param>
 /// <param name="points">Points obtained if consumed</param>
 /// <param name="lifeTime">Time until it dissapears</param>
 public IceCream(Vector2 position, float x, float y, int points, int lifeTime)
     : base(position, x, y, points, lifeTime)
 {
     artist = new DrawingComponent(SpriteDatabase.GetAnimation("Ice Cream"), Color.White,
         new Vector2(SettingsManager.GetInstance().Scale, SettingsManager.GetInstance().Scale), 0);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Transition from one state to another
        /// </summary>
        /// <param name="newState">State to transition into</param>
        public override void TransitionToState(State newState)
        {
            if (state == newState)
            {
                return;
            }

            state = newState;

            switch (newState)
            {
                case State.Bouncing:

                    artist = new DrawingComponent(SpriteDatabase.GetAnimation("Lettuce Bounce"), Color.White,
                        new Vector2(SettingsManager.GetInstance().Scale, SettingsManager.GetInstance().Scale), 1);

                    break;

                case State.Done:

                    numberOfRiders = 0;
                    numberOfLevels = 0;

                    artist = null;

                    for (int i = 0; i != touched.GetLength(0); ++i)
                    {
                        touched[i] = false;
                    }

                    break;

                case State.Falling:

                    artist = null;

                    lastTile = World.map.MapPosition(position);

                    // Nudge as to avoid another collision
                    position += speed * Vector2.UnitY;

                    for (int i = 0; i != positions.GetLength(0); ++i)
                    {
                        positions[i].Y = position.Y;
                    }

                    // Rider
                    foreach (Enemy enemy in World.enemies)
                    {
                        if (enemy.BoundingBox.Collides(boundingBox) &&
                            enemy.GetState != Enemy.State.Riding &&
                            enemy.GetState != Enemy.State.Dying &&
                            enemy.GetState != Enemy.State.Dead)
                        {
                            enemy.TransitionToState(Enemy.State.Riding);
                            enemy.SetRider(this);
                            ++numberOfRiders;
                            SoundManager.GetInstance().PlaySound("Ride", position.X);
                        }
                    }

                    if (numberOfRiders == 0)
                    {
                        numberOfLevels = 0;
                    }

                    break;

                case State.Static:

                    numberOfRiders = 0;
                    numberOfLevels = 0;

                    artist = null;

                    for (int i = 0; i != touched.GetLength(0); ++i)
                    {
                        touched[i] = false;
                    }

                    break;
            }

            if (artist != null)
            {
                artist.Reset();
            }

            foreach (DrawingComponent draw in artists)
            {
                draw.Reset();
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Basic constructor
        /// </summary>
        /// <param name="position">Position</param>
        /// <param name="x">Radius X of bounding box</param>
        /// <param name="y">Radius Y of bounding box</param>
        /// <param name="horizontalSpeed">Horizontal movement speed</param>
        /// <param name="verticalSpeed">Vertical movement speed</param>
        public PeterPepper(Vector2 position, float x, float y, float horizontalSpeed, float verticalSpeed)
            : base(position, x, y)
        {
            this.horizontalSpeed = horizontalSpeed;
            this.verticalSpeed = verticalSpeed;

            state = State.Walking;
            movementDirection = Vector2.Zero;
            faceDirection = Vector2.UnitX;
            speed = 0;

            artist = new DrawingComponent(SpriteDatabase.GetAnimation("Peter Pepper Walk"), Color.White,
                new Vector2(SettingsManager.GetInstance().Scale, SettingsManager.GetInstance().Scale), 0);
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Basic constructor
 /// </summary>
 /// <param name="position">Position</param>
 /// <param name="x">Collision x radius</param>
 /// <param name="y">Collision y radius</param>
 public Plate(Vector2 position, float x, float y)
     : base(position, x, y)
 {
     artist = new DrawingComponent(SpriteDatabase.GetAnimation("Plate"), Color.White,
         new Vector2(SettingsManager.GetInstance().Scale, SettingsManager.GetInstance().Scale), 1);
 }