public static bool TowerTargetHostile(UnitTower tower) { _TowerType type = tower.type; if (type == _TowerType.Turret || type == _TowerType.AOE) { return(true); } return(false); }
public static bool TowerUseShootObjectT(UnitTower tower) { _TowerType type = tower.type; if (type == _TowerType.AOE) { return(true); } return(false); }
public static bool TowerDealDamage(UnitTower tower) { _TowerType type = tower.type; if (type == _TowerType.Turret || type == _TowerType.AOE) { return(true); } return(false); }
public static bool TowerUseTurret(UnitTower tower) { _TowerType type = tower.type; if (type == _TowerType.Turret) { return(true); } return(false); }
void UpdateBuildableTypeLength(int num) { _TowerType[] tempList = new _TowerType[num]; for (int i = 0; i < tempList.Length; i++) { if (i >= platform.buildableType.Length) { tempList[i] = _TowerType.TurretTower; } else { tempList[i] = platform.buildableType[i]; } } platform.buildableType = tempList; }
public static bool CheckBuildPoint(Vector3 pointer, _TowerType type, int specialID) { if (!CheckBuildPoint(pointer)) { return(false); } if (specialID > 0) { if (currentBuildInfo.specialBuildableID != null && currentBuildInfo.specialBuildableID.Length > 0) { foreach (int specialBuildableID in currentBuildInfo.specialBuildableID) { if (specialBuildableID == specialID) { return(true); } } } return(false); } else { if (currentBuildInfo.specialBuildableID != null && currentBuildInfo.specialBuildableID.Length > 0) { return(false); } foreach (_TowerType buildabletype in currentBuildInfo.buildableType) { if (type == buildabletype) { return(true); } } } currentBuildInfo.buildable = false; return(false); }
//show to draw the selected tower info panel, which include the upgrade and sell button void SelectedTowerUI() { float startX = Screen.width - 260; float startY = Screen.height - 455 - bottomPanelRect.height; float widthBox = 250; float heightBox = 450; towerUIRect = new Rect(startX, startY, widthBox, heightBox); for (int i = 0; i < 3; i++) { GUI.Box(towerUIRect, ""); } startX = Screen.width - 260 + 20; startY = Screen.height - 455 - bottomPanelRect.height + 20; float width = 250 - 40; float height = 20; GUIStyle tempGUIStyle = new GUIStyle(); tempGUIStyle.fontStyle = FontStyle.Bold; tempGUIStyle.fontSize = 16; tempGUIStyle.normal.textColor = new Color(1, 1, 0, 1f); string towerName = currentSelectedTower.unitName; GUIContent guiContentTitle = new GUIContent(towerName); GUI.Label(new Rect(startX, startY, width, height), guiContentTitle, tempGUIStyle); tempGUIStyle.fontStyle = FontStyle.Bold; tempGUIStyle.fontSize = 13; tempGUIStyle.normal.textColor = new Color(1, 0, 0, 1f); GUI.Label(new Rect(startX, startY += height, width, height), "Level: " + currentSelectedTower.GetLevel().ToString(), tempGUIStyle); startY += 20; string towerInfo = ""; _TowerType type = currentSelectedTower.type; //display relevent information based on tower type if (type == _TowerType.SupportTower) { //show buff info only BuffStat buffInfo = currentSelectedTower.GetBuff(); string buff = ""; if (buffInfo.damageBuff != 0) { buff += "Buff damage by " + (buffInfo.damageBuff * 100).ToString("f1") + "%\n"; } if (buffInfo.rangeBuff != 0) { buff += "Buff range by " + (buffInfo.rangeBuff * 100).ToString("f1") + "%\n"; } if (buffInfo.cooldownBuff != 0) { buff += "Reduce CD by " + (buffInfo.cooldownBuff * 100).ToString("f1") + "%\n"; } if (buffInfo.regenHP != 0) { buff += "Renegerate HP by " + (buffInfo.regenHP).ToString("f1") + " per seconds\n"; } towerInfo += buff; } else if (type == _TowerType.TurretTower || type == _TowerType.AOETower) { //show the basic info for turret and aoeTower if (currentSelectedTower.GetDamage() > 0) { towerInfo += "Damage: " + currentSelectedTower.GetDamage().ToString("f1") + "\n"; } if (currentSelectedTower.GetCooldown() > 0) { towerInfo += "Cooldown: " + currentSelectedTower.GetCooldown().ToString("f1") + "sec\n"; } if (type == _TowerType.TurretTower && currentSelectedTower.GetAoeRadius() > 0) { towerInfo += "AOE Radius: " + currentSelectedTower.GetAoeRadius().ToString("f1") + "\n"; } if (currentSelectedTower.GetStunDuration() > 0) { towerInfo += "Stun target for " + currentSelectedTower.GetStunDuration().ToString("f1") + "sec\n"; } //if the tower have damage over time value, display it Dot dot = currentSelectedTower.GetDot(); float totalDot = dot.damage * (dot.duration / dot.interval); if (totalDot > 0) { string dotInfo = "Cause " + totalDot.ToString("f1") + " damage over the next " + dot.duration + " sec\n"; towerInfo += dotInfo; } //if the tower have slow value, display it Slow slow = currentSelectedTower.GetSlow(); if (slow.duration > 0) { string slowInfo = "Slow target by " + (slow.slowFactor * 100).ToString("f1") + "% for " + slow.duration.ToString("f1") + "sec\n"; towerInfo += slowInfo; } } //show the tower's description towerInfo += "\n\n" + currentSelectedTower.description; GUIContent towerInfoContent = new GUIContent(towerInfo); //draw all the information on screen float contentHeight = GUI.skin.GetStyle("Label").CalcHeight(towerInfoContent, 200); GUI.Label(new Rect(startX, startY += 20, width, contentHeight), towerInfoContent); //reset the draw position startY = Screen.height - 180 - bottomPanelRect.height; if (enableTargetPrioritySwitch) { if (currentSelectedTower.type == _TowerType.TurretTower) { //~ if(currentSelectedTower.targetingArea!=_TargetingArea.StraightLine){ GUI.Label(new Rect(startX, startY, 120, 30), "Targeting Priority:"); if (GUI.Button(new Rect(startX + 120, startY - 3, 100, 30), currentSelectedTower.targetPriority.ToString())) { if (currentSelectedTower.targetPriority == _TargetPriority.Nearest) { currentSelectedTower.SetTargetPriority(1); } else if (currentSelectedTower.targetPriority == _TargetPriority.Weakest) { currentSelectedTower.SetTargetPriority(2); } else if (currentSelectedTower.targetPriority == _TargetPriority.Toughest) { currentSelectedTower.SetTargetPriority(3); } else if (currentSelectedTower.targetPriority == _TargetPriority.Random) { currentSelectedTower.SetTargetPriority(0); } } startY += 30; //~ } } } //check if the tower can be upgrade bool upgradable = false; if (!currentSelectedTower.IsLevelCapped() && currentSelectedTower.IsBuilt()) { upgradable = true; } //reset the draw position startY = Screen.height - 50 - bottomPanelRect.height; //if the tower is eligible to upgrade, draw the upgrade button if (upgradable) { if (GUI.Button(new Rect(startX, startY, 100, 30), new GUIContent("Upgrade", "1"))) { //upgrade the tower, if false is return, player have insufficient fund if (!currentSelectedTower.Upgrade()) { Debug.Log("Insufficient Resource"); } } } //sell button if (currentSelectedTower.IsBuilt()) { if (GUI.Button(new Rect(startX + 110, startY, 100, 30), new GUIContent("Sell", "2"))) { currentSelectedTower.Sell(); } } //if the cursor is hover on the upgrade button, show the cost if (GUI.tooltip == "1") { int[] cost = currentSelectedTower.GetCost(); GUI.Label(new Rect(startX + 10, startY, 150, 25), " - " + cost[0].ToString() + "resource"); } //if the cursor is hover on the sell button, show the resource gain else if (GUI.tooltip == "2") { int[] sellValue = currentSelectedTower.GetTowerSellValue(); GUI.Label(new Rect(startX + 120, startY, 150, 25), " + " + sellValue[0].ToString() + "resource"); } }
//similar to CheckBuildPoint but called by UnitTower in DragNDrop mode, check tower type before return public static bool CheckBuildPoint(Vector3 pointer, _TowerType type) { return(CheckBuildPoint(pointer, type, -1)); }
//can build with restriction to certain tower type public void BuildSpotInto(Vector3 pos, _TowerType[] bT) { position=pos; buildableType=bT; }
public static bool CheckBuildPoint(Vector3 pointer, _TowerType type, int specialID) { if(!CheckBuildPoint(pointer)) return false; if(specialID>0){ if(currentBuildInfo.specialBuildableID!=null && currentBuildInfo.specialBuildableID.Length>0){ foreach(int specialBuildableID in currentBuildInfo.specialBuildableID){ if(specialBuildableID==specialID){ return true; } } } return false; } else{ if(currentBuildInfo.specialBuildableID!=null && currentBuildInfo.specialBuildableID.Length>0){ return false; } foreach(_TowerType buildabletype in currentBuildInfo.buildableType){ if(type==buildabletype){ return true; } } } currentBuildInfo.buildable=false; return false; }
//similar to CheckBuildPoint but called by UnitTower in DragNDrop mode, check tower type before return public static bool CheckBuildPoint(Vector3 pointer, _TowerType type) { return CheckBuildPoint(pointer, type, -1); }