public void MouseOverNewObject(GameObject go) { if (this.curSelectedObject == go) { return; } this.curSelectedObject = go; Destroy(this.currentObjectInfo); if (go.GetComponentInParent <UnitController> () != null) { UnitController curController = go.GetComponentInParent <UnitController> (); this.selectedObjectNameText.text = curController.UnitData.Name.ToUpper(); this.selectedObjectNameText.color = Color.white; this.currentObjectInfo = Instantiate(this.selectedUnitPrefab, this.selectedObjectParent.transform) as GameObject; this.currentObjectInfo.GetComponent <UnitInfoPanel> ().SetUnitData(curController.UnitData); this.currentObjectInfo.transform.position = this.selectedObjectParent.transform.position; this.selectedObjectPanel.SetActive(true); } else if (go.GetComponentInParent <ResourceController> () != null) { ResourceController curController = go.GetComponentInParent <ResourceController> (); this.selectedObjectNameText.text = curController.Name.ToUpper(); this.selectedObjectNameText.color = curController.ResColor; this.currentObjectInfo = Instantiate(this.selectedResourcePrefab, this.selectedObjectParent.transform) as GameObject; this.currentObjectInfo.GetComponent <ResourceInfoPanel> ().SetResourceData(curController); this.currentObjectInfo.transform.position = this.selectedObjectParent.transform.position; this.selectedObjectPanel.SetActive(true); } else if (go.GetComponentInParent <HomeBaseController> () != null) { HomeBaseController curController = go.GetComponentInParent <HomeBaseController> (); this.selectedObjectNameText.text = "ANCIENT WAGON"; this.selectedObjectNameText.color = Color.white; this.currentObjectInfo = Instantiate(this.selectedBasePrefab, this.selectedObjectParent.transform) as GameObject; this.currentObjectInfo.GetComponent <BaseInfoPanel> ().SetData(curController); this.currentObjectInfo.transform.position = this.selectedObjectParent.transform.position; this.selectedObjectPanel.SetActive(true); } }
// Start is called before the first frame update void Start() { if (instance == null) { instance = this; } else { Destroy(gameObject); return; } mainCamera = Camera.main; player = GameObject.Find("FPSController").GetComponent <FlowerPlayerControler>(); foreach (MeshFilter filter in GetComponentsInChildren <MeshFilter>()) { filter.mesh.bounds = new Bounds(Vector3.zero, new Vector3(10, 20, 10)); } if (PlayerPrefs.HasKey("economy_0_0")) { loadEconomy(); } else { for (int x = 0; x < 4; x++) { List <int> toPickFrom = new List <int>(); List <int> toPickFrom2 = new List <int>(); for (int y = 0; y < 16; y++)//for every part of the flower the possible options are shuffleded { toPickFrom.Add(y); toPickFrom2.Add(y); } for (int y = 0; y < 16; y++) { int rand = Random.Range(0, toPickFrom.Count);//pick random start int index = toPickFrom[rand]; toPickFrom.RemoveAt(rand); float currentVal = (float)categories[index] + Random.Range(0f, (float)max[index] - categories[index]); rand = Random.Range(0, toPickFrom2.Count);//pick random target int index2 = toPickFrom2[rand]; toPickFrom2.RemoveAt(rand); float targetVal = (float)categories[index2] + Random.Range(0f, (float)max[index2] - categories[index2]); partsEconomy[x, y] = new FlowerPart(index, index2, currentVal, targetVal, Random.Range(lowerJumpRange[(int)jumpIndex.l], lowerJumpRange[(int)jumpIndex.u]), Random.Range(upperJumpRange[(int)jumpIndex.l], upperJumpRange[(int)jumpIndex.u])); } } float minValue = 20f; int[,] shuffleHelper = //I want to make sure there is at least one of each part on home planet that is worth more than minValue, having this makes the following code easier { { 1, 2, 4, 7 }, //these are the parts that are available on homeworld { 0, 4, 9, 11 }, { 0, 2, 8, 15 }, { 0, 1, 3, 6 } }; for (int i = 0; i < 4; i++) { //if nothing is above minValue if (partsEconomy[i, shuffleHelper[i, 0]].currentValue < minValue && partsEconomy[i, shuffleHelper[i, 1]].currentValue < minValue && partsEconomy[i, shuffleHelper[i, 2]].currentValue < minValue && partsEconomy[i, shuffleHelper[i, 3]].currentValue < minValue) { //find one that is and swap them int toAdjust = shuffleHelper[i, Random.Range(0, 4)]; int newOne = Random.Range(0, 16); while (partsEconomy[i, newOne].currentValue < minValue) { newOne = Random.Range(0, 16); } FlowerPart temp = partsEconomy[i, newOne]; partsEconomy[i, newOne] = partsEconomy[i, toAdjust]; partsEconomy[i, toAdjust] = temp; } } } totalFlowersSold = startingWorldCount; //sell balance test /*string toPrint = ""; * for (int i = 0; i < 4; i++) * { * toPrint += "{"; * for (int j = 0; j < 16; j++) * { * toPrint += partValue[i, j] + ", "; * } * toPrint = toPrint.Substring(0, toPrint.Length - 2); * toPrint += "}\n"; * } * print(toPrint); * for (int i = 0; i < 50; i++) * { * uint returnIndex = 0; * for (int j = 0; j < 8; j++) * { * returnIndex += (uint)Random.Range(0, 5); * returnIndex *= 16; * } * processFlowerSell(returnIndex); * } * for (int i = 0; i < 80; i++) * { * uint returnIndex = 0; * for (int j = 0; j < 8; j++) * { * returnIndex += (uint)Random.Range(0,9); * returnIndex *= 16; * } * processFlowerSell(returnIndex); * } * for (int i = 0; i < 110; i++) * { * uint returnIndex = 0; * for (int j = 0; j < 8; j++) * { * returnIndex += (uint)Random.Range(0, 13); * returnIndex *= 16; * } * processFlowerSell(returnIndex); * } * for (int i = 0; i < 200; i++) * { * uint returnIndex = 0; * for (int j = 0; j < 8; j++) * { * returnIndex += (uint)Random.Range(0, 17); * returnIndex *= 16; * } * processFlowerSell(returnIndex); * } * toPrint = ""; * for (int i = 0; i < 4; i++) * { * toPrint += "{"; * for (int j = 0; j < 16; j++) * { * toPrint += partValue[i, j] + ", "; * } * toPrint = toPrint.Substring(0, toPrint.Length - 2); * toPrint += "}\n"; * } * print(toPrint);*/ }
public void SetData(HomeBaseController baseData) { hpText.text = "HP\n" + baseData.HomeBaseData.CurrentHitPoints + "/" + baseData.HomeBaseData.MaxHitPoints; }