internal IGrid GetGridFor(PortalCell c) { if (c == _cellOne) { return(_gridOne); } return(_gridTwo); }
/// <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(); }
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); }
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); }
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; }
internal IGrid GetGridFor(PortalCell c) { if (c == _cellOne) { return _gridOne; } return _gridTwo; }
/// <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(); }
/// <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(); }