コード例 #1
0
        public void Logout(string email)
        {
            var ptc = new LogoutProtocol();

            ptc.Email = email;
            var packet = new BasicPacket();

            packet.Opcode = 99;
            packet.Data   = ptc.ToBytes();
            _client.Write(packet.ToBytes());
        }
コード例 #2
0
    void MakeWindow(int id)
    {
        Functions.DrawBackground(new Rect(0, 0, width, height), bgTexture);

        GUIStyle style = new GUIStyle(GUI.skin.label);

        style.alignment = TextAnchor.UpperCenter;
        style.font      = font;
        style.fontSize  = 16;

        GUI.Label(new Rect((windowRect.width - 100) / 2, 0, 100, 30), "Convergence Game", style);
        if (GUI.Button(new Rect(windowRect.width - 100 - bufferBorder, 0, 100, 30), "Logout"))
        {
            NetworkManager.Send(LogoutProtocol.Prepare(0), ProcessLogout);
        }

        GUI.BeginGroup(new Rect(bufferBorder, 0, windowRect.width, 100));
        style.alignment = TextAnchor.LowerLeft;
        style.fontSize  = 14;
        GUI.Label(new Rect(0, 0, 300, 30), "Select Ecosystem:", style);
        GUI.SetNextControlName("ecosystem_idx_field");
        int new_idx;

        new_idx = GUI.SelectionGrid(new Rect(0, 35, windowRect.width - 20, 30), ecosystem_idx,
                                    ecosysDescripts, ecosysDescripts.Length);
        GUI.EndGroup();
        if (!isProcessing && new_idx != ecosystem_idx)
        {
            //Debug.Log ("Updating selected ecosystem.");
            SetIsProcessing(true);
            new_ecosystem_idx = new_idx;
            new_ecosystem_id  = GetEcosystemId(new_ecosystem_idx);
            GetPriorAttempts();
        }
        if (graphs != null)
        {
            graphs.DrawGraphs();
        }

        GUIStyle styleEdit = new GUIStyle(GUI.skin.textArea);

        styleEdit.wordWrap = true;

        //data entry fields
        DrawParameterFields(style);

        if (isInitial && GUI.GetNameOfFocusedControl() == "")
        {
            GUI.FocusControl("ecosystem_idx_field");
            isInitial = false;
        }

        string buttonTitle = isProcessing ? "Processing" : "Submit";

        if (!(isProcessing && !blinkOn))
        {
            if (GUI.Button(new Rect(bufferBorder, height - 30 - bufferBorder, 100, 30), buttonTitle) &&
                !isProcessing)
            {
                //make sure new config is distinct from prior attempts and initial value
                currAttempt.UpdateConfig();                   //update config based on user data entry changes
                ConvergeAttempt prior = attemptList.Find(entry => entry.config == currAttempt.config);
                if (prior == null && currAttempt.ParamsUpdated())
                {
                    Submit();
                    SetIsProcessing(true);
                }
                else if (!showPopup)
                {
                    int prior_idx = attemptList.FindIndex(entry => entry.config == currAttempt.config);
                    if (prior_idx == Constants.ID_NOT_SET)
                    {
                        popupMessage = "Duplicate configuration to initial ecosystem.  Please try again.";
                    }
                    else
                    {
                        popupMessage = "Duplicate configuration to prior attempt (#" + (prior_idx + 1) + ").  Please try again.";
                    }
                    //Debug.Log (popupMessage);
                    showPopup = true;
                }
            }
        }

        if (GUI.Button(new Rect(bufferBorder + 110, height - 30 - bufferBorder, 110, 30), "Progress Report"))
        {
            GenerateBarGraph();
        }

        int screenOffset = 0;

        if (currAttempt != null && currAttempt.allow_hints)
        {
            screenOffset += bufferBorder + 110;
            if (GUI.Button(new Rect(bufferBorder * 2 + 110 * 2, height - 30 - bufferBorder, 110, 30), "Get Hint"))
            {
                //only give new hint if one hasn't been provided during this session.
                if (currAttempt.hint_id == Constants.ID_NOT_SET)
                {
                    int hintId = GetRandomHint(true);
                    if (hintId == Constants.ID_NOT_SET)
                    {
                        popupMessage = "Sorry, no new hints are available.";
                    }
                    else
                    {
                        popupMessage        = hintDict[hintId];
                        currAttempt.hint_id = hintId;
                    }
                }
                else
                {
                    if (hintDict.ContainsKey(currAttempt.hint_id))
                    {
                        popupMessage = hintDict[currAttempt.hint_id] + "\n[Only one hint is provided per attempt.]";
                    }
                    else
                    {
                        Debug.LogError("Invalid hint for current attempt, ID = " + currAttempt.hint_id);
                        popupMessage = "Error, hint not available.";
                    }
                }
                if (priorHintIdList.Count > 0)
                {
                    popupMessage += "\n\nPrior Hints:";
                }
                for (int i = 0; i < priorHintIdList.Count; i++)
                {
                    popupMessage += "\n\n" + hintDict[priorHintIdList[i]];
                }
                //Debug.Log (popupMessage);
                showPopup = true;
            }
        }

        DrawResetButtons(screenOffset, style);
    }