コード例 #1
0
        public static PortalDirection GetOppositeDirection(PortalDirection direction)
        {
            switch (direction)
            {
            case PortalDirection.Ceiling:
                return(PortalDirection.Floor);

            case PortalDirection.Floor:
                return(PortalDirection.Ceiling);

            case PortalDirection.WallPositiveX:
                return(PortalDirection.WallNegativeX);

            case PortalDirection.WallNegativeX:
                return(PortalDirection.WallPositiveX);

            case PortalDirection.WallPositiveZ:
                return(PortalDirection.WallNegativeZ);

            case PortalDirection.WallNegativeZ:
                return(PortalDirection.WallPositiveZ);

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
コード例 #2
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);
        }
コード例 #3
0
        /// <summary>
        /// Creates a runtime Connector Portal instance.
        /// </summary>
        /// <param name="host">The host GameObject.</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="relativeToTransform">Controls whether the given bounds are treated as relative to the host transform.</param>
        /// <returns>The connector portal</returns>
        public static GridPortalComponent CreateConnector(GameObject host, PortalDirection direction, Bounds portalOne, Bounds portalTwo, bool relativeToTransform)
        {
            var p = host.AddComponent <RuntimeGridPortalComponent>();

            p.Configure(PortalType.Connector, direction, portalOne, portalTwo, relativeToTransform, string.Empty);

            return(p);
        }
コード例 #4
0
        }                                                      // direction of this gateway


        public PortalTemplate(
            string stringID,
            PathRole pathrole,
            PortalDirection direction
            )
        {
            this.stringID  = stringID;
            this.pathrole  = pathrole;
            this.direction = direction;
        }
コード例 #5
0
            internal void Configure(PortalType type, PortalDirection direction, Bounds portalOne, Bounds portalTwo, bool relativeToTransform, string portalName)
            {
                this.type                = type;
                this.direction           = direction;
                this.portalOne           = portalOne;
                this.portalTwo           = portalTwo;
                this.relativeToTransform = relativeToTransform;
                this.portalName          = portalName;

                base.Awake();
                OnStartAndEnable();
            }
コード例 #6
0
        public static IntVector2 GetIntVector2(this PortalDirection portalDirection)
        {
            switch (portalDirection)
            {
            default:
            case PortalDirection.North: return(IntVector2.up);

            case PortalDirection.East: return(IntVector2.right);

            case PortalDirection.South: return(IntVector2.down);

            case PortalDirection.West: return(IntVector2.left);
            }
        }
コード例 #7
0
        public static DoorDirection GetDoorDirection(this PortalDirection portalDirection)
        {
            switch (portalDirection)
            {
            default:
            case PortalDirection.None: return(DoorDirection.North);

            case PortalDirection.Any: return(DoorDirection.North);

            case PortalDirection.North: return(DoorDirection.North);

            case PortalDirection.East: return(DoorDirection.East);

            case PortalDirection.South: return(DoorDirection.South);

            case PortalDirection.West: return(DoorDirection.West);
            }
        }
コード例 #8
0
        public static PortalDirection GetOpposite(this PortalDirection portalDirection)
        {
            switch (portalDirection)
            {
            default:
            case PortalDirection.None: return(PortalDirection.Any);

            case PortalDirection.Any: return(PortalDirection.Any);

            case PortalDirection.North: return(PortalDirection.South);

            case PortalDirection.East: return(PortalDirection.West);

            case PortalDirection.South: return(PortalDirection.North);

            case PortalDirection.West: return(PortalDirection.East);
            }
        }
コード例 #9
0
        public static PortalDirection GetRotated(this PortalDirection portalDirection)
        {
            //rotate matehmatically positive
            switch (portalDirection)
            {
            default:
            case PortalDirection.None: return(PortalDirection.None);

            case PortalDirection.Any: return(PortalDirection.Any);

            case PortalDirection.North: return(PortalDirection.West);

            case PortalDirection.East: return(PortalDirection.North);

            case PortalDirection.South: return(PortalDirection.East);

            case PortalDirection.West: return(PortalDirection.South);
            }
        }
コード例 #10
0
        public static Direction?GetDirection(PortalDirection direction)
        {
            switch (direction)
            {
            case PortalDirection.WallNegativeX:
                return(LevelData.Direction.NegativeX);

            case PortalDirection.WallPositiveX:
                return(LevelData.Direction.PositiveX);

            case PortalDirection.WallNegativeZ:
                return(LevelData.Direction.NegativeZ);

            case PortalDirection.WallPositiveZ:
                return(LevelData.Direction.PositiveZ);

            default:
                return(null);
            }
        }
コード例 #11
0
        public static RectangleInt2 GetOppositePortalArea(PortalDirection direction, RectangleInt2 area)
        {
            switch (direction)
            {
            case PortalDirection.WallPositiveX:
                return(area + new VectorInt2(-1, 0));

            case PortalDirection.WallPositiveZ:
                return(area + new VectorInt2(0, -1));

            case PortalDirection.WallNegativeZ:
                return(area + new VectorInt2(0, 1));

            case PortalDirection.WallNegativeX:
                return(area + new VectorInt2(1, 0));

            default:
                return(area);
            }
        }
コード例 #12
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);
        }
コード例 #13
0
ファイル: Blocks.cs プロジェクト: SirJosh3917/SwitchAsm
 public Portal(int x, int y, BlockType id, PortalDirection rotation, int curId, int targetId) : this(new RelativePoint(x, y), id, new PortalInfo(curId, targetId, rotation))
 {
 }
コード例 #14
0
ファイル: Blocks.cs プロジェクト: SirJosh3917/SwitchAsm
 public Portal(RelativePoint pos, BlockType id, PortalDirection rotation, int curId, int targetId) : this(pos, id, new PortalInfo(curId, targetId, rotation))
 {
 }
コード例 #15
0
ファイル: Blocks.cs プロジェクト: SirJosh3917/SwitchAsm
 public PortalInfo(int curId, int targetId, PortalDirection rotate)
 {
     this.CurrentId = curId;
     this.TargetId  = targetId;
     this.Rotation  = rotate;
 }
コード例 #16
0
 /// <summary>
 /// Used when adding a gateway to a dungeon based on an instance of PortalTemplate
 /// </summary>
 public Portal(PortalTemplate template)
 {
     this.template  = template;
     this.direction = template.direction; //can get modified
 }
コード例 #17
0
        /// <summary>
        /// Creates a runtime Portal instance.
        /// </summary>
        /// <typeparam name="TAction">The type of the action.</typeparam>
        /// <param name="host">The host GameObject.</param>
        /// <param name="type">The portal type.</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="relativeToTransform">Controls whether the given bounds are treated as relative to the host transform.</param>
        /// <param name="portalName">Name of the portal.</param>
        /// <returns>The portal</returns>
        public static GridPortalComponent Create <TAction>(GameObject host, PortalType type, PortalDirection direction, Bounds portalOne, Bounds portalTwo, bool relativeToTransform, string portalName) where TAction : Component, IPortalAction
        {
            host.AddComponent <TAction>();

            var p = host.AddComponent <RuntimeGridPortalComponent>();

            p.Configure(type, direction, portalOne, portalTwo, relativeToTransform, portalName);

            return(p);
        }
コード例 #18
0
ファイル: GridPortal.cs プロジェクト: forwolk/UnityApex
        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);
        }
コード例 #19
0
ファイル: GridPortal.cs プロジェクト: forwolk/UnityApex
        /// <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;
        }
コード例 #20
0
 public PortalInstance(RectangleInt2 area, PortalDirection direction, Room adjoiningRoom = null)
     : base(area)
 {
     AdjoiningRoom = adjoiningRoom;
     Direction     = direction;
 }