コード例 #1
0
        internal IGrid GetGridFor(PortalCell c)
        {
            if (c == _cellOne)
            {
                return(_gridOne);
            }

            return(_gridTwo);
        }
コード例 #2
0
        /// <summary>
        /// Executes the action.
        /// </summary>
        /// <param name="unit">The unit that has entered the portal.</param>
        /// <param name="from">The portal cell that was entered.</param>
        /// <param name="to">The destination at the other side of the portal.</param>
        /// <param name="callWhenComplete">The callback to call when the move is complete.</param>
        public void Execute(Transform unit, PortalCell from, IPositioned to, Action callWhenComplete)
        {
            var heightSampler = GameServices.heightStrategy.heightSampler;
            float fromHeight;
            if (!heightSampler.TrySampleHeight(unit.position, out fromHeight))
            {
                fromHeight = to.position.y;
            }

            var heightAdjustment = to.position.y - fromHeight;
            unit.position = new Vector3(to.position.x, unit.position.y + heightAdjustment, to.position.z);

            callWhenComplete();
        }
コード例 #3
0
        /// <summary>
        /// Executes the action.
        /// </summary>
        /// <param name="unit">The unit that has entered the portal.</param>
        /// <param name="from">The portal cell that was entered.</param>
        /// <param name="to">The destination at the other side of the portal.</param>
        /// <param name="callWhenComplete">The callback to call when the move is complete.</param>
        public void Execute(Transform unit, PortalCell from, IPositioned to, Action callWhenComplete)
        {
            var   heightSampler = GameServices.heightStrategy.heightSampler;
            float fromHeight;

            if (!heightSampler.TrySampleHeight(unit.position, out fromHeight))
            {
                fromHeight = to.position.y;
            }

            var heightAdjustment = to.position.y - fromHeight;

            unit.position = new Vector3(to.position.x, unit.position.y + heightAdjustment, to.position.z);

            callWhenComplete();
        }
コード例 #4
0
ファイル: PortalCell.cs プロジェクト: beelol/invoke
        internal IGrid Initialize(PortalCell partner, Bounds portalBounds)
        {
            var grid = GridManager.instance.GetGrid(portalBounds.center);

            if (grid == null)
            {
                return(null);
            }

            _partner        = partner;
            this.parent     = grid.cellMatrix;
            this.position   = portalBounds.center;
            _neighbourNodes = grid.GetCoveredCells(portalBounds).ToArray();
            _matrixBounds   = grid.cellMatrix.GetMatrixBounds(portalBounds, 0.0f, true);

            return(grid);
        }
コード例 #5
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);
        }
コード例 #6
0
ファイル: PortalCell.cs プロジェクト: jdeter14/game1
        internal IGrid Initialize(PortalCell partner, Bounds portalBounds)
        {
            var grid = GridManager.instance.GetGrid(portalBounds.center);
            if (grid == null)
            {
                return null;
            }

            _partner = partner;
            this.parent = grid.cellMatrix;
            this.position = portalBounds.center;
            _neighbourNodes = grid.GetCoveredCells(portalBounds).ToArray();

            return grid;
        }
コード例 #7
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);
        }
コード例 #8
0
ファイル: GridPortal.cs プロジェクト: forwolk/UnityApex
        internal IGrid GetGridFor(PortalCell c)
        {
            if (c == _cellOne)
            {
                return _gridOne;
            }

            return _gridTwo;
        }
コード例 #9
0
 /// <summary>
 /// Executes the specified unit.
 /// </summary>
 /// <param name="unit">The unit that has entered the portal.</param>
 /// <param name="from">The portal cell that was entered.</param>
 /// <param name="to">The destination at the other side of the portal.</param>
 /// <param name="callWhenComplete">The callback to call when the move is complete.</param>
 public void Execute(Transform unit, PortalCell from, IPositioned to, Action callWhenComplete)
 {
     callWhenComplete();
 }
コード例 #10
0
 /// <summary>
 /// Executes the action.
 /// </summary>
 /// <param name="unit">The unit that has entered the portal.</param>
 /// <param name="from">The portal cell that was entered.</param>
 /// <param name="to">The destination at the other side of the portal.</param>
 /// <param name="callWhenComplete">The callback to call when the move is complete.</param>
 public void Execute(Transform unit, PortalCell from, IPositioned to, Action callWhenComplete)
 {
     callWhenComplete();
 }