Пример #1
0
    public override void OnJoinedLobby()
    {
        networkState = NetworkState.Connected;

        gameSession = FindObjectOfType <CrironaSession>();
        if (gameSession)
        {
            gameSession.OnJoinedLobby();
        }
    }
Пример #2
0
    public override void OnServerCreated()
    {
        // Create game session
        CrironaSession oldSession = FindObjectOfType <CrironaSession>();

        if (oldSession == null)
        {
            GameObject serverSession = Instantiate(CrironaSessionPrefab);
            NetworkServer.Spawn(serverSession);
        }
        else
        {
            Debug.LogError("GameSession already exists");
        }
    }
Пример #3
0
    public override void OnStartClient()
    {
        if (instance)
        {
            Debug.LogError("ERROR: Another GameSession");
        }

        instance = this;

        networkListener             = FindObjectOfType <CrironaExampleListener>();
        networkListener.gameSession = this;

        _networkTransmitter = GetComponent <CrironaNetworkTransmitter>();

        if (gameState != CrironaState.Lobby)
        {
            gameState = CrironaState.Lobby;
        }
    }
Пример #4
0
    void OnGUI()
    {
        if (isLocalPlayer)
        {
            GUILayout.BeginArea(new Rect(0, Screen.height * 0.7f, Screen.width, 100));
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            CrironaSession gameSession = CrironaSession.instance;
            if (gameSession)
            {
                if (gameSession.gameState == CrironaState.Lobby)// || gameSession.gameState == CrironaState.Countdown)
                {
                    //if (GUILayout.Button(IsReady() ? "Not ready" : "Ready", GUILayout.Width(Screen.width * 0.3f), GUILayout.Height(100)))
                    //if (IsReady())
                    //SendNotReadyToBeginMessage();
                    //else
                    SendReadyToBeginMessage();
                }

                else if (gameSession.gameState == CrironaState.WaitForLocationSync)
                {
                    if (isServer && locationSent == false)
                    {
                        gameSession.CmdSendWorldMap();
                        locationSent = true;
                    }
                }
                else if (gameSession.gameState == CrironaState.Game)
                {
                }
            }

            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            GUILayout.EndArea();
        }
    }