// If not enough money, color the node red IEnumerator CheckMoney(TowerBlueprint towerToBuild) { while (towerGhost != null) { if (PlayerStats.GetMoney() - towerToBuild.cost < 0) { rend.color = cannotBuildColor; } else { rend.color = secondColor; } yield return(new WaitForSeconds(checkTime)); } }
//Node seçtiğimiz fonksiyon public void SelectNode(Node node) { //Yani node zaten seçiliyken seçersek deselect etsin. if (selectedNode == node) { DeselectNode(); return; //alttaki kodları çalıştırma. } selectedNode = node; //Ya yeni bir turret seçicez ya da node u seçip oradaki turreta işlemler yapacağız. Bu nedenle birisini seçince diğerini iptal etmemiz gerek. towerToBuild = null; //Node seçildiğinde UI çağırılacak nodeUI.SetTarget(node); }
public void BuildTower(TowerBlueprint blueprintTower) { if (PlayerStats.ammountOfMoney < blueprintTower.price) { Debug.Log("Not enough money!"); return; } GameObject _tower = Instantiate(blueprintTower.prefab, GetPositionToBuild(), Quaternion.identity); tower = _tower; towerBlueprint = blueprintTower; PlayerStats.ammountOfMoney -= blueprintTower.price; }
private void SetUpgradeText() { NodeController node = bm.GetSelectedNode; TowerBlueprint tb = TowersShop.GetTower(node.GetTowerTitle); if (tb != null) { if (tb.upgradeCost == 0) { upgradeText.text = "Can't\nupgrade"; } else { upgradeText.text = "Upgrade\n$" + tb.upgradeCost; } } }
//kule insa etme void buildTower(TowerBlueprint blueprint) { if (PlayerStats.Money < blueprint.cost) { Debug.Log("Yeterli para yok"); return; } PlayerStats.Money -= blueprint.cost; GameObject _tower = (GameObject)Instantiate(blueprint.prefab, GetBuildPosition(), Quaternion.identity); tower = _tower; towerBlueprint = blueprint; Debug.Log("Kule insa edildi!"); }
void BuildTower(TowerBlueprint blueprint) { if (PlayerStats.Money < blueprint.cost) { Debug.Log("Not enough money to build that tower!"); return; } PlayerStats.Money -= blueprint.cost; GameObject tower = Instantiate(blueprint.prefab, GetBuildPosition(), Quaternion.identity); this.tower = tower; towerBluprint = blueprint; GameObject effect = (GameObject)Instantiate(buildManager.buildEffect, GetBuildPosition(), Quaternion.identity); Destroy(effect, 5f); Debug.Log("Tower built!"); }
void BuildTower(TowerBlueprint blueprint) { if (PlayerStats.Money < blueprint.cost) { Debug.Log("Not enough money to build!"); return; } PlayerStats.Money -= blueprint.cost; //Создаём башню на данной платформе GameObject tower = (GameObject)Instantiate(blueprint.prefab, this.GetBuildPosition(), Quaternion.identity); this.installedTower = tower; towerBluePrint = blueprint; GameObject effect = Instantiate(BuildManager.instance.buildEffect, this.GetBuildPosition(), Quaternion.identity); Destroy(effect, 4f); }
public void SelectNode(Node node) { if (selectedNode) { DeselectNode(); return; } selectedNode = node; if (node.tower != null) { tower towerCom = node.tower.GetComponent <tower>(); Draw.DrawCircle(node.gameObject, towerCom.range); } towerToBuild = null; if (node.nature) { natureUI.SetTarget(node); } else if (node.tower) { nodeUI.SetTarget(node); } }
public void SellTower() { if (!isUpgraded && !isUpgradedTwice) //Level 1 ise { PlayerStats.Gold += towerBlueprint.GetSellValueForLevel1(); } else if (isUpgraded && !isUpgradedTwice) //Level 2 ise { PlayerStats.Gold += towerBlueprint.GetSellValueForLevel2(); } else if (isUpgraded && isUpgradedTwice) //Level 3 ise { PlayerStats.Gold += towerBlueprint.GetSellValueForLevel3(); } //Sell turret efekti; //GameObject effect = Instantiate(buildManager.sellEffect, GetBuildPosition(), Quaternion.identity); //Destroy(effect, 5f); //Sattıktan sonra turretı yokedip, mevcut blueprinti de null yapmamız gerek. Destroy(tower); towerBlueprint = null; }
public void ChooseTowerToBuild(int index) { towerToBuild = _towers[index].towerBlueprints[defaultStage]; }
private void Build(TowerBlueprint towerToBuild) { Instantiate(towerToBuild.towerPrefab, _buildingPosition.position, Quaternion.identity, _buildingPlace.transform); _buildingPlace.SetOccupy(true); }
public void SelectTowerToBuild(TowerBlueprint blueprint) { _towerToBuild = blueprint; DeselectNode(); }
public void SellectTowerToBuild(TowerBlueprint towerBluePrint) { towerToBuild = towerBluePrint; }
public void SelectTowerToBuild(TowerBlueprint tower) { towerToBuild = tower; selectedTower = null; }
public void setTowerBlueprintToBuild(TowerBlueprint selectedTower) { Debug.Log("Setting tower blueprint"); towerBlueprintToBuild = selectedTower; }
public void deselectTowerBluerpint() { towerBlueprintToBuild = null; }
// Building private void SetTower(TowerBlueprint towerBlueprint) { GameObject tower = (GameObject)Instantiate(towerBlueprint.prefab, selectedNode.BuildPosition(), Quaternion.identity); selectedNode.SetTower(tower, towerBlueprint.title); }
public void SelectBaseToBuild(BaseBlueprint _base) { baseToBuild = _base; towerToBuild = null; DeselectNode(); }
public void SelectTowerToBuild(TowerBlueprint _tower) { towerToBuild = _tower; baseToBuild = null; DeselectNode(); }
// Store the selected tower in shop public void SetTowerToBuild(TowerBlueprint t) { towerToBuild = t; }
private void LoadTowers() { Rect windoPosition = position; Vector2 newNodePosition = new Vector2(windoPosition.x, windoPosition.y); string[] result = AssetDatabase.FindAssets("t:TowerBlueprint", workingFolders); if (result.Length != 0) { if (nodes == null) { nodes = new List <Node>(); } if (result.Length <= nodes.Count) { //we have already loaded once Debug.LogWarning("We have already loaded the Towers once... no need to have duplicate nodes"); return; } foreach (String asset in result) { string path = AssetDatabase.GUIDToAssetPath(asset); tower = (TowerBlueprint)AssetDatabase.LoadAssetAtPath(path, typeof(TowerBlueprint)); Debug.Log("Towers Found = " + tower.name); TowerNode towerNode = new TowerNode(tower); if (tower.getEditorPosition() == null) { //Debug.Log("editor position is null"); tower.setEditorPosition(newNodePosition); } //Debug.Log(tower.name + " Editor position to load in = " + tower.getEditorPosition()); nodes.Add(new Node(tower.getEditorPosition(), 200, 50, nodeStyle, selectedNodeStyle, inPointStyle, outPointStyle, OnClickInPoint, OnClickOutPoint, OnClickRemoveNode, towerNode)); } /*for (int i = 0; i < nodes.Count; ++i) * { * for (int j = 0; j < nodes[i].skill.skill_Dependencies.Length; ++j) * { * if (skillDictionary.TryGetValue(nodes[i].skill.skill_Dependencies[j], out outSkill)) * { * for (int k = 0; k < nodes.Count; ++k) * { * if (nodes[k].skill.id_Skill == outSkill.id_Skill) * { * outNode = nodes[k]; * OnClickOutPoint(outNode.outPoint); * break; * } * } * OnClickInPoint(nodes[i].inPoint); * } * } * }*/ for (int i = 0; i < nodes.Count; i++) { //string curTowerName = nodes[i].myInfo.title; string path = AssetDatabase.GUIDToAssetPath(result[i]); tower = (TowerBlueprint)AssetDatabase.LoadAssetAtPath(path, typeof(TowerBlueprint)); for (int j = 0; j < tower.upgradesFrom.Count; j++) { string nameToMatch = tower.upgradesFrom[j].name; for (int k = 0; k < nodes.Count; ++k) { Node nodeToMatch; if (nodes[k].myInfo.title == nameToMatch) { nodeToMatch = nodes[k]; OnClickOutPoint(nodeToMatch.outPoint); OnClickInPoint(nodes[i].inPoint); break; } } } for (int j = 0; j < tower.upgradesTo.Count; j++) { } } } else { Debug.Log("No TowerBlueprints seems to exist yet"); } }
//Set the tower we want to build as the tower we give it. public void SelectTowerToBuild(TowerBlueprint tower) { towerToBuild = tower; DeselectNode(); }
private void saveNodes() { if (nodes.Count > 0) { // We fill with as many skills as nodes we have TowerBlueprint[] blueprints = new TowerBlueprint[nodes.Count]; int[] In_dependencies; int[] Out_dependencies; List <int> In_dependenciesList = new List <int>(); List <int> Out_dependenciesList = new List <int>(); // Iterate over all of the nodes. Populating the skills with the node info for (int i = 0; i < nodes.Count; ++i) { if (connections != null) { List <Connection> In_connectionsToRemove = new List <Connection>(); List <Connection> Out_connectionsToRemove = new List <Connection>(); for (int j = 0; j < connections.Count; j++) { if (connections[j].inPoint == nodes[i].inPoint) { for (int k = 0; k < nodes.Count; ++k) { if (connections[j].outPoint == nodes[k].outPoint) { //Debug.Log("node k = " + k); In_dependenciesList.Add(k); } } In_connectionsToRemove.Add(connections[j]); } if (connections[j].outPoint == nodes[i].outPoint) { for (int k = 0; k < nodes.Count; ++k) { if (connections[j].inPoint == nodes[k].inPoint) { Out_dependenciesList.Add(k); } } Out_connectionsToRemove.Add(connections[j]); } } } In_dependencies = In_dependenciesList.ToArray(); In_dependenciesList.Clear(); Out_dependencies = Out_dependenciesList.ToArray(); Out_dependenciesList.Clear(); TowerNode newTowerNode = (TowerNode)nodes[i].myInfo; blueprints[i] = newTowerNode.GetTower(); //Debug.Log(blueprints[i].name +" In dependecies length = " + In_dependencies.Length.ToString()); //Debug.Log(blueprints[i].name + "Out dependecies length = " + Out_dependencies.Length.ToString()); for (int k = 0; k < In_dependencies.Length; k++) { TowerNode towerNode = (TowerNode)nodes[In_dependencies[k]].myInfo; TowerBlueprint towerToAdd = ScriptableObject.CreateInstance <TowerBlueprint>(); towerToAdd = towerNode.GetTower(); string _path = workingFolders[0] + "/" + towerToAdd.name + ".asset"; TowerBlueprint _towerToAdd = AssetDatabase.LoadAssetAtPath(_path, typeof(TowerBlueprint)) as TowerBlueprint; //Debug.LogWarning("Tower to add type: " + towerToAdd.GetType()); blueprints[i].upgradesFrom.Add(_towerToAdd); string tempPath = workingFolders[0] + "/" + blueprints[i].name + ".asset"; TowerBlueprint tempBlueprintsI = AssetDatabase.LoadAssetAtPath(tempPath, typeof(TowerBlueprint)) as TowerBlueprint; TowerBlueprint tempTowerToAdd = _towerToAdd; //move this functionallity out of bluprints[i] loop } blueprints[i].setEditorPosition(new Vector2(nodes[i].nodeRect.x, nodes[i].nodeRect.y) + drag); //Debug.Log(blueprints[i].name + " Editor Position = " + blueprints[i].getEditorPosition()); string path = workingFolders[0] + "/" + blueprints[i].name + ".asset"; TowerBlueprint asset = AssetDatabase.LoadAssetAtPath(path, typeof(TowerBlueprint)) as TowerBlueprint; if (asset == null) { AssetDatabase.CreateAsset(blueprints[i], workingFolders[0] + "/" + blueprints[i].name + ".asset"); } else { EditorUtility.CopySerialized(blueprints[i], asset); } } for (int i = 0; i < blueprints.Length; i++) { for (int j = 0; j < blueprints[i].upgradesFrom.Count; j++) { for (int k = 0; k < blueprints.Length; k++) { if (blueprints[i].upgradesFrom[j].name == blueprints[k].name) { //Debug.Log(blueprints[k].name + " || " + blueprints[i].name); string tempOutPath = workingFolders[0] + "/" + blueprints[k].name + ".asset"; string tempInPath = workingFolders[0] + "/" + blueprints[i].name + ".asset"; TowerBlueprint tempOutTower = AssetDatabase.LoadAssetAtPath(tempOutPath, typeof(TowerBlueprint)) as TowerBlueprint; TowerBlueprint tempInTower = AssetDatabase.LoadAssetAtPath(tempInPath, typeof(TowerBlueprint)) as TowerBlueprint; blueprints[k].upgradesTo.Add(tempInTower); //tempTowerToAdd.upgradesTo.Add(tempBlueprintsI); EditorUtility.CopySerialized(blueprints[k], tempOutTower); } } } } Debug.Log("Towers have been saved/updated"); } }
//called in PlaceTower script public void SelectTowerToBuild(TowerBlueprint tower) { towerToBuild = tower; }
public void SetTurretToBuild(TowerBlueprint turret) { turretToBuild = turret; }