public virtual void Accept(IUnitVisitor visitor) { foreach (var unit in this.units) { unit.Accept(visitor); } }
public void VisitInRadius(WorldEntity referer, float radius, IUnitVisitor unitVisitor) { int cellRange = Mathf.CeilToInt(radius / gridCellSize); GridCell originCell = referer.CurrentCell; if (originCell == null) { return; } int minX = Mathf.Clamp(originCell.X - cellRange, 0, cellCountX - 1); int maxX = Mathf.Clamp(originCell.X + cellRange, 0, cellCountX - 1); int minZ = Mathf.Clamp(originCell.Z - cellRange, 0, cellCountZ - 1); int maxZ = Mathf.Clamp(originCell.Z + cellRange, 0, cellCountZ - 1); for (int i = minX; i <= maxX; i++) { for (int j = minZ; j <= maxZ; j++) { Drawing.DrawLine(referer.Position + Vector3.up, cells[i, j].Center + Vector3.up * 20, Color.red, 1.0f); Drawing.DrawLine(cells[i, j].MaxBounds + Vector3.up * 20, cells[i, j].MinBounds + Vector3.up * 20, cells[i, j] != originCell ? Color.green : Color.yellow, 1.0f); cells[i, j].Visit(unitVisitor); } } }
internal void Visit(IUnitVisitor unitVisitor) { for (var i = 0; i < worldPlayers.Count; i++) { worldPlayers[i].Accept(unitVisitor); } for (var i = 0; i < worldCreatures.Count; i++) { worldCreatures[i].Accept(unitVisitor); } }
public override void Accept(IUnitVisitor visitor) { visitor.Visit(this); base.Accept(visitor); }
public void VisitInRadius(WorldEntity referer, float radius, IUnitVisitor unitVisitor) { mapGrid.VisitInRadius(referer, radius, unitVisitor); }