//public void AddGold(int amount) //{ // Gold += amount; // EventData eventData = new EventData("OnGoldCountChangedEvent"); // GameManager.Instance.EventManager.CallOnGoldCountChangedEvent(eventData); // //TROPHY EarnXGoldCumulatively // GameManager.Instance.Player.OnTrophyEvent(ETrophyType.EarnXGoldCumulatively, amount); // //TROPHY HaveXGoldInTheBank // int val = GameManager.Instance.Player.TrophiesItems[ETrophyType.HaveXGoldInTheBank].Param; // GameManager.Instance.Player.OnTrophyEvent(ETrophyType.HaveXGoldInTheBank, val, false); // // //} //public void RemoveGold(int amount) //{ // Gold -= amount; // EventData eventData = new EventData("OnGoldCountChangedEvent"); // GameManager.Instance.EventManager.CallOnGoldCountChangedEvent(eventData); //} ////Trophies public void OnTrophyEvent(ETrophyType tType, int param, bool commulative = true) { if (TrophiesItems[tType].Completed) { return; } int newParam = 0; if (commulative) { newParam = TrophiesItems[tType].Param + param; } else { newParam = param; } TrophyData tData = GameManager.Instance.GameData.XMLtrophiesData[tType]; if (newParam > tData.Param) { newParam = tData.Param; } TrophiesItems[tType].Param = newParam; if (newParam == tData.Param) { // completed Debug.Log("Trophy " + tType.ToString() + " completed!"); TrophiesItems[tType].Completed = true; EventData eventData = new EventData("OnTrophyCompletedEvent"); eventData.Data["type"] = tType; GameManager.Instance.EventManager.CallOnTrophyCompletedEvent(eventData); //TROPHY GetAllOtherTrophies - check if final trophy completed int completedAmount = 0; foreach (var trophy in TrophiesItems) { if (trophy.Value.Completed) { ++completedAmount; } } if (completedAmount == TrophiesItems.Count - 1) { // completed all trophies! Debug.Log("All trophies " + tType.ToString() + " completed!"); TrophiesItems[ETrophyType.GetAllOtherTrophies].Param = 1; TrophiesItems[ETrophyType.GetAllOtherTrophies].Completed = true; EventData eventData2 = new EventData("OnTrophyCompletedEvent"); eventData2.Data["type"] = ETrophyType.GetAllOtherTrophies; GameManager.Instance.EventManager.CallOnTrophyCompletedEvent(eventData2); } } }
public void InitPopup(ETrophyType trophyType) { _trophyType = trophyType; RewardAmountText.text = "$" + GameManager.Instance.GameData.XMLtrophiesData[trophyType].Reward.ToString(); DescriptionText.text = Localer.GetText(_trophyType.ToString()); ShowPopup(); }
public void UpdateTrophy(ETrophyType id) { Id = id; Group.alpha = 1; TrophyData trophyData = GameManager.Instance.GameData.XMLtrophiesData[id]; TrophyCompleteData completeData = GameManager.Instance.Player.TrophiesItems[id]; // progress if (trophyData.Param <= 1 || trophyData.IsSingle) { ProgressText.gameObject.SetActive(false); } else { ProgressText.gameObject.SetActive(true); //if (Id == ETrophyType.PlayMoreThan5hoursCumulative) //{ // int hours = completeData.Param / (60 * 60); // ProgressText.text = hours.ToString() + "/5"; //} else { ProgressText.text = completeData.Param.ToString() + "/" + trophyData.Param.ToString(); } } // money MoneyText.text = trophyData.Reward.ToString(); // description text DescriptionText.text = Localer.GetText(id.ToString()); // trophy icon if (completeData.Completed) { CompleteObj.SetActive(true); Filler.gameObject.SetActive(false); } else { CompleteObj.SetActive(false); if (completeData.Param <= 0) { Filler.gameObject.SetActive(false); } else { Filler.gameObject.SetActive(true); Filler.fillAmount = (float)completeData.Param / (float)trophyData.Param; } } }