void Start() { controller = GetComponent<CPUComputeTimeController>(); scale = scaleInPercent/100.0f; yPositionModifier = yPositionInPercent/100.0f; xPositionModifier = xPositionInPercent/100.0f; fontSize =(int)(11.0f*scale)/1024*Screen.width; }
void UpdateButtonsCreate(GameObject tower, int x, int y, CPUComputeTimeController controller ) { if(controller.CPUTime<DMGPrice) {GUI.enabled = false;} GUI.skin.label.fontSize = fontSize; GUI.Label(new Rect(x+((int)buttonSize*0.65f),y-buttonSize,buttonSize/2,buttonSize/3),"DMG"); if (GUI.Button(new Rect(x, y-buttonSize, buttonSize, buttonSize), new GUIContent("",("DMGlabel")), customGuiStyle)) { //Increase DMG upgradeComp =tower.GetComponent<NPCShooter>(); if(upgradeComp.HasDamage){ controller.CPUTime -= DMGPrice; upgradeComp.WeaponDamage += 1;} } GUI.enabled = true; if(controller.CPUTime<DMGPrice) {GUI.enabled = false;} GUI.skin.label.fontSize = fontSize; GUI.Label(new Rect(x+buttonSize+((int)buttonSize*0.65f),y-buttonSize,buttonSize/2,buttonSize/3),"RNG"); if (GUI.Button(new Rect(x+buttonSize, y-buttonSize, buttonSize, buttonSize), new GUIContent("",("RNGlabel")), customGuiStyle)) { //increase Range upgradeComp =tower.GetComponent<NPCShooter>(); if(upgradeComp.HasRadius && controller.CPUTime>RangePrice) { controller.CPUTime -= RangePrice; upgradeComp.BiggerRadius(1);} } GUI.enabled = true; if(controller.CPUTime<DMGPrice) {GUI.enabled = false;} GUI.skin.label.fontSize = fontSize; GUI.Label(new Rect(x+buttonSize*2+((int)buttonSize*0.65f),y-buttonSize,buttonSize/2,buttonSize/3),"SPD"); if (GUI.Button(new Rect(x+buttonSize*2, y-buttonSize, buttonSize, buttonSize), new GUIContent("",("SPDlabel")), customGuiStyle)) { //increase Speed upgradeComp =tower.GetComponent<NPCShooter>(); // TODO: Creates an exception if the script hasnt been started! if(upgradeComp.HasDelay && controller.CPUTime>SpeedPrice) { controller.CPUTime -= SpeedPrice; tower.GetComponent<NPCShooter>().Delay /= 1.1f;} } GUI.enabled = true; if(true) {GUI.enabled = false;} GUI.skin.label.fontSize = fontSize; GUI.Label(new Rect(x+buttonSize*3+((int)buttonSize*0.65f),y-buttonSize,buttonSize/2,buttonSize/3),"SLL"); if (GUI.Button(new Rect(x+buttonSize*3, y-buttonSize, buttonSize, buttonSize), new GUIContent("",("SLLlabel")), customGuiStyle)) { //sell tower //controller.CPUTime += tower.GetComponent<TowerCost>().CPUTimeCost; //Destroy(tower); GUI.enabled = true; } }
void TowerButtonCreate(GameObject tower, string name, int x, int y, CPUComputeTimeController controller ) { int cost = tower.GetComponent<TowerCost>().CPUTimeCost; string costString = cost.ToString(); int time = controller.CPUTime; if (time<cost) { GUI.enabled = false; } GUI.skin.label.fontSize = fontSize; GUI.Label(new Rect(x+((int)buttonSize*0.65f),y-5,buttonSize/2,buttonSize/3),name); GUI.Label(new Rect(x+((int)buttonSize*0.65f),y+(int)(buttonSize-fontSize*1.6f),buttonSize/2,buttonSize/3),costString); if (GUI.Button(new Rect(x, y, buttonSize, buttonSize),new GUIContent("",(name+"label")), customGuiStyle)) { controller.CPUTime -= cost; selectedTower = (GameObject)Instantiate(tower, Vector3.zero, Quaternion.identity); } GUI.enabled = true; }
void Start() { controller = GetComponent<CPUComputeTimeController>(); yPositionModifier = yPositionInPercent/100.0f; xPositionModifier = xPositionInPercent/100.0f; scale = scaleInPercent/100.0f; fontSize =(int)(9.0f*scale); }