public static TankData FindTankData(DostempneCzolgi myTank) { for (int i = 0; i < tanks.Count; i++) { if (tanks[i].tank == myTank) { return(tanks[i].tankData); } } return(null); }
[PunRPC]// \/ void UstawCzolgRPC(DostempneCzolgi newTank, float cameraSize, float damage, float damageLotery, float maxHp, float reload, float speed, int maxAmmo) { TankData mySuspectTank = TanksData.FindTankData(newTank); mySuspectTank.cameraSize = cameraSize; mySuspectTank.damage = damage; mySuspectTank.damageLotery = damageLotery; mySuspectTank.maxHp = maxHp; mySuspectTank.reload = reload; mySuspectTank.speed = speed; mySuspectTank.maxAmmo = maxAmmo; SetTankObject(mySuspectTank); }
void SendPlayerRPC(PhotonPlayer remotePlayerPP, int remotePlayerID, NationManager.Nation remoteNation, float remoteHP, DostempneCzolgi remoteTank, bool remotePlayer = false) { //Tworzę gracza i dodaje go do mojej listy graczy Player player = new Player(); if (remotePlayer) { player = Player.FindPlayer(remotePlayerPP); } else { Player.players.Add(player); } //Ustawiam podstawowe dane tego gracza player.nick = remotePlayerPP.NickName; player.pp = remotePlayerPP; player.nation = remoteNation; player.hp = remoteHP; player.tank = remoteTank; //Ustawiam odwołanie gracza z listy i właściwego obiektu GameObject newPlayerGO = PhotonView.Find(remotePlayerID).gameObject; player.gameObject = newPlayerGO; //Tu jest problem newPlayerGO.GetComponent <PlayerGO>().myPlayer = player; //Taki bajer newPlayerGO.name = "Player_" + player.nick; //+nick //Ustawiam dane widoczne dla gracza proszącego (ustawiam czołg, sliderHP i nick) newPlayerGO.GetComponent <PlayerGO>().myPlayer.hp = player.hp; newPlayerGO.GetComponent <PlayerGO>().myPlayer.nick = player.nick; newPlayerGO.GetComponent <Nick>().nick.text = player.nick; newPlayerGO.GetComponent <PlayerGO>().myPlayer.nation = player.nation; newPlayerGO.GetComponent <PlayerGO>().myPlayer.tank = player.tank; newPlayerGO.GetComponent <TankEvolution>().SetStartTankHowNewPlayer(player.tank); }
void PleaseServerForUpdateRPC(DostempneCzolgi newTank, PhotonMessageInfo pmi) { #region Security int playerOldTankLevel = TanksData.FindTankData(Player.FindPlayer(pmi.sender).tank).level; //(int)newTank - 1;// TankManager.czolgii[newTank].level - 1;//Player.FindPlayer(pmi.sender).gameObject.GetComponent<TankEvolution>().myTank.level; int requiredScore = TankEvolution.UstawGranice(playerOldTankLevel); if (!PhotonNetwork.isMasterClient) { Debug.LogError("Tylko server ma prawo ulepszać czołgi graczy!"); //to ma sens ;) return; } if (TanksData.FindTankData(newTank).level != playerOldTankLevel + 1) { Debug.LogError("Niewłaściwy level 'starego' czołgu gracza! ~" + TanksData.FindTankData(newTank).level + " <= " + (playerOldTankLevel + 1).ToString() ); //może być tylko o jeden mniejszy od nowego albo ten sam return; } if (Player.FindPlayer(pmi.sender).score < requiredScore) { Debug.LogError("Gracz ma za mało score!"); //Przynajmniej w kopii gry servera return; } #endregion { TankData goodTankParametrs = TanksData.FindTankData(newTank); Player.FindPlayer(pmi.sender).tank = newTank; //Server przechowuje i tylko on sobie ustawia właściwy typ i u siebie trzyma photonView.RPC("UstawCzolgRPC", PhotonTargets.All, newTank, goodTankParametrs.cameraSize, goodTankParametrs.damage, goodTankParametrs.damageLotery, goodTankParametrs.maxHp, goodTankParametrs.reload, goodTankParametrs.speed, goodTankParametrs.maxAmmo ); } // / } // \ <- upośledzona strzałka ;)
/// <summary> /// Bardo niebezpieczna metoda no ale cóż, kiedyś się poprawi ;) TODO: 0_0 /// </summary> /// <param name="tank"></param> public void SetStartTankHowNewPlayer(DostempneCzolgi tank) { SetTankObject(TanksData.FindTankData(tank)); }