public Placeable CreateNewPlaceable(PlaceableData data, GardenNode pos) { Placeable newplace = null; if (data) { GameObject pref = null; switch (data.placeableType) { case PlaceableData.ePlaceableType.DECORATION: pref = decorationPlaceablePrefab; break; case PlaceableData.ePlaceableType.HOME: pref = homePlaceablePrefab; break; case PlaceableData.ePlaceableType.GENERATOR: pref = generatorPlaceablePrefab; break; } newplace = Instantiate(pref, pos.transform.position, Quaternion.Euler(0, Random.value * (360f), 0), WorldManager.Instance.WorldParent.transform).GetComponent <Placeable>(); if (newplace) { newplace.placeableData = data; newplace.nodeOccupied = pos; pos.occupied = newplace; } } return(newplace); }
void RpcHarvest(int nodeID) { GardenNode _node = GardenNodes.gardenNodes[nodeID].GetComponent <GardenNode>(); if (_node.plantComponent == null) { return; } _node.plantComponent.Harvest(true); }
void RpcPlant(int nodeID, int plantID) { GardenNode _node = GardenNodes.gardenNodes[nodeID].GetComponent <GardenNode>(); if (_node.plantComponent != null) { Destroy(_node.plant); } _node.Plant(GardenNodeUI.plantListReference[plantID]); }
private void Awake() { gardenNodes = new Transform[transform.childCount]; for (int i = 0; i < gardenNodes.Length; ++i) { gardenNodes[i] = transform.GetChild(i); GardenNode nodeComponent = gardenNodes[i].GetComponent <GardenNode>(); nodeComponent.nodeID = i; nodeComponent.UI = UI; } }
public void SetTarget(GardenNode _target) { if (!WaveSpawner.Instance.gameStarted) { BuildManager.Instance.message.PlayMessage("Cannot plant until game starts!", _target.transform, Color.white); return; } if (_target == target) { Hide(); return; } target = _target; transform.position = target.transform.position; if (target.plantComponent != null) { plantButtons.SetActive(false); currentPlantInfoBox.SetActive(true); currentPlantNameText.text = target.plantComponent.displayName; currentPlantInfoText.text = target.plantComponent.info; currentPlantInfoBoxImage.color = target.plantComponent.displayColor; } else { plantButtons.SetActive(true); currentPlantInfoBox.SetActive(false); harvestCooldown.fillAmount = 0; } if (!target.CheckRipe()) { harvestTime.text = target.timeTillRipe - Time.time + " seconds till ripe!"; harvestButton.interactable = false; } else { harvestTime.text = "Ready!"; harvestButton.interactable = true; } UI.SetActive(true); }
public void Hide() { UI.SetActive(false); target = null; }