// Start is called before the first frame update void Start() { nm = GameObject.FindObjectOfType <NetworkManager>(); if (nm) { selfNode = GameObject.FindGameObjectWithTag("Nav").GetComponent <NodeInstanceManager>(); } }
// Update is called once per frame void Update() { if (nm) { if (this.GetComponent <ItemScript>().type == "Canister1") { this.nodeColor = GameObject.Find("OxygenColor").GetComponent <Text>(); selfNode = GameObject.Find("LungTarget").GetComponent <NodeInstanceManager>(); } else if (this.GetComponent <ItemScript>().type == "Canister2") { this.nodeColor = GameObject.Find("Oxygen2Color").GetComponent <Text>(); selfNode = GameObject.Find("Lungs_2Target").GetComponent <NodeInstanceManager>(); } else { this.nodeColor = GameObject.Find("StomachColor").GetComponent <Text>(); selfNode = GameObject.Find("StomachTarget").GetComponent <NodeInstanceManager>(); } } if (lifetime > 0 && !(this.GetComponent <ItemScript>().type == "Canister1" || this.GetComponent <ItemScript>().type == "Canister2")) { lifetime -= Time.deltaTime; if (lifetime <= 0 && !this.gameObject.GetComponent <ItemScript>().pickedUp) { Destroy(this.gameObject); } else if (this.gameObject.GetComponent <ItemScript>().pickedUp) { lifetime = startingLife; } } }