Example #1
0
        public override void FixedUpdate(AriesEntity entity, float dt)
        {
            AriesController     ctrl      = entity.GetAgent().GetComponent <AriesController>();
            Rigidbody2D         rigid     = entity.GetAgent().GetComponent <Rigidbody2D>();
            EnvironmentDetector envDector = entity.GetAgent().GetComponent <EnvironmentDetector>();

            Vector2 curVelocity = rigid.velocity;

            if (ctrl.m_jumpButton.IsRelease())
            {
                m_jumpComp.JumpBtnReleased();
            }
            else
            {
                if (
                    (ctrl.m_jumpButton.IsPress() || ctrl.m_jumpButton.IsHold()) &&
                    m_jumpComp.GetLeftAvailableHoldDurationForJump1() > 0
                    )
                {
                    m_jumpComp.UpdateJump(dt);
                }
            }

            if (curVelocity.y < 0)
            {
                entity.ChangeState(AriesState.Fall);
            }
        }
Example #2
0
 void Awake()
 {
     m_rigid        = GetComponent <Rigidbody2D>();
     m_spriteRender = GetComponent <SpriteRenderer>();
     m_animator     = GetComponent <Animator>();
     m_ctrl         = GetComponent <AriesController>();
 }
        // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
        public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
        {
            base.OnStateEnter(animator, stateInfo, layerIndex);
            m_controller = animator.GetComponent <ff.AriesController>();
            GameObject slash = CreateSlash();

            // attach parent
            slash.transform.parent = m_controller.transform;
        }
Example #4
0
 public AriesStateHurt(AriesEntity entity) : base(entity)
 {
     m_beHit          = entity.GetAgent().GetComponent <AriesBeHit>();
     m_ctrl           = entity.GetAgent().GetComponent <AriesController>();
     m_animBridge     = entity.GetAgent().GetComponent <AriesAnimBridge>();
     m_transform      = entity.GetAgent().GetComponent <Transform>();
     m_spriteRenderer = entity.GetAgent().GetComponent <SpriteRenderer>();
     m_animator       = entity.GetAgent().GetComponent <Animator>();
     m_rigidBody      = entity.GetAgent().GetComponent <Rigidbody2D>();
     m_envDetector    = entity.GetAgent().GetComponent <EnvironmentDetector>();
 }
        public void InitWithOwner(AriesController controller)
        {
            m_controller = controller;
            switch (m_controller.m_faceDir)
            {
            case FaceDir.LEFT:
                transform.localScale = new Vector3(-1, 1, 1);
                break;

            case FaceDir.RIGHT:
                transform.localScale = new Vector3(1, 1, 1);
                break;
            }
        }
Example #6
0
        public override void FixedUpdate(AriesEntity entity, float dt)
        {
            AriesController     ctrl      = entity.GetAgent().GetComponent <AriesController>();
            AriesJump           jumpComp  = entity.GetAgent().GetComponent <AriesJump>();
            Rigidbody2D         rigid     = entity.GetAgent().GetComponent <Rigidbody2D>();
            EnvironmentDetector envDector = entity.GetAgent().GetComponent <EnvironmentDetector>();

            Vector2 curVelocity = rigid.velocity;

            if (curVelocity.y < 0)
            {
                entity.ChangeState(AriesState.Fall);
            }
        }
Example #7
0
        public override void Update(AriesEntity entity, float dt)
        {
            AriesController     ctrl      = entity.GetAgent().GetComponent <AriesController>();
            Rigidbody2D         rigid     = entity.GetAgent().GetComponent <Rigidbody2D>();
            EnvironmentDetector envDector = entity.GetAgent().GetComponent <EnvironmentDetector>();

            ctrl.UpdateHorizontalMove();

            Vector2 curVelocity = rigid.velocity;

            if (ctrl.m_jumpButton.IsPress() && m_jumpComp.CheckJumpChance())
            {
                entity.ChangeState(AriesState.Jump2);
            }
        }
Example #8
0
        public override void FixedUpdate(AriesEntity entity, float dt)
        {
            AriesDash       dash  = entity.GetAgent().GetComponent <AriesDash>();
            Rigidbody2D     rigid = entity.GetAgent().GetComponent <Rigidbody2D>();
            AriesController ctrl  = entity.GetAgent().GetComponent <AriesController>();

            Vector3 dir = ctrl.GetFront();

            rigid.velocity = dir * dash.m_dashSpeed;

            m_leftTime -= dt;
            if (m_leftTime <= 0)
            {
                entity.ChangeState(AriesState.Fall);
            }
        }
Example #9
0
        public override void Update(AriesEntity entity, float dt)
        {
            AriesController ctrl  = entity.GetAgent().GetComponent <AriesController>();
            Rigidbody2D     rigid = entity.GetAgent().GetComponent <Rigidbody2D>();

            ctrl.UpdateHorizontalMove();

            if (Mathf.Abs(rigid.velocity.x) > 0)
            {
                entity.ChangeState(AriesState.Walk);
            }
            if (ctrl.m_jumpButton.IsPress())
            {
                entity.ChangeState(AriesState.Jump1);
            }
        }
Example #10
0
        public override void Update(AriesEntity entity, float dt)
        {
            AriesController     ctrl      = entity.GetAgent().GetComponent <AriesController>();
            AriesJump           jumpComp  = entity.GetAgent().GetComponent <AriesJump>();
            Rigidbody2D         rigid     = entity.GetAgent().GetComponent <Rigidbody2D>();
            EnvironmentDetector envDector = entity.GetAgent().GetComponent <EnvironmentDetector>();

            ctrl.UpdateHorizontalMove();

            if (ctrl.m_jumpButton.IsHold() &&
                jumpComp.GetLeftAvailableHoldDurationForJump2() > 0 &&
                !jumpComp.HasJumpBtnReleased())
            {
                jumpComp.UpdateJump2(dt);
            }
        }
Example #11
0
        public override void Update(AriesEntity entity, float dt)
        {
            if (m_bShallChangeToIdle)
            {
                entity.ChangeState(AriesState.Idle);
                return;
            }

            AriesController ctrl     = entity.GetAgent().GetComponent <AriesController>();
            AriesJump       jumpComp = entity.GetAgent().GetComponent <AriesJump>();

            ctrl.UpdateHorizontalMove();

            //bool bCtrlJump = ctrl.m_jumpButton.IsPress() || ctrl.m_jumpButton.IsHold();
            bool bCtrlJump = ctrl.m_jumpButton.IsPress();

            if (bCtrlJump && jumpComp.CheckJumpChance())
            {
                m_jumpComp.UpdateJump2(dt);
                entity.ChangeState(AriesState.Jump2);
            }
        }
Example #12
0
 void Awake()
 {
     m_ctrl = GetComponent <AriesController>();
 }