public ResourceMessenger Init(SpinWheelWin pInitData, RectTransform pParen) { initData = pInitData; trans.SetParent(pParen); trans.position = pParen.position; trans.rotation = pParen.rotation; trans.localScale = Vector3.one; SpinWheelWinData data = SpinWheelWinsManager.Instance.GetData(pInitData.win_type); if (data != null) { // nastavit ikonu img_icon.sprite = data.Icon; // nastavit náhodnou hodnotu value = pInitData.values[Random.Range(0, pInitData.values.Length - 1)]; txt_value.text = value.ToString(); Reward = new ResourceMessenger(data.Id, value); return(Reward); } else { Debug.Log("no data"); } return(null); }
public void GenerateWins() { SpinWheelSettingsData data = RemoteSettingsData.Instance.spinWheelSettingsData; int winsCount = data.Wins.Length; if (winsCount > prizeHolders.Length) { winsCount = prizeHolders.Length; } ClearPrizes(); List <SpinWheelWin> wins = new List <SpinWheelWin>(data.Wins); SpinWheelWin rndWin; // generuji výhry for (int i = 0; i < winsCount; i++) { SpinWheelPrize prize = Instantiate(prizePrefab); rndWin = wins[Random.Range(0, wins.Count - 1)]; ResourceMessenger resourceCount = prize.Init(rndWin, prizeHolders[i]); maxRewards[resourceCount.Type] += resourceCount.Count; wins.Remove(rndWin); prizes.Add(prize); } }
public void GiveReward(ResourceMessenger pReward) { switch (pReward.Type) { case PlayerData.PlayerResourceType.coins: coinsReward += pReward.Count; coinsProgressbar.SetValueAnim(coinsReward); break; case PlayerData.PlayerResourceType.gems: break; case PlayerData.PlayerResourceType.hearts: heartsReward += pReward.Count; heartsProgressBar.SetValueAnim(heartsReward); break; default: throw new ArgumentOutOfRangeException(nameof(pReward.Type), pReward.Type, null); } }