public override void OnInitObject() { base.OnInitObject(); // UI this.m_ShopContent = CRootManager.FindObjectWith(GameObject, "ShopContent"); // BUTTONS this.m_QuitButton = CRootManager.FindObjectWith(GameObject, "QuitButton").GetComponent <Button>(); this.m_QuitButton.onClick.AddListener(this.OnQuitClick); this.m_AdmobButton = CRootManager.FindObjectWith(GameObject, "AdmobButton").GetComponent <Button>(); this.m_AdmobButton.onClick.AddListener(this.OnAdmobClick); this.m_AdmobRewardText = CRootManager.FindObjectWith(GameObject, "AdmobRewardText").GetComponent <Text>(); this.m_AdmobRewardText.text = string.Format("+{0}", CGameSetting.GOLD_VIDEO_REWARD); this.m_ShopScrollRect = CRootManager.FindObjectWith(GameObject, "ShopScrollRect").GetComponent <ScrollRect>(); // ITEM PREFAB this.m_ShopItemPrefab = Resources.Load <CShopItem>("Items/ShopItem"); this.m_ShopConfig = Resources.Load <TextAsset>("Shop/shop"); this.m_OpenShop = new List <CShopItem>(); this.LoadConfig(this.m_ShopConfig.text); }
private void LoadItems() { using (var conn = new NpgsqlConnection(Constants.DB_World0_ConString)) { conn.Open(); using (var cmd = new NpgsqlCommand($"SELECT shopitem_id, shopid, itemid, price, discountrate, tokenitemid, tokenprice, levellimited FROM {Constants.DB_All_World_Schema_Name}.shopitems", conn)) using (var x = cmd.ExecuteReader()) { while (x.Read()) { var nShopItemId = x.GetInt32(0); var nShopId = x.GetInt32(1); //TODO: Set position field in pItem and Sort() var pItem = new CShopItem(x.GetInt32(2), x.GetInt32(3)) { nDiscountRate = (byte)x.GetInt32(4), nTokenItemID = x.GetInt32(5), nTokenPrice = x.GetInt32(6), nLevelLimited = x.GetInt32(7) }; if (!m_aShops.ContainsKey(nShopId)) { //Missing ID continue; } m_aShops[nShopId].Items.Add(pItem); } } } foreach (var item in m_aShops.Values) { item.AddDefaultItems(); } }