public HuntUIButton(HuntInfo h) { hunt = h; Width.Set(bgTex.Width * scale, 0); Height.Set(bgTex.Height * scale, 0); }
public void SetHuntRewards(HuntInfo huntInfo, string huntName, int numCoins, int numGems, int numStars, int xp, string message) { _huntID = huntInfo.ID; CoinsReward = numCoins; GemsReward = numGems; StarsReward = numStars; XPReward = xp; _huntNameText.text = "You completed " + huntName + "!"; _coinsText.text = numCoins.ToString(); _gemsText.text = numGems.ToString(); _starsText.text = numStars.ToString(); _xpText.text = xp.ToString() + " XP"; _messageText.text = message; foreach (var box in _itemBoxes) { box.Hide(); } //Assuming 4 item rewards maximum for (int i = 0; i < huntInfo.RewardItems.Count; i++) { _itemBoxes[i].Show(); _itemBoxes[i].SetItem(huntInfo.RewardItems[i]); } }
public StartedHunt AddStartedHunt(HuntInfo info, int step = 0) { StartedHunt startedHunt = new StartedHunt(info, step); _startedHunts.Add(startedHunt); UpdateView(); return(startedHunt); }
private List <HuntInfo> HuntInfosFromJContainer(JContainer jContainer) { var list = new List <HuntInfo>(); foreach (var hunt in jContainer) { HuntInfo info = HuntInfo.FromJObject((JObject)hunt); list.Add(info); } return(list); }
public void Show(HuntInfo info) { HuntInfo = info; _nameText.text = info.Name; _descriptionText.text = info.Description; _rating.ShowRating(info.UserRating); _difficulty.ShowDifficulty(info.OfficialDifficulty); _rewardText.text = info.RewardCoins.ToString() + " Coins"; _appearingWindow.Open(); foreach (var box in _itemBoxes) { box.Hide(); } //Assuming 4 item rewards maximum for (int i = 0; i < info.RewardItems.Count; i++) { _itemBoxes[i].Show(); _itemBoxes[i].SetItem(info.RewardItems[i]); } }
private void OnReceivedStartedHunts(string response) { JObject obj = JObject.Parse(response); if ((int)obj["code"] != 200) { UpdateView(); return; } _startedHunts.Clear(); foreach (JObject startedHunt in obj["data"]) { HuntInfo info = HuntInfo.FromJObject((JObject)startedHunt["hunt_info"]); AddStartedHunt(info, (int)startedHunt["started_hunt"]["current_clue"]); } UpdateView(); }
private void OnReceived_CompletedHunts(string response) { JObject obj = JObject.Parse(response); if ((int)obj["code"] != 200) { UpdateView(); return; } _completedHunts.Clear(); foreach (JObject completedHunt in obj["data"]) { HuntInfo info = HuntInfo.FromJObject((JObject)completedHunt["hunt_info"]); _completedHunts.Add(info); } UpdateView(); }
/// <summary> /// This is called after we've got a successful response from server. /// If this was the last task, server has already marked whole Hunt as complete. /// </summary> public void AdvanceHunt(string popupMessage = "", string response = "") { PopupMessageManager.Show(popupMessage); CurrentHuntPanel.Get.CurrentHunt.CompleteStep(); //Update view of current hunt panel CurrentHuntPanel.Get.SetHunt(CurrentHuntPanel.Get.CurrentHunt); HuntInfo completedHunt = CurrentHuntPanel.Get.CurrentHunt.Info; //Check if completed whole Hunt if (CurrentHuntPanel.Get.CurrentHunt.CurrentStep == completedHunt.NumClues) { CompletedHuntsManager.Get.AddCompletedHunt(completedHunt); var completedWindow = Instantiate(_huntCompletedWindow_prefab, GetComponentInParent <Canvas>().transform); if (!LocalTest.Testing) { Debug.Log(response); JObject obj = JObject.Parse(response); coinsAmount = (int)obj["data"]["coins_reward"]; gemsAmount = (int)obj["data"]["gems_reward"]; starsAmount = (int)obj["data"]["stars_reward"]; xpAmount = (int)obj["data"]["total_xp"]; message = (string)obj["data"]["message"]; } else { coinsAmount = 117; gemsAmount = 10; starsAmount = Random.Range(0, 3) == 0 ? 1 : 0; xpAmount = 150; } completedWindow.GetComponent <HuntCompletedWindow>().SetHuntRewards(completedHunt, completedHunt.Name, coinsAmount, gemsAmount, starsAmount, xpAmount, message); StartedHuntsManager.Get.RemoveHunt(completedHunt.ID); StartedHuntsManager.Get.HideHunt(); } }
public StartedHunt(HuntInfo info, int currentStep) { Info = info; CurrentStep = currentStep; }
public void SetHunt(HuntInfo huntInfo) { HuntInfo = huntInfo; _nameText.text = huntInfo.Name; }
public void AddCompletedHunt(HuntInfo info) { _completedHunts.Add(info); UpdateView(); }