void PickupPotato_RPC(int driverId, int gunnerId, int teamId) { if (driverId == PhotonNetwork.LocalPlayer.ActorNumber || (driverId < 0 && PhotonNetwork.IsMasterClient)) { PhotonView otherpv = FindObjectOfType <PlayerTransformTracker>().GetVehicleTransformFromTeamId(teamId).GetComponent <PhotonView>(); NetworkPlayerVehicle npv = otherpv.GetComponentInParent <NetworkPlayerVehicle>(); HealthManager hm = otherpv.gameObject.GetComponentInChildren <HealthManager>(); TeamNameSetup tns = otherpv.gameObject.GetComponentInParent <TeamNameSetup>(); HotPotatoManager hpm = otherpv.gameObject.GetComponentInParent <HotPotatoManager>(); this.GetComponent <PhotonView>().RPC(nameof(PunPickup), RpcTarget.AllViaServer, npv.GetDriverID(), npv.GetGunnerID()); hm.HealObject(healthIncrease); tns.ChangeColour(true); hpm.pickupPotato(); GameObject a = Instantiate(nutsNBoltsPrefab, transform.position, transform.rotation); Destroy(a, 4f); if (PhotonNetwork.IsMasterClient) { PhotonNetwork.Destroy(this.gameObject); } if (GetComponent <PhotonView>().IsMine) { PhotonNetwork.Destroy(this.gameObject); } } }
public virtual void SetupAbility() { driverPhotonView = transform.root.GetComponent <PhotonView>(); // assign photon view to the driver abilityPhotonView = GetComponent <PhotonView>(); abilityPhotonView.TransferOwnership(driverPhotonView.Owner); //Player gunnerPlayer = gunnerPhotonView.Owner; _networkPlayerVehicle = driverPhotonView.GetComponent <NetworkPlayerVehicle>(); myVehicleManager = driverPhotonView.GetComponent <VehicleHealthManager>(); driverAbilityManager = driverPhotonView.GetComponent <DriverAbilityManager>(); if (_networkPlayerVehicle != null) { myNickName = _networkPlayerVehicle.GetDriverNickName(); myPlayerId = _networkPlayerVehicle.GetDriverID(); myTeamId = _networkPlayerVehicle.teamId; } else { Debug.LogError("Ability does not belong to a valid vehicle!! Assigning owner to null"); } uiCanvas = FindObjectOfType <UiCanvasBehaviour>().GetComponent <Canvas>(); targetOverlay = Instantiate(targetOverlayPrefab, uiCanvas.transform); targetOverlay.SetActive(false); lastTarget = transform; isSetup = true; Invoke(nameof(GetCarList), 2f); }
void DelayedStart() { NetworkPlayerVehicle npv = GetComponentInParent <NetworkPlayerVehicle>(); myDriverId = npv.GetDriverID(); myGunnerId = npv.GetGunnerID(); }
public void SetupDriverAbilityManager() { isHost = PhotonNetwork.IsMasterClient; ultimateUiManager = FindObjectOfType <UltimateUiManager>(); gamestateTracker = FindObjectOfType <GamestateTracker>(); driverPhotonView = GetComponent <PhotonView>(); NetworkPlayerVehicle npv = GetComponent <NetworkPlayerVehicle>(); if (npv != null) { driverId = npv.GetDriverID(); if (driverId == PhotonNetwork.LocalPlayer.ActorNumber) { isDriver = true; } gunnerId = npv.GetGunnerID(); if (driverId < 0) { driverBot = true; } if (gunnerId < 0) { gunnerBot = true; } AdjustDriverUltimateProgress(0); } abilityPrimary.SetupAbility(); abilitySecondary.SetupAbility(); gunnerWeaponManager = GetComponentInChildren <GunnerWeaponManager>(); isSetup = true; // abilitySecondary.SetupAbility(); }
//----------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------- public virtual void SetupWeapon() { // assign photon view to the gunner //Player gunnerPlayer = gunnerPhotonView.Owner; _networkPlayerVehicle = GetComponentInParent <NetworkPlayerVehicle>(); myVehicleManager = GetComponentInParent <VehicleHealthManager>(); gunnerWeaponManager = gunnerPhotonView.GetComponent <GunnerWeaponManager>(); if (_networkPlayerVehicle != null) { myNickName = _networkPlayerVehicle.GetGunnerNickName(); myPlayerId = _networkPlayerVehicle.GetGunnerID(); myTeamId = _networkPlayerVehicle.teamId; } else { Debug.LogError("Weapon does not belong to a valid vehicle!! Assigning owner to null"); } //weaponPhotonView.TransferOwnership(gunnerPlayer); weaponUi = FindObjectOfType <WeaponUi>(); _playerTransformTracker = FindObjectOfType <PlayerTransformTracker>(); if (fullSalvoOnStart) { currentSalvo = salvoSize; } isSetup = true; }
public override void TriggerEnter(PhysXCollider other) { // we only call Pickup() if "our" character collides with this PickupItem. // note: if you "position" remote characters by setting their translation, triggers won't be hit. // get gunner and driver id of pickup people. // execute if the driver id is mine or if I am the master client and driver id < 0 if (PhotonNetwork.IsMasterClient) { NetworkPlayerVehicle npv = other.GetComponentInParent <NetworkPlayerVehicle>(); if (npv != null && !npv.GetComponent <VehicleHealthManager>().isDead) { if (this.SentPickup) { return; } int gunnerID = npv.GetGunnerID(); int driverID = npv.GetDriverID(); HotPotatoManager hpm = other.gameObject.GetComponentInParent <HotPotatoManager>(); if (hpm.canPickupPotato) { SentPickup = true; GetComponent <PhotonView>().RPC(nameof(PickupPotato_RPC), RpcTarget.All, driverID, gunnerID, npv.teamId); } } } }
private void Start() { // Debug.LogWarning("Driver Crash Detector has not been ported to the new PhysX system"); // return; npv = GetComponent <NetworkPlayerVehicle>(); myRb = GetComponent <PhysXRigidBody>(); currentSensorReport = new CurrentSensorReportStruct(); currentSensorReport.lastCrashedPlayer = transform.root; }
void PickupPotatoEffects() { isPotato = true; potatoEffects = GetComponentInChildren <PotatoEffects>(); NetworkPlayerVehicle npv = GetComponent <NetworkPlayerVehicle>(); myGunnerId = npv.GetGunnerID(); myGunnerId = npv.GetGunnerID(); potatoEffects.ActivatePotatoEffects(myDriverId, myGunnerId); }
public void Setup() { animation = GetComponent <Animation>(); // Invoke(nameof(DelayedStart), 1f); regShader = Shader.Find("Shader No Border"); Debug.Log("regShader.name: " + regShader.name); hpShader = Shader.Find("Unlit/Hot Potato Shader"); Debug.Log("hpShader.name: " + hpShader.name); rend.GetMaterials(mats); NetworkPlayerVehicle npv = GetComponentInParent <NetworkPlayerVehicle>(); myDriverId = npv.GetDriverID(); myGunnerId = npv.GetGunnerID(); }
/* * public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) * { * // read the description in SecondsBeforeRespawn * * * if (stream.IsWriting && SecondsBeforeRespawn <= 0) * { * stream.SendNext(this.gameObject.transform.position); * } * else * { * // this will directly apply the last received position for this PickupItem. No smoothing. Usually not needed though. * Vector3 lastIncomingPos = (Vector3)stream.ReceiveNext(); * this.gameObject.transform.position = lastIncomingPos; * } * } */ public virtual void Pickup(PhotonView otherpv) { if (this.SentPickup) { // skip sending more pickups until the original pickup-RPC got back to this client return; } this.SentPickup = true; Debug.Log("Picked up base item"); NetworkPlayerVehicle npv = otherpv.GetComponentInParent <NetworkPlayerVehicle>(); this.GetComponent <PhotonView>().RPC(nameof(PunPickup), RpcTarget.AllViaServer, npv.GetDriverID(), npv.GetGunnerID()); }
public override void Pickup(PhotonView otherpv) { if (this.SentPickup) { // skip sending more pickups until the original pickup-RPC got back to this client return; } this.SentPickup = true; NetworkPlayerVehicle npv = otherpv.GetComponentInParent <NetworkPlayerVehicle>(); HealthManager hm = otherpv.gameObject.GetComponentInChildren <HealthManager>(); hm.TakeDamage(-healthIncrease); this.GetComponent <PhotonView>().RPC(nameof(PunPickup), RpcTarget.AllViaServer, npv.GetDriverID(), npv.GetGunnerID()); }
protected new void Start() { baseCollisionResistance = deathForce / maxHealth; myRb = GetComponent <PhysXRigidBody>(); if (GetComponent <HotPotatoManager>() != null) { hasHotPotatoManager = true; hotPotatoManager = GetComponent <HotPotatoManager>(); collisionNpv = GetComponent <NetworkPlayerVehicle>(); if (collisionNpv != null && !collisionNpv.botDriver) { driverCrashDetector = GetComponent <DriverCrashDetector>(); } } base.Start(); }
public void pickupPotato() { NetworkPlayerVehicle npv = GetComponent <NetworkPlayerVehicle>(); myDriverId = npv.GetDriverID(); myGunnerId = npv.GetGunnerID(); isPotato = true; canPickupPotato = false; InvokeRepeating("buffs", 2f, 2f); GetComponent <PhotonView>().RPC(nameof(PickupPotatoEffects), RpcTarget.All); // telecastManager.PickupPotato(npv); AnnouncerManager a = FindObjectOfType <AnnouncerManager>(); a.PlayAnnouncerLine(a.announcerShouts.potatoPickup, myDriverId, myGunnerId); }
void RemovePotato_RPC() { isPotato = false; PhotonView otherpv = GetComponent <PhotonView>(); NetworkPlayerVehicle npv = otherpv.GetComponentInParent <NetworkPlayerVehicle>(); HealthManager hm = otherpv.gameObject.GetComponentInChildren <HealthManager>(); TeamNameSetup tns = otherpv.gameObject.GetComponentInParent <TeamNameSetup>(); HotPotatoManager hpm = otherpv.gameObject.GetComponentInParent <HotPotatoManager>(); canPickupPotato = false; Invoke(nameof(ReactivatePickupPotato), 5f); myDriverId = npv.GetDriverID(); myGunnerId = npv.GetGunnerID(); tns.ChangeColour(false); potatoEffects = GetComponentInChildren <PotatoEffects>(); potatoEffects.DeactivatePotatoEffects(myDriverId, myGunnerId); }
public void SetupVehicleManager() { // Debug.LogWarning("Vehicle Health Manager has not been fully ported to the new PhysX system"); gamestateTracker = FindObjectOfType <GamestateTracker>(); gamestateTrackerPhotonView = gamestateTracker.GetComponent <PhotonView>(); networkManager = FindObjectOfType <NetworkManager>(); maxHealth = health; rb = GetComponent <PhysXRigidBody>(); icd = GetComponent <InterfaceCarDrive>(); icd4 = GetComponent <InterfaceCarDrive4W>(); carDriver = icd.GetComponent <IDrivable>(); inputDriver = GetComponent <InputDriver>(); myPhotonView = GetComponent <PhotonView>(); npv = GetComponent <NetworkPlayerVehicle>(); announcerManager = FindObjectOfType <AnnouncerManager>(); _rammingDetails = new Weapon.WeaponDamageDetails(null, 0, 0, Weapon.DamageType.ramming, 0, Vector3.zero); for (int i = 0; i < collisionAreas.Count; i++) { CollisionArea collisionArea = collisionAreas[i]; collisionArea.rotation.eulerAngles = collisionArea.rotationEuler; collisionAreas[i] = collisionArea; } defaultDrag = rb.linearDamping; defaultAngularDrag = rb.angularDamping; playerTransformTracker = FindObjectOfType <PlayerTransformTracker>(); PlayerEntry player = gamestateTracker.players.Get((short)PhotonNetwork.LocalPlayer.ActorNumber); if (player.teamId == teamId) { tutorials.SetActive(true); } else { tutorials.SetActive(false); } player.Release(); }
void SetupGunnerWeaponManager() { NetworkPlayerVehicle npv = GetComponentInParent <NetworkPlayerVehicle>(); if (npv != null) { driverId = npv.GetDriverID(); gunnerId = npv.GetGunnerID(); if (driverId < 0) { driverBot = true; } if (gunnerId < 0) { gunnerBot = true; } AdjustGunnerUltimateProgress(0); } }
// Enable the arrow and find the player's own vehicle. Shouldn't be called until all vehicles are activated. public void ReadyUp() { hpms = FindObjectsOfType <HotPotatoManager>().ToList(); gamestateTracker = FindObjectOfType <GamestateTracker>(); meshRenderer = GetComponentInChildren <MeshRenderer>(); PlayerEntry player = gamestateTracker.players.Get((short)PhotonNetwork.LocalPlayer.ActorNumber); List <NetworkPlayerVehicle> vehicles = FindObjectsOfType <NetworkPlayerVehicle>().ToList(); foreach (NetworkPlayerVehicle vehicle in vehicles) { if (vehicle.teamId == player.teamId) { playerNPV = vehicle; playerHPM = vehicle.GetComponent <HotPotatoManager>(); player.Release(); break; } } isEnabled = true; }
public override void Pickup(PhotonView otherpv) { if (this.SentPickup) { // skip sending more pickups until the original pickup-RPC got back to this client return; } this.SentPickup = true; NetworkPlayerVehicle npv = otherpv.GetComponentInParent <NetworkPlayerVehicle>(); GunnerWeaponManager gm = otherpv.gameObject.GetComponentInChildren <GunnerWeaponManager>(); if (!gm.usingUltimate) { gm.AdjustGunnerUltimateProgress(ultIncrease); this.GetComponent <PhotonView>().RPC(nameof(PunPickup), RpcTarget.AllViaServer, npv.GetDriverID(), npv.GetGunnerID()); } }
void Update() { // fire 1 if (Input.GetButton("Fire1")) { if (gunnerPhotonView.IsMine) { if (gunnerWeaponManager.CurrentWeaponGroupCanFire()) { Vector3 targetHitpoint; if (turretController.inDeadZone) { targetHitpoint = CalculateTargetingHitpoint(cam); } else { targetHitpoint = CalculateTargetingHitpoint(barrelTransform); } gunnerWeaponManager.FireCurrentWeaponGroup(targetHitpoint); } } } // jank ram damage thing if (Input.GetButtonDown("Fire2")) { Debug.Log("mark fire btn press"); if (gunnerPhotonView.IsMine) { Debug.Log("mark fire"); VehicleHealthManager hitvm = GetClosestVehicleHealthManager(cam); if (hitvm != null) { Debug.Log("mark hitvm not null"); NetworkPlayerVehicle npv = GetComponentInParent <NetworkPlayerVehicle>(); int teamId = npv.teamId; int driverId = npv.GetDriverID(); int gunnerId = npv.GetGunnerID(); // remove last mark if (lastMarkedTeam != 0) { FindObjectOfType <PlayerTransformTracker>().GetVehicleTransformFromTeamId(lastMarkedTeam).GetComponent <PhotonView>().RPC(nameof(CollidableHealthManager.RemoveMarkedTeam_RPC), RpcTarget.All, lastMarkedTeam, driverId, gunnerId); } // add new mark GetComponent <PhotonView>().RPC(nameof(MarkAudioPlay_RPC), RpcTarget.All); hitvm.GetComponent <PhotonView>().RPC(nameof(CollidableHealthManager.MarkTeam_RPC), RpcTarget.All, teamId, driverId, gunnerId); lastMarkedTeam = hitvm.gameObject.GetComponent <NetworkPlayerVehicle>().teamId; Debug.Log("mark done"); } if (hitvm == null) { Debug.Log("mark is null"); } if (hitvm.transform == transform.root) { Debug.Log("mark is me"); } } } if (Input.GetButtonUp("Fire1")) { if (gunnerPhotonView.IsMine) { gunnerWeaponManager.CeaseFireCurrentWeaponGroup(); } } // // relaod if (Input.GetButtonDown("Reload")) { if (gunnerPhotonView.IsMine) { gunnerWeaponManager.ReloadCurrentWeaponGroup(); } } if (Input.GetButtonDown("Ultimate")) { if (gunnerPhotonView.IsMine) { gunnerWeaponManager.SelectUltimate(); } } if (Input.GetKey(KeyCode.Space)) { camera.m_Lens.FieldOfView = Mathf.Lerp(camera.m_Lens.FieldOfView, 30, 0.1f); } else { camera.m_Lens.FieldOfView = Mathf.Lerp(camera.m_Lens.FieldOfView, 60, 0.1f); } turretController.ChangeTargetYaw(cameraSensitivity * Input.GetAxis("Mouse X") * Time.deltaTime); turretController.ChangeTargetPitch(-(cameraSensitivity * Input.GetAxis("Mouse Y") * Time.deltaTime)); turretController.UpdateTargeterRotation(); float newy = Mathf.Max(cinemachineTransposer.m_FollowOffset.y - Input.mouseScrollDelta.y * 0.2f, 1.5f); float newz = Mathf.Min(cinemachineTransposer.m_FollowOffset.z + Input.mouseScrollDelta.y * 0.6f, -3f); if (newy < maxZoomOut) { cinemachineTransposer.m_FollowOffset.y = newy; cinemachineTransposer.m_FollowOffset.z = newz; } }
// Update is called once per frame public void PickupPotato(NetworkPlayerVehicle npv) { GetComponent <PhotonView>().RPC(nameof(PickupPotato_RPC), RpcTarget.All, npv.teamId); }
private void Start() { tutorialManager = FindObjectOfType <TutorialManager>(); npv = GetComponentInParent <NetworkPlayerVehicle>(); StartCoroutine(nameof(LateStart)); }