//[Command] //public void CmdDropCurrentWeapon() //{ // GameObject newGunContainer = (GameObject)Instantiate(this.gunContainerPrefab, GetBulletSpawnLocation(), new Quaternion()); // GunContainer newGunContainerScript = newGunContainer.GetComponent<GunContainer>(); // GameObject oldGun = currentGunObject; // IGun oldGunScript = oldGun.GetComponent<IGun>(); // //newGunContainerScript.SetContainedGun(oldGun); // NetworkServer.Spawn(newGunContainer); // currentGunObject = null; // currentGun = null; // //RpcUpdateContainerGun(newGunContainer.GetComponent<NetworkIdentity>().netId, oldGun.GetComponent<NetworkIdentity>().netId, oldGunScript.ammoData); //} //================================================================================================= //Client Functions //================================================================================================= //[ClientRpc] //public void RpcUpdatePlayerGun(NetworkInstanceId gunID) //{ // if (isServer) // return; // SetPlayersGun(ClientScene.FindLocalObject(gunID)); //} //[ClientRpc] //public void RpcUpdateContainerGun(NetworkInstanceId containerID, NetworkInstanceId gunID, GunBase.AmmoData ammoData) //{ // if (isServer) // return; // GameObject gunContainerPrefab = ClientScene.FindLocalObject(containerID); // GunContainer gunContainerScript = gunContainerPrefab.GetComponent<GunContainer>(); // gunContainerScript.SetContainedGun(ClientScene.FindLocalObject(gunID)); // GunBase containerGunScript = gunContainerScript.containedGun.GetComponent<GunBase>(); // containerGunScript.ammoData = ammoData; //} //Sets the gun container that the player is currently able to pick up public void SetSwappableGunContainer(GunContainer gunContainer) { this.swapableGunContainer = gunContainer; if (gunContainer == null || gunContainer.GetContainedGun() == null) { //Debug.LogWarning("Container: " + gunContainer); //Debug.LogWarning("Gun: " + gunContainer.GetContainedGun().GetWeaponName()); playerHud.ClearWeaponPickupName(); } else { playerHud.SetWeaponPickupName(gunContainer.GetContainedGun().GetWeaponName()); } }
public void SwapGun() { DropCurrentWeapon(); GunContainer pickupGunContainer = swapableGunContainer; SetWeapon(pickupGunContainer.GetContainedGun()); pickupGunContainer.DestroyContainer(); //RpcUpdatePlayerGun(GetComponent<NetworkIdentity>().netId, newGun.GetComponent<NetworkIdentity>().netId, newGunScript.ammoData); //RpcUpdateContainerGun(newGunContainer.GetComponent<NetworkIdentity>().netId, oldGun.GetComponent<NetworkIdentity>().netId, oldGunScript.ammoData); }