// Use this for initialization
 void Start()
 {
     PhotonNetwork.ConnectUsingSettings();
     //PhotonNetwork.ConnectToRegion("cn");
     _lobbyUiController = GetComponent <LobbyUIController>();
     _lobbyUiController.LobbyInit();
 }
Beispiel #2
0
    private void Awake()
    {
        // sprite list load
        abilitySpriteList = Resources.LoadAll <Sprite>("UI/AbilityIcons");

        instance = this;
    }
Beispiel #3
0
    public void SetLobbyUI()
    {
        if (createlobbyUI == null)
        {
            Debug.LogError("UIManager CreateIngameUI is Null !!");
            return;
        }

        if (lobbyUI == null)
        {
            GameObject go = Instantiate(createlobbyUI, transform);
            lobbyUI = go.GetComponent <LobbyUIController>();
        }

        if (inGameUI != null)
        {
            inGameUI.gameObject.SetActive(false);
        }

        if (loadingUI != null)
        {
            loadingUI.gameObject.SetActive(false);
        }

        lobbyUI.gameObject.SetActive(true);
        lobbyUI.OnInitialized();

        SetMainCanvasScale(lobbyUI.GetComponent <CanvasScaler>());
    }
Beispiel #4
0
 void OnLevelWasLoaded(int levelNum)
 {
     if (levelNum == 1)
     {
         lobbyUI        = FindObjectOfType <LobbyUIController>();
         lobbyUI.client = this;
     }
 }
Beispiel #5
0
        // Use this for initialization
        void Awake()
        {
            Debug.Log(PhotonNetwork.InLobby + "  Room" + PhotonNetwork.InRoom);

            PhotonNetwork.ConnectUsingSettings();
            //PhotonNetwork.ConnectToRegion("cn");
            _lobbyUiController = GetComponent <LobbyUIController>();
            _lobbyUiController.LobbyInit();
        }
 // Start is called before the first frame update
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else
     {
         Destroy(gameObject);
     }
 }
Beispiel #7
0
 void Start()
 {
     backgroundMusic = GetComponent <AudioSource>();
     instance        = this;
 }
    void updateRooms()
    {
        // check each room thats not the lobby
        for (int roomIndex = 1; roomIndex < rooms.Count; ++roomIndex)
        {
            Room room = rooms[roomIndex];
            List <PlayerState> playersInRoom = rooms[roomIndex].players;

            //if game not going
            if (room.countdownTimer > 0)
            {
                // check if all players are ready
                bool allReady = true;
                for (int i = 0; i < playersInRoom.Count; ++i)
                {
                    if (!playersInRoom[i].ready)
                    {
                        allReady = false;
                        break;
                    }
                }
                if (allReady && playersInRoom.Count >= 2)
                {
                    int btime = (int)(room.countdownTimer + 1);
                    room.countdownTimer -= Time.deltaTime;
                    int ptime = (int)(room.countdownTimer + 1);
                    if (ptime != btime)
                    {
                        if (ptime == 0)
                        {
                            generateAndSendStartPackets(roomIndex);
                        }
                        else
                        {
                            Packet cdPacket = new Packet(PacketType.GAME_COUNTDOWN);
                            cdPacket.Write(ptime);
                            broadcastPacket(cdPacket, roomIndex);
                        }
                    }
                }
                else
                {
                    room.countdownTimer = 5.0f;
                }
                continue;
            }

            // find number of alive players in this room (also check for winner while your at it)
            PlayerState winner   = null;
            int         numAlive = 0;
            for (int i = 0; i < playersInRoom.Count; ++i)
            {
                if (playersInRoom[i].alive)
                {
                    ++numAlive;
                    winner = playersInRoom[i];
                }
            }
            if (numAlive <= 1)   // if either of these then game is over
            {
                Packet gpacket = new Packet(PacketType.GAME_END);
                string message = "";
                if (numAlive == 0)
                {
                    message = LobbyUIController.getTextWithColor("It's a Draw!", Color.yellow);
                }
                else
                {
                    message = LobbyUIController.getTextWithColor(winner.name, winner.color) + " Wins!";
                }
                gpacket.Write(message);
                broadcastPacket(gpacket, roomIndex);

                for (int i = 0; i < playersInRoom.Count; ++i)
                {
                    Debug.Log("SERVER: moving " + playersInRoom[i].name + " back to lobby");
                    movePlayerToRoom(playersInRoom[i], 0); // move them back to lobby
                }
                --roomIndex;                               // a room got removed from room list so do this
                continue;
            }

            // else game still going so send state updates
            Packet updatePacket = new Packet(PacketType.STATE_UPDATE);
            updatePacket.Write(numAlive);
            // send positions of other alive players in room
            for (int i = 0; i < playersInRoom.Count; ++i)
            {
                if (playersInRoom[i].alive)
                {
                    updatePacket.Write(playersInRoom[i].id);
                    updatePacket.Write(playersInRoom[i].pos);
                }
            }
            // send out packet to all players in room
            broadcastPacket(updatePacket, roomIndex);
        }
    }
Beispiel #9
0
 public void init(LobbyUIController lui, Transform parent)
 {
     lobbyUI = lui;
     rt.SetParent(parent, false);
 }