Inheritance: NetworkBehaviour
Esempio n. 1
0
    public override void OnStartLocalPlayer()
    {
        Debug.Log("OnStartLocalPlayer");

        SetupLocalPlayer();
		SendAvatarInfo ();

		MyPlayer = this;
    }
Esempio n. 2
0
    public void AddPlayer(LobbyPlayer player)
    {
        _players.Add(player);

        player.transform.SetParent(playerListContentTransform, false);
        addButtonRow.transform.SetAsLastSibling();

        PlayerListModified();
    }
    private WaitForSeconds m_StartWait; // Used to have a delay whilst the round starts.

    #endregion Fields

    #region Methods

    // int playerNum, Color c, string name, int localID);
    /// <summary>
    /// Add a player from the lobby hook
    /// </summary>
    /// <param name="player">The actual GameObject instantiated by the lobby, which is a NetworkBehaviour</param>
    /// <param name="lobbyPlayer">The Lobby Player</param>
    /// lp.slot, lp.playerColor, lp.nameInput.text, lp.playerControllerId
    public static void AddPlayer(GameObject player, LobbyPlayer lobbyPlayer)
    {
        PlayMakerSanPlayerManager tmp = new PlayMakerSanPlayerManager();
        tmp.m_Instance = player;
        tmp.m_PlayerNumber = lobbyPlayer.playerControllerId;
        tmp.m_PlayerColor = lobbyPlayer.playerColor;
        tmp.m_PlayerName = lobbyPlayer.nameInput.name;
        tmp.m_LocalPlayerID = lobbyPlayer.playerControllerId;
        tmp.Setup();

        m_Players.Add(tmp);
    }
Esempio n. 4
0
 // Set artifact tree
 public static Coroutine SetArtifactInventory(LobbyPlayer player, ArtifactInventory inv)
 {
     return GameDB.instance.StartCoroutine(GameDB.Set<ArtifactInventory>(
         "AccountToArtifactInventory",
         player.accountId,
         inv,
         data => {
             if(data == null)
                 Lobby.RPC("ArtifactInventorySaveError", player.peer);
             else
                 player.artifactInventory = data;
         }
     ));
 }
Esempio n. 5
0
    // --------------------------------------------------------------------------------
    // AccountToArtifactInventory
    // --------------------------------------------------------------------------------
    // Get artifact inventory
    public static Coroutine GetArtifactInventory(LobbyPlayer player)
    {
        return GameDB.instance.StartCoroutine(GameDB.Get<ArtifactInventory>(
            "AccountToArtifactInventory",
            player.accountId,
            data => {
                if(data == null) {
                    player.artifactInventory = new ArtifactInventory();
                } else {
                    player.artifactInventory = data;
                }

                Lobby.RPC("ReceiveArtifactInventory", player.peer, player.accountId, Jboy.Json.WriteObject(player.artifactInventory));
            }
        ));
    }
Esempio n. 6
0
    // Get artifact tree
    public static Coroutine GetArtifactTree(LobbyPlayer player)
    {
        return GameDB.instance.StartCoroutine(GameDB.Get<ArtifactTree>(
            "AccountToArtifactTree",
            player.accountId,
            data => {
                if(data == null) {
                    player.artifactTree = ArtifactTree.GetStarterArtifactTree();
                } else {
                    player.artifactTree = data;
                }

                Lobby.RPC("ReceiveArtifactTree", player.peer, player.accountId, Jboy.Json.WriteObject(player.artifactTree));
            }
        ));
    }
Esempio n. 7
0
 // Called when this Client receives the 'SetLocalPlayer' message.
 private void SetLocalPlayer(NetworkMessage networkMessage)
 {
     myPlayer = networkMessage.ReadMessage <LobbyPlayer>();
 }
Esempio n. 8
0
 protected virtual UserFormSubmission Vote(LobbyPlayer player)
 {
     return(CommonSubmissions.SubmitSingleSelector(player.UserId));
 }
Esempio n. 9
0
 public void RemovePlayer(LobbyPlayer player)
 {
     player.RemovePlayer();
 }
    private void RemoveLocalPlayer(int player)
    {
        LobbyPlayer lobbyPlayer = GameObject.Find("LobbyPlayer (" + player + ")").GetComponent <LobbyPlayer>();

        lobbyPlayer.RemovePlayer();
    }
Esempio n. 11
0
    public static void AddPlayer(GameObject playerGo, LobbyPlayer lobbyPlayer, LobbyPlayerParam param)
    {
        UIDebug.Log("AddPlayer Slot:{0} isLocalPlayer:{1} RoleName:{2} Instance:{3}", param.Slot, param.isLocalPlayer, param.RoleName, Instance);

        PLAYER_LIST.Add(new PlayerManager(playerGo, param.Slot, param.RoleName, param.RoleColor));
    }
Esempio n. 12
0
    void ClientChat(string channelName, string msg, LobbyMessageInfo info)
    {
        LobbyPlayer player = LobbyServer.GetLobbyPlayer(info);

        // Command?
        if (ProcessLobbyChatCommands(player, msg))
        {
            LogManager.Chat.Log("Lobby chat command: [" + channelName + "][" + player.name + "] '" + msg + "'");
            return;
        }

        // Add instance to channel name
        if (channelName == "Map")
        {
            if (player.canUseMapChat)
            {
                var instance = player.instance;

                if (instance == null)
                {
                    LogManager.Chat.LogError("Player instance is null on [" + channelName + "][" + player.name + "] '" + msg + "'");
                    return;
                }

                var postfix = instance.node.publicAddress + ":" + instance.port;
                channelName += "@" + postfix;
            }
            else
            {
                LogManager.Chat.LogError("Player tries to use map chat while not being in an instance [" + channelName + "][" + player.name + "] '" + msg + "'");
                LogManager.Chat.LogError(player.gameInstance.ToString());
                return;
            }
        }

        // Log all chat tries
        LogManager.Chat.Log("[" + channelName + "][" + player.name + "] '" + msg + "'");

        // Access level?
        if (channelName == "Announcement" && player.accessLevel < AccessLevel.CommunityManager)
        {
            LogManager.Chat.LogError("Player tried to chat in announcement channel without having the rights for it!");
            return;
        }

        // Does the channel exist?
        if (!LobbyChatChannel.channels.ContainsKey(channelName))
        {
            LogManager.Chat.LogError(string.Format("Channel '{0}' does not exist in the global channel list!", channelName));
            return;
        }

        var channel = LobbyChatChannel.channels[channelName];

        // Channel member?
        if (!channel.members.Contains(player))
        {
            LogManager.Chat.LogError(string.Format("Player '{0}' is not a member of chat channel '{1}'!", player.name, channelName));
            return;
        }

        // Broadcast message
        channel.BroadcastMessage(player.name, msg);
    }
 public override void OnLobbyServerSceneLoadedForPlayer(NetworkManager manager, GameObject lobbyPlayer, GameObject gamePlayer)
 {
     LobbyPlayer lobby = lobbyPlayer.GetComponent <LobbyPlayer>();
 }
Esempio n. 14
0
 public void AddPlayer(LobbyPlayer player)
 {
     player.transform.SetParent(playerListContentTransform, false);
 }
Esempio n. 15
0
 protected virtual UserFormSubmission MakePrompt(LobbyPlayer player)
 {
     return(CommonSubmissions.SubmitSingleText(player.UserId));
 }
Esempio n. 16
0
 public void RemovePlayer(LobbyPlayer player)
 {
     _players.Remove(player);
     PlayerListModified();
 }
    void Start()
    {
        //setContent Holder Height;
        content.sizeDelta = new Vector2(0, LobbyManager.s_Singleton.numPlayers * 120);

        for (int i = 0; i < LobbyManager.s_Singleton.lobbySlots.Length; ++i)
        {
            LobbyPlayer p = LobbyManager.s_Singleton.lobbySlots[i] as LobbyPlayer;

            if (p != null)
            {
                //Altezza dello slot del playerResult
                float spawnY = i * 120;

                //Nuova posizione dello slot
                Vector3 pos = new Vector3(0, -spawnY, spawnPoint.position.z);

                //Spawnato uno slot player
                GameObject playerSlot = Instantiate(playerResult, pos, spawnPoint.rotation) as GameObject;

                playerSlot.transform.SetParent(spawnPoint, false);

                playerSlot.GetComponentsInChildren <Text>()[0].text = i + 1 + ".";
                playerSlot.transform.GetComponentsInChildren <Image>()[1].sprite = p.imgMiniature.sprite;
                playerSlot.GetComponentsInChildren <Text>()[1].text = p.txtPlayerName.text;
                playerSlot.GetComponentsInChildren <Text>()[2].text = p.globalCharacterScore + "";
            }
        }
        //foreach (LobbyPlayer lp in LobbyManager.s_Singleton.lobbySlots)
        //{
        //    if (lp != null)
        //    {
        //        lp.isReady = false;
        //        Debug.Log("messo falso");
        //    }
        //}

        //GameObject lm = GameObject.FindGameObjectWithTag("LobbyManager");
        //Debug.Log("lobbyslots trovati: " );
        //foreach (GameObject player in lobbyPlayers)
        //{
        //    if (!player.GetComponent<NetworkIdentity>().isLocalPlayer)
        //        Debug.Log("ciao vez");
        //}
        // For the host to do: use the timer and control the time.

        foreach (GameObject go in GameObject.FindGameObjectsWithTag("Player"))
        {
            if (go.GetComponent <SwipeDetector>() != null)
            {
                go.GetComponent <SwipeDetector>().enabled = false;
            }
            if (go.GetComponent <ChubbyTummySwipeDetector>() != null)
            {
                go.GetComponent <ChubbyTummySwipeDetector>().enabled = false;
            }
        }

        GameObject toDeleteButton = GameObject.Find("FireButton");

        if (toDeleteButton != null)
        {
            toDeleteButton.SetActive(false);
        }
        toDeleteButton = GameObject.Find("JumpButton");
        if (toDeleteButton != null)
        {
            toDeleteButton.SetActive(false);
        }
    }
Esempio n. 18
0
 /// <summary>
 /// Get the layer bitmask associated to a specific player.
 /// Used to filter out things that can only be seen by a given player (such as HUD, ecc.)
 /// </summary>
 public static int GetPlayerLayerBitmask(LobbyPlayer player)
 {
     return(1 << GetPlayerLayer(player));
 }
Esempio n. 19
0
 /// <summary>
 /// Get the layer associated to a specific player.
 /// Used to filter out things that can only be seen by a given player (such as HUD, ecc.)
 /// </summary>
 public static int GetPlayerLayer(LobbyPlayer player)
 {
     return(LayerMask.NameToLayer(string.Format("Player{0}Only", player.player_index + 1)));
 }
Esempio n. 20
0
 protected virtual UserFormSubmission MakeDrawing(LobbyPlayer player)
 {
     return(CommonSubmissions.SubmitSingleDrawing(player.UserId, Drawings[Rand.Next(Drawings.Count)]));
 }
Esempio n. 21
0
 /// <summary>
 /// Called whenever a player score changes.
 /// </summary>
 private void OnPlayerScore(LobbyPlayer lobby_player)
 {
     text_mesh.text = string.Format("{0:0000}", lobby_player.score);
 }
Esempio n. 22
0
 void Start()
 {
     lobbyPlayer = GetComponentInParent <Player>().lobbyPlayer;
     textMesh    = GetComponent <TextMesh>();
 }
Esempio n. 23
0
 public void AddPlayer( LobbyPlayer player ) {
     player.transform.position = new Vector3( 0, 0, 0 );
     player.transform.SetParent( playerListContentTransform, false );
 }
Esempio n. 24
0
 public void SetLobbyPlayer(LobbyPlayer lp)
 {
     lobbyPlayer = lp;
     LobbyTeam = lp.MyTeam;
 }
Esempio n. 25
0
 // Remove player
 public void RemovePlayer(LobbyPlayer player)
 {
     playerList.Remove(player);
     player.queue = null;
 }
Esempio n. 26
0
 public void RemovePlayer(LobbyPlayer player)
 {
     _players.Remove(player);
     PlayerListModified();
 }
Esempio n. 27
0
 public override void OnStartClient()
 {
     base.OnStartClient();
     lobbyPlayer = GetComponent <LobbyPlayer>();
 }
Esempio n. 28
0
 public override void OnStartLocalPlayer()       //2 - if local player
 {
     Me = this;
     CmdPlayerName(Data.PlayerName);
 }
Esempio n. 29
0
 /// <summary>
 /// Create our lobby object
 /// </summary>
 private void CreateLobbyObject()
 {
     LobbyObject = Instantiate(_lobbyPrefab).GetComponent <LobbyPlayer>();
     LobbyObject.Init(this);
 }
Esempio n. 30
0
 protected virtual UserFormSubmission Query(LobbyPlayer player, int numSliders)
 {
     return(CommonSubmissions.SubmitSliders(player.UserId, range: true, numSliders: numSliders));
 }
Esempio n. 31
0
 public void SetLobbyPlayer(LobbyPlayer player)
 {
     _lobbyPlayer = player;
 }
Esempio n. 32
0
 public void Load(LobbyPlayer player)
 {
     PlayerColorImage.color = player.isLocalPlayer ? LocalColor : OtherColor;
     PlayerNameText.text    = player.PlayerName;
     CheckImage.enabled     = player.readyToBegin;
 }
Esempio n. 33
0
 public LobbyData(LobbyPlayer copyFrom)
 {
     Name  = copyFrom.name;
     Color = copyFrom.playerColor;
 }
Esempio n. 34
0
 protected virtual UserFormSubmission MakeDrawing(LobbyPlayer player)
 {
     return(CommonSubmissions.SubmitSingleDrawing(player.UserId));
 }
 public override void OnLobbyServerSceneLoadedForPlayer(UnityEngine.Networking.NetworkManager manager,
                                                        GameObject lobbyPlayer, GameObject gamePlayer)
 {
     LobbyPlayer I = lobbyPlayer.GetComponent <LobbyPlayer> ();
     //PlayerBoard playerB = gamePlayer.GetComponent<PlayerBoard> ();
 }
Esempio n. 36
0
 IEnumerator PositionPlayers(LobbyPlayer instance)
 {
     instance.transform.SetParent(lobbyPlayerListPanel, false);
     yield return(new WaitForEndOfFrame());
 }
Esempio n. 37
0
 public static void RegisterNewClient(LobbyPlayer newClient)
 {
     newClient.transform.SetParent(_instance.clientsContent, false);
 }
Esempio n. 38
0
 protected virtual UserFormSubmission Vote(LobbyPlayer player, UserPrompt prompt)
 {
     return(CommonSubmissions.SubmitSingleRadio(player.UserId, Rand.Next(prompt.SubPrompts[0].Answers.Length)));
 }
Esempio n. 39
0
    void ProcessLobbyMessage(LobbyMessage lobbyMessage, IPEndPoint remoteEndPoint)
    {
        if (lobbyMessage.requestRoomList)
        {
            if (lobby != null && lobby.isMaster && lobbyState == LobbyState.InLobby)
            {
                BroadcastLobby();
            }
        }
        else if (lobbyMessage.startGame && lobbyState == LobbyState.InLobby)
        {
            if (lobbyMessage.senderGuid == lobby.master.guid)
            {
                StartGame();
                NotifyStartGame();
            }
        }
        else if (lobbyMessage.startGame && lobbyState == LobbyState.InGame && lobby.isMaster)
        {
            var targetPlayer = lobby.players.Find(item => item.guid == lobbyMessage.senderGuid);
            if (targetPlayer != null)
            {
                targetPlayer.started = true;
            }
            CheckReady();
        }
        else if (lobby != null && lobby.isMaster) // I am the lobby master
        {
            if (lobbyMessage.masterGuid != guidStr)
            {
                return;
            }

            if (lobbyMessage.iWantToJoin)
            {
                var targetPlayer = lobby.players.Find(item => item.guid == lobbyMessage.senderGuid);
                if (targetPlayer == null && lobby.players.Count < MAX_PLAYER_COUNT)
                {
                    targetPlayer = new LobbyPlayer {
                        guid     = lobbyMessage.senderGuid,
                        endPoint = new IPEndPoint(remoteEndPoint.Address, lobbyMessage.myPort), isMaster = false
                    };
                    lobby.players.Add(targetPlayer);
                    NotifyJoinSuccess(targetPlayer);
                    ThreadSafeLog(string.Format("player on {0} joined.", targetPlayer.endPoint));
                }
            }
        }
        else if (lobbyState == LobbyState.NoLobby) // then I'm just a guest player
        {
            if (lobbyMessage.iWantToJoin == false)
            {
                var targetLobby = lobbyList.Find(item => item.master.guid == lobbyMessage.senderGuid);
                if (targetLobby == null)
                {
                    var newLobby = new Lobby
                    {
                        currentCount = lobbyMessage.currentPlayerCount,
                        maxCount     = lobbyMessage.maxPlayerCount,
                        isMaster     = false,
                        master       = new LobbyPlayer {
                            guid = lobbyMessage.senderGuid, endPoint = new IPEndPoint(remoteEndPoint.Address, lobbyMessage.myPort), isMaster = true
                        }
                    };
                    lobbyList.Add(newLobby);
                    ThreadSafeLog("Found lobby on " + newLobby.master.endPoint.ToString());
                    if (autoJoin)
                    {
                        RequestJoinLobby(newLobby);
                    }
                }
                else if (targetLobby.master.guid == lobbyMessage.senderGuid)
                {
                    targetLobby.currentCount = lobbyMessage.currentPlayerCount;
                    if (lobbyMessage.joinStatus == 1)
                    {
                        lobby      = targetLobby;
                        master     = lobby.master;
                        lobbyState = LobbyState.InLobby;
                        ThreadSafeLog("Successfully joined lobby: " + lobby.master.endPoint.ToString());
                    }
                }
            }
        }
    }
Esempio n. 40
0
 public void RpcResetUserUI(LobbyPlayer player)
 {
 }
    public void AddPlayer(LobbyPlayer player)
    {
        //if(HomePlayerListTransform.childCount > AwayPlayerListTransform.childCount)
          //  player.transform.SetParent(AwayPlayerListTransform, false);
        //else
		player.UI.SetParent(HomePlayerListTransform, false);
    }
Esempio n. 42
0
 public void RemovePlayer(LobbyPlayer player)
 {
     player.RemovePlayer();
 }
Esempio n. 43
0
 public override void OnStartLocalPlayer()
 {
     me = this;
     CmdSendIdentity(Data.playerName);
 }
Esempio n. 44
0
 void UpdatePlayers(string playerStr)
 {
     players.Clear();
     string[] plStr = playerStr.Split(new char[]{'\n'});
     int dataSegmentPerPlayer = 3;
     for (int i = 0; i < plStr.Length / dataSegmentPerPlayer; i++) {
         LobbyPlayer newPlayer = new LobbyPlayer();
         bool parseOk = int.TryParse (plStr[dataSegmentPerPlayer * i], out newPlayer.clientID);
         if (!parseOk) {
             Debug.Log ("Couldn't parse ClientID " + plStr[dataSegmentPerPlayer * i]);
         }
         if (newPlayer.clientID == localClientID) {
             newPlayer.isLocalPlayer = true;
             localPlayerIndex = i;
         }
         else { /* NOP */ }
         newPlayer.name = plStr[dataSegmentPerPlayer * i + 1];
         newPlayer.isReady = String2Bool(plStr[dataSegmentPerPlayer * i + 2]);
         players.Add(newPlayer);
     }
 }
Esempio n. 45
0
    // Unity editor calls this to make sure the inputs in the editor are correct
    void OnValidate()
    {
        if (minPlayers < 0)
        {
            minPlayers = 0;
        }

        if (minPlayers > maxPlayers)
        {
            minPlayers = maxPlayers;
        }

        if (m_LobbyPlayerPrefab != null)
        {
            var uv = m_LobbyPlayerPrefab.GetComponent<NetworkIdentity>();
            if (uv == null)
            {
                m_LobbyPlayerPrefab = null;
                Debug.LogWarning("LobbyPlayer prefab must have a NetworkIdentity component.");
            }
        }

        if (m_GamePlayerPrefab != null)
        {
            var uv = m_GamePlayerPrefab.GetComponent<NetworkIdentity>();
            if (uv == null)
            {
                m_GamePlayerPrefab = null;
                Debug.LogWarning("GamePlayer prefab must have a NetworkIdentity component.");
            }
        }
    }
Esempio n. 46
0
 void Start()
 {
     image = GetComponent<Image>();
     lobbyPlayer = GetComponentInParent<LobbyPlayer>();
 }
Esempio n. 47
0
 // Set artifact tree
 public static Coroutine SetArtifactTree(LobbyPlayer player, ArtifactTree tree)
 {
     return GameDB.instance.StartCoroutine(GameDB.Set<ArtifactTree>(
         "AccountToArtifactTree",
         player.accountId,
         tree,
         data => {
             if(data == null)
                 Lobby.RPC("ArtifactTreeSaveError", player.peer);
             else
                 player.artifactTree = data;
         }
     ));
 }
Esempio n. 48
0
 void Start()
 {
     lobbyPlayer = GetComponentInParent<Player>().lobbyPlayer;
     textMesh = GetComponent<TextMesh>();
 }
 void Start()
 {
     text        = GetComponent <Text>();
     lobbyPlayer = GetComponentInParent <LobbyPlayer>();
 }
Esempio n. 50
0
 void Start()
 {
     text = GetComponent<Text>();
     lobbyPlayer = GetComponentInParent<LobbyPlayer>();
 }
Esempio n. 51
0
    private void Lobby_MemberJoined(object sender, MemberEventArgs e) {
      Dispatcher.Invoke(() => {
        var invitee = e.Member as LobbyInvitee;
        var member = e.Member as CustomLobbyMember;

        if (member != null) {
          StackPanel stack;

          if (member.Team == 0) stack = BlueTeam;
          else if (member.Team == 1) stack = RedTeam;
          else throw new Exception("UNEXPECTED TEAM");

          var player = new LobbyPlayer(member);
          stack.Children.Add(player);

          if (e.Member.IsMe) {
            RedJoin.Visibility = BlueJoin.Visibility = Visibility.Collapsed;
            if (member.Team != 0) BlueJoin.Visibility = Visibility.Visible;
            if (member.Team != 1) RedJoin.Visibility = Visibility.Visible;
          }

          Sort();
        } else {
          var player = new InvitedPlayer(invitee);
          InviteList.Children.Add(player);
        }
      });
    }