public void UpdateScoreToPlayerAll(int playerId) { PhotonPlayer player = PhotonPlayer.Find(playerId); player.AddScore(1); photonView.RPC("UpdateScoreToPlayer", PhotonTargets.All, playerId); }
public void AddKill(PhotonPlayer player) { // show killfeed thingo // update my copy of their score player.AddScore(1); }
public void DropFish(PhotonPlayer owner) { if (owner.GetScore() > 0 && owner.ID == view.ownerId) { owner.AddScore(-1); view.RPC("DropFishMasterClient", PhotonTargets.MasterClient, FishEject.transform.position, transform.TransformDirection(Vector3.back)); view.RPC("UpdateListScoreForAllPlayers", PhotonTargets.All); } }
public void EndRound(PhotonPlayer winner) { if (!complete) { if (PhotonNetwork.isMasterClient && !scoreAdded) { if (callbyply) { winner.AddScore(1); } else { winnerrr.GetComponent <AIControl> ().score++; } callbyply = false; scoreAdded = true; photonView.RPC("UpdateScore", winner); } PlayerPrefs.SetInt("Score", PhotonNetwork.player.GetScore()); if ((round < 10 || Tie()) && Reachable()) { StartCoroutine("NewRound"); updateHudInfo(); aba.gameObject.SetActive(true); aba.NextRound(Tie() && round >= 10); } else { if (PhotonNetwork.isMasterClient) { updateHudInfo(); aba.gameObject.SetActive(true); string[] tabstring = GetStanding(); PlayerPrefs.SetString("std_off_1", tabstring [0]); PlayerPrefs.SetString("std_off_2", tabstring [1]); PlayerPrefs.SetString("std_off_3", tabstring [2]); PlayerPrefs.SetString("std_off_4", tabstring [3]); UpdateStats(); EndGame(); } } complete = true; } }
public void TakeDamage(float dmg, PhotonPlayer player) { if (health <= 0f) { return; } health -= dmg; if (health <= 0f) { player.AddScore(1); Destroy(gameObject, 1f); FindObjectOfType <GameManager>().Respawn(); } }
public void EndRound(PhotonPlayer winner) { if (!complete) { if (PhotonNetwork.isMasterClient && !scoreAdded) { winner.AddScore(1); scoreAdded = true; photonView.RPC("UpdateScore", winner); } PlayerPrefs.SetInt("Score", PhotonNetwork.player.GetScore()); if ((round < 10 || Tie()) && Reachable()) { Invoke("NewRound", 3f); updateHudInfo(); aba.gameObject.SetActive(true); aba.NextRound(Tie() && round >= 10); } else { if (PhotonNetwork.isMasterClient) { updateHudInfo(); aba.gameObject.SetActive(true); //Set winner decision here int[] TabID = GetStanding(); roomProp.Add("C1", TabID [0]); roomProp.Add("C2", TabID [1]); roomProp.Add("C3", TabID [2]); roomProp.Add("C4", TabID [3]); room.SetCustomProperties(roomProp, room.customProperties); photonView.RPC("EndGame", PhotonTargets.AllViaServer); } } complete = true; } }
// Update is called once per frame void Update() { if (PhotonNetwork.inRoom) { if (respawnTimer > 0) { respawnTimer -= Time.deltaTime; if (respawnTimer <= 0) { respawnPlayer(); } } if (respawnTimerAI > 0) { respawnTimerAI -= Time.deltaTime; if (respawnTimerAI <= 0) { respawnPlayerAI(0); } } if (respawnTimerAI1 > 0) { respawnTimerAI1 -= Time.deltaTime; if (respawnTimerAI1 <= 0) { respawnPlayerAI(1); } } if (respawnTimerAI2 > 0) { respawnTimerAI2 -= Time.deltaTime; if (respawnTimerAI2 <= 0) { respawnPlayerAI(2); } } if (respawnTimerAI3 > 0) { respawnTimerAI3 -= Time.deltaTime; if (respawnTimerAI3 <= 0) { respawnPlayerAI(3); } } if (respawnTimerAI4 > 0) { respawnTimerAI4 -= Time.deltaTime; if (respawnTimerAI4 <= 0) { respawnPlayerAI(4); } } if (leaderBoardTimer > 0) { leaderBoardTimer -= Time.deltaTime; if (leaderBoardTimer <= 0) { AI1.AddScore(10); leaderBoardTimer = 5f; } } /* if (change <= 0) * { * * change = 4.5f; * } else * { * change -= Time.deltaTime; * } */ if (recoveryRegion == null && createRecoveryRegion) { Vector3 spawnPoint = new Vector3(Random.Range(min, max), Random.Range(min, max), 0); recoveryRegion = PhotonNetwork.Instantiate("RecoveryRegion", spawnPoint, Quaternion.identity, 0); } starTimer = createRegion(starTimer, "Star"); if (starTimer <= 0) { starTimer = 0.5f; } erekiPowerTimer = createRegion(erekiPowerTimer, "Ereki Power"); if (erekiPowerTimer <= 0) { erekiPowerTimer = 20f; } firePowerTimer = createRegion(firePowerTimer, "Fire Power"); if (firePowerTimer <= 0) { firePowerTimer = 20f; } invisPowerTimer = createRegion(invisPowerTimer, "Invisible Power"); if (invisPowerTimer <= 0) { invisPowerTimer = 20f; } normalPowerTimer = createRegion(normalPowerTimer, "Normal Power"); if (normalPowerTimer <= 0) { normalPowerTimer = 20f; } } }
public void GetShot(float damage, PhotonPlayer enemy) { health -= damage; if (health <= 0 && photonView.isMine) { // photonView.isMine stops everyone from trying to remove the object at the same time, so only I can remove it instead if(SendNetworkMessage != null) { enemy.AddScore(1); SendNetworkMessage(PhotonNetwork.player.name + " was killed by " + enemy.name); RequestUpdateScore(); } if (RespawnMe != null) { // if there is an event registered RespawnMe(5f); // 5 seconds } PhotonNetwork.Destroy(gameObject); } }
private void AddScoreAndWaitForDestroy(Collider2D collision) { print(collision.GetComponent <PhotonView>() != null); int curScore = new int(); curScore = photonPlayer.GetScore(); HitTarget(collision); if (collision.transform.gameObject.name == "Character01(Clone)") { if (transform.name == "GT0(Clone)" || transform.name == "GT1(Clone)") { if (collision.GetComponent <PhotonView>().owner.NickName != photonPlayer.NickName) { print("plusScore += " + plusScore); if (photonView.isMine) { photonPlayer.AddScore(plusScore); sfxCreator.Create(addPoint, 0.658f, 1f); } CheckMatchingPhotonPlayers(1); waitForDestroy = true; } } else { if (collision.GetComponent <PhotonView>().owner.NickName != photonPlayer.NickName) { if (curScore > 0) { print("minusScore -= " + minusScore); if (photonView.isMine) { photonPlayer.AddScore(minusScore); if (curScore < 0) { print("(Score < 0) Score += " + curScore); photonPlayer.AddScore(-(curScore)); } } sfxCreator.Create(minusPoint, 0.658f, 1f); CheckMatchingPhotonPlayers(2); waitForDestroy = true; } else { sfxCreator.Create(minusPoint, 0.658f, 1f); CheckMatchingPhotonPlayers(2); waitForDestroy = true; } } } } else if (collision.transform.gameObject.name == "Character02(Clone)") { if (transform.name == "HT0(Clone)" || transform.name == "HT1(Clone)") { if (collision.GetComponent <PhotonView>().owner.NickName != photonPlayer.NickName) { print("plusScore += " + plusScore); if (photonView.isMine) { photonPlayer.AddScore(plusScore); sfxCreator.Create(addPoint, 0.658f, 1f); } CheckMatchingPhotonPlayers(1); waitForDestroy = true; } } else { if (collision.GetComponent <PhotonView>().owner.NickName != photonPlayer.NickName) { if (curScore > 0) { print("minusScore -= " + minusScore); if (photonView.isMine) { photonPlayer.AddScore(minusScore); if (curScore < 0) { print("(Score < 0) Score += " + curScore); photonPlayer.AddScore(-(curScore)); } } sfxCreator.Create(minusPoint, 0.658f, 1f); CheckMatchingPhotonPlayers(2); waitForDestroy = true; } else { sfxCreator.Create(minusPoint, 0.658f, 1f); CheckMatchingPhotonPlayers(2); waitForDestroy = true; } } } } else if (collision.transform.gameObject.name == "Character03(Clone)") { if (transform.name == "OT0(Clone)" || transform.name == "OT1(Clone)") { if (collision.GetComponent <PhotonView>().owner.NickName != photonPlayer.NickName) { print("plusScore += " + plusScore); if (photonView.isMine) { photonPlayer.AddScore(plusScore); sfxCreator.Create(addPoint, 0.658f, 1f); } CheckMatchingPhotonPlayers(1); waitForDestroy = true; } } else { if (collision.GetComponent <PhotonView>().owner.NickName != photonPlayer.NickName) { if (curScore > 0) { print("minusScore -= " + minusScore); if (photonView.isMine) { photonPlayer.AddScore(minusScore); if (curScore < 0) { print("(Score < 0) Score += " + curScore); photonPlayer.AddScore(-(curScore)); } } sfxCreator.Create(minusPoint, 0.658f, 1f); CheckMatchingPhotonPlayers(2); waitForDestroy = true; } else { sfxCreator.Create(minusPoint, 0.658f, 1f); CheckMatchingPhotonPlayers(2); waitForDestroy = true; } } } } else if (collision.transform.gameObject.name == "Character04(Clone)") { if (transform.name == "RT0(Clone)" || transform.name == "RT1(Clone)") { if (collision.GetComponent <PhotonView>().owner.NickName != photonPlayer.NickName) { print("plusScore += " + plusScore); if (photonView.isMine) { photonPlayer.AddScore(plusScore); sfxCreator.Create(addPoint, 0.658f, 1f); } CheckMatchingPhotonPlayers(1); waitForDestroy = true; } } else { if (collision.GetComponent <PhotonView>().owner.NickName != photonPlayer.NickName) { if (curScore > 0) { print("minusScore -= " + minusScore); if (photonView.isMine) { photonPlayer.AddScore(minusScore); if (curScore < 0) { print("(Score < 0) Score += " + curScore); photonPlayer.AddScore(-(curScore)); } } sfxCreator.Create(minusPoint, 0.658f, 1f); CheckMatchingPhotonPlayers(2); waitForDestroy = true; } else { sfxCreator.Create(minusPoint, 0.658f, 1f); CheckMatchingPhotonPlayers(2); waitForDestroy = true; } } } } else { print("Character name have change."); } }
private void Start() { SetParent(); photonPlayer.AddScore(0); }