Advertisement
Guest User

Untitled

a guest
Sep 19th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. namespace PMG.Collisions {
  6. public class IonsSpecificElectronRemovedObserver : EventObserver_IonModeElectronSlot_IonModeElectron {
  7.  
  8. private const float ANGLE_THRESHOLD = 10f;
  9.  
  10. [SerializeField] private float angleOfElectronToWatch;
  11.  
  12. private GameObject electronObjectToWatch;
  13.  
  14. private void OnValidate() {
  15. this.eventName = "JustBeforeIonModeElectronRemoved";
  16. }
  17.  
  18. protected override void Awake() {
  19. base.Awake();
  20. this.eventName = "JustBeforeIonModeElectronRemoved";
  21. }
  22.  
  23. protected override void onEvent(IonModeElectronSlot slot, IonModeElectron electron) {
  24. IonModeAtom ionModeAtom = electron.AtomAttachedTo;
  25. if(ionModeAtom != null) {
  26. Vector2 delta = electron.transform.position - ionModeAtom.transform.position;
  27. float angle = Math.Instance.getAngleFromDirectionVec(delta);
  28. if(Math.Instance.getAngleDifference(angle, this.angleOfElectronToWatch) < ANGLE_THRESHOLD) {
  29. this.OnObservation.Invoke();
  30. }
  31. }
  32. }
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement