// Member Types // Member Functions // Public: // Protected: override protected void Initialise(ref string _rsDescription, ref EType _reSpellType, ref float _rfCooldownLength, ref float _rfDamageLevelIncrement, ref float _rfPushbackLevelIncrement, ref float _rfRange, ref uint _ruiCurrancyUpgradeCost, ref float _rfCastDelay) { CSpellData.TSpellData tData = GameApp.GetInstance().GetSpellDataComponent().GetSpellData(CSpell.EType.SWAP); _rsDescription = tData.sDescription; _reSpellType = tData.eType; _rfCooldownLength = tData.fCooldown; _rfDamageLevelIncrement = tData.fDamageLevelInrement; _rfPushbackLevelIncrement = tData.fPushbackLevelIncrement; _rfRange = tData.fRange; _ruiCurrancyUpgradeCost = tData.uiUpgradeCost; _rfCastDelay = tData.fCastDelay; m_fRadius = tData.fRadius; m_fCooldownLength = tData.fCooldown; m_fCooldownTimerLevelIncrement = tData.fCooldownLevelIncrement; m_fCastDelay = tData.fCastDelay; m_fCastDelayLevelIncrement = tData.fCastDelayLevelIncrement; m_fDamageAmount = tData.fDamage; m_fDamageLevelIncrement = tData.fDamageLevelInrement; m_fPushbackAmount = tData.fPushback; m_fPushbackLevelIncrement = tData.fPushbackLevelIncrement; m_fRange = tData.fRange; m_fRangeLevelIncrement = tData.fRangeLevelIncrement; m_fRadius = tData.fRadius; m_fRadiusLevelIncrement = tData.fRadiusLevelIncrement; }
// Member Types // Member Functions // Public: // Private: void Start() { CSpellData.TSpellData tData = GameApp.GetInstance().GetSpellDataComponent().GetSpellData(CSpell.EType.TETHER); CSpell oSpell = GameApp.GetInstance().GetWarlock().GetComponent <CSpellbook>().GetSpell(CSpell.EType.TETHER); m_fTimer = 0.0f; m_fTimerTime = 0.1f; m_fDamage = oSpell.GetDamageAmount(); m_fPushBack = oSpell.GetPushbackAmount(); m_fVelocity = 13.0f; m_bExplode = false; m_bHooked = false; m_fRange = oSpell.GetRange(); m_fDuration = 0.0f; m_fMaxDuration = 6.2f; m_fMaxSize = 2.0f; m_fRadius = oSpell.GetRadius(); m_fTimer = 0.1f; m_fDistanceTraveled = 0.0f; }
// Use this for initialization void Start() { CSpellData.TSpellData tData = GameApp.GetInstance().GetSpellDataComponent().GetSpellData(CSpell.EType.SONIC_WAVE); CSpell oSpell = GameApp.GetInstance().GetWarlock().GetComponent <CSpellbook>().GetSpell(CSpell.EType.SONIC_WAVE); m_fDamage = oSpell.GetDamageAmount(); m_fPushbackAmount = oSpell.GetPushbackAmount(); m_fDuration = 0.0f; m_fMaxDuration = 0.53f; m_fMaxSize = 5.0f; m_fRadius = oSpell.GetRadius(); }
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); }
// 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; } }
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; }