示例#1
0
        public bool HostGame(string _matchID, GameObject _player, bool publicMatch, out int playerIndex, int maxPlayers, Match.MatchType matchType)
        {
            playerIndex = -1;
            Debug.Log("estoy llamando HOST GAME");

            if (!matchIDs.Contains(_matchID))
            {
                matchIDs.Add(_matchID);
                Match match = new Match(_matchID, _player, publicMatch, maxPlayers, matchType);
                matches.Add(match);
                Debug.Log($"Match generated");
                _player.GetComponent <PlayerNetwork>().currentMatch = match;

                for (int i = 0; i < matches.Count; i++)
                {
                    if (matches[i].matchID == _matchID)
                    {
                        roomListManager.FillListHost(matches[i].players.ToArray(), _matchID);
                    }
                }

                playerIndex = 1;
                return(true);
            }
            else
            {
                Debug.Log($"Match ID already exists");
                return(false);
            }
        }
    public void UCE_ExploreArea()
    {
        if (UCE_myExploration && UCE_myExploration.explorationRequirements.isActive && UCE_myExploration.explorationRequirements.checkRequirements(this))
        {
            // -- explore the area

            if (!UCE_exploredAreas.Contains(UCE_myExploration.name))
            {
                UCE_exploredAreas.Add(UCE_myExploration.name);

                UCE_myExploration.explorationRewards.gainRewards(this);

                var msg = UCE_myExploration.explorePopup.message + UCE_myExploration.name;
                UCE_ShowPopup(msg, UCE_myExploration.explorePopup.iconId, UCE_myExploration.explorePopup.soundId);
                UCE_MinimapSceneText(UCE_myExploration.name);
                fTimerCache = NetworkTime.time + fTimerInterval;

                // -- show notice if already explored
            }
            else if (UCE_myExploration.noticeOnEnter)
            {
                if (NetworkTime.time <= fTimerCache)
                {
                    return;
                }
                var msg = UCE_myExploration.enterPopup.message + UCE_myExploration.name;
                UCE_ShowPopup(msg, UCE_myExploration.enterPopup.iconId, UCE_myExploration.enterPopup.soundId);
                UCE_MinimapSceneText(UCE_myExploration.name);
                fTimerCache = NetworkTime.time + fTimerInterval;
            }
        }
    }
示例#3
0
    private void RpcPlayersFree()
    {
        // Se guarda en una variable los jugadores que hay en el mapa.
        GameObject[] players = GameObject.FindGameObjectsWithTag("Player");

        // Recorre cada jugador del vector de jugadores....
        foreach (GameObject player in players)
        {
            // Lee las variables isSending y isBusy de cada jugador... si es un jugador en modo activo, se añade a la lista.
            if (player.GetComponent <PlayerCode>().IsSending() && !player.GetComponent <PlayerCode>().IsBusy())
            {
                if (!playerFree.Contains(player.GetComponent <PlayerCode>().GetName()))
                {
                    // Se añade a la lista....
                    playerFree.Add(player.GetComponent <PlayerCode>().GetName());
                }
            }
            else
            // Lee las variables isSending y isBusy de cada jugador... si es un jugador en modo ocupado o desocupado, se elimina de la lista.
            {
                if (playerFree.Contains(player.GetComponent <PlayerCode>().GetName()))
                {
                    // Se elimina de la lista....
                    playerFree.Remove(player.GetComponent <PlayerCode>().GetName());
                }
            }
        }
    }
示例#4
0
    // Ésta función crea botones con el nombre de las salas activas.
    private void CreateButtons()
    {
        // Buscará el GameObject CallManager en la escena. Ya que es el encargado de gestionar el tema de los nombres de los jugadores que tienen o no abierta una sala de streaming.
        GameObject CallManager = GameObject.FindGameObjectWithTag("CallManager");
        // Mediante la función GetListFree creada en el script CallManager del GameObject del mismo nombre, se obtiene una lista de nombres correspondientes a los jugadores que tienen una sala activada.
        SyncListString namesFree = CallManager.GetComponent <CallManager>().GetListFree();

        // Mediante este bucle for, se añade a cada jugador con su sala abierta, una posición en la lista de streaming abiertos.
        for (int i = 0; i < namesFree.Count; i++)
        {
            // Si el nombre obtenido de la lista, no es el propio, no aparecerá en la lista (ya que no tiene sentido meterse en una sala de streaming que ha creado uno mismo)
            if (!namesFree.Contains(selfPlayer.GetComponent <PlayerCode>().GetName()))
            {
                // Crea un botón con la una de las posiciones de los vectores inicializados anteriormente.
                buttons[i] = (GameObject)Instantiate(Button, SpawnButton[i], Quaternion.identity);
                // Asigna la posición del vector de manera relativa a la posición de la lista dentro de la lista de streaming activos
                buttons[i].transform.SetParent(StreamingPanel.transform, false);
                // Muestra el botón
                buttons[i].SetActive(true);
                // El botoón tendrá el nombre del jugador que ha creado la sala. De modo que si se presione sobre ese bótón, la función que realizará la entrada a la sala
                // recibirá como parámetro de entrada el nombre del botón. Ya que, a la hora de crear las salas de streaming, estas se crean un nombre que las identifica de las demas. Este nombre no es otro que el nombre del jugador que crea la sala
                GameObject name = buttons[i].transform.Find("Nombre").gameObject;
                name.GetComponent <UnityEngine.UI.Text>().text = namesFree[i].ToString();
            }
        }
    }
示例#5
0
    public void Update()
    {
        // Mediante esta función la lista de streaming activos se actualizará incluso cuando esté abierta. De modo que en el momento de abrirla si alguna sala se cierra
        // por alguna razón, desaparecerá su botón correspondiente de la lista automáticamente.

        // Si la lista de streaming está abierta.....
        if (StreamingPanel.activeSelf)
        {
            // Se hace una comprobación de los nombres de los jugadores que tienen abierta su sala.
            GameObject     CallManager = GameObject.FindGameObjectWithTag("CallManager");
            SyncListString namesFree   = CallManager.GetComponent <CallManager>().GetListFree();
            for (int i = 0; i < buttons.Length; i++)
            {
                if (buttons[i] != null)
                {
                    nombre = buttons[i].transform.Find("Nombre").gameObject;
                    // Si el nombre de algún jugador de la lista ya no se encuentra dentro de la variable namesFree, desaparecerá su botón.
                    if (!namesFree.Contains(nombre.GetComponent <UnityEngine.UI.Text>().text))
                    {
                        Destroy(buttons[i]);
                    }
                }
            }
        }
    }
 public bool HostGame(string _matchID, GameObject _player, out int playerIndex)
 {
     playerIndex = -1;
     if (!matchIDs.Contains(_matchID))
     {
         matchIDs.Add(_matchID);
         matches.Add(new Match(_matchID, _player));
         Debug.Log($"Match generated");
         playerIndex = 1;
         return(true);
     }
     else
     {
         Debug.Log($"Match ID already exists");
         return(false);
     }
 }
示例#7
0
        public bool HostGame(string _matchID, GameObject _player, bool publicMatch, out int playerIndex)
        {
            playerIndex = -1;

            if (!matchIDs.Contains(_matchID))
            {
                matchIDs.Add(_matchID);
                Match match = new Match(_matchID, _player, publicMatch);
                matches.Add(match);
                Debug.Log($"Match generated");
                _player.GetComponent <Player> ().currentMatch = match;
                playerIndex = 1;
                return(true);
            }
            else
            {
                Debug.Log($"Match ID already exists");
                return(false);
            }
        }
示例#8
0
 // Boolean mikä vaatii peliIdn, ja pelaajan. Varmistetaan että peliIdtä
 // ei ole olemassa ja lisätään listaan peleistä tämä uusi peli;
 public bool HostGame(string _peliID, GameObject _pelaaja, bool publicMatch, out int playerIndex)
 {
     playerIndex = -1;
     if (!(matchIDs.Contains(_peliID)))
     {
         //Lisätään matchId listaan tämän pelin match id
         matchIDs.Add(_peliID);
         //luodaan uusi match käyttäen tätä peliidtä ja pelaajaa
         Match match = new Match(_peliID, _pelaaja);
         //Asetetaan bool klikatun matsin perusteella private false, public true
         match.publicMatch = publicMatch;
         // lisätään meidän peli listaan peleistä
         matches.Add(match);
         Debug.Log("Match generated");
         playerIndex = 1;
         return(true);
     }
     else
     {
         Debug.Log("Match id already exists");
         return(false);
     }
 }
示例#9
0
    // Check a specific finding is in a specific location.
    public bool findingContains(string finding, Location location)
    {
        bool contains = false;

        switch (location)
        {
        case Location.core:
            contains = coreFindings.Contains(finding);
            break;

        case Location.extremity:
            contains = extremityFindings.Contains(finding);
            break;
        }

        return(contains);
    }
示例#10
0
文件: PlayerHub.cs 项目: Glaze96/INO
    /// <summary>
    /// Removes player from the playerlist
    /// </summary>
    /// <param Connection ID of the PLayer="connectionId"></param>
    public void RemovePlayer(int idNumber)
    {
        Player player = GetPlayer(idNumber);

        // Add name back into pool
        _namePool.Add(player.Id.Name);
        _activeIdNumbers.Remove(idNumber);

        // If found player, remove it
        if (_playerUserIdList.Contains(player.Id.FullId))
        {
            _playerUserIdList.Remove(player.Id.FullId);
        }
        else
        {
            Debug.LogError("HUB - TRYING TO REMOVE, BUT CANNOT FIND: " + player.Id.FullId);
        }

        Debug.Log("HUB - FOUND AND REMOVED: " + player.Id.FullId);
    }
    private void Update()
    {
        if (isLocalPlayer)
        {
            if (_choosePlayerMode)
            {
                if (Input.GetKeyDown(KeyCode.UpArrow))
                {
                    SelectPlayer();
                }
            }
            else if (_inputMode)
            {
                string input = Input.inputString;
                if (!input.Equals("\n") && !input.Equals("\b"))
                {
                    _tmpMessage += input;
                }

                if (input.Equals("\b"))
                {
                    RemoveLastChar();
                }

                _text.text = _tmpMessage + "_";
            }
            else if (_inputNameMode)
            {
                string input = Input.inputString;
                if (!input.Equals("\n") && !input.Equals("\b"))
                {
                    _tmpMessage += input;
                }

                if (input.Equals("\b"))
                {
                    RemoveLastChar();
                }

                _playerName.text = _tmpMessage + "_";
            }
            else if (Input.GetAxis("Horizontal") != 0 || Input.GetAxis("Vertical") != 0)
            {
                transform.position += Time.deltaTime * speed *
                                      (Vector3.right * Input.GetAxis("Horizontal") +
                                       Vector3.up * Input.GetAxis("Vertical"));
            }


            if (Input.GetKeyDown(KeyCode.Return))
            {
                if (_choosePlayerMode)
                {
                    if (!_autorizedNameList.Contains(_list[_playerIndex].GetComponent <SimpleController>()._name))
                    {
                        CmdAddAuthorizationList(_list[_playerIndex].GetComponent <SimpleController>()._name);
                        _listName.color = Color.green;
                    }
                    else
                    {
                        CmdRemoveAutorizationList(_list[_playerIndex].GetComponent <SimpleController>()._name);
                        _listName.color = Color.red;
                    }
                }
                else if (_inputMode)
                {
                    _inputMode = !_inputMode;
                    RemoveLastChar();
                    CmdPrintText(Compress(Encrypt(_tmpMessage)));
                    _tmpMessage = "";
                }
                else if (_inputNameMode)
                {
                    _inputNameMode = !_inputNameMode;
                    RemoveLastChar();
                    CmdChangeName(_tmpMessage);
                    _tmpMessage = "";
                }
                else
                {
                    _inputMode = !_inputMode;
                }
            }

            if (Input.GetKeyDown(KeyCode.Tab))
            {
                OpenClosePlayerList();
            }
        }
    }