예제 #1
0
 void DetonateNow(bool isSplash)
 {
     if (isSplash)
     {
         theNetwork.Detonate("rocketsplash", transform.position, shooterID, viewID);
     }
     else
     {
         theNetwork.Detonate("rocket", transform.position, shooterID, viewID);
     }
 }
    // Update is called once per frame
    void Update()
    {
        if (active)
        {
            transform.position += moveVector * Time.deltaTime;

            moveVector.y -= Time.deltaTime * 18f;

            RaycastHit hitInfo      = new RaycastHit();
            int        layerMask    = (1 << 0);
            Vector3    rayDirection = (transform.position - lastPos).normalized;
            if (Physics.SphereCast(lastPos, 0.15f, rayDirection, out hitInfo, Vector3.Distance(transform.position, lastPos), layerMask))
            {
                transform.position = hitInfo.point + (hitInfo.normal * 0.15f);
                moveVector         = Vector3.Reflect(moveVector, hitInfo.normal);
                moveVector        *= 0.5f;

                if (moveVector.magnitude > 2f)
                {
                    audio.clip   = sfx_bounce;
                    audio.volume = 2f;
                    audio.pitch  = Random.Range(0.95f, 1.05f);
                    audio.Play();
                }
            }
            lastPos = transform.position;

            if (Time.time > detonationTime)
            {
                active = false;
                if (theNetwork.isServer)
                {
                    //detonate now
                    theNetwork.Detonate("grenade", transform.position, shooterID, viewID);
                }
            }
        }
        else
        {
        }
    }