Пример #1
0
    // Update is called once per frame
    void Update()
    {
        ResetLayout();

        uint uiCost;

        m_bFirstClick = true;
        bool bHasSpell;
        uint uiLevel;

        CCursor oCursor   = GameApp.GetInstance().GetCursor();
        Vector2 vMousePos = oCursor.GetScreenPosition();

        vMousePos.x -= m_rectTitle.x;
        vMousePos.y -= m_rectTitle.y;

        Rect      rectNextEntry = m_rectSpellEntry;
        const int iColMax       = 2;
        const int iRowMax       = 4;

        for (int iCol = 0; iCol < iColMax; ++iCol)
        {
            for (int iRow = 0; iRow < iRowMax; ++iRow)
            {
                int iSpellIndex = (iCol * iRowMax) + iRow;
                // Check for spell ownership
                CSpellData.TSpellData tSpell = m_atSpellData[iSpellIndex];
                if (tSpell.eType == CSpell.EType.INVALID)
                {
                    Debug.Log(tSpell.eType.ToString());
                    // continue
                    // Note continue didnt work so I had to group it in this else block
                }
                else
                {
                    bHasSpell = m_oSpellBook.HasSpell(tSpell.eType);

                    if (bHasSpell)
                    {
                        uiLevel = m_oSpellBook.GetSpell(tSpell.eType).GetUpgradedLevel();
                        uiCost  = tSpell.uiUpgradeCost + uiLevel;
                    }
                    else
                    {
                        //sSpellDesc = "";
                        uiCost  = tSpell.uiBuyCost;
                        uiLevel = 0;
                    }

                    if (rectNextEntry.Contains(vMousePos))
                    {
                        if (Input.GetMouseButtonUp(0))
                        {
                            if (m_oSpellBook.HasSpell(tSpell.eType))
                            {
                                UpgradeSpell(tSpell.eType, uiCost);
                            }
                            else
                            {
                                PurchaseSpell(tSpell.eType, uiCost);
                            }
                        }
                    }

                    rectNextEntry.y += 132;                     // height offset
                }
            }

            rectNextEntry.x += 365;             // width offset
            rectNextEntry.y  = m_rectSpellEntry.y;
        }
    }
Пример #2
0
    void OnGUI()
    {
        GUI.skin.font = m_fStandard;

        // Title
        GUI.DrawTexture(m_rectTitle, m_TitleTexture);

        GUILayout.BeginArea(m_rectTitle);

        Rect rectNextEntry      = m_rectSpellEntry;
        Rect rectNextSpellTitle = m_rectSpellTitle;
        Rect rectNextSpellIcon  = m_rectSpellIcon;
        Rect rectNextSpellCost  = m_rectSpellCost;
        Rect rectNextSpellDesc  = m_rectSpellDesc;

        CCursor oCursor   = GameApp.GetInstance().GetCursor();
        Vector2 vMousePos = oCursor.GetScreenPosition();

        vMousePos.x -= m_rectTitle.x;
        vMousePos.y -= m_rectTitle.y;

        bool bHasSpell;
        //string sSpellDesc;
        uint uiCost;
        uint uiLevel;

        const int iColMax = 2;
        const int iRowMax = 4;

        for (int iCol = 0; iCol < iColMax; ++iCol)
        {
            for (int iRow = 0; iRow < iRowMax; ++iRow)
            {
                int iSpellIndex = (iCol * iRowMax) + iRow;
                // Check for spell ownership
                CSpellData.TSpellData tSpell = m_atSpellData[iSpellIndex];
                if (tSpell.eType == CSpell.EType.INVALID)
                {
                    Debug.Log(tSpell.eType.ToString());
                    // continue
                    // Note continue didnt work so I had to group it in this else block
                }
                else
                {
                    bHasSpell = m_oSpellBook.HasSpell(tSpell.eType);

                    if (bHasSpell)
                    {
                        uiLevel = m_oSpellBook.GetSpell(tSpell.eType).GetUpgradedLevel();
                        uiCost  = tSpell.uiUpgradeCost + uiLevel;
                    }
                    else
                    {
                        //sSpellDesc = "";
                        uiCost  = tSpell.uiBuyCost;
                        uiLevel = 0;
                    }

                    GUI.DrawTexture(rectNextEntry, m_SpellEntry);

                    // Show Desc here
                    GUI.Label(rectNextSpellDesc, "Lv: " + uiLevel + Environment.NewLine + tSpell.sDescription);



                    if (rectNextEntry.Contains(vMousePos))
                    {
                        if (oCursor.IsMouseDown())
                        {
                            GUI.DrawTexture(rectNextEntry, m_SpellEntry_Selected);
                        }
                        else
                        {
                            GUI.DrawTexture(rectNextEntry, m_SpellEntry_MouseOver);
                        }
                        if (Input.GetMouseButtonUp(0) && m_bFirstClick)
                        {
//							if(m_oSpellBook.HasSpell(tSpell.eType))
//							{
//								UpgradeSpell(tSpell.eType, uiCost);
//							}
//							else
//							{
//								//PurchaseSpell(tSpell.eType, uiCost);
//							}
//
//							 m_bFirstClick = false;
                        }

                        // Show Buy/Upgrade Desc here

                        if (bHasSpell)
                        {
                            GUI.Label(rectNextSpellDesc, "Lv: " + uiLevel + " -> " + (uiLevel + 1) + Environment.NewLine + m_oSpellBook.GetSpell(tSpell.eType).GetShopUpgradeDetails());
                        }
                        else
                        {
                            GUI.Label(rectNextSpellDesc, "Lv: " + uiLevel + " -> " + (uiLevel + 1) + Environment.NewLine + tSpell.sShopDetails);
                        }
                    }

                    GUI.DrawTexture(rectNextSpellTitle, tSpell.tNameTexture);

                    // Text Spell titles
                    GUI.skin.font = m_fXXLarge;
                    Rect rectLabel = rectNextSpellTitle;
                    rectLabel.y      -= 5;
                    rectLabel.height += 5;
                    GUI.Label(rectLabel, tSpell.sTitle);
                    GUI.skin.font = m_fStandard;

                    GUI.DrawTexture(rectNextSpellIcon, tSpell.tTexture);
                    GUI.DrawTexture(rectNextSpellIcon, m_tSpellFrame);


                    GUI.DrawTexture(rectNextSpellCost, m_tCrystalCost);
                    Rect rectSpellCost = rectNextSpellCost;
                    rectSpellCost.x += 35;
                    rectSpellCost.y += 6;

                    GUI.skin.font = m_fXLarge;
                    GUI.Label(rectSpellCost, uiCost.ToString());
                    GUI.skin.font = m_fStandard;


                    rectNextEntry.y      += 132;                // height offset
                    rectNextSpellTitle.y += 132;
                    rectNextSpellIcon.y  += 132;
                    rectNextSpellCost.y  += 132;
                    rectNextSpellDesc.y  += 132;
                }
            }

            rectNextEntry.x += 365;             // width offset
            rectNextEntry.y  = m_rectSpellEntry.y;

            rectNextSpellTitle.x += 365;             // width offset
            rectNextSpellTitle.y  = m_rectSpellTitle.y;

            rectNextSpellIcon.x += 365;             // width offset
            rectNextSpellIcon.y  = m_rectSpellIcon.y;

            rectNextSpellCost.x += 365;             // width offset
            rectNextSpellCost.y  = m_rectSpellCost.y;

            rectNextSpellDesc.x += 365;             // width offset
            rectNextSpellDesc.y  = m_rectSpellDesc.y;
        }

        GUI.skin.font = m_fXXLarge;
        GUI.Label(m_rectOwnedCrystals, m_oWarlockCurrency.Get().ToString());

        Rect rTime = m_rectOwnedCrystals;

        rTime.x -= 200;
        //GUI.Label(rTime, CSceneArena.m_kfShoppingDuration.ToString());
        GUI.Label(rTime, GameApp.GetInstance().GetSceneArena().GetShopTimer().ToString());

        GUILayout.EndArea();



        GUI.skin.font = m_fLarge;
    }