示例#1
0
        public void RPC_Fire(Player Owner, Vector3 direction)
        {
            //GameObject spawnedFlag = PhotonNetwork.Instantiate(bulletPrefab.name, bulletSpawner.transform.position, Quaternion.identity);
            GameObject     bullet = GameObject.Instantiate(bulletPrefab, bulletSpawner.transform.position, Quaternion.identity);
            OwnedComponent fc     = bullet.GetComponent <OwnedComponent>();

            fc.Owner  = Owner;
            fc.UserId = Owner.UserId;
            BulletComponent bulletComponent = bullet.GetComponent <BulletComponent>();

            bulletComponent.Player = Owner;
            bulletComponent.SetDirection(direction);
        }
    private void OnTriggerEnter(Collider other)
    {
        int otherLayer = other.gameObject.layer;

        if (otherLayer == LayerMask.NameToLayer("bullet"))
        {
            OwnedComponent ownedComponent = other.GetComponent <OwnedComponent>();
            if (PhotonNetwork.IsMasterClient && !photonView.Owner.UserId.Equals(ownedComponent.UserId))
            {
                GetKilled();
            }

            Destroy(other);
        }
        else if (otherLayer == LayerMask.NameToLayer("flag"))
        {
            Flag = other.gameObject;
        }
    }