private async Task <bool> AddTempZone(Vector2 position, EnumZoneTypes Type) { if (Type == EnumZoneTypes.Residential) { var zone = ResidentialZoneScene.Instance(); Node z1 = zone as Node; CallDeferred("add_child", zone); var _z = z1 as ResidentialZone; _z.Position = position; TempZoneArea.Add(_z); } else if (Type == EnumZoneTypes.Business) { var zone = BusinessZoneScene.Instance(); Node z1 = zone as Node; CallDeferred("add_child", zone as Node); var _z = z1 as BusinessZone; _z.Position = position; TempZoneArea.Add(_z); } else if (Type == EnumZoneTypes.Industry) { var zone = IndustryZoneScene.Instance(); Node z1 = zone as Node; CallDeferred("add_child", zone as Node); var _z = z1 as IndustryZone; _z.Position = position; TempZoneArea.Add(_z); } return(await Task.FromResult(true).ConfigureAwait(false)); }
private void OnResidentialAction() { if (_zone != null) { _zone.QueueFree(); _zone = null; } ZoneMode = true; zoneType = EnumZoneTypes.Residential; var z = ResidentialZoneScene.Instance(); AddChild(z); _zone = z as ResidentialZone; }
private void OnIndustryAction() { if (_zone != null) { _zone.QueueFree(); _zone = null; } ZoneMode = true; zoneType = EnumZoneTypes.Industry; var z = IndustryZoneScene.Instance(); AddChild(z); _zone = z as IndustryZone; }
private void OnBusinessAction() { if (_zone != null) { _zone.QueueFree(); _zone = null; } ZoneMode = true; zoneType = EnumZoneTypes.Business; var z = BusinessZoneScene.Instance(); AddChild(z); _zone = z as BusinessZone; }
private async void ZoneArea(Vector2 StartLocation, Vector2 EndLocation, EnumZoneTypes Type) { var NumX = Mathf.Abs(StartLocation.x - EndLocation.x) / GridSize.x; var NumY = Mathf.Abs(StartLocation.y - EndLocation.y) / GridSize.y; for (int i = 0; i < NumX + 1; i++) { for (int ii = 0; ii < NumY + 1; ii++) { Vector2 pos = new Vector2(); float thisX; float thisY; if (StartLocation.x > EndLocation.x) { thisX = StartLocation.x - (GridSize.x * i); } else { thisX = (GridSize.x * i) + StartLocation.x; } if (StartLocation.y > EndLocation.y) { thisY = StartLocation.y - (GridSize.y * ii); } else { thisY = (GridSize.y * ii) + StartLocation.y; } pos = new Vector2(thisX, thisY); await AddTempZone(pos, Type).ConfigureAwait(false); } } }