/** UNIQUE ROUTINES **/ public void SpawnTowerComponents(TowerNode tn) { // TODO // We're gonna want to find some way to make this routine flexible // Clear away existing instances if (diveComponent != null) { DestroyTowerComponents(); } // Create the raw prefab GameObject comp = Instantiate(towerFab); diveComponent = comp; // Child and center the instance comp.transform.SetPositionAndRotation(transform.position, tn.transform.rotation); //TEMP: rotate the catapult if (isCatapult) { comp.transform.Rotate(new Vector3(0, 180, 0)); } Rigidbody rigid = comp.GetComponent <Rigidbody>(); if (rigid != null) { rigid.isKinematic = true; } }
/** PHYSICS ROUTINES **/ void OnTriggerEnter(Collider col) { if (intersectedNode == null && col.CompareTag("TowerNode")) { intersectedNode = col.gameObject.GetComponent <TowerNode>(); } }
void OnTriggerExit(Collider col) { if (intersectedNode != null && col.CompareTag("TowerNode")) { if (col.gameObject.GetComponent <TowerNode>() == intersectedNode) { intersectedNode = null; } } }
/** UNITY SYSTEM ROUTINES **/ void Update() { bool diveIn = (leftHand != null && diveInAction.GetStateDown(leftHand.handType)) || (rightHand != null && diveInAction.GetStateDown(rightHand.handType)) || Input.GetKeyDown(KeyCode.E) && !diving && currentDT == null; if (diveIn) { print("Yeet me"); TowerNode tn = null; Hand divingHand = rightHand; if (leftHand.hoveringInteractable != null && leftHand.hoveringInteractable.GetComponent <TowerNode>() != null) { tn = leftHand.hoveringInteractable.GetComponent <TowerNode>(); divingHand = leftHand; } else if (rightHand.hoveringInteractable != null && rightHand.hoveringInteractable.GetComponent <TowerNode>() != null) { tn = rightHand.hoveringInteractable.GetComponent <TowerNode>(); divingHand = rightHand; } else if (fallBackHand != null && fallBackHand.hoveringInteractable != null && fallBackHand.hoveringInteractable.GetComponent <TowerNode>() != null) { tn = fallBackHand.hoveringInteractable.GetComponent <TowerNode>(); divingHand = fallBackHand; } if (tn != null) { print("Yeet you"); } if (tn != null && tn.GetDiveTarget() != null) { print("Yeet us"); TryDiveIn(tn.GetDiveTarget(), divingHand); } } bool diveOut = (leftHand != null && diveOutAction.GetStateDown(leftHand.handType)) || (rightHand != null && diveOutAction.GetStateDown(rightHand.handType)) || Input.GetKeyDown(KeyCode.E) && !diving && currentDT != null; if (diveOut) { print("Yeet them"); TryDiveOut(); } }