public void Move(Vector2Int CellLocation) { if (CurrentTask == TaskType.Build) { if (building == null) { return; } building.transform.position = grid.GridToLocation(CellLocation) + FlyOffset; if (!grid.CheckPlace(building, CellLocation) && renderer != null) { renderer.material.color = Color.red; } else { renderer.material.color = Color.white; } } else if (CurrentTask == TaskType.Dig) { SoilBlock soil = grid.GetBuildingAt(CellLocation) as SoilBlock; if (soil == null) { return; } soil.HighLightType = 1; } }
//public void HighLight public void Dig(SoilBlock Soil) { //SoilBlock soil = grid.GetBuildingAt(CellLocation) as SoilBlock; if (Soil == null) { return; } if (Soil.Cost <= SessionData.Data.ResourceStorage.Money) { SessionData.Data.ResourceStorage.SpendMoney(Soil.Cost); BuildingInProcess newProcess = new BuildingInProcess(null, "Clearing place", 5); GridComponent.grid.ReplaceBuilding(Soil, newProcess); Kanban.Board.BuildingProcessStarted("Clearing place", newProcess); PlayerController.MainController.SetBuildingControlMode(newProcess); } else { PlayerController.MainController.ShowMessage("You don't have enought money"); } }
public void Dig(Vector2Int CellLocation) { SoilBlock soil = grid.GetBuildingAt(CellLocation) as SoilBlock; if (soil == null) { return; } if (soil.Cost <= resources.Money) { resources.SpendMoney(soil.Cost); grid.RemoveBuilding(soil); CurrentTask = TaskType.Build; building = null; enabled = false; } else { print("Нужно больше золота"); //ToDo Make output to user } }
public override void OnHitByProjectile(CellFace cellFace, WorldItem worldItem) { if (cellFace.Y < 0 || cellFace.Y > 127 || worldItem.Velocity.Length() < 10f) { return; } int value = Terrain.ExtractContents(worldItem.Value); if (value == 102) { for (int i = -1; i < 2; i++) { for (int j = -1; j < 2; j++) { int cellValueFast = SubsystemTerrain.Terrain.GetCellValueFast(cellFace.X + i, cellFace.Y, cellFace.Z + j); if (Terrain.ExtractContents(cellValueFast) == 168) { SubsystemTerrain.ChangeCell(cellFace.X + i, cellFace.Y, cellFace.Z + j, 168 | SoilBlock.SetNitrogen(Terrain.ExtractData(cellValueFast), 3) << 14); worldItem.ToRemove = true; } } } } else if (value == SeedsBlock.Index && SubsystemTerrain.Terrain.GetCellContentsFast(cellFace.X, cellFace.Y + 1, cellFace.Z) == 0) { value = 0; switch (worldItem.Value) { case 16557: value = 20 | FlowerBlock.SetIsSmall(0, true) << 14; break; case 173: value = 19 | TallGrassBlock.SetIsSmall(0, true) << 14; break; case 49325: value = 25 | FlowerBlock.SetIsSmall(0, true) << 14; break; case 32941: value = 24 | FlowerBlock.SetIsSmall(0, true) << 14; break; case 82093: value = 174 | RyeBlock.SetSize(RyeBlock.SetIsWild(0, false), 0) << 14; break; case 65709: value = 174 | RyeBlock.SetSize(RyeBlock.SetIsWild(0, false), 0) << 14; break; case 114861: value = 131 | BasePumpkinBlock.SetSize(BasePumpkinBlock.SetIsDead(0, false), 0) << 14; break; case 98477: value = 204 | CottonBlock.SetSize(CottonBlock.SetIsWild(0, false), 0) << 14; break; } if (value != 0) { SubsystemTerrain.ChangeCell(cellFace.X, cellFace.Y + 1, cellFace.Z, value); worldItem.ToRemove = true; } } }
public void SetData(SoilBlock Soil) { this.Soil = Soil; Show(); Refresh(); }