Beispiel #1
0
 public override void Shoot(Vector3 pos, int force, int demage, RaycastHit hit)
 {
     M_Rigidbody.AddForce(pos * force);
     //箭头子弹的伤害值
     this.Demage = demage;
     this.hit    = hit;
 }
Beispiel #2
0
 /// <summary>
 /// 散弹枪子弹射击
 /// </summary>
 public override void Shoot(Vector3 pos, int force, int demage, RaycastHit hit)
 {
     M_Rigidbody.AddForce(pos * force);
     //每个子弹的伤害值
     this.Demage = demage;
     //从当前子弹的位置往前发射一条射线 用于获得弹痕生成UV流
     ray = new Ray(M_Transform.position, pos);
     //接受hit碰撞信息  1000米最远射线距离,所能接受到的层是 11层 Env层
     //LayerMask.LayerToName(11);
 }
Beispiel #3
0
    /// <summary>
    /// 发射子弹.
    /// </summary>
    /// <param name="dir">方向.</param>
    /// <param name="force">力度.</param>
    /// <param name="damage">弹头伤害.</param>
    public override void Shoot(Vector3 dir, int force, int damage)
    {
        this.Damage = damage;

        M_Rigidbody.AddForce(dir * force, ForceMode.Impulse);

        ray = new Ray(M_Transform.position, dir);
        int layer = (1 << LayerMask.NameToLayer("EnvModel")) | (1 << LayerMask.NameToLayer("AIModel"));

        Physics.Raycast(ray, out hit, 1000, layer);
    }
Beispiel #4
0
 public override void Shoot(Vector3 dir, int force, int damage, ObjectPool bulletPool)
 {
     trailTrans.gameObject.SetActive(true);
     M_Rigidbody.AddForce(dir * force);
     this.bulletPool = bulletPool;
     ray             = new Ray(M_Transform.position, dir);
     this.damage     = damage;
     TimerSvc.Instance.AddTimeTask((int tid) =>
     {
         taskID = tid;
         M_Rigidbody.Sleep();
         bulletPool.AddObject(gameObject);
     }, 3000);
     trailTaskID = TimerSvc.Instance.AddTimeTask((int tid) =>
     {
         trailTrans.gameObject.SetActive(false);
     }, 500);
 }
Beispiel #5
0
    /// <summary>
    /// 射击
    /// </summary>
    /// <param name="dir"></param>
    public override void Shoot(Vector3 dir, int force, int arrowDamage)
    {
        Damage = arrowDamage;
        Ray tRay = new Ray(M_Transform.position, dir);

        M_Rigidbody.AddForce(dir * force);
        //1 << 11?
        if (Physics.Raycast(tRay, out hit, 1000, 1 << 11))
        {
        }

        if (Physics.Raycast(tRay, out aiEffectHit, 1000, 1 << 12))
        {
        }
        ;

        M_Rigidbody.AddForce(dir * force);
        StartCoroutine("DestorySelf");
    }
Beispiel #6
0
    /// <summary>
    /// 射击辅助函数
    /// </summary>
    /// <param name="vec">方向</param>
    /// <param name="force">力度</param>
    /// <param name="damgae">伤害</param>
    public override void Shoot(Vector3 dir, int force, int bulletDamage)
    {
        Damage = bulletDamage;
        Ray tRay = new Ray(M_Transform.position, dir);

        //1 << 12 , 结果是 4096, 11 是 AI 的层数
        if (Physics.Raycast(tRay, out aiHit, 1000, 1 << 12))
        {
        }
        ;

        //1 << 11 , 结果是 2048, 11 是 Env 的层数
        if (Physics.Raycast(tRay, out uiHit, 1000, 1 << 11))
        {
        }

        M_Rigidbody.AddForce(dir * force);

        StartCoroutine(DestorySelf());
    }