Beispiel #1
0
        protected bool shouldShoot; //Determines if the player should shoot.

        #endregion Fields

        #region Constructors

        //The initial direction of each player is down.
        protected Player(string name, GridPosition position, ObjectColor color)
            : base(position, 'V', color)
        {
            this.Name = name;
            this.Score = 0;
            this.Health = Player.PlayerMaxHealth;

            this.shouldShoot = false;
            this.lastMoveDirection = new GridPosition(1, 0);
        }
Beispiel #2
0
 /// <summary>
 /// Returns a block created from the specified type, position and color.
 /// </summary>
 public static StaticObject CreateBlock(int blockType, GridPosition position, ObjectColor color)
 {
     switch (blockType)
     {
         case 0: return new Wall(position, color);
         case 1: return new GiftBlock(position, color, rand.Next(0, 10));
         case 2: return new HealthBlock(position);  //The health block is always red.
         case 3: return new Obstacle(position, color);
         default: return new Obstacle(position, color);
     }
 }
Beispiel #3
0
 public GiftBlock(GridPosition position, ObjectColor color, int bonus)
     : base(position, '$', color)
 {
     if (bonus < 0 || bonus > 9)
     {
         throw new ArgumentOutOfRangeException();
     }
     else
     {
         this.Bonus = bonus;
     }
 }
Beispiel #4
0
        public HumanPlayer(string name, GridPosition position, ObjectColor color, IUserInterface userInterface)
            : base(name, position, color)
        {
            this.userInterface = userInterface;

            this.userInterface.OnLeftRequest += OnMoveLeft;

            this.userInterface.OnRightRequest += OnMoveRight;

            this.userInterface.OnDownRequest += OnMoveDown;

            this.userInterface.OnUpRequest += OnMoveUp;

            this.userInterface.OnActionRequest += OnShoot;
        }
Beispiel #5
0
        /// <summary>
        /// Tells the player to move up.
        /// </summary>
        protected virtual void OnMoveUp(object sender, EventArgs args)
        {
            this.Direction = new GridPosition(-1, 0);
            this.lastMoveDirection = this.Direction;

            if (this.image != '^')
            {
                this.image = '^';
            }
        }
Beispiel #6
0
        /// <summary>
        /// Tells the player to move right.
        /// </summary>
        protected virtual void OnMoveRight(object sender, EventArgs args)
        {
            this.Direction = new GridPosition(0, 1);
            this.lastMoveDirection = this.Direction;

            if (this.image != '>')
            {
                this.image = '>';
            }
        }
Beispiel #7
0
 public StaticObject(GridPosition position, char image, ObjectColor color)
     : base(position, image, color)
 {
 }
Beispiel #8
0
 public StaticObject(GridPosition position, char image, ObjectColor color)
     : base(position, image, color)
 {
 }
Beispiel #9
0
 public Obstacle(GridPosition position, ObjectColor color)
     : base(position, '#', color)
 {
 }
Beispiel #10
0
        public const int Damage = 25; //The damage done by a bullet.

        #endregion Fields

        #region Constructors

        public Bullet(GridPosition position, ObjectColor color, GridPosition direction)
            : base(position, '+', color, direction)
        {
        }
Beispiel #11
0
 public Obstacle(GridPosition position, ObjectColor color)
     : base(position, '#', color)
 {
 }
Beispiel #12
0
        public const int HealthBonus = 25;  //The bonus health which the block gives.

        public HealthBlock(GridPosition position)
            : base(position, '♥', ObjectColor.Red)
        {
        }
Beispiel #13
0
 public MovingObject(GridPosition position, char image, ObjectColor color, GridPosition direction)
     : base(position, image, color)
 {
     this.Direction = direction;
 }
Beispiel #14
0
 public MovingObject(GridPosition position, char image, ObjectColor color)
     : base(position, image, color)
 {
     this.Direction = new GridPosition(0, 0);
 }
Beispiel #15
0
 public static bool operator !=(GridPosition a, GridPosition b)
 {
     return(!GridPosition.Equals(a, b));
 }
Beispiel #16
0
 public ScoreBlock(GridPosition position, ObjectColor color, int bonus)
     : base(position, (char)(bonus + '0'), color)
 {
 }
Beispiel #17
0
        public const int HealthBonus = 25; //The bonus health which the block gives.

        #endregion Fields

        #region Constructors

        public HealthBlock(GridPosition position)
            : base(position, '♥', ObjectColor.Red)
        {
        }