void PickupPotatoEffects() { isPotato = true; potatoEffects = GetComponentInChildren <PotatoEffects>(); NetworkPlayerVehicle npv = GetComponent <NetworkPlayerVehicle>(); myGunnerId = npv.GetGunnerID(); myGunnerId = npv.GetGunnerID(); potatoEffects.ActivatePotatoEffects(myDriverId, myGunnerId); }
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 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); } } } }
//----------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------- 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; }
void DelayedStart() { NetworkPlayerVehicle npv = GetComponentInParent <NetworkPlayerVehicle>(); myDriverId = npv.GetDriverID(); myGunnerId = npv.GetGunnerID(); }
IEnumerator LateStart() { yield return(new WaitForEndOfFrame()); if (tutorialNumber == 1) // Gunner tutorials { if (npv.botGunner) { gameObject.SetActive(false); } } else if (tutorialNumber == 0 || tutorialNumber == 2) // Driver tutorials { if (npv.botDriver) { gameObject.SetActive(false); } } else if (tutorialNumber == 3) // Shared tutorials { if (npv.botDriver && npv.botGunner) { gameObject.SetActive(false); } else if (npv.GetGunnerID() != PhotonNetwork.LocalPlayer.ActorNumber && npv.GetDriverID() != PhotonNetwork.LocalPlayer.ActorNumber) { gameObject.SetActive(false); } } }
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(); }
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); }
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); } }
// called to activate UI elements and transfer photonview public virtual void ActivateWeapon() { if (!isSetup) { SetupWeapon(); } if (gunnerPhotonView != null && weaponUi != null) { if (_networkPlayerVehicle.GetGunnerID() == PhotonNetwork.LocalPlayer.ActorNumber && !_networkPlayerVehicle.botGunner) { weaponUi.SetCanvasVisibility(true); } } // weaponPhotonView.RPC(nameof(AnimatorSetTriggerNetwork), RpcTarget.All, weaponSelectTriggerName); UpdateHud(); }
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); }
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()); } }
// Die is a LOCAL function that is only called by the driver when they get dead. protected void Die(bool updateDeath, bool updateKill) { // Update gamestate networkManager.CallRespawnVehicle(5f, teamId); TeamEntry team = gamestateTracker.teams.Get((short)teamId); myPhotonView.RPC(nameof(SetGunnerHealth_RPC), RpcTarget.All, 0f); bool hadPotato = hpm.removePotato(); if (!hadPotato) { announcerManager.PlayAnnouncerLine(announcerManager.announcerShouts.onKilled, npv.GetDriverID(), npv.GetGunnerID()); } team.Release(); // update my deaths if (updateDeath) { /*GamestateTracker.TeamDetails myRecord = gamestateTracker.getTeamDetails(teamId); * myRecord.deaths += 1; * myRecord.isDead = true; * gamestateTrackerPhotonView.RPC(nameof(GamestateTracker.UpdateTeamWithNewRecord), RpcTarget.All, teamId, * JsonUtility.ToJson(myRecord));*/ TeamEntry teamEntry = gamestateTracker.teams.Get((short)teamId); teamEntry.deaths += 1; teamEntry.isDead = true; teamEntry.Increment(); } if (updateKill) { // update their kills /*GamestateTracker.TeamDetails theirRecord = gamestateTracker.getTeamDetails(lastHitDetails.sourceTeamId); * theirRecord.kills += 1; * gamestateTrackerPhotonView.RPC(nameof(GamestateTracker.UpdateTeamWithNewRecord), RpcTarget.All, * lastHitDetails.sourceTeamId, JsonUtility.ToJson(theirRecord));*/ TeamEntry teamEntry = gamestateTracker.teams.Get((short)lastHitDetails.sourceTeamId); teamEntry.kills += 1; teamEntry.Increment(); } }
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); } } }
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; } }
public void CollisionEnter(PhysXCollision collision) { // Debug.Log("crashed into: " + collision.gameObject); float dSpeed = myRb.velocity.magnitude; float impulse = collision.impulse.magnitude; if (collision.rigidBody != null) { dSpeed = (myRb.velocity - collision.rigidBody.velocity).magnitude; } if (myPhotonView.IsMine && collision.contactCount > 0 && dSpeed > 1.5 && collisionTimer < 0) { collisionTimer = maxCollisionRate; Vector3 collisionNormal = collision.GetContact(0).normal; Vector3 collisionForce = collision.impulse; if (Vector3.Dot(collisionForce, collisionNormal) < 0) { collisionForce = -collisionForce; } collisionForce /= Time.fixedDeltaTime; collisionForce = transform.InverseTransformDirection(collisionForce); VehicleHealthManager otherVehicleManager = collision.gameObject.GetComponent <VehicleHealthManager>(); Vector3 collisionPoint = Vector3.zero; for (int i = 0; i < collision.contactCount; i++) { collisionPoint += collision.GetContact(i).point; } collisionPoint /= collision.contactCount; Vector3 contactDirection = transform.InverseTransformPoint(collisionPoint); float damage = CalculateCollisionDamage(collisionForce, contactDirection, otherVehicleManager != null); // instantiate damage sound over network if ((damage > crashSoundsSmallDamageThreshold || (otherVehicleManager != null)) && timeSinceLastRam > 0.25f) { PlayDamageSoundNetwork(damage); } damage = damage / rammingDamageResistance; if (myPhotonView.IsMine && hasHotPotatoManager && otherVehicleManager != null && timeSinceLastRam > 0.25f) { if (collisionNpv.GetDriverID() == PhotonNetwork.LocalPlayer.ActorNumber || collisionNpv.GetGunnerID() == PhotonNetwork.LocalPlayer.ActorNumber) { // Debug.LogError("Slow down should happen"); hotPotatoManager.SlowedCollision(); } if (collisionSparks != null) { GameObject a = Instantiate(collisionSparks, collisionPoint, Quaternion.identity); a.transform.parent = transform; } if (collisionNpv != null && !collisionNpv.botDriver) { if (damage > 4) { driverCrashDetector.CrashCollisionCamera(collision, false); } else { driverCrashDetector.CrashCollisionCamera(collision, true); } } } if (damage > 5) { if (otherVehicleManager != null) { if (otherVehicleManager != null) { damage *= otherVehicleManager.rammingDamageMultiplier; } Weapon.WeaponDamageDetails rammingDetails = otherVehicleManager.rammingDetails; rammingDetails.damage = damage; if (markedByTeams.Contains(rammingDetails.sourceTeamId)) { rammingDetails.damage *= markedTeamDamageIncrease; } TakeDamage(rammingDetails); } else { TakeDamage(damage); } } } if (collision.rigidBody != null) { timeSinceLastRam = 0f; } }
/* * 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()); }