Find() публичный статический Метод

Try to get a specific player by id.
public static Find ( int ID ) : PhotonPlayer,
ID int ActorID
Результат PhotonPlayer,
Пример #1
0
        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);
            }
        }
Пример #2
0
    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());
    }
Пример #3
0
        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();
        }
Пример #4
0
        public override void SendTangoRoomInfo(int id)
        {
            string data = "";

            if (TangoDatabase.Rooms.Count > 0)
            {
                data = TangoDatabase.GetAllRooms();
            }

            photonView.RPC("RecieveTangoRoomInfo", PhotonPlayer.Find(id), data);
        }
Пример #5
0
    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);
    }
Пример #6
0
        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;
        }
Пример #7
0
        public override void OnEnter()
        {
            bool _result = PhotonNetwork.CloseConnection(PhotonPlayer.Find(playerId.Value));

            if (!result.IsNone)
            {
                result.Value = _result;
            }

            Fsm.Event(_result ? willProceed : willNotProceed);
            Finish();
        }
Пример #8
0
 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);
         }
     }
 }
Пример #9
0
    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);
    }
Пример #10
0
 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");
 }
Пример #11
0
    /// <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);
    }
Пример #12
0
        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);
        }
Пример #13
0
 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);
     }
 }
Пример #14
0
 // 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);
         }
     }
 }
Пример #15
0
    public override bool containsDifferentProperty(int playerId)
    {
        PhotonPlayer player = PhotonPlayer.Find(playerId);

        if (player != null)
        {
            return(this.main.containsDifferentProperty(player));
        }
        else
        {
            return(false);
        }
    }
Пример #16
0
 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);
         }
     }
 }
Пример #17
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;
             }
         }
     }
 }
Пример #18
0
    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
    }
Пример #19
0
 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}");
         }
     }
 }
Пример #20
0
        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"));
            }
        }
Пример #21
0
        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);
        }
Пример #22
0
    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));
    }
Пример #23
0
    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();
        }
    }
Пример #24
0
        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 });
                }
Пример #25
0
        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));
        }
Пример #27
0
    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;
    }
Пример #29
0
    // 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;
    }
Пример #30
0
 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();
         }
     }
 }