Esempio n. 1
0
    private void FixedUpdate()
    {
        Collider2D[] Colliders = Physics2D.OverlapBoxAll(transform.position, transform.lossyScale * 1.01f, transform.rotation.z, _playerLayers);
        if (_sender != null)
        {
            for (int i = 0; i < Colliders.Length; i++)
            {
                if (Colliders[i].gameObject != _sender && Colliders[i].gameObject != gameObject)
                {
                    CharacterBase health = Colliders[i].GetComponent <CharacterBase>();
                    if (health != null)
                    {
                        health.DealDamage(_damageAmmound, _Element, photonView.Owner.NickName);
                    }
                    if (PhotonNetwork.InRoom)
                    {
                        photonView.RPC("destroyRPC", RpcTarget.All);
                    }
                    else
                    {
                        Destroy(gameObject);
                    }
                }
            }
        }

        Colliders = Physics2D.OverlapBoxAll(transform.position, transform.lossyScale * 1.01f, transform.rotation.z, ~_playerLayers);
        if (Colliders.Length > 0)
        {
            if (PhotonNetwork.InRoom)
            {
                photonView.RPC("destroyRPC", RpcTarget.All);
            }
            else
            {
                Destroy(gameObject);
            }
        }

        if (photonView.IsMine)
        {
            transform.up = _rigidbody.velocity;
        }
    }