public void InteractableInitialize() { //In case I forget... gameObject.layer = LayerMask.NameToLayer("Interactable"); if (GetComponent <PowerCube>() != null) { pc = GetComponent <PowerCube>(); it = InteractableType.PowerCube; } else if (GetComponent <PowerStation>() != null) { ps = GetComponent <PowerStation>(); it = InteractableType.PowerStation; } else if (GetComponent <DoorButton>() != null) { db = GetComponent <DoorButton>(); it = InteractableType.DoorButton; } else if (GetComponent <TimedDoorButton>() != null) { timd = GetComponent <TimedDoorButton>(); it = InteractableType.TimedDoorButton; } else { it = InteractableType.None; } //If universal functionality is needed, that will go here }
private void OnTriggerEnter(Collider other) { if (other.tag == "Player") { TimedDoorButton.StopAllTimers(); } }
public void PoweredInteractableInitialize() { if (GetComponent <DoorButton>() != null) { pdb = GetComponent <DoorButton>(); pt = PoweredType.DoorButton; } else if (GetComponent <TimedDoorButton>() != null) { tim = GetComponent <TimedDoorButton>(); pt = PoweredType.TimedDoorButton; } else if (GetComponent <HeavyDoor>() != null) { hd = GetComponent <HeavyDoor>(); pt = PoweredType.HeavyDoor; } else if (GetComponent <PoweredLight>() != null) { pl = GetComponent <PoweredLight>(); pt = PoweredType.PoweredLight; } else if (GetComponent <PoweredDialogueActivator>() != null) { pda = GetComponent <PoweredDialogueActivator>(); pt = PoweredType.PoweredDialogueActivator; } else { pt = PoweredType.None; } //Start() will only run on the "lowest-level" class //If Class A that derives from Class B does not implement Start(), //Class B Start() will be used. //If Class A & Class B both have Start(), Start() will be called on Class A because it is "lower" InteractableInitialize(); }