Last active
March 12, 2017 03:15
-
-
Save robochase6000/f2f31d5213f70f396cfb13120564b25e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public class HandHitbox : MonoBehaviour | |
{ | |
void OnTriggerEnter(Collider collider) | |
{ | |
Interactable interactable = collider.GetComponent<Interactable> (); | |
if (interactable != null) { | |
interactable.TouchedBy (this); | |
} | |
} | |
void OnTriggerExit(Collider collider) | |
{ | |
Interactable interactable = collider.GetComponent<Interactable> (); | |
if (interactable != null) { | |
interactable.TouchedByComplete (this); | |
} | |
} | |
} | |
public class Interactable : MonoBehaviour { | |
virtual public void TouchedBy(HandHitbox hand) | |
{ | |
} | |
virtual public void TouchedByComplete(HandHitbox hand) | |
{ | |
} | |
} | |
public class PushButton : Interactable | |
{ | |
public Animation Anim; | |
public TextMesh Label; | |
public event OnPushButtonPressed HandlePushButtonPressed; | |
override public void TouchedBy(HandHitbox hitbox) | |
{ | |
base.TouchedBy (hitbox); | |
Anim.Play ("PushButtonDown"); | |
if (HandlePushButtonPressed != null) { | |
HandlePushButtonPressed.Invoke (this); | |
} | |
} | |
override public void TouchedByComplete(HandHitbox hitbox) | |
{ | |
base.TouchedByComplete (hitbox); | |
Anim.Play ("PushButtonUp"); | |
} | |
} | |
public class ClearLogButton : PushButton | |
{ | |
override public void TouchedBy(HandHitbox hitbox) | |
{ | |
base.TouchedBy (hitbox); | |
WristLog.Instance.Clear (); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment