void OnMouseDown() { CreateManager createManager = GameObject.FindGameObjectWithTag("createManager").transform.GetComponent <CreateManager> (); bool creating = createManager.creating; if (creating) { if (this.GridType == 1) { createManager.creating = false; return; } Transform newTransform = createManager.newTransform; Quaternion rotation = createManager.rotation; int maxOutput = createManager.maxOutput; int directionIndex = createManager.directionIndex; int cost = createManager.cost; Vector3 pos = transform.position; pos.y += 1; Transform newObject = (Transform)Instantiate(newTransform, pos, rotation); TurbineInfo newTurbineInfo = newObject.GetComponent <TurbineInfo> (); newTurbineInfo.maxOutput = maxOutput; newTurbineInfo.CalculateOutput(Elevation); newTurbineInfo.directionIndex = directionIndex % 8; newTurbineInfo.cost = cost; MoneyManager.money -= cost + ExtraCost; createManager.turbineNum++; createManager.creating = false; } if (!creating) { GameObject.FindGameObjectWithTag("screens").GetComponent <CustomizationSwitch> ().toSelectionP(); GameObject.FindGameObjectWithTag("selectionPanel").GetComponent <InfoPanel> ().UpdateInfo(gameObject.transform.GetComponent <GridInfo>()); Debug.Log(GetInfo()); GameObject.FindGameObjectWithTag("createManager").transform.position = gameObject.transform.position; } }
void OnMouseDown() { if (LockUI.OverGui) { return; } //sellButton.GetComponent<SellManager>().disableButton(); GameObject sellBtn = GameObject.FindGameObjectWithTag("sellButton"); GameObject repairBtn = GameObject.FindGameObjectWithTag("repairButton"); if (sellBtn != null) { sellBtn.GetComponent <SellManager> ().disableButton(); } if (repairBtn != null) { repairBtn.GetComponent <RepairManager> ().disableButton(); } AudioSource.PlayClipAtPoint(click, Camera.main.transform.position, 0.8f); CreateManager createManager = GameObject.FindGameObjectWithTag("createManager").transform.GetComponent <CreateManager> (); bool creating = createManager.creating; CreateManager.createType createType = createManager.currentType; if (creating) { if (this.GridType == 1 || TerrainInfo.placeItemInfo[x, z] == 1) { createManager.creating = false; return; } if (createType == CreateManager.createType.turbine) { Transform newTransform = createManager.newTransform; Quaternion rotation = createManager.rotation; int maxOutput = createManager.maxOutput; int directionIndex = createManager.directionIndex; int cost = createManager.cost; float timeForWork = createManager.timeForWork; Vector3 pos = transform.position; pos.y += 1; Transform newObject = (Transform)Instantiate(newTransform, pos, rotation); TurbineInfo newTurbineInfo = newObject.GetComponent <TurbineInfo> (); newTurbineInfo.maxOutput = maxOutput; newTurbineInfo.CalculateOutput(Elevation); newTurbineInfo.directionIndex = directionIndex % 8; newTurbineInfo.cost = cost; newTurbineInfo.timeForWork = timeForWork; newTurbineInfo.turbineColor = createManager.turbineColor; Debug.Log(timeForWork); newTurbineInfo.x = x; newTurbineInfo.z = z; if (MoneyManager.money < cost + ExtraCost) { createManager.finishCreateTurbine(); Destroy(newObject.gameObject); } else { MoneyManager.money -= cost + ExtraCost; CreateManager.turbineNum++; createManager.finishCreateTurbine(); TerrainInfo.placeItemInfo[x, z] = 1; } } //Create Pump here else if (createType == CreateManager.createType.pump) { } //Create Transformer here else if (createType == CreateManager.createType.transformer) { } } if (!creating) { GameObject.FindGameObjectWithTag("screens").GetComponent <CustomizationSwitch> ().toSelectionP(); GameObject.FindGameObjectWithTag("selectionPanel").GetComponent <InfoPanel> ().UpdateInfo(gameObject.transform.GetComponent <GridInfo>()); Debug.Log(GetInfo()); GameObject.FindGameObjectWithTag("createManager").transform.position = gameObject.transform.position; } }