示例#1
0
 public AreaTransitionTrigger(Area owner, Area target, Point tilePos, AreaSideEnum side, Point globalTarget, Point destTile)
     : this(owner, target, tilePos, side)
 {
     m_hasGlobalTarget = true;
     m_globalTarget = globalTarget;
     m_destTile = destTile;
 }
        private AreaSideEnum m_side; // used to determine where to place the PC in the target Area

        #endregion Fields

        #region Constructors

        public AreaTransitionTrigger(Area owner, Area target, Point tilePos, AreaSideEnum side)
            : base(calculateBounds(owner, tilePos, side))
        {
            this.m_owner = owner;
            this.m_target = target;

            this.m_tilePos = tilePos;

            this.m_side = side;
        }
 /// <summary>
 /// Used during construction to get the shape of the collision box
 /// </summary>
 /// <returns></returns>
 private static Rectangle calculateBounds(Area owner, Point tilePos, AreaSideEnum side)
 {
     const int attSize = 10;
     int tileWidth = owner.TileSet.tileWidth;
     int tileHeight = owner.TileSet.tileHeight;
     switch (side)
     {
         case AreaSideEnum.Top:
             return new Rectangle(
                 tileWidth * tilePos.X,
                 -attSize,
                 tileWidth,
                 attSize);
         case AreaSideEnum.Bottom:
             return new Rectangle(
                 tileWidth * tilePos.X,
                 tileHeight * tilePos.Y + tileHeight,
                 tileWidth,
                 attSize);
         case AreaSideEnum.Left:
             return new Rectangle(
                 -attSize,
                 tileHeight * tilePos.Y,
                 attSize,
                 tileHeight);
         case AreaSideEnum.Right:
             return new Rectangle(
                 tileWidth * tilePos.X + tileWidth,
                 tileHeight * tilePos.Y,
                 attSize,
                 tileHeight);
         case AreaSideEnum.Other:
             return new Rectangle(
                 tileWidth * tilePos.X,
                 tileHeight * tilePos.Y,
                 tileWidth,
                 tileHeight);
         default:
             throw new Exception("Unknown value for AreaSideEnum");
     }
 }
示例#4
0
 /// <summary>
 /// Place a new area transition trigger in the Area; handles registering collision box
 /// </summary>
 /// <param name="tileX"></param>
 /// <param name="tileY"></param>
 /// <param name="target"></param>
 /// <param name="side"></param>
 public void addAreaTransitionTrigger(int tileX, int tileY, Area target, AreaSideEnum side)
 {
     AreaTransitionTrigger att =
         new AreaTransitionTrigger(this, target, new Point(tileX, tileY), side);
     add(att);
 }