Пример #1
0
    /// <summary>
    /// Current game status
    /// Game map
    /// isStarted?
    /// </summary>
    /// <param name="value">Incoming message</param>
    private void OnGame_Status(string[] value)
    {
        SNet_Network.Game_Status readMessage = SNet_Network.SNetMessage.ReadMessage <SNet_Network.Game_Status>(value[0]);
        readMessage.s = ulong.Parse(value[1]);

        if (!SNet_Network.instance.isHost(readMessage.s))
        {
            return; // only host can send this
        }
        if (mapIsLoading)
        {
            return; // Map is currently loading. Wait for finish.
        }
        Button_levelSelector.captionText.text = readMessage.l;

        GameObject sGame = panel_Lobby.transform.Find("back").Find("StartGame").gameObject;

        if (!sGame.activeSelf)
        {
            sGame.SetActive(true);
        }

        if (!gameStatus.iS && readMessage.iS)
        {
            sGame.GetComponentInChildren <Text>().text = "Stop Game";
            panel_Lobby.Open(false);
            panel_Game.Open(true);
        }

        if (gameStatus.iS && !readMessage.iS)
        {
            sGame.GetComponentInChildren <Text>().text = "Start Game";
            panel_Game.Open(false);
            panel_Lobby.Open(true);
        }

        if (readMessage.iS)
        {
            /*
             * LOAD LEVEL ASYNC
             * */
            if (gameStatus == null || gameStatus.iS != readMessage.iS || gameStatus.l != readMessage.l)
            {
                Debug.Log("Loading: " + readMessage.l);
                StartCoroutine(LoadYourAsyncScene(readMessage.l));
            }

            /*
             * */
        }
        else if (mapLoaded)
        {
            UnloadLevel();
        }

        gameStatus = readMessage;
    }
Пример #2
0
    // Use this for initialization
    private void Awake()
    {
        gameStatus = new SNet_Network.Game_Status(); // Reset the game status

        if (instance != null)
        {
            SNet_Auth.Init();
            Destroy(gameObject);
            return;
        }

        gameObject.name = "SteamManager";

        // This will always remain.
        DontDestroyOnLoad(gameObject);

        panel_Loading.Open();
        instance         = this;
        nextMemberUpdate = Time.time + 1;

        ///Register the main handlers

        SNet_Network.RegisterHandler("Spawn", OnSpawn);
        SNet_Network.RegisterHandler("Spawn_Request", OnSpawn_Request);
        SNet_Network.RegisterHandler("Spawn_Player", OnSpawn_Player);
        SNet_Network.RegisterHandler("Spawn_Item", OnSpawn_Item);
        SNet_Network.RegisterHandler("Game_Status", OnGame_Status);
        SNet_Network.RegisterHandler("Destroyed", OnDestroyed);
        SNet_Network.RegisterHandler("Impact", OnImpact);
        SNet_Network.RegisterHandler("A_Bool", OnA_Bool);
        SNet_Network.RegisterHandler("A_Float", OnA_Float);
        SNet_Network.RegisterHandler("A_Trigger", OnA_Trigger);
        SNet_Network.RegisterHandler("A_Int", OnA_Int);
        SNet_Network.RegisterHandler("RB", OnRB);
        SNet_Network.RegisterHandler("Pos", OnPos);
        SNet_Network.RegisterHandler("Rot", OnRot);
        SNet_Network.RegisterHandler("IS", OnIS);
        SNet_Network.RegisterHandler("PlayerItem", OnPlayerItem);
        SNet_Network.RegisterHandler("EquipItem", OnEquipItem);
        SNet_Network.RegisterHandler("A", OnA);
        SNet_Network.RegisterHandler("St", OnSt);
        SNet_Network.RegisterHandler("Health", OnHealth);
        SNet_Network.RegisterHandler("UserHit", OnUserHit);
        SNet_Network.RegisterHandler("Exploded", OnExploded);
        SNet_Network.RegisterHandler("V", OnV);
        SNet_Network.RegisterHandler("Interact", OnInteract);
        SNet_Network.RegisterHandler("VI", OnVI);
        SNet_Network.RegisterHandler("VH", OnVH);
        SNet_Network.RegisterHandler("CSRequest", OnCSRequest);
    }
Пример #3
0
    void UnloadLevel()
    {
        Debug.Log("Unloading level.");

        /// Free the camera
        MouseOrbitImproved.instance.target = null;
        MouseOrbitImproved.instance.transform.SetParent(null);
        ///

        mapLoaded  = false;
        gameStatus = new SNet_Network.Game_Status();
        panel_Lobby.transform.Find("back").Find("StartGame").GetComponentInChildren <Text>().text = "Start Game";
        StartCoroutine(LoadYourAsyncScene("Empty", true));

        /*
         * Empty scene is used for finishing the game and return to lobby. But lobby must remain. We cannot load Game scene again so here is 'Empty'
         * */
    }