Example #1
0
#pragma warning restore 0649
        #endregion

        #region Base - Override

        public override bool PassCondition(ActorData hActorData, List <IActorBehaviourData> lstBehaviourData)
        {
            if (!PassAllCondition(hActorData, lstBehaviourData))
            {
                return(false);
            }

            return(m_bIsHolding == FlagUtility.HasFlagUnsafe(hActorData.m_hInputData.m_eHoldingInput, m_eInput));
        }
#pragma warning restore 0649
        #endregion

        #region Base - Override

        public override bool PassCondition(ActorData hActorData, List <IActorBehaviourData> lstBehaviourData)
        {
            if (!PassAllCondition(hActorData, lstBehaviourData))
            {
                return(false);
            }

            return(m_bIsTrue == FlagUtility.HasFlagUnsafe(hActorData.m_eStateFlag, ActorStateFlag.IsGrounding));
        }
        protected virtual void OnJump(ActorData hActorData, List <IActorBehaviourData> lstBehaviourData)
        {
            if (hActorData.m_hRigid == null || hActorData.m_hStatus == null)
            {
                return;
            }

            hActorData.m_hRigid.AddForce(new Vector2(0, hActorData.m_hStatus.status.m_fJumpForce));
        }
        public override void OnDestroyBehaviour(ActorData hActorData, List <IActorBehaviourData> lstBehaviourData)
        {
            if (lstBehaviourData.TryGetData <JumpCacheData>(out int nOutIndex))
            {
                lstBehaviourData.RemoveAt(nOutIndex);
            }

            base.OnDestroyBehaviour(hActorData, lstBehaviourData);
        }
        public override void OnStopBehaviour(ActorData hActorData, List <IActorBehaviourData> lstBehaviourData)
        {
            if (lstBehaviourData.TryGetData(out JumpCacheData hOutData))
            {
                hActorData.m_hInputData.m_hInputCallback.Remove((InputEventType.Jump, GetInputType.Down), hOutData.m_actJump);
            }

            base.OnStopBehaviour(hActorData, lstBehaviourData);
        }
        public override void OnCreateBehaviour(ActorData hActorData, List <IActorBehaviourData> lstBehaviourData)
        {
            base.OnCreateBehaviour(hActorData, lstBehaviourData);

            lstBehaviourData.Add(new JumpCacheData
            {
                m_actJump = OnJump
            });
        }
        protected virtual void OnGravityIncrease(ActorData hActorData, List <IActorBehaviourData> lstBehaviourData)
        {
            if (hActorData.m_hRigid == null)
            {
                return;
            }

            Vector2 vVelocity = hActorData.m_hRigid.velocity;

            vVelocity.y += Physics2D.gravity.y * hActorData.m_hRigid.gravityScale * m_fGravityMultiplier * Time.deltaTime;
            hActorData.m_hRigid.velocity = vVelocity;
        }
Example #8
0
        public override void OnDestroyBehaviour(ActorData hActorData, List <IActorBehaviourData> lstBehaviourData)
        {
            base.OnDestroyBehaviour(hActorData, lstBehaviourData);

            if (!HasBehaviourInArray())
            {
                return;
            }

            for (int i = 0; i < m_arrBehaviour.Length; i++)
            {
                m_arrBehaviour[i]?.OnDestroyBehaviour(hActorData, lstBehaviourData);
            }
        }
Example #9
0
#pragma warning restore 0649
        #endregion

        #region Base - Override

        public override bool PassCondition(ActorData hActorData, List <IActorBehaviourData> lstBehaviourData)
        {
            if (!PassAllCondition(hActorData, lstBehaviourData))
            {
                return(false);
            }

            if (hActorData.m_hRigid == null)
            {
                return(true);
            }

            Vector2 vVelocity = hActorData.m_hRigid.velocity;

            return(CheckVelocityX(vVelocity) && CheckVelocityY(vVelocity));
        }
Example #10
0
        public override void OnLateUpdateBehaviour(ActorData hActorData, List <IActorBehaviourData> lstBehaviourData)
        {
            base.OnLateUpdateBehaviour(hActorData, lstBehaviourData);

            if (!HasBehaviourInArray())
            {
                return;
            }

            for (int i = 0; i < m_arrBehaviour.Length; i++)
            {
                var hBehaviour = m_arrBehaviour[i];
                if (hBehaviour != null && hBehaviour.isRunning)
                {
                    hBehaviour.OnLateUpdateBehaviour(hActorData, lstBehaviourData);
                }
            }
        }
#pragma warning restore 0649
        #endregion

        #region Base - Override

        public override void OnUpdateBehaviour(ActorData hActorData, List <IActorBehaviourData> lstBehaviourData)
        {
            base.OnUpdateBehaviour(hActorData, lstBehaviourData);

            float   fHorizontal = hActorData.m_hInputData.m_fHorizontal;
            Vector3 vAngle      = hActorData.m_hActor.localEulerAngles;

            if (fHorizontal > 0 && vAngle.y != m_fRightAngle)
            {
                vAngle.y = m_fRightAngle;
            }
            else if (fHorizontal < 0 && vAngle.y == m_fRightAngle)
            {
                vAngle.y = m_fLeftAngle;
            }

            hActorData.m_hActor.localEulerAngles = vAngle;
        }
Example #12
0
        public override void OnStopBehaviour(ActorData hActorData, List <IActorBehaviourData> lstBehaviourData)
        {
            if (!isRunning)
            {
                return;
            }

            isRunning = false;

            if (!HasBehaviourInArray())
            {
                return;
            }

            for (int i = 0; i < m_arrBehaviour.Length; i++)
            {
                m_arrBehaviour[i]?.OnStopBehaviour(hActorData, lstBehaviourData);
            }
        }
Example #13
0
        public override void OnUpdateBehaviour(ActorData hActorData, List <IActorBehaviourData> lstBehaviourData)
        {
            base.OnUpdateBehaviour(hActorData, lstBehaviourData);

            if (!HasBehaviourInArray())
            {
                return;
            }

            for (int i = 0; i < m_arrBehaviour.Length; i++)
            {
                var hBehaviour = m_arrBehaviour[i];
                if (hBehaviour == null)
                {
                    continue;
                }

                bool bRunning = false;

                if (hBehaviour.isRunning)
                {
                    if (!hBehaviour.PassCondition(hActorData, lstBehaviourData))
                    {
                        hBehaviour.OnStopBehaviour(hActorData, lstBehaviourData);
                    }
                    else
                    {
                        isRunning = true;
                    }
                }
                else if (hBehaviour.PassCondition(hActorData, lstBehaviourData))
                {
                    hBehaviour.OnStartBehaviour(hActorData, lstBehaviourData);
                    isRunning = true;
                }

                if (bRunning)
                {
                    hBehaviour.OnUpdateBehaviour(hActorData, lstBehaviourData);
                }
            }
        }
Example #14
0
        public override void OnStartBehaviour(ActorData hActorData, List <IActorBehaviourData> lstBehaviourData)
        {
            if (isRunning)
            {
                return;
            }

            isRunning = true;

            if (!HasBehaviourInArray())
            {
                return;
            }

            for (int i = 0; i < m_arrBehaviour.Length; i++)
            {
                var hBehaviour = m_arrBehaviour[i];
                if (hBehaviour != null && hBehaviour.PassCondition(hActorData, lstBehaviourData))
                {
                    hBehaviour.OnStartBehaviour(hActorData, lstBehaviourData);
                }
            }
        }
Example #15
0
        public static bool PassAllCondition(this DSC_ActorBehaviourCondition[] arrCondition, ActorData hActorData, List <IActorBehaviourData> lstBehaviourData)
        {
            if (arrCondition == null || arrCondition.Length <= 0)
            {
                return(true);
            }

            for (int i = 0; i < arrCondition.Length; i++)
            {
                var hCondition = arrCondition[i];
                if (hCondition != null && !hCondition.PassCondition(hActorData, lstBehaviourData))
                {
                    return(false);
                }
            }

            return(true);
        }
#pragma warning restore 0649
        #endregion

        #region Base - Override

        public override void OnFixedUpdateBehaviour(ActorData hActorData, List <IActorBehaviourData> lstBehaviourData)
        {
            base.OnFixedUpdateBehaviour(hActorData, lstBehaviourData);

            OnGravityIncrease(hActorData, lstBehaviourData);
        }