Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Skatebirb;
- using UnityEngine;
- namespace Skatebirb
- {
- public class GapGateZone : MonoBehaviour
- {
- protected virtual void AttemptToTriggerGap(Collider triggeringCollider)
- {
- if (triggeringCollider.attachedRigidbody == null || triggeringCollider.attachedRigidbody.gameObject == null) { return; }
- ISkateboardGateway triggeringSkateboard = triggeringCollider.attachedRigidbody.gameObject.GetComponent<ISkateboardGateway>();
- if (triggeringSkateboard == null)
- {
- Gameplay.Skater triggeringSkater = triggeringCollider.attachedRigidbody.gameObject.GetComponent<Gameplay.Skater>();
- if (triggeringSkater != null) { triggeringSkateboard = triggeringSkater.OurSkateboard; }
- }
- if (triggeringSkateboard == null) { return; }
- if (!IsGateTriggeredBy(triggeringSkateboard)) { return; }
- // Generally, once a gate is triggered - that's it, we're done, poof!
- Managers.MissionManager.GapGatePassed(triggeringSkateboard, this);
- }
- protected virtual bool IsGateTriggeredBy(ISkateboardGateway triggeringBoard)
- {
- return false;
- }
- protected virtual void OnTriggerEnter(Collider other)
- {
- if (other == null || other.gameObject == null) { return; }
- AttemptToTriggerGap(other);
- }
- private void OnDrawGizmosSelected()
- {
- Color transparentColor = Color.grey;
- transparentColor.a = 0.5f;
- Gizmos.color = transparentColor;
- BoxCollider ourBox = GetComponent<BoxCollider>();
- if (ourBox != null)
- {
- Gizmos.matrix = gameObject.transform.localToWorldMatrix;
- Gizmos.DrawCube(ourBox.center, ourBox.size);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment