private Transform newDestination(Transform destinationAt) { //Temp listwithout current at to avoid repeating current gate List <Transform> tempList = new List <Transform>(); foreach (GameObject dest in Destinations) { tempList.Add(dest.transform); } //In case there's only 1 gate, keep it in the list for return if (tempList.Count > 1) { tempList.Remove(destinationAt); } //prepare random destination Transform random = tempList[Random.Range(0, tempList.Count)]; //Check for cases destination is not a portal? if (!destinationAt.GetComponent <OffMeshLink>()) { return(random); } //check if the destination is an active gate scr_PortGate destGate = destinationAt.transform.parent.GetComponent <scr_PortGate>(); //Return current gates destination if active (off mesh linked) or random return(destGate.active ? destGate.destination : random); }
public void activatePortal(scr_KeyData keyData) { scr_PortGate destGateScript = keyData.transform.GetComponent <scr_PortGate>(); //Change this gate's stuff setDestination(destGateScript); //Change destination gate stuff destGateScript.setDestination(this); destinationGateObject.GetComponentInChildren <Camera>().enabled = true; //Enable camera on destination gate when activated }
public void deactivatePortal(scr_KeyData keyData) { scr_PortGate destGateScript = destinationGateObject.GetComponent <scr_PortGate>(); //Change this gate's stuff unsetDestination(destGateScript); //Change destination gate stuff destGateScript.unsetDestination(this); destinationGateObject = null; }
public void unsetDestination(scr_PortGate gateScript) { if (tag == "MasterPortal") { updateExitLift(); } destination = spawn; Material material = GetComponent <Renderer>().material; material.mainTexture = inactiveTexture;//set this gates texture navLink.activated = false; active = false; audioController.idleSFX(active); destinationGateObject = null; //set dest gate for visible/invisible camera switching camera.enabled = false; //just for safety in case there are two gates visible at once when disabling }
public void setDestination(scr_PortGate gateScript) { if (tag == "MasterPortal") { updateExitLift(); } destination = gateScript.spawn; //set this gates destination transform Material material = GetComponent <Renderer>().material; material.mainTexture = gateScript.gateOutlook;//set this gates texture material.SetTexture("_BumpMap", null); navLink.endTransform = gateScript.navLink.transform; navLink.activated = true; active = true; audioController.idleSFX(active); destinationGateObject = gateScript.transform.gameObject; //store dest gate for visible/invisible camera switching }