Exemple #1
0
    void Start()
    {
        Application.runInBackground = true;


        m_cSpellData = gameObject.AddComponent(typeof(CSpellData)) as CSpellData;
        gameObject.AddComponent(typeof(CFogSystem));
        m_cTerrian = gameObject.AddComponent(typeof(GlobalTerrain)) as GlobalTerrain;

        m_fFont = Resources.Load("Fonts/NewRocker-Large") as Font;
    }
Exemple #2
0
    void OnGUI()
    {
        // Draw the back
        GUI.DrawTexture(UnityGUIExt.CreateRect(0, 0, 800, 188,
                                               UnityGUIExt.GUI_ALLIGN.BOT_CENTRE,
                                               UnityGUIExt.GUI_ALLIGN.BOT_CENTRE), m_GameHUD);

        int iBorderWidth  = 50;
        int iBorderHeight = 50;
        int iOffset       = 2;
        int iIconStartX   = -100;
        int iIconStartY   = 57;

        // Draw the spells
        Rect rectSpellIcon = UnityGUIExt.CreateRect(iIconStartX, iIconStartY, iBorderWidth, iBorderHeight,
                                                    UnityGUIExt.GUI_ALLIGN.BOT_CENTRE,
                                                    UnityGUIExt.GUI_ALLIGN.BOT_CENTRE);

        int        iStartX = (int)rectSpellIcon.x;
        int        iCol    = 0;
        int        iSpell  = 0;
        CSpellData cData   = GameApp.GetInstance().GetSpellDataComponent();

        string[] asKeys = new string[(int)ESettings.SPELLS_MAX];
//		asKeys[0] = "1";
//		asKeys[1] = "2";
//		asKeys[2] = "3";
//		asKeys[3] = "4";
//		asKeys[4] = "Q";
//		asKeys[5] = "W";
//		asKeys[6] = "E";
//		asKeys[7] = "R";

        asKeys[0] = " Q";
        asKeys[1] = " W";
        asKeys[2] = " E";
        asKeys[3] = " R";
        asKeys[4] = " A";
        asKeys[5] = " S";
        asKeys[6] = " D";
        asKeys[7] = " F";

        foreach (CSpell spell in m_acSpellBook)
        {
            if (spell == null)
            {
                continue;
            }

            if (spell.GetSpellType() == CSpell.EType.INVALID)
            {
                continue;
            }

            CSpellData.TSpellData tSpell = cData.GetSpellData(spell.GetSpellType());

            string sSpellDesc = tSpell.sTitle + Environment.NewLine +
                                "Level: " + GetSpell(spell.GetSpellType()).GetUpgradedLevel() + Environment.NewLine +
                                tSpell.sDescription;

            GUI.DrawTexture(rectSpellIcon, cData.GetSpellData(spell.GetSpellType()).tTexture);
            if (rectSpellIcon.Contains(GameApp.GetInstance().GetCursor().GetScreenPosition()))
            {
                GUI.Label(UnityGUIExt.CreateRect(0, 50, 200, 200,
                                                 UnityGUIExt.GUI_ALLIGN.BOT_CENTRE,
                                                 UnityGUIExt.GUI_ALLIGN.BOT_CENTRE), sSpellDesc);
            }



            // Draw Keys
            GUI.Label(rectSpellIcon, asKeys[iSpell]);


            Rect rectThisSpell = rectSpellIcon;


            if (spell.IsOnCooldown())
            {
                GUI.DrawTexture(rectThisSpell, m_CooldownIconOverlay);

                rectThisSpell.y += rectThisSpell.height;

                rectThisSpell.height = rectSpellIcon.height * ((spell.GetCooldownTimer() - spell.GetCooldownLength()) / spell.GetCooldownLength());
                if (rectThisSpell.height < 0.0f)
                {
                    rectThisSpell.height *= -1.0f;
                }
                rectThisSpell.y -= rectThisSpell.height;

                GUI.DrawTexture(rectThisSpell, m_RefresherIconOverlay);
            }
            else if (m_bSpellSelected &&
                     iSpell == m_uiSelectedSpellId)
            {
                GUI.DrawTexture(rectThisSpell, m_SelectedIconOverlay);
            }

            rectSpellIcon.x += iOffset + iBorderWidth;

            ++iCol;
            if (iCol == 4)
            {
                rectSpellIcon.x  = iStartX;
                rectSpellIcon.y += iOffset + iBorderHeight;
            }

            ++iSpell;
        }

        // Draw the borders over the spell

        Rect rectBorder = UnityGUIExt.CreateRect(iIconStartX, iIconStartY, iBorderWidth, iBorderHeight,
                                                 UnityGUIExt.GUI_ALLIGN.BOT_CENTRE,
                                                 UnityGUIExt.GUI_ALLIGN.BOT_CENTRE);

        for (int i = 0; i < 2; ++i)
        {
            iStartX = (int)rectBorder.x;
            for (int j = 0; j < 4; ++j)
            {
                GUI.DrawTexture(rectBorder, m_SpellBorder);

                rectBorder.x += iOffset + iBorderWidth;
            }

            rectBorder.x  = iStartX;
            rectBorder.y += iOffset + iBorderHeight;
        }



        // Draw the overlay
//		GUI.DrawTexture(UnityGUIExt.CreateRect(0, 0, 800, 188,
//												UnityGUIExt.GUI_ALLIGN.BOT_CENTRE,
//												UnityGUIExt.GUI_ALLIGN.BOT_CENTRE), m_GameHUDOverlay);
    }