Esempio n. 1
0
        // Utils
        public int GetAtkDir()          // Caster-Target
        {
            SkEntity thisTar = _target != null ? _target : _tmpTar;

            if (thisTar == null || thisTar == null)
            {
                Debug.LogError("[SkInst]:Error in GetAtkDir");
                return(0);
            }
            if (_colInfo == null)
            {
                return(0);
            }

            Transform transTarget = thisTar.GetTransform();
            Vector3   vecAtk      = -_colInfo.hitDir;
            Vector3   vecTarFwd   = transTarget.forward;
            float     cosFwd      = Vector3.Dot(vecAtk, vecTarFwd);

            if (cosFwd > 0.866f)
            {
                return(2);                                                                              //front
            }
            if (cosFwd < -0.866f)
            {
                return(3);                                                                              //back
            }
            Vector3 vecTarUwd = transTarget.up;
            float   cosUwd    = Vector3.Dot(vecAtk, vecTarUwd);

            if (cosUwd > 0.707f)
            {
                return(4);                                                                              //up
            }
            if (cosUwd < -0.707f)
            {
                return(5);                                                                              //down
            }
            Vector3 vecRgt = Vector3.Cross(vecTarUwd, vecTarFwd);
            float   cosRgt = Vector3.Dot(vecAtk, vecRgt);

            return((cosRgt < 0) ? 0 : 1);               // left right
        }
Esempio n. 2
0
 public Vector3 GetCollisionContactPoint()
 {
     return(_colInfo != null ? _colInfo.hitPos : _caster.GetTransform().position);
 }