public ITask GetTask(AIBrain brain) { for (int i = 0; i < ConstructionBuildings.Count; i++) { ConstructionObject constructionObject = ConstructionBuildings[i]; TargetPosition emptyPosition = ConstructionBuildings[i].GetEmptyPosition(); if (emptyPosition != null) { return(new ConstructionTask(brain, constructionObject)); } } for (int i = 0; i < MarkedVegetation.Count; i++) { VegetationObject vegetationObject = MarkedVegetation[i]; if (vegetationObject.Targetable()) { return(new WoodcuttingTask(brain, vegetationObject)); } } return(null); }
private void GenerateVegetation(float[,] heightMap, int offsetX, int offsetY) { for (int y = 2; y < heightMap.GetLength(1) - 1; y++) { for (int x = 1; x < heightMap.GetLength(0) - 1; x++) { if (HeightCurve.Evaluate(heightMap[x, y]) > .02f) { continue; } if (Random.Range(0, 1f) > VegetationDensity) { continue; } Vector3 position = new Vector3(x + offsetX, HeightCurve.Evaluate(heightMap[x, y]) * HeightMultiplier, offsetY + _chunkSize - y); GameObject spawnedTree = Instantiate(_exampleTree, position, Quaternion.identity, _vegetationContainer.transform); VegetationObject vegetationObject = spawnedTree.GetComponent <VegetationObject>(); vegetationObject.Initialize(); GridController.Get.GetCellAtWorldPosition(position - new Vector3(0, 0, 1)).Vegetation = vegetationObject; } } }
public CutTreeAction(VegetationObject tree) { _tree = tree; }
public WoodcuttingTask(AIBrain brain, VegetationObject tree) : base(brain) { _tree = tree; tree.Targeted = true; }