Exemplo n.º 1
0
    public int Show()
    {
        if (forceToUnShow)
        {
            forceToUnShow = false;
            isClickedComboButton = false;
        }

        bool done = false;
        int controlID = GUIUtility.GetControlID(FocusType.Passive);

        switch (Event.current.GetTypeForControl(controlID))
        {
            case EventType.mouseUp:
                {
                    if (isClickedComboButton)
                    {
                        done = true;
                    }
                }
                break;
        }

        if (GUI.Button(rect, buttonContent, buttonStyle))
        {
            if (useControlID == -1)
            {
                useControlID = controlID;
                isClickedComboButton = false;
            }

            if (useControlID != controlID)
            {
                forceToUnShow = true;
                useControlID = controlID;
            }
            isClickedComboButton = true;
        }

        if (isClickedComboButton)
        {
            Rect listRect = new Rect(rect.x, rect.y + listStyle.CalcHeight(listContent[0], 1.0f) + 3,
                      rect.width, listStyle.CalcHeight(listContent[0], 1.0f) * listContent.Length + 20);

            GUI.Box(listRect, "", boxStyle);
            int newSelectedItemIndex = GUI.SelectionGrid(listRect, selectedItemIndex, listContent, 1, listStyle);
            if (newSelectedItemIndex != selectedItemIndex)
            {
                selectedItemIndex = newSelectedItemIndex;
                buttonContent = listContent[selectedItemIndex];

                perso = PlayerManager._instance.GetDefaultStats(buttonContent.text.ToString());
                useControlID = -1;
            }
        }
        if (done)
        {
            isClickedComboButton = false;
            useControlID = -1;
        }

        return selectedItemIndex;
    }
Exemplo n.º 2
0
 public void ResetContent()
 {
     buttonContent = listContent[0];
     perso = PlayerManager._instance.GetDefaultStats(buttonContent.text.ToString());
 }
Exemplo n.º 3
0
    private static void doCreateWindow(int windowID)
    {
        GUI.BringWindowToFront(windowID);
        // Ornament
        GUI.DrawTexture(new Rect(20, 4, 31, 40), ColoredGUISkin.Skin.customStyles[0].normal.background);

        GUILayout.Space(30);
        GUILayout.BeginHorizontal();

        GUILayout.BeginVertical();
        GUILayout.FlexibleSpace();
        GUILayout.Label("Nom:", ColoredGUISkin.Skin.label);
        GUILayout.FlexibleSpace();
        GUILayout.EndVertical();

        GUI.SetNextControlName("name");
        GUI.FocusControl("name");
        characName = GUILayout.TextField(characName, 12, ColoredGUISkin.Skin.textField, GUILayout.MaxWidth(185)).Replace("\n", "");
        GUILayout.EndHorizontal();
        GUILayout.BeginHorizontal();

        GUILayout.BeginVertical();
        GUILayout.FlexibleSpace();
        GUILayout.Label("Classe:", ColoredGUISkin.Skin.label);
        GUILayout.FlexibleSpace();
        GUILayout.EndVertical();

        cb.SelectedItemIndex = cb.Show();
        perso = cb.GetStats();

        GUILayout.BeginVertical();
        GUILayout.BeginHorizontal();
        GUI.DrawTexture(new Rect(15.0f, 145f, 32, 32), listIcons[0], ScaleMode.StretchToFill, true, 0.0f);  // Health
        GUI.Label(new Rect(50.0f, 150f, 32, 32), ": " + perso.Health);
        GUI.DrawTexture(new Rect(115.0f, 145f, 32, 32), listIcons[1], ScaleMode.StretchToFill, true, 0.0f); // Magic
        GUI.Label(new Rect(150.0f, 150f, 32, 32), ": " + perso.Magic);
        GUILayout.EndHorizontal();
        GUILayout.BeginHorizontal();
        GUI.DrawTexture(new Rect(15.0f, 185f, 32, 32), listIcons[2], ScaleMode.StretchToFill, true, 0.0f);  // Watk
        GUI.Label(new Rect(50.0f, 190f, 32, 32), ": " + perso.PhysAtk);
        GUI.DrawTexture(new Rect(115.0f, 185f, 32, 32), listIcons[3], ScaleMode.StretchToFill, true, 0.0f); // Wdef
        GUI.Label(new Rect(150.0f, 190f, 32, 32), ": " + perso.PhysDef);
        GUILayout.EndHorizontal();
        GUILayout.BeginHorizontal();
        GUI.DrawTexture(new Rect(15.0f, 220f, 32, 32), listIcons[4], ScaleMode.StretchToFill, true, 0.0f);  // Matk
        GUI.Label(new Rect(50.0f, 225f, 32, 32), ": " + perso.MagicAtk);
        GUI.DrawTexture(new Rect(115.0f, 220f, 32, 32), listIcons[5], ScaleMode.StretchToFill, true, 0.0f); // Mdef
        GUI.Label(new Rect(150.0f, 225f, 32, 32), ": " + perso.MagicDef);
        GUILayout.EndHorizontal();
        GUILayout.EndVertical();

        sprite1 = ResourceManager.GetSprite(perso.ClassName, 1);
        sprite2 = ResourceManager.GetSprite(perso.ClassName, 2);

        GUILayout.BeginHorizontal();
        GUILayout.BeginArea(new Rect(200f, 165f, 150, 150));
        GUI.DrawTexture(new Rect(20f, 10f, 50, 50), sprite1, ScaleMode.StretchToFill, true, 0.0f);
        GUILayout.EndArea();
        GUILayout.BeginArea(new Rect(270f, 165f, 150, 150));
        GUI.DrawTexture(new Rect(60f, 10f, 50, 50), sprite2, ScaleMode.StretchToFill, true, 0.0f);
        GUILayout.EndArea();
        GUILayout.EndHorizontal();

        GUILayout.EndHorizontal();
        GUILayout.Space(100);
        GUILayout.BeginHorizontal();
        GUI.enabled = characName.Trim() != "";

        if (GUILayout.Button("Créer", GUILayout.Height(37)))
        {
            // Create the character
            characClass = contents[cb.SelectedItemIndex].text;

            if (PlayerManager._instance.SendCreateCharacter(characName, characClass))
            {
                wantToCreate = false;
                PlayerManager._instance._characNames.Add(characName);
                onMainMenu.tabCharac = PlayerManager._instance._characNames;
                characName = "";
                cb.ResetContent();
                error = false;
            }
            else
            {
                error = true;
            }
        }
        GUI.enabled = true;
        if (error)
        {
            lblError.normal.textColor = Color.red;
            GUI.Label(new Rect(rectCreate.width / 2 + (rectCreate.width * 0.03f), rectCreate.height / 2 - 53, 200, 40),
                "Ce nom est invalide ou déjà utilisé", lblError);
        }
        else
        {
            GUI.Label(new Rect(rectCreate.width / 2 + (rectCreate.width * 0.03f), rectCreate.height / 2 - 50, 100, 40),
                "", lblError);
        }

        if (GUILayout.Button("Annuler", GUILayout.Height(37)))
        {
            wantToCreate = false;
            characName = "";
            cb.ResetContent();
            error = false;
        }
        GUILayout.EndHorizontal();
    }
Exemplo n.º 4
0
 public Personnages GetStats()
 {
     if (perso == null)
         perso = PlayerManager._instance.GetDefaultStats(listContent[0].text.ToString());
     return perso;
 }
Exemplo n.º 5
0
        public static Personnages returnPersonnage(string nom)
        {
            Personnages personnage = new Personnages();

            OracleConnection conn = Connection.getInstance().conn;
            OracleCommand sqlSelect = conn.CreateCommand();

            sqlSelect.CommandText = "GESTIONJEU.GETPERSONNAGE";
            sqlSelect.CommandType = CommandType.StoredProcedure;

            OracleParameter refCursor = new OracleParameter(":perso", OracleDbType.RefCursor);
            refCursor.Direction = ParameterDirection.ReturnValue;
            sqlSelect.Parameters.Add(refCursor);

            OracleParameter paramGUID = new OracleParameter(":characterID", OracleDbType.Int32);
            paramGUID.Value = getGUID(nom);
            paramGUID.Direction = ParameterDirection.Input;
            sqlSelect.Parameters.Add(paramGUID);

            OracleDataReader read = sqlSelect.ExecuteReader();


            while (read.Read())
            {
                personnage.Nom = read.GetString(0);
                personnage.Xp = read.GetInt32(1);
                personnage.Level = read.GetInt32(2);
                personnage.ClassName = read.GetString(3);
                personnage.Health = read.GetInt32(4);
                personnage.PhysAtk = read.GetInt32(5);
                personnage.PhysDef = read.GetInt32(6);
                personnage.MagicAtk = read.GetInt32(7);
                personnage.MagicDef = read.GetInt32(8);
            }
            read.Close();

            return personnage;
        }