using UnityEngine; using System.Collections; using System.Collections.Generic; public class ConduitItem : MonoBehaviour { public Vector3 startPosition; public Dictionary td; public GameObject target; public GameObject machine; public GameObject billboard; public GameObject billboard2; public bool active; public void Start() { startPosition = transform.position; } public void Update() { if (active == true && td != null) { if (machine != null) { if (machine.GetComponent() != null) { if (machine.GetComponent().outputObject != null) { target = machine.GetComponent().outputObject; if (td.ContainsKey(machine.GetComponent().outputType)) { billboard.GetComponent().material.mainTexture = td[machine.GetComponent().outputType]; } } } if (machine.GetComponent() != null) { if (machine.GetComponent().outputObject != null) { target = machine.GetComponent().outputObject; billboard.GetComponent().material.mainTexture = td["Regolith"]; } } if (machine.GetComponent() != null) { if (machine.GetComponent().inputObject != null) { target = machine.GetComponent().inputObject; if (td.ContainsKey(machine.GetComponent().type)) { billboard.GetComponent().material.mainTexture = td[machine.GetComponent().type]; } } } if (machine.GetComponent() != null) { if (machine.GetComponent().outputObject != null) { target = machine.GetComponent().outputObject; billboard.GetComponent().material.mainTexture = td["Dark Matter"]; } } if (machine.GetComponent() != null) { if (machine.GetComponent().outputObject != null) { target = machine.GetComponent().outputObject; billboard.GetComponent().material.mainTexture = td["Dark Matter"]; } } if (machine.GetComponent() != null) { if (machine.GetComponent().outputObject != null) { target = machine.GetComponent().outputObject; if (td.ContainsKey(machine.GetComponent().outputType)) { billboard.GetComponent().material.mainTexture = td[machine.GetComponent().outputType]; } } } if (machine.GetComponent() != null) { if (machine.GetComponent().outputObject != null) { target = machine.GetComponent().outputObject; if (td.ContainsKey(machine.GetComponent().outputType)) { billboard.GetComponent().material.mainTexture = td[machine.GetComponent().outputType]; } } } if (machine.GetComponent() != null) { if (machine.GetComponent().outputObject != null) { target = machine.GetComponent().outputObject; if (td.ContainsKey(machine.GetComponent().outputType)) { billboard.GetComponent().material.mainTexture = td[machine.GetComponent().outputType]; } } } if (machine.GetComponent() != null) { if (machine.GetComponent().outputObject != null) { target = machine.GetComponent().outputObject; if (td.ContainsKey(target.GetComponent().type)) { billboard.GetComponent().material.mainTexture = td[target.GetComponent().type]; billboard2.GetComponent().material.mainTexture = td[target.GetComponent().type]; } } } if (machine.GetComponent() != null) { if (machine.GetComponent().outputObject != null) { target = machine.GetComponent().outputObject; if (td.ContainsKey(machine.GetComponent().outputType)) { billboard.GetComponent().material.mainTexture = td[machine.GetComponent().outputType]; } } } if (machine.GetComponent() != null) { if (machine.GetComponent().outputObject != null) { target = machine.GetComponent().outputObject; if (td.ContainsKey(machine.GetComponent().type)) { billboard.GetComponent().material.mainTexture = td[machine.GetComponent().type]; } } } if (machine.GetComponent() != null) { if (machine.GetComponent().outputObject != null) { target = machine.GetComponent().outputObject; if (td.ContainsKey(machine.GetComponent().type)) { billboard.GetComponent().material.mainTexture = td[machine.GetComponent().type]; } } } } if (target != null) { billboard.GetComponent().enabled = true; transform.LookAt(target.transform.position); transform.position += transform.forward * 10 * Time.deltaTime; if (Vector3.Distance(transform.position, target.transform.position) < 1) { transform.position = startPosition; } } else { billboard.GetComponent().enabled = false; } } else { billboard.GetComponent().enabled = false; td = GetComponent().dictionary; } } }