Ejemplo n.º 1
0
 internal PortalCell(GridPortal parentPortal, IPortalAction action)
 {
     _parentPortal = parentPortal;
     _action = action;
 }
Ejemplo n.º 2
0
 internal PortalCell(GridPortal parentPortal, bool oneWay, IPortalAction action)
 {
     _parentPortal = parentPortal;
     _isOneWay     = oneWay;
     _action       = action;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates a GridPortal instance.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="type">The type of the portal.</param>
        /// <param name="direction">The direction of the portal.</param>
        /// <param name="portalOne">The bounds of the first portal.</param>
        /// <param name="portalTwo">The bounds of the second portal.</param>
        /// <param name="exclusiveTo">The attribute mask to indicate if this portal is exclusive to (only available to) certain units.</param>
        /// <param name="action">The action that handles moving between portals.</param>
        /// <returns>The portal instance</returns>
        public static GridPortal Create(string name, PortalType type, PortalDirection direction, Bounds portalOne, Bounds portalTwo, AttributeMask exclusiveTo, IPortalAction action)
        {
            var p = new GridPortal();
            p.Initialize(name, type, direction, portalOne, portalTwo, exclusiveTo, action);

            return p;
        }
Ejemplo n.º 4
0
        private void Initialize(string name, PortalType type, PortalDirection direction, Bounds portalOne, Bounds portalTwo, AttributeMask exclusiveTo, IPortalAction action)
        {
            _type = type;
            _direction = direction;
            _exclusiveTo = exclusiveTo;
            _portalOneBounds = portalOne;
            _portalTwoBounds = portalTwo;

            _cellOne = new PortalCell(this, false, action);
            _cellTwo = new PortalCell(this, _direction == PortalDirection.Oneway, action);

            _gridOne = _cellOne.Initialize(_cellTwo, portalOne);
            _gridTwo = _cellTwo.Initialize(_cellOne, portalTwo);

            if (_gridOne == null || _gridTwo == null)
            {
                throw new ArgumentException("A grid portal has been placed with one or more of its portals outside a grid. Portals must be on a grid.");
            }

            _name = GridManager.instance.RegisterPortal(name, this);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Creates a GridPortal instance.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="type">The type of the portal.</param>
 /// <param name="portalOne">The bounds of the first portal.</param>
 /// <param name="portalTwo">The bounds of the second portal.</param>
 /// <param name="exclusiveTo">The attribute mask to indicate if this portal is exclusive to (only available to) certain units.</param>
 /// <param name="action">The action that handles moving between portals.</param>
 /// <returns>The portal instance</returns>
 public static GridPortal Create(string name, PortalType type, Bounds portalOne, Bounds portalTwo, AttributeMask exclusiveTo, IPortalAction action)
 {
     return Create(name, type, PortalDirection.Twoway, portalOne, portalTwo, exclusiveTo, action);
 }
Ejemplo n.º 6
0
        private void Initialize(string name, PortalType type, PortalDirection direction, Bounds portalOne, Bounds portalTwo, AttributeMask exclusiveTo, IPortalAction action)
        {
            _type            = type;
            _direction       = direction;
            _exclusiveTo     = exclusiveTo;
            _portalOneBounds = portalOne;
            _portalTwoBounds = portalTwo;

            _cellOne = new PortalCell(this, false, action);
            _cellTwo = new PortalCell(this, _direction == PortalDirection.Oneway, action);

            _gridOne = _cellOne.Initialize(_cellTwo, portalOne);
            _gridTwo = _cellTwo.Initialize(_cellOne, portalTwo);

            if (_gridOne == null || _gridTwo == null)
            {
                throw new ArgumentException("A grid portal has been placed with one or more of its portals outside a grid. Portals must be on a grid.");
            }

            _name = GridManager.instance.RegisterPortal(name, this);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Creates a GridPortal instance.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="type">The type of the portal.</param>
        /// <param name="direction">The direction of the portal.</param>
        /// <param name="portalOne">The bounds of the first portal.</param>
        /// <param name="portalTwo">The bounds of the second portal.</param>
        /// <param name="exclusiveTo">The attribute mask to indicate if this portal is exclusive to (only available to) certain units.</param>
        /// <param name="action">The action that handles moving between portals.</param>
        /// <returns>The portal instance</returns>
        public static GridPortal Create(string name, PortalType type, PortalDirection direction, Bounds portalOne, Bounds portalTwo, AttributeMask exclusiveTo, IPortalAction action)
        {
            var p = new GridPortal();

            p.Initialize(name, type, direction, portalOne, portalTwo, exclusiveTo, action);

            return(p);
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Creates a GridPortal instance.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="type">The type of the portal.</param>
 /// <param name="portalOne">The bounds of the first portal.</param>
 /// <param name="portalTwo">The bounds of the second portal.</param>
 /// <param name="exclusiveTo">The attribute mask to indicate if this portal is exclusive to (only available to) certain units.</param>
 /// <param name="action">The action that handles moving between portals.</param>
 /// <returns>The portal instance</returns>
 public static GridPortal Create(string name, PortalType type, Bounds portalOne, Bounds portalTwo, AttributeMask exclusiveTo, IPortalAction action)
 {
     return(Create(name, type, PortalDirection.Twoway, portalOne, portalTwo, exclusiveTo, action));
 }
 internal PortalCell(GridPortal parentPortal, bool oneWay, IPortalAction action)
 {
     _parentPortal = parentPortal;
     _isOneWay = oneWay;
     _action = action;
 }