Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- namespace PMG.Collisions {
- public class IonsSpecificElectronRemovedObserver : EventObserver_IonModeElectronSlot_IonModeElectron {
- private const float ANGLE_THRESHOLD = 10f;
- [SerializeField] private float angleOfElectronToWatch;
- private GameObject electronObjectToWatch;
- private void OnValidate() {
- this.eventName = "JustBeforeIonModeElectronRemoved";
- }
- protected override void Awake() {
- base.Awake();
- this.eventName = "JustBeforeIonModeElectronRemoved";
- }
- protected override void onEvent(IonModeElectronSlot slot, IonModeElectron electron) {
- IonModeAtom ionModeAtom = electron.AtomAttachedTo;
- if(ionModeAtom != null) {
- Vector2 delta = electron.transform.position - ionModeAtom.transform.position;
- float angle = Math.Instance.getAngleFromDirectionVec(delta);
- if(Math.Instance.getAngleDifference(angle, this.angleOfElectronToWatch) < ANGLE_THRESHOLD) {
- this.OnObservation.Invoke();
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement