示例#1
0
 public GameEventListener(Event listenerEvent, GameObject sender)
 {
     Event = listenerEvent;
     Event.AddListener(this);
     IntendedSender = sender;
     actions        = new UnityEvent();
 }
示例#2
0
        // Use this for initialization
        void Start()
        {
            if (!Event)
            {
                Event = new Event();
            }

            Event.AddListener(this);
        }
示例#3
0
        /// <summary>
        /// Disables movement on the grid.
        /// </summary>
        /// <param name="moveEvent">When this event is raised, movement will be enabled.</param>
        /// <param name="intendedSender">Thhe game object that will send the event. If null, movement will be
        /// enabled regardless of what raises the event.</param>
        /// <param name="waitForEndOfMovement">If the object is moving, its movement will be disabled once its reached
        /// its destination. If false, movement is stopped immediately.</param>
        /// <param name="overridesMoveCondition">This condition to enable movement will override the move condition from an earlier call.</param>
        public void DisableMovement(GridGame.Event moveEvent, GameObject intendedSender = null, bool waitForEndOfMovement = true, bool overridesMoveCondition = false)
        {
            if (!_canMove)
            {
                return;
            }

            if (IsMoving && waitForEndOfMovement)
            {
                AddOnMoveEndTempAction(() => { _canMove = false; StopAllCoroutines(); });
            }
            else
            {
                _canMove = false;
                StopAllCoroutines();
            }

            _moveEnabledEventListener.Event          = moveEvent;
            _moveEnabledEventListener.IntendedSender = intendedSender;
            _moveEnabledEventListener.AddAction(() => { _canMove = true; });
            _moveDisabledEventListener.Invoke(gameObject);
            _tempAlignment = Alignment;
        }
示例#4
0
 public void ClearEvent()
 {
     Event = new Event();
 }