예제 #1
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.tag.Equals("Player"))
     {
         MasterClientAgent.DestroyRequestToMaster(gameObject);
     }
 }
예제 #2
0
    IEnumerator Explosion()
    {
        if (ownerStats != null)
        {
            yield return(new WaitForSeconds(explosionDelay));

            //부딪힌 곳을 시작으로 radius만큼 주변에 있는 콜라이더들을 가져움
            Collider[] colliders = Physics.OverlapSphere(transform.position, radius);
            foreach (var col in colliders)
            {
                //로컬플레이어 혹은 움직일 수 없는 오브젝트면 패스.
                if (col.CompareTag("LocalPlayer"))
                {
                    continue;
                }

                Rigidbody rib = col.GetComponent <Rigidbody>();
                if (rib != null)
                {
                    rib.AddExplosionForce(power, transform.position, radius, upForce, ForceMode.Force);
                    CharacterStats targetStats = col.GetComponent <CharacterStats>();
                    if (targetStats != null)
                    {
                        targetStats.TakeDamageRPC(ownerStats.attack.GetValue() + damage);
                    }
                }
            }

            //파티클 시스템 재생
            GameObject effectObj = PhotonNetwork.Instantiate(effect.name, transform.position, Quaternion.identity);
            MasterClientAgent.DestroyRequestToMaster(gameObject);
        }
    }
    private void OnTriggerEnter(Collider other)
    {
        CharacterStats target = other.GetComponent <CharacterStats>();

        if (target != null && ownerStats != null && target != ownerStats)
        {
            target.TakeDamageRPC(ownerStats.attack.GetValue());
            MasterClientAgent.DestroyRequestToMaster(gameObject);
        }
    }
 // Update is called once per frame
 void Update()
 {
     if (ownerStats == null)
     {
         return;
     }
     //사거리 벗어나면 사라짐
     if (Vector3.Distance(owner.position, transform.position) > ownerStats.range.GetValue())
     {
         MasterClientAgent.DestroyRequestToMaster(gameObject);
     }
 }