Guest User

Untitled

a guest
May 30th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. namespace SpartanFist
  5. {
  6. public class Twiddler : MonoBehaviour
  7. {
  8. [Header("References"), Tooltip("The switch we're twiddling")]
  9. public Switch toTwiddle;
  10.  
  11. [Header("Twiddling"), Tooltip("If true, we can twiddle the switch from off to on")]
  12. public bool offToOn = false;
  13. [Tooltip("If true, we can twiddle the switch from on to off")]
  14. public bool onToOff = false;
  15.  
  16. protected virtual void Twiddle()
  17. {
  18. if (toTwiddle == null) { return; }
  19. Twiddle(!toTwiddle.SwitchState);
  20. }
  21.  
  22. protected virtual bool Twiddle(bool targetState)
  23. {
  24. if (toTwiddle == null) { return false; }
  25.  
  26. if (targetState && offToOn && !toTwiddle.SwitchState) { toTwiddle.SwitchState = true; return true; }
  27. else if (!targetState && onToOff && toTwiddle.SwitchState) { toTwiddle.SwitchState = false; return true; }
  28.  
  29. return false;
  30. }
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment