public void showTooltip(ShroomTree tree) { currentTree = tree; oldHealthValue = newHealthValue = currentTree.getHP(); tooltipPanel.SetActive(true); tooltipShowing = true; }
public void addInfectedTree(ShroomTree tree) { tree.setInfection(true); infectedTrees.Add(tree); Instantiate(InfectionMarkerPrefab, tree.transform.position + new Vector3(0, 15, 0), Quaternion.identity); EventManager.Instance.SendTreeCountChange(1); }
void OnTriggerEnter(Collider c) { if (c.gameObject.layer != LayerMask.NameToLayer("Floor")) { ShroomTree tree = c.gameObject.GetComponent <ShroomTree> (); if (tree != null) { if (tree.isInfected()) { return; } Ray ray = new Ray(transform.position, tree.transform.position - transform.position); RaycastHit hit; Physics.Raycast(ray, out hit); Debug.DrawLine(ray.origin, hit.point); Debug.DrawRay(ray.origin, tree.transform.position - transform.position); GameObject other = hit.collider.gameObject; if (other.GetComponent <ShroomTree> () != null) { OpalmaCareSystem.Instance.addInfectedTree(tree); //NEIN NEIN nicht mehr hier! das ist zu schnell! //tree.gameObject.AddComponent<Infection> (); } } } }
public void SendTreeInfectionComplete(ShroomTree tree) { if (OnTreeInfectionComplete != null) { OnTreeInfectionComplete(tree); } }
// Use this for initialization void Start() { collider = GetComponent <SphereCollider>(); collider.radius = 0; time = 0; tree = gameObject.GetComponent <ShroomTree> (); }
public void plantTrees() { List <ShroomTree> listOfTrees = new List <ShroomTree>(); int planted = 0; while (planted < numOfTrees) { Vector3 position; position = getTreePosition(); ShroomTree model = treePrefabs[Random.Range(0, treePrefabs.Length)]; Quaternion randomRotation = Random.rotation; listOfTrees.Add(Instantiate <ShroomTree>(model, position, Quaternion.Euler(0, Random.Range(0, 360f), 0))); planted++; } ShroomTree IT1 = GameObject.Find("InfectedTree1").GetComponent <ShroomTree>(); ShroomTree IT2 = GameObject.Find("InfectedTree2").GetComponent <ShroomTree>(); ShroomTree IT3 = GameObject.Find("InfectedTree3").GetComponent <ShroomTree>(); ShroomTree IT4 = GameObject.Find("InfectedTree4").GetComponent <ShroomTree>(); OpalmaCareSystem.Instance.addInfectedTree(IT1); OpalmaCareSystem.Instance.addInfectedTree(IT2); OpalmaCareSystem.Instance.addInfectedTree(IT3); OpalmaCareSystem.Instance.addInfectedTree(IT4); listOfTrees.Add(IT1); listOfTrees.Add(IT2); listOfTrees.Add(IT3); listOfTrees.Add(IT4); foreach (ShroomTree tree in listOfTrees) { Destroy(tree.transform.GetChild(3).gameObject); } }
public void deleteTree(ShroomTree s) { treeNeighbors.Remove(s); if (treeNeighbors.Count == 0) { die(); } }
//deletes the given tree if its connected to the network public void delete_Tree(ShroomTree tree) { if (connected_Trees.Contains(tree)) { connected_Trees.Remove(tree); tree.transform.GetChild(0).gameObject.SetActive(false); EventManager.Instance.SendTreeCountChange(--tree_Amount); calculateSporeGain(); NodeManager.Instance.remove_Node(tree); } }
//adds a new tree to the connected Tree array //doesnt do anything if the tree is already connected public void add_Tree(ShroomTree tree) { if (!connected_Trees.Contains(tree)) { connected_Trees.Add(tree); tree.transform.GetChild(0).gameObject.SetActive(true); tree.transform.GetChild(1).gameObject.SetActive(true); EventManager.Instance.SendTreeCountChange(++tree_Amount); calculateSporeGain(); NodeManager.Instance.add_Nodes(tree); } }
//Fires "tree is dying" event public void addDyingTree(ShroomTree tree) { dyingTrees.Add(tree); EventManager.Instance.SendTreeInfectionComplete(tree); }
public bool hasTree(ShroomTree tree) { return(connected_Trees.Contains(tree)); }