public static void Init(Vector3 spawn, Vector3 forw, InventoryItem weapon, AttackDes att, MeteorUnit owner)
    {
        GameObject dartObj = GameObject.Instantiate(ResMng.LoadPrefab("DartLoader"), spawn, Quaternion.identity, null) as GameObject;

        dartObj.layer = LayerMask.NameToLayer("Flight");
        DartLoader dart = dartObj.GetComponent <DartLoader>();

        dart.LoadAttack(weapon, forw, att, owner);
    }
 public void AddDamageCheck(MeteorUnit unit, AttackDes attackDef)
 {
     if (unit == null || unit.Dead)
     {
         return;
     }
     if (unit.GetWeaponType() == (int)EquipWeaponType.Gun)
     {
         Ray          r          = CameraFollow.Ins.m_Camera.ScreenPointToRay(new Vector3(Screen.width / 2, Screen.height / 2, DartLoader.MaxDistance));
         RaycastHit[] allHit     = Physics.RaycastAll(r, 3000, 1 << LayerMask.NameToLayer("Bone") | 1 << LayerMask.NameToLayer("Scene") | 1 << LayerMask.NameToLayer("Monster") | 1 << LayerMask.NameToLayer("LocalPlayer"));
         RaycastHit[] allHitSort = SortRaycastHit(allHit);
         //先排个序,从近到远
         for (int i = 0; i < allHitSort.Length; i++)
         {
             if (allHitSort[i].transform.gameObject.layer == LayerMask.NameToLayer("Scene"))
             {
                 break;
             }
             MeteorUnit unitAttacked = allHitSort[i].transform.gameObject.GetComponentInParent <MeteorUnit>();
             if (unitAttacked != null)
             {
                 if (unit.SameCamp(unitAttacked))
                 {
                     continue;
                 }
                 if (unitAttacked.Dead)
                 {
                     continue;
                 }
                 unitAttacked.OnAttack(unit, attackDef);
             }
         }
     }
     else
     {
         //飞镖,那么从绑点生成一个物件,让他朝
         //"Sphere3"是挂点
         //即刻生成一个物件飞出去。
         if (unit.charLoader.sfxEffect != null)
         {
             if (unit.GetWeaponType() == (int)EquipWeaponType.Dart)
             {
                 //飞镖.
                 Transform bulletBone = unit.charLoader.sfxEffect.FindEffectByName("Sphere_3");//出生点,
                 Vector3   vecSpawn   = bulletBone.position + 10 * Vector3.up;
                 Vector3   forw       = Vector3.zero;
                 if (unit.Attr.IsPlayer)
                 {
                     Vector3 vec = CameraFollow.Ins.m_Camera.ScreenToWorldPoint(new Vector3(Screen.width / 2, (Screen.height) / 2 + 75, DartLoader.MaxDistance));
                     forw = (vec - vecSpawn).normalized;
                 }
                 else
                 {
                     //敌人在未发现敌人时随便发飞镖?
                     if (unit.GetLockedTarget() == null)
                     {
                         forw = (-unit.transform.forward + new Vector3(Random.Range(1, 10), Random.Range(1, 10), Random.Range(1, 10))).normalized;//角色的面向
                     }
                     else
                     {
                         forw = (unit.GetLockedTarget().mPos - new Vector3(unit.mPos.x + Random.Range(1, 10), unit.mPos.y + Random.Range(1, 20), unit.mPos.z + Random.Range(1, 10))).normalized;//要加一点随机,否则每次都打一个位置不正常
                     }
                 }
                 //主角则方向朝着摄像机正前方
                 //不是主角没有摄像机,那么就看有没有目标,有则随机一个方向,根据与目标的包围盒的各个顶点的,判定这个方向
                 //得到武器模型,在指定位置出生.
                 InventoryItem weapon = unit.weaponLoader.GetCurrentWeapon();
                 DartLoader.Init(vecSpawn, forw, weapon, attackDef, unit);
             }
             else if (unit.GetWeaponType() == (int)EquipWeaponType.Guillotines)
             {
                 //隐藏右手的飞轮
                 unit.weaponLoader.HideWeapon();
                 //飞轮
                 Vector3       vecSpawn = unit.WeaponR.transform.position;
                 InventoryItem weapon   = unit.weaponLoader.GetCurrentWeapon();
                 if (unit.Attr.IsPlayer)
                 {
                     FlyWheel.Init(vecSpawn, autoTarget, weapon, attackDef, unit);
                 }
                 else
                 {
                     FlyWheel.Init(vecSpawn, unit.GetLockedTarget(), weapon, attackDef, unit);
                 }
             }
         }
     }
 }