Пример #1
0
 private Vector2 GetHitDir(GameObject caster)
 {
     if (caster != null)
     {
         Vector2 dir = m_transform.position.x >= caster.transform.position.x ?
                       new Vector2(1, m_beHit.m_angleFactor) :
                       new Vector2(-1, m_beHit.m_angleFactor);
         return(dir.normalized);
     }
     else
     {
         Vector3 front = m_ctrl.GetFront();
         return(new Vector2(-front.x, front.y).normalized);
     }
 }
Пример #2
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);
            }
        }
Пример #3
0
        private GameObject CreateSlash()
        {
            // create slash
            GameObject slash = GameObject.Instantiate(m_slashPrefab, Vector3.zero, Quaternion.identity);

            if (slash.GetComponent <SlashEnvDetector>() != null)
            {
                slash.GetComponent <SlashEnvDetector>().InitWithOwner(m_controller.gameObject);
            }
            if (slash.GetComponent <CanBlockAttack>() != null)
            {
                CanBlockAttack cba = slash.GetComponent <CanBlockAttack>();
                CanBeHit       cbh = m_controller.GetComponent <CanBeHit>();
                if (cbh != null)
                {
                    cba.SetOwner(cbh);
                }
            }

            // locate position
            m_slashPos = m_controller.transform.position;
            float horizonOffset = m_offset.x;

            if (m_controller.m_faceDir == FaceDir.LEFT)
            {
                horizonOffset = -horizonOffset;
            }
            m_slashPos.x += horizonOffset;
            m_slashPos.y += m_offset.y;

            // update face
            if (m_isHorizontalSlash && slash.GetComponent <ff.AriesHorizontalSlash>() != null)
            {
                // horizontal slash
                m_slashPos += m_controller.GetFront();
                ff.AriesHorizontalSlash horizonSlash = slash.GetComponent <ff.AriesHorizontalSlash>();
                horizonSlash.InitWithOwner(m_controller);
            }
            slash.transform.position         = m_slashPos;
            slash.transform.localEulerAngles = m_euler;
            return(slash);
        }