Beispiel #1
0
        /// <summary>
        /// Add behaviour to data.
        /// </summary>
        /// <param name="hBehaviour">Behaviour want to add to data.</param>
        public virtual void AddBehaviour(BaseActorBehaviour hBehaviour)
        {
            if (hBehaviour == null)
            {
                return;
            }

            if (listBehaviour == null)
            {
                listBehaviour = new List <BaseActorBehaviour>();
            }

            listBehaviour.Add(hBehaviour);
            CreateBehaviour(hBehaviour);
        }
Beispiel #2
0
        /// <summary>
        /// Call stop function in this behaviour.
        /// </summary>
        /// <param name="hBehaviour">Behaviour want to call stop.</param>
        protected virtual void StopBehaviour(BaseActorBehaviour hBehaviour)
        {
            if (listBehaviourRunning == null)
            {
                listBehaviourRunning = new List <BaseActorBehaviour>();
            }

            if (hBehaviour == null || !listBehaviourRunning.Contains(hBehaviour))
            {
                return;
            }

            listBehaviourRunning.Remove(hBehaviour);
            hBehaviour.OnStopBehaviour(this);
        }
        public static void RunEvent(this BaseActorBehaviourEvent[] arrayEvent, BaseActorController hBaseController, BaseActorBehaviour hBaseBehaviour)
        {
            if (arrayEvent == null || arrayEvent.Length <= 0)
            {
                return;
            }

            for (int i = 0; i < arrayEvent.Length; i++)
            {
                var hEvent = arrayEvent[i];
                if (hEvent != null)
                {
                    hEvent.RunEvent(hBaseController, hBaseBehaviour);
                }
            }
        }
        public static void RunEvent(this List <BaseActorBehaviourEvent> listEvent, BaseActorController hBaseController, BaseActorBehaviour hBaseBehaviour)
        {
            if (listEvent == null || listEvent.Count <= 0)
            {
                return;
            }

            for (int i = 0; i < listEvent.Count; i++)
            {
                var hEvent = listEvent[i];
                if (hEvent != null)
                {
                    hEvent.RunEvent(hBaseController, hBaseBehaviour);
                }
            }
        }
Beispiel #5
0
 /// <summary>
 /// Call late update function in this behaviour.
 /// </summary>
 /// <param name="behaviour">Behaviour want to call late update.</param>
 protected virtual void LateUpdateBehaviour(BaseActorBehaviour behaviour)
 {
     behaviour?.OnLateUpdateBehaviour(this);
 }
Beispiel #6
0
 /// <summary>
 /// Call fix update function in this behaviour.
 /// </summary>
 /// <param name="behaviour">Behaviour want to call fixed update.</param>
 protected virtual void FixedUpdateBehaviour(BaseActorBehaviour behaviour)
 {
     behaviour?.OnFixedUpdateBehaviour(this);
 }
Beispiel #7
0
 /// <summary>
 /// Call destroy function in this behaviour.
 /// </summary>
 /// <param name="hBehaviour">Behaviour want to call destroy.</param>
 protected virtual void DestroyBehaviour(BaseActorBehaviour hBehaviour)
 {
     hBehaviour?.OnDestroyBehaviour(this);
 }
Beispiel #8
0
 /// <summary>
 /// Call create function in this behaviour.
 /// </summary>
 /// <param name="hBehaviour">Behaviour want to call create.</param>
 protected virtual void CreateBehaviour(BaseActorBehaviour hBehaviour)
 {
     hBehaviour?.OnCreateBehaviour(this);
 }
Beispiel #9
0
 /// <summary>
 /// Remove this behaviour type ID in data and add new one to data instead.
 /// </summary>
 /// <param name="hNewBehaviour">New behaviour for replace old one.</param>
 public virtual void ChangeBehaviour(BaseActorBehaviour hNewBehaviour)
 {
     RemoveBehaviour(hNewBehaviour.behaviourTypeID);
     AddBehaviour(hNewBehaviour);
 }
Beispiel #10
0
 /// <summary>
 /// Remove this behaviour type in data and add new one to data instead.
 /// </summary>
 /// <typeparam name="T">Behaviour type that want to change.(Remove first one that found.)</typeparam>
 /// <param name="hNewBehaviour">>New behaviour for replace old one.</param>
 public virtual void ChangeBehaviour <T>(BaseActorBehaviour hNewBehaviour) where T : BaseActorBehaviour
 {
     RemoveBehaviour <T>();
     AddBehaviour(hNewBehaviour);
 }
 public abstract void RunEvent(BaseActorController hBaseController, BaseActorBehaviour hBaseBehaviour);