Ejemplo n.º 1
0
 /// <summary>
 /// Finds the part of the box the bullet collided with.
 /// </summary>
 /// <param name="portalBox">The box the bullet collided with. This box must be able to hold 
 /// portals.</param>
 /// <param name="portal">The portal that will be made.</param>
 /// <param name="bulletExists">The bool that says whether the bullet exists.</param>
 private void portalMade(Box portalBox, ref Portal portal, ref bool bulletExists)
 {
     double tempDouble = Collision.TestVertical(this, portalBox);
     if (tempDouble == 10)
     { tempDouble = Collision.TestHorizontal(this, portalBox); }
     portal.Created(portalBox, tempDouble, ref bulletExists);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Instantiates the portal when it is created by a bullet. Instantiates the portal's position, 
        /// using the box's position and the facing of the portal, the portal's sprite, and then 
        /// destroys the bullet.
        /// </summary>
        /// <param name="portalBox">The box that the bullet hit. Must be able to hold portals.</param>
        /// <param name="facing">The direction that the portal will be facing, in radians.</param>
        /// <param name="bulletExists">The flag for the existence of the bullet.</param>
        public void Created(Box portalBox, double facing, ref bool bulletExists)
        {
            if (facing == 0)
            {
                sprite = sprites["UP"];
                roomX = portalBox.roomX;
                roomY = portalBox.roomY + portalBox.sprite.Height - 5;
                portalDirection = facing;
            }
            if (facing == Math.PI)
            {
                sprite = sprites["DOWN"];
                roomX = portalBox.roomX;
                roomY = portalBox.roomY - 5;
                portalDirection = facing;
            }
            if (facing == -Math.PI / 2)
            {
                sprite = sprites["LEFT"];
                roomX = portalBox.roomX + portalBox.sprite.Width - 5;
                roomY = portalBox.roomY;
                portalDirection = -facing;
            }
            if (facing == Math.PI / 2)
            {
                sprite = sprites["RIGHT"];
                roomX = portalBox.roomX - 5;
                roomY = portalBox.roomY;
                portalDirection = -facing;
            }

            exists = true;
            bulletExists = false;

            if (facing == 10)
            {
                exists = false;
                bulletExists = true;
            }
        }