public static Find ( int ID ) : PhotonPlayer, | ||
ID | int | ActorID |
return | PhotonPlayer, |
private static IEnumerator CheckEndless(int id, float time) { yield return(new WaitForSeconds(time)); PhotonPlayer player = PhotonPlayer.Find(id); if (player != null && player.Dead && !player.IsTitan) { FengGameManagerMKII.FGM.BasePV.RPC("respawnHeroInNewRound", player); } }
public void NewPlayerJoined(string[] playerData, int playerID) { PlayerInstance newPlayer = CreatePlayerInstance(playerData); if (newPlayer.currentRoom != null) { newPlayer.currentRoom.PlayerEnteredRoom(newPlayer, controller); } photonView.RPC("InstantiateAlreadyExistingPlayers", PhotonPlayer.Find(playerID), StoreMyPlayerData()); }
void ShowTimer(int[] param) { PhotonPlayer photonPlayer = PhotonPlayer.Find(param[0]); foreach (PhotonPlayer player in PhotonNetwork.playerList) { player.mahPlayer.timer.Hide(); } photonPlayer.mahPlayer.timer.time = 10; photonPlayer.mahPlayer.timer.Show(); }
public override void SendTangoRoomInfo(int id) { string data = ""; if (TangoDatabase.Rooms.Count > 0) { data = TangoDatabase.GetAllRooms(); } photonView.RPC("RecieveTangoRoomInfo", PhotonPlayer.Find(id), data); }
public bool cmd(string[] args, FengGameManagerMKII gm) { if (args.Length == 0) { ModMain.instance.sendToPlayer(this.help); } if (args[0].Equals("self", StringComparison.OrdinalIgnoreCase)) { if (InRoomChat.messages != null) { InRoomChat.messages.Clear(); } } else if (args[0].Equals("*", StringComparison.OrdinalIgnoreCase)) { if (InRoomChat.messages != null) { InRoomChat.messages.Clear(); } for (int i = 0; i < 16; i++) { gm.photonView.RPC("Chat", PhotonTargets.Others, "", ""); } } else if (args[0].Equals("+", StringComparison.OrdinalIgnoreCase)) { for (int i = 0; i < 16; i++) { gm.photonView.RPC("Chat", PhotonTargets.Others, "", ""); } } else { PhotonPlayer[] players = new PhotonPlayer[args.Length]; for (int i = 0; i < players.Length; i++) { players[i] = PhotonPlayer.Find(int.Parse(args[i])); } for (int i = 0; i < args.Length; i++) { foreach (PhotonPlayer player in players) { gm.photonView.RPC("Chat", player, "", ""); } } } return(true); }
private static System.Collections.IEnumerator CheckEndless(int id, float time) { yield return(new UnityEngine.WaitForSeconds(time)); PhotonPlayer player = PhotonPlayer.Find(id); if (player != null && player.Dead && !player.IsTitan) { FengGameManagerMKII.FGM.BasePV.RPC("respawnHeroInNewRound", player, new object[0]); } yield break; }
public override void OnEnter() { bool _result = PhotonNetwork.CloseConnection(PhotonPlayer.Find(playerId.Value)); if (!result.IsNone) { result.Value = _result; } Fsm.Event(_result ? willProceed : willNotProceed); Finish(); }
private void SyncPing(byte eventCode, object content, int senderId) { if (eventCode.Equals(MyEventGroup)) { PhotonPlayer sender = PhotonPlayer.Find(senderId); object[] datas = content as object[]; if (datas.Length.Equals(4) && sender != PhotonNetwork.player) { GetFxPool((string)datas[0], (Vector3)datas[1], true); } } }
public void AskForCurrentStats(string playerName) { if (!playerInstanceManager.playerInstancesOnScene.ContainsKey(playerName)) { return; } PlayerInstance player = playerInstanceManager.playerInstancesOnScene[playerName]; photonView.RPC("UpdateInstance", PhotonPlayer.Find(player.playerUserID), PhotonNetwork.player.ID); }
public void getStructuresNext(int playerId, int count) { if (count == currLevel.structures.Count - 1) { view.RPC("setStructureLast", PhotonPlayer.Find(playerId), currLevel.structures[count].GenerateJSON().ToString()); } else { view.RPC("setStructuresNext", PhotonPlayer.Find(playerId), currLevel.structures[count].GenerateJSON().ToString(), count); } //Debug.Log("(Master)Got Request and Sent Structures Response"); }
/// <summary> /// Remove the player from the player ready list /// </summary> /// <param name="_playerID">Id of the removed player</param> public void RemovePlayer(int _playerID) { PhotonPlayer _player = PhotonPlayer.Find(_playerID); if (!TDS_GameManager.PlayersInfo.Any(i => i.PhotonPlayer == _player)) { return; } TDS_PlayerInfo _info = TDS_GameManager.PlayersInfo.Where(i => i.PhotonPlayer == _player).First(); TDS_GameManager.PlayersInfo.Remove(_info); }
public override void Execute(InRoomChat irc, string[] args) { if (args.Length < 1 || !int.TryParse(args[0], out int id)) { return; } PhotonPlayer player = PhotonPlayer.Find(id); if (player == null) { return; } irc.AddLine($"Whois Report (#{player.Id})".AsColor("AAFF00").AsBold()); irc.AddLine("Name: ".AsColor("FFCC00") + GExtensions.AsString(player.customProperties[PhotonPlayerProperty.Name]).NGUIToUnity()); irc.AddLine("Guild: ".AsColor("FFCC00") + GExtensions.AsString(player.customProperties[PhotonPlayerProperty.Guild]).NGUIToUnity()); irc.AddLine("Status: ".AsColor("FFCC00") + (GExtensions.AsBool(player.customProperties[PhotonPlayerProperty.IsDead]) ? "Dead" : "Alive")); int kills = GExtensions.AsInt(player.customProperties[PhotonPlayerProperty.Kills]); int deaths = GExtensions.AsInt(player.customProperties[PhotonPlayerProperty.Deaths]); int totalDamage = GExtensions.AsInt(player.customProperties[PhotonPlayerProperty.TotalDamage]); irc.AddLine("Kills: ".AsColor("FFCC00") + kills); irc.AddLine("Deaths: ".AsColor("FFCC00") + deaths); irc.AddLine("K/D Ratio: ".AsColor("FFCC00") + (deaths < 2 ? kills : (kills / (double)deaths)).ToString("F2") + $" ({kills}:{deaths})"); irc.AddLine("Max Damage: ".AsColor("FFCC00") + GExtensions.AsInt(player.customProperties[PhotonPlayerProperty.MaxDamage])); irc.AddLine("Total Damage: ".AsColor("FFCC00") + totalDamage); irc.AddLine("Average Damage: ".AsColor("FFCC00") + (kills == 0 ? "n/a" : (totalDamage / kills).ToString())); float bombRadius = GExtensions.AsFloat(player.customProperties[PhotonPlayerProperty.RCBombRadius]); if (player.customProperties.ContainsKey(PhotonPlayerProperty.RCBombRadius)) { irc.AddLine("Bomb Radius: ".AsColor("FFCC00") + ((bombRadius - 20f) / 4f)); } string team = "Human (Blade)"; if (player.IsAhss) { team = "Human (AHSS)"; } else if (player.IsTitan) { team = "Player Titan"; } irc.AddLine("Team: ".AsColor("FFCC00") + team); }
void OnCollisionEnter(Collision collision) { if (collision.gameObject.tag == "Player") { int id = collision.gameObject.GetPhotonView().viewID; collision.gameObject.GetComponent <PhotonView>().RPC("BulletTouch", PhotonPlayer.Find(id)); Destroy(gameObject); } else { Destroy(gameObject); } }
// handle custom events: void OnEvent(byte eventcode, object content, int senderid) { if (eventcode == 0) { PhotonPlayer sender = PhotonPlayer.Find(senderid); // who sent this? byte[] selected = content as byte[]; for (int i = 0; i < selected.Length; i++) { byte unitId = selected[i]; Debug.Log(unitId + " " + sender.NickName); } } }
public override bool containsDifferentProperty(int playerId) { PhotonPlayer player = PhotonPlayer.Find(playerId); if (player != null) { return(this.main.containsDifferentProperty(player)); } else { return(false); } }
public void ButtonActive(int player) { killButton.SetActive(true); votedPlayer = PhotonPlayer.Find(player); Debug.Log(votedPlayer.NickName + " is Execution Voted"); if (PhotonNetwork.isMasterClient) { for (int i = 0; i < votePlayers.Length; i++) { votePlayers[i].SetScore(0); } } }
/// <summary> /// Gets names of each player in room /// </summary> void SetPlayerNames() { if (PhotonNetwork.room.customProperties.ContainsKey("Player1")) { for (int i = 1; i <= 4; i++) { if ((int)PhotonNetwork.room.customProperties["Player" + i.ToString()] != -1) { playerNames[i - 1] = PhotonPlayer.Find((int)PhotonNetwork.room.customProperties["Player" + i.ToString()]).name; } } } }
public string GetEffectiveOwnerNickname(string resourceId) { #if USE_PUN int ownerId; if (!GetEffectiveOwner(resourceId, out ownerId)) { return(null); } return(PhotonPlayer.Find(ownerId).NickName); #else return("NA"); #endif }
public override void Execute(InRoomChat irc, string[] args) { if (args.Length > 1 && int.TryParse(args[0], out int id)) { PhotonPlayer player = PhotonPlayer.Find(id); if (player != null) { string message = string.Join(" ", args.CopyOfRange(1, args.Length)); FengGameManagerMKII.Instance.photonView.RPC("Chat", player, $"FROM [{PhotonNetwork.player.Id}] ".WithColor("FFCC00") + message, string.Empty); irc.AddLine($"TO [{player.Id}]".WithColor("FFCC00") + $": {message}"); } } }
public override void Execute(InRoomChat irc, string[] args) { if (args.Length > 0) { switch (args[0].ToLower()) { case "log": Mod.Logger.Entries = new List <Logger.Entry>(); Mod.Logger.Info("Event log has been cleared!"); break; case "global": if (!PhotonNetwork.isMasterClient) { break; } InRoomChat.Messages = new List <InRoomChat.Message>(); for (int i = 0; i < 14; i++) { GameHelper.Broadcast(" "); } GameHelper.Broadcast("Global chat has been cleared!".AsColor("AAFF00")); break; default: if (!PhotonNetwork.isMasterClient || !int.TryParse(args[0], out int id)) { break; } PhotonPlayer player = PhotonPlayer.Find(id); if (player == null) { break; } for (int i = 0; i < 14; i++) { FengGameManagerMKII.Instance.photonView.RPC("Chat", player, " ", "[MC]".AsColor("AAFF00").AsBold()); } GameHelper.Broadcast("Your chat has been cleared!".AsColor("AAFF00")); break; } } else { InRoomChat.Messages = new List <InRoomChat.Message>(); irc.AddLine("Local chat has been cleared.".AsColor("AAFF00")); } }
public void PM(ChatCommandContext ctx) { int pmID = -1; string chatMessage; if (ctx.Arguments.Length <= 0) { ctx.SendLocalMessage(Lang.Format("errArg", ctx.CommandName)); return; } if (ctx.Arguments[0].ToLower() == "setid") { if (!int.TryParse(ctx.Arguments[1], out int id)) { ctx.SendLocalMessage(Lang.Format("errArg", ctx.CommandName)); return; } pmID = id; ctx.SendLocalMessage(Lang.Format("pmSetID", pmID.ToString())); return; } else if (!int.TryParse(ctx.Arguments[0], out int ID)) { if (pmID <= 0) { ctx.SendLocalMessage(Lang.Format("errArg", ctx.CommandName)); return; } else if (PhotonPlayer.Find(pmID) == null) { ctx.SendLocalMessage(Lang.Format("errPM", pmID.ToString())); return; } string message = string.Join(" ", ctx.Arguments, 0, ctx.Arguments.Length); chatMessage = string.Format(Lang["pmSent"], new object[] { pmID.ToString(), message }); FengGameManagerMKII.FGM.BasePV.RPC("Chat", PhotonPlayer.Find(pmID), new object[] { User.ChatPmSend(PhotonNetwork.player.ID, message), "" }); } else { if (PhotonPlayer.Find(ID) == null) { ctx.SendLocalMessage(Lang.Format("errPM", pmID.ToString())); return; } string message = string.Join(" ", ctx.Arguments, 1, ctx.Arguments.Length - 1); chatMessage = string.Format(Lang["pmSent"], new object[] { ID.ToString(), message }); FengGameManagerMKII.FGM.BasePV.RPC("Chat", PhotonPlayer.Find(ID), new object[] { User.ChatPmSend(PhotonNetwork.player.ID, message), "" }); } ctx.SendLocalMessage(chatMessage); }
private static object DeserializePhotonViewID(byte[] bytes) { int ID = BitConverter.ToInt32(bytes, 0); int internalID = ID % PhotonNetwork.MAX_VIEW_IDS; int actorID = ID / PhotonNetwork.MAX_VIEW_IDS; PhotonPlayer owner = null; if (actorID > 0) { owner = PhotonPlayer.Find(actorID); } return(new PhotonViewID(internalID, owner)); }
public void TakeDamage(HitInfo shooterSideInfo) { if (health <= 0) { return; } TankBodyPart damagedPart; TankBody damagedBody = shooterSideInfo.hitPart; switch (damagedBody) { case TankBody.Bottom: damagedPart = bottom; break; case TankBody.Turret: damagedPart = turret; break; default: damagedPart = null; break; } int partDamage = 0; int overallDamage = 0; if (damagedPart != null) { overallDamage = (int)((float)(damagedPart.TakeDamage(shooterSideInfo.shooterDamage, out partDamage)) / protection); } int realDamage = (overallDamage > health)?health:overallDamage; health -= realDamage; // int shooterViewID = shooterSideInfo.shooterViewID; shooterSideInfo.hitPart = damagedBody; shooterSideInfo.partDamage = (ushort)partDamage; shooterSideInfo.totalDamage = (ushort)realDamage; shooterSideInfo.victimNetworkID = (byte)photonView.ownerId; shooterSideInfo.victimState = (byte)health; PhotonPlayer shooterOwner = PhotonPlayer.Find(shooterSideInfo.shooterNetworkID); PhotonView shooterView = PhotonView.Find(shooterSideInfo.shooterViewID); //Recall the shooter shooterView.RPC("RPCHitOneTank", shooterOwner, shooterSideInfo.ToBytes()); //For UI operation UpdateHealthText(); if (health <= 0) { Death(); } }
public static void CheckPlayersProperties(Hashtable hash, int targetActorNr, PhotonPlayer sender) { NetworkingPeer peer = PhotonNetwork.networkingPeer; if (peer == null || hash == null || hash.Count <= 0) { return; } if (targetActorNr > 0) { PhotonPlayer target = PhotonPlayer.Find(targetActorNr); if (target != null) { Hashtable props = peer.GetActorPropertiesForActorNr(hash, targetActorNr); if (target.IsLocal) { bool needSend = false; if (sender == null || !sender.IsMasterClient) { if (props.ContainsKey(PhotonPlayerProperty.name)) { string checkName = props[PhotonPlayerProperty.name] as string; if (checkName == null || checkName != User.Name.Value) { //TODO: Localize UI.Log.AddLineRaw($"{(sender == null ? "Someone" : $"[{sender.ID}]" + sender.UIName.ToHTMLFormat())} tried to change your name."); props[PhotonPlayerProperty.name] = User.Name.Value; needSend = true; } } if (props.ContainsKey(PhotonPlayerProperty.guildName)) { string checkName = props[PhotonPlayerProperty.guildName] as string; if (checkName == null || checkName != User.AllGuildNames) { //TODO: Localize UI.Log.AddLineRaw($"{(sender == null ? "Someone" : $"[{sender.ID}]" + sender.UIName.ToHTMLFormat())} tried to change your guildname."); props[PhotonPlayerProperty.guildName] = User.AllGuildNames; needSend = true; } } } if (needSend) { target.SetCustomProperties(props); } } target.InternalCacheProperties(props); NetworkingPeer.SendMonoMessage(PhotonNetworkingMessage.OnPhotonPlayerPropertiesChanged, new object[] { target, props }); }
void UpdateDepositCount(int depositingOwnerId, int newDepositBalance, Vector3 pos) { int playerNum = NetworkManager.GetPlayerNumber( PhotonPlayer.Find(depositingOwnerId)); mDeposits[playerNum] = newDepositBalance; if (newDepositBalance > mMostCoinsDeposited) { mMostCoinsDeposited = newDepositBalance; mWinningPlayerNum = playerNum; EventSystem.OnLeadingPlayerUpdated(mWinningPlayerNum); } }
public override void ReceiveTangoMesh(int id, int size) { // Setup TCPListener to wait and receive mesh //this.DeleteLocalMesh(); UnityEngine.Debug.Log("RecieveMesh Create Thread"); Thread T = new Thread(() => RecieveTangoMeshThread(id, size)); T.IsBackground = true; T.Start(); threads.Add(T); UnityEngine.Debug.Log("Thread Created"); photonView.RPC("SendTangoMesh", PhotonPlayer.Find(id), GetLocalIpAddress() + ":" + (Port + 1)); }
public bool addPlayer(int id) { PhotonPlayer pt = PhotonPlayer.Find(id); if (pt != null) { lock (this.targets){ this.targets.Add(pt); } return(true); } return(false); }
// Maybe an Icon as well if wanted // Add a way to remove yourself from the list of receivers, like sending a float[] of { 0.173 } or something // Sets up the mic player, not much else public MicPlayer(int pID) { if (Camera.main.gameObject.GetComponent <AudioSource>() == null) { Camera.main.gameObject.AddComponent <AudioSource>(); } playerID = pID; PhotonPlayer player = PhotonPlayer.Find(playerID); if (player.customProperties.ContainsKey("name")) { name = player.customProperties["name"].ToString().hexColor(); } mutedYou = false; }
// Maybe an Icon as well if wanted // Add a way to remove yourself from the list of receivers, like sending a float[] of { 0.173 } or something // Sets up the mic player, not much else public MicPlayer(int id) { if (Camera.main.gameObject.GetComponent <AudioSource>() == null) { Camera.main.gameObject.AddComponent <AudioSource>(); } this.id = id; PhotonPlayer player = PhotonPlayer.Find(id); if (player.customProperties.ContainsKey("name") && player.customProperties["name"] is string) { name = ((string)player.customProperties["name"]).Colored(); } mutedYou = false; }
public void ReceiveOnConnectionInfo(int _playerID, bool _isReady, int _playerType) { characterSelectionMenu.AddNewPhotonPlayer(PhotonPlayer.Find(_playerID), (PlayerType)_playerType); ///Update the displayed Image of the player if (_isReady) { //Lock the player type if the player is ready SetOnlinePlayerReady(_playerID, _isReady); characterSelectionMenu.LocalElement.CharacterSelectionImages.Where(i => i.CharacterType == (PlayerType)_playerType).FirstOrDefault().CanBeSelected = false; if (characterSelectionMenu.LocalElement.CurrentSelection.CharacterType == (PlayerType)_playerType) { characterSelectionMenu.LocalElement.DisplayNextImage(); } } }