private void OnTriggerEnter(Collider other) { AbilityPickup pickup = other.gameObject.GetComponentInChildren <AbilityPickup>(); if (pickup != null) { switch (pickup.ability) { case AbilityPickup.Ability.Jump: allowJump = true; break; case AbilityPickup.Ability.Pickup: Debug.Log("Enable pickup"); allowPickup = true; break; case AbilityPickup.Ability.WalkLeft: allowLeftMovement = true; break; case AbilityPickup.Ability.WalkRight: allowRightMovement = true; break; } Destroy(pickup.gameObject); } InsertZone insert = other.gameObject.GetComponent <InsertZone>(); if (insert != null) { Debug.Log("Add insert " + insert.name); inserts.Add(insert.insert); } }
private void OnTriggerExit(Collider other) { InsertZone insert = other.gameObject.GetComponent <InsertZone>(); if (insert != null && interactable != null && insert == interactable) { interactable = null; } }
private void OnTriggerEnter(Collider other) { InsertZone insert = other.gameObject.GetComponent <InsertZone>(); if (insert != null) { interactable = insert; } }
private void Update() { if (currentPlug && insertZone) { Plug temp = currentPlug; currentPlug = null; temp.InteractWithInsert(insertZone); insertZone = null; } if (currentPlug != null) { currentPlug.transform.position = plugPoint.transform.position; currentPlug.transform.rotation = Quaternion.Euler(-90, 0, 0); } bool hasPower = providesPower; if (!hasPower && currentPlug) { hasPower = currentPlug.HasPower(); } if (hasPower != isPowered) { isPowered = hasPower; if (isPowered) { foreach (WirePowerAction action in powerActions) { action.OnPowerEnabledInternal(); } } else { foreach (WirePowerAction action in powerActions) { action.OnPowerDisabledInternal(); } } Color color = isPowered ? Color.green : Color.white; foreach (LineRenderer renderer in lineRenderers) { renderer.startColor = color; renderer.endColor = color; } } }
public void InteractWithInsert(InsertZone insert) { interactable = insert; Interact(); }