public void DoSacrifice(int index) { ShopItem s = LoadTxt.GetShopItem(GameData._playerData.sacrificeList [index]); Mats m = LoadTxt.MatDic [s.itemId]; int price = s.bundleNum * m.price; if (_gameData.CountInHome(GameConfigs.AltarMarkId / 10000) < price) { return; } _gameData.ConsumeItemInHome(GameConfigs.AltarMarkId / 10000, price); _gameData.AddItem(m.id * 10000, s.bundleNum); _floating.CallInFloating(m.name + " +" + s.bundleNum, 0); UpdateSacrifice(); }
public void UpdateSacrifice() { for (int i = 0; i < Items.Length; i++) { Text[] ts = Items [i].GetComponentsInChildren <Text> (); Button b = Items [i].GetComponentInChildren <Button> (); ShopItem s = LoadTxt.GetShopItem(GameData._playerData.sacrificeList [i]); Mats m = LoadTxt.MatDic [s.itemId]; int price = s.bundleNum * m.price; ts [0].text = m.name + "×" + s.bundleNum; ts [0].color = GameConfigs.MatColor [m.quality]; ts [1].text = m.description; int j = 2; if (m.property != null) { foreach (int key in m.property.Keys) { ts [j].text = PlayerData.GetPropName(key) + " " + (m.property [key] > 0 ? "+" : "-") + m.property [key]; ts [j].color = Color.white; j++; } } else { ts [j].text = "Can not use directly."; ts [j].color = Color.white; j++; } ts [4].text = "Pray(" + price + ")"; bool isEnough = _gameData.CountInHome(GameConfigs.AltarMarkId / 10000) >= price; b.interactable = isEnough; ts [4].color = isEnough ? Color.green : Color.gray; } }