示例#1
0
 public static void callOnGuiEvent(Events.GUI message)
 {
     if (OnGuiEvent != null)
     {
         Console.Log("[Gui Event]:" + message.ToString());
         OnGuiEvent(message);
     }
 }
示例#2
0
    /*void OnGUI()
     * {
     * buttonNum = 0;
     * OnGuiDrawConsole();
     * //OnGuiDrawNetMenu();
     * }*/

    public void GuiEvent(Events.GUI message)
    {
        bool messageSucses = false;

        switch (message)
        {
        case Events.GUI.SERVER_MENU:
            if (nsm.menuState == NetworkState.newInstance)
            {
                nsm.menuState = NetworkState.host_menu;
                messageSucses = true;
            }
            break;

        case Events.GUI.START_SERVER:
            if (nsm.menuState == NetworkState.host_menu)
            {
                netInstance = new Server(nsm, this, Settings.Player.roomname);
                netInstance.Init();
                messageSucses = true;
            }
            break;

        case Events.GUI.MENU_SERVERLIST:
            if (nsm.menuState == NetworkState.newInstance)
            {
                netInstance = new Client(nsm, this);
                netInstance.Init();
                nsm.menuState = NetworkState.client1;
                messageSucses = true;
            }
            break;

        case Events.GUI.BACK:
            if (nsm.menuState == NetworkState.host_menu)
            {
                nsm.menuState = NetworkState.newInstance;
                messageSucses = true;
            }
            if (nsm.menuState == NetworkState.host_lobby)
            {
                netInstance.Close();
                nsm.menuState = NetworkState.newInstance;
                netInstance   = null;
                messageSucses = true;
            }
            if (nsm.menuState == NetworkState.client1)
            {
                nsm.menuState = NetworkState.newInstance;
                messageSucses = true;
            }
            if (nsm.menuState == NetworkState.client2)
            {
                nsm.menuState = NetworkState.newInstance;
                netInstance.Close();
                messageSucses = true;
            }
            break;

        case Events.GUI.REFRESH:
            if (nsm.menuState == NetworkState.client1)
            {
                RefreshHostList();
                messageSucses = true;
            }
            break;
        }
        if (!messageSucses)
        {
            Debug.LogError("NetEvent state error - current state: " + nsm.menuState + " - event: " + message.ToString());
        }
        else
        {
            Debug.Log("NetEvent - current state: " + nsm.menuState + " - event: " + message.ToString());
        }
    }