示例#1
0
    private void HitscanHit(RaycastHit hit, float pierceMult)
    {
        if (hit.transform.GetComponent <Unit>())
        {
            float falloffMult = hit.distance - pj.falloffRange;
            // Is within falloff range
            if (falloffMult <= 0f)
            {
                falloffMult = 1f;
            }
            else
            {
                falloffMult = 1 / (falloffMult * pj.falloffRate);
            }
            hit.transform.GetComponent <Unit>().Hurt(pj.damage * pierceMult * falloffMult);

            // Create sound and decal
            AudioMaster.Create(pj.soundHit, transform.position);
            GameObject prf = InstantiatePrefab(pj.decalEnd) as GameObject;
            prf.transform.rotation = transform.rotation;
            prf.transform.position = hit.point;
            prf.transform.parent   = hit.transform;
        }
        else
        {
            GameObject prf = InstantiatePrefab(pj.decalEnd) as GameObject;
            prf.transform.rotation = hit.normal;
            prf.transform.posiiton = hit.point;
            AudioMaster.Create(pj.soundBounce, transform.position);
        }
    }
示例#2
0
 private void OnCollisionEnter(Collision collision)
 {
     // Hits a unit
     if (collision.gameObject.tag == "Unit")
     {
         Unit unit = collision.gameObject.GetComponent <Unit>();
         if (unit.unitID == ownerID)
         {
             // Disc return
             Kill();
         }
         else
         {
             AudioMaster.Create(pj.soundHit, transform.position);
             unit.Hurt(pj.damage);
             pj.bounces = pj.killOnHurt ? 1 : pj.bounces;
         }
     }
     pj.bounces--;
     if (pj.bounces == 0)
     {
         GameObject prf = InstantiatePrefab(pj.decalEnd) as GameObject;
         prf.transform.rotation = transform.rotation;
         prf.transform.position = transform.position;
         AudioMaster.Create(pj.soundBounce, transform.position);
         Kill();
     }
     else
     {
         GameObject prf = InstantiatePrefab(pj.decalBounce) as GameObject;
         prf.transform.rotation = transform.rotation;
         prf.transform.position = transform.position;
         AudioMaster.Create(pj.soundBounce, transform.position);
     }
 }
示例#3
0
 // Near miss
 private void OnTriggerExit(Collider collider)
 {
     if (collider.gameObject.tag == "Unit")
     {
         AudioMaster.Create(pj.soundMiss, transform.position);
     }
 }