private void UpdateRowChestInfo(ChestFutureRngInstance rngInstance, DataGridViewRow row) { const string item1 = "Item 1"; const string item2 = "Item 2"; const int cellOffset = 3; // start filling data in the 4th spot int chestCount = rngInstance.ChestRewards.Count; for (int chestIndex = 0; chestIndex < chestCount; chestIndex++) { ChestReward reward = rngInstance.ChestRewards.ElementAt(chestIndex); if (reward.Reward is RewardType.Gil) { row.Cells[chestIndex + cellOffset].Value = reward.GilAmount; } else if (reward.Reward is RewardType.Item1) { row.Cells[chestIndex + cellOffset].Value = item1; } else { row.Cells[chestIndex + cellOffset].Value = item2; } if (reward.ChestWillSpawn) { DataGridViewCell currentCell = row.Cells[chestIndex + cellOffset]; Font currentStyle = currentCell.InheritedStyle.Font; currentCell.Style.Font = new Font(currentStyle, FontStyle.Bold); } } }
//===================================================== public static ChestReward GetChestReward(eChestType type, eTradingCardClassification cardClassification, eTradingCardRarity cardRarity, eTradingCardCondition cardCondition) { var reward = new ChestReward(); var rewardCard = (type == eChestType.LARGE && cardClassification != eTradingCardClassification.NULL && cardRarity != eTradingCardRarity.NULL); // 50% chance of awarding a card or gem if (rewardCard == false && Random.Range(0, 99) % 2 == 0) { rewardCard = true; } if (rewardCard == true) { reward.Card = TradingCardItemsManager.GetCard(type, cardClassification, cardRarity, cardCondition); reward.CardCondition = cardCondition; //Debug.Log( "SceneManager: Reward card" ); } else { // Small, medium or large number of gems var maxGems = Convert.ToInt32(SettingsManager.GetSettingsItem("AWARD_GEMS_CHEST_" + type, -1)); reward.Gems = Random.Range(maxGems / 2, maxGems); //Debug.Log( "SceneManager: Reward gems" ); } return(reward); }
async Task OpenInternalAsync(ulong userId, uint amount) { var dbInventory = await DB.Inventory.GetAsync(userId); if (dbInventory.Chests == 0) { await messageService.SendMessageAsync("chests-nochests", Settings.ChannelId.Commands, new FormatData(userId)); return; } if (dbInventory.Chests < amount || amount == 0) { await messageService.SendMessageAsync("chests-notenoughchests", Settings.ChannelId.Commands, new FormatData(userId)); return; } await DB.Inventory.RemoveAsync(userId, new InventoryData { Chests = amount }); ChestsOpened?.Invoke(null, new ChestsOpenedEventArgs(userId, amount)); var reward = new ChestReward(amount); await rewardService.DeliverToAsync(userId, reward); await DB.Statistics.AddAsync(userId, new StatisticData { ChestsOpened = amount }); await messageService.SendMessageAsync("chests-open-success", Settings.ChannelId.Commands, new FormatData(userId) { Reward = reward }); }
//===================================================== private void SetRewardItem(eSwitchItem switchItem, eTradingCardClassification cardClassification, eTradingCardRarity cardRarity, eTradingCardCondition cardCondition) { if (switchItem == eSwitchItem.NULL) { // Reset reward to gems or a card _reward = SceneManager.GetChestReward(_type, cardClassification, cardRarity, cardCondition); } else { if (_reward == null) { _reward = new ChestReward(); } // Clear other reward items if switchItem is set _reward.Gems = 0; _reward.Card = null; _reward.SwitchItem = switchItem; } //Debug.Log( "Chest: " + _type + " : " + _reward ); // Initialise chest switchItem as reward if (_chestReward != null && _reward != null) { _chestReward.Init(_reward); } }
//===================================================== public static void AwardPlayer(ChestReward reward) { if (reward == null) { return; } if (reward.Gems > 0) { AddPlayerGems(reward.Gems); //Debug.Log( "Gems collected: " + reward.Gems ); } else if (string.IsNullOrEmpty(reward.Card.id) == false) { // Add card to players collection var heldCard = GameDataManager.Instance.AddTradingCard(reward.Card.id, reward.CardCondition); // If card rarity is TEACHER unlock special NPC e.g. Faragonda if (reward.Card.rarity == eTradingCardRarity.TEACHER && reward.Card.id != "NULL") { var npc = NPCItemsManager.GetNPCItemIDFromCardId(reward.Card.id); if (npc != eNPC.NULL) { GameDataManager.Instance.UnlockPlayerNPC(npc); } } // Show popup if (PopupChestReward.instance != null) { PopupChestReward.instance.Show(heldCard, 1.5f); } //Debug.Log( "Card collected: " + reward.Card._id ); } else if (reward.SwitchItem != eSwitchItem.NULL) { _currentSwitchItem = reward.SwitchItem; //Debug.Log( "Switch Item received: " + _currentSwitchItem ); } // Play player's celebrate animation PlayerManager.OnCelebrate(); }
//===================================================== public void Init(ChestReward reward) { // Hack to fix chest that don't find the reward items during first Awake() if (_card == null) { Awake(); } // Store current reward item if (string.IsNullOrEmpty(reward.Card.id) == false) { _currentReward = _card; } else if (reward.SwitchItem != eSwitchItem.NULL) { _currentReward = _key; } else { _currentReward = _gem; } }
//===================================================== private void Start() { // Inject this object into trigger _triggerFindTarget.GetComponent <TriggerTargetInRange>().Init(this); // Clear jobs list if (_currentJobs != null) { _currentJobs.Clear(); } // ToDo: Update this so that a reward is only given on a new day (GameDataManager should clear NPCsVisited array each new-day) // Set up simple speech bubble var isRewardAvailable = true; //_isRewardAwarded = false; if (GameDataManager.Instance.IsPlayerNPCVisited(_type)) { _guiBubbleSimple.ShowNewMeetingIcon(); isRewardAvailable = false; //_isRewardAwarded = true; //Debug.Log( "Visited" ); } else { _guiBubbleSimple.ShowAttentionIcon(); //Debug.Log( "NOT Visited" ); } // Set up reward speech bubble if (_reward == null) { _reward = new ChestReward(); } switch (_type) { case eNPC.NPC_STUDENT: // Gems _reward.Gems = Convert.ToInt32(NPCItemsManager.GetNPCItemGemReward(_type)); break; default: // Reward common card or gems if (Random.Range(0, 99) < 50) { _reward.Card = SceneManager.GetNPCReward(); } else { _reward.Gems = Convert.ToInt32(NPCItemsManager.GetNPCItemGemReward(_type)); } break; } // Set reward available / unavailable if (_guiBubbleEmoticon != null) { _guiBubbleEmoticon.SetReward(isRewardAvailable, _reward.Gems > 0); } else { Debug.Log("Warning: Emoticon bubble is probably disabled in NPC prefab."); } }