예제 #1
0
        //constructor
        /// <summary>
        /// PlayerEntity, constructor.
        /// </summary>
        public PlayerEntity(PlayerType playerType)
            : base(270.0, 430.0, new HitBox[] { new HitBox(270.0 - (GameResources.GameImage("Player").Width / 2.0), 430.0 - (GameResources.GameImage("Player").Height / 2.0), GameResources.GameImage("Player").Width / 2.0, GameResources.GameImage("Player").Height / 2.0)}, 1, "Player")
        {
            HitBox[] grazeBoxes = new HitBox[] { new HitBox(270.0 - (GameResources.GameImage("Player").Width / 2.0), 430.0 - (GameResources.GameImage("Player").Height / 2.0), GameResources.GameImage("Player").Width, GameResources.GameImage("Player").Height)};

            foreach(HitBox grazeBox in grazeBoxes)
            {
                _grazeBoxes.Add(grazeBox);
            }

            _mainLevel = 0;
            _auxLevel = 0;
        }
예제 #2
0
        //constructor
        /// <summary>
        /// Entity, constructor
        /// </summary>
        /// <param name="x">X position of the entity</param>
        /// <param name="y">Y position of the entity</param>
        /// <param name="hitBoxes">HitBoxes of the entity</param>
        /// <param name="hitPoints">HitPoints of the entity</param>
        /// <param name="bitmap">Bitmap name</param>
        public Entity(double x, double y, HitBox[] hitBoxes, int hitPoints, string bitmap)
        {
            _x = x;
            _y = y;

            foreach(HitBox hitBox in hitBoxes)
            {
                _hitBoxes.Add(hitBox);
            }

            _hitPoints = hitPoints;

            _bitmap = bitmap;

            _tick = 0;
        }
예제 #3
0
 //methods
 /// <summary>
 /// Collides Method
 /// Dectects a colition against the provided Hit Box
 /// </summary>
 /// <param name="hitBox">The Hit Box to check against</param>
 /// <returns>true if colition is detected</returns>
 public bool Collides(HitBox hitBox)
 {
     // HitBoxes Colide if all the folowing conditions are met:
     // x + width > hitBox x
     // x < hitBox x + hitBox width
     // y + height > hitBox y
     // y < hitBox y + hitBox height
     if (_x + _width > hitBox.X && _x < hitBox.X + hitBox.Width && _y + _height > hitBox.Y && _y < hitBox.Y + hitBox.Height)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
예제 #4
0
 /// <summary>
 /// RemoveHitBox, removes the provided hitbox
 /// </summary>
 /// <param name="hitBox">HitBox to remove</param>
 public void RemoveHitbox(HitBox hitBox)
 {
     _hitBoxes.Remove(hitBox);
 }
예제 #5
0
 /// <summary>
 /// AddHitBox, adds the provided hitbox to the entities list of hitboxes
 /// </summary>
 /// <param name="hitBox">HitBox to add</param>
 public void AddHitBox(HitBox hitBox)
 {
     _hitBoxes.Add(hitBox);
 }
예제 #6
0
 /// <summary>
 /// RemoveHitBox, removes the provided hitbox
 /// </summary>
 /// <param name="hitBox">HitBox to remove</param>
 public void RemoveHitbox(HitBox hitBox)
 {
     _hitBoxes.Remove(hitBox);
 }
예제 #7
0
 /// <summary>
 /// AddHitBox, adds the provided hitbox to the entities list of hitboxes
 /// </summary>
 /// <param name="hitBox">HitBox to add</param>
 public void AddHitBox(HitBox hitBox)
 {
     _hitBoxes.Add(hitBox);
 }
예제 #8
0
 //methods
 /// <summary>
 /// Collides Method
 /// Dectects a colition against the provided Hit Box
 /// </summary>
 /// <param name="hitBox">The Hit Box to check against</param>
 /// <returns>true if colition is detected</returns>
 public bool Collides(HitBox hitBox)
 {
     // HitBoxes Colide if all the folowing conditions are met:
     // x + width > hitBox x
     // x < hitBox x + hitBox width
     // y + height > hitBox y
     // y < hitBox y + hitBox height
     if(_x + _width > hitBox.X && _x < hitBox.X + hitBox.Width && _y + _height > hitBox.Y && _y < hitBox.Y + hitBox.Height)
     {
         return true;
     }
     else
     {
         return false;
     }
 }
예제 #9
0
        public void TestHitBoxCreation()
        {
            HitBox testHitBox = new HitBox(0, 0, 10, 10);

            Assert.IsInstanceOf <HitBox>(testHitBox);
        }