public GameObject CreateProb(ProbType type, Vector3 position, Quaternion rotation) { var prob = GameManager.Instance.Pooler.Get(type, position, rotation); ActiveProbs.Add(prob.GetComponent <Probs>()); return(prob); }
//TODO Refactor this Later, Code Duplication public GameObject Get(ProbType type, Vector3 pos, Quaternion quat) { var probPrefab = _originals.FirstOrDefault(x => x.GetComponent <Probs>().ProbType == type); if (_freeInstances.ContainsKey(type)) { var stack = _freeInstances[type]; GameObject ret = stack.Count > 0 ? stack.Pop() : Object.Instantiate(probPrefab); ret.SetActive(true); ret.transform.position = pos; ret.transform.rotation = quat; ret.transform.SetParent(this.transform); return(ret); } else { GameObject ret = Object.Instantiate(probPrefab); ret.SetActive(true); ret.transform.position = pos; ret.transform.rotation = quat; ret.transform.SetParent(this.transform); return(ret); } }
public void BuyItem(ProbType type, int index, int price) { if (!PurchaseManager.Instance.PayCoin(price)) { NeedMoreCoins(); } _profileManage.AddProb(type, index); ReInitiate(); }
private void ShowBuyItem(ProbType type, int index, int price) { string describe = PurchaseItemDescribe.Replace("****", PersianFixer.Fix(price.ToString())); string title = PersianFixer.Fix("خرید"); PreviewProb(type, index, title, describe); BuyButton.gameObject.SetActive(true); BuyButton.onClick.RemoveAllListeners(); BuyButton.onClick.AddListener(() => BrStoreList.Instance.BuyItem(type, index, price)); Description.gameObject.SetActive(true); }
public void PreviewProb(ProbType type, int index, string title, string describe, bool needBP = false) { Title.text = title; Description.text = describe; Character.SetActive(false); Flag.SetActive(false); Para.SetActive(false); CharacterImage.SetActive(false); ParaImage.SetActive(false); FlagImage.SetActive(false); BuyButton.gameObject.SetActive(false); //Description.gameObject.SetActive(false); switch (type) { case ProbType.Character: CharactersList[index].SetToCharacter(Character.GetComponent <BrCharacterModel>()); Character.SetActive(true); CharacterImage.SetActive(true); break; case ProbType.Para: ParasList[index].SetToPara(Para.GetComponent <Para>()); Para.SetActive(true); ParaImage.SetActive(true); break; case ProbType.Flag: FlagsList[index].SetToFlag(Flag.GetComponent <Flag>()); Flag.SetActive(true); FlagImage.SetActive(true); break; case ProbType.Emot: CharactersList[index].SetToCharacter(Character.GetComponent <BrCharacterModel>()); Character.SetActive(true); CharacterImage.SetActive(true); break; default: break; } GetComponent <PlayableDirector>().Play(); }
/* * public void ShowProb(Inventory inventory, bool battle) * { * ProbType probType = inventory.GetProb(); * * if (probType==ProbType.NoProb) * return; * * OnProbSelected( * probType, * inventory.Value, * (battle&&ProfileManager.Instance().PlayerProfile.HasBattlePass==0)); * } * */ public void PreviewProb(Inventory inventory, bool battle, int level) { ProbType probType = inventory.GetProb(); if (probType == ProbType.NoProb) { return; } OnProbSelectednew( probType, inventory.Value, PersianFixer.Fix("جایزه سطح " + level.ToString()), "", battle && !ProfileManager.Instance().PlayerProfile.HasBattlePass); }
public bool HaveItem(ProbType probType, int index) { switch (probType) { case ProbType.Character: return(PlayerProfile.AvalableCharacters.Contains(index)); case ProbType.Para: return(PlayerProfile.AvalableParas.Contains(index)); case ProbType.Flag: return(PlayerProfile.AvalableFlags.Contains(index)); case ProbType.Emot: return(PlayerProfile.AvalableEmotes.Contains(index)); } return(false); }
public Texture2D GetProbIcon(int index, ProbType probType) { switch (probType) { case ProbType.Character: return(CharactersList.Characters[index].BodyIcon); case ProbType.Para: return(ParasList.Paras[index].Icon); case ProbType.Flag: return(FlagsList.Flags[index].Icon); case ProbType.Emot: return(CharactersList.Characters[index].BodyIcon); } return(null); }
public void AddProb(ProbType type, int index) { switch (type) { case ProbType.Character: PlayerProfile.AvalableCharacters.Add(index); break; case ProbType.Para: PlayerProfile.AvalableParas.Add(index); break; case ProbType.Flag: PlayerProfile.AvalableFlags.Add(index); break; case ProbType.Emot: PlayerProfile.AvalableEmotes.Add(index); break; } SaveProfile(); }
public void Init(ProbType type, int initialSize) { var probPrefab = _originals.FirstOrDefault(x => x.GetComponent <Probs>().ProbType == type); if (probPrefab != null) { var stack = new Stack <GameObject>(initialSize); for (int i = 0; i < initialSize; ++i) { GameObject obj = Object.Instantiate(probPrefab); obj.SetActive(false); stack.Push(obj); } if (_freeInstances.ContainsKey(type)) { _freeInstances[type] = stack; } else { _freeInstances.Add(type, stack); } } }
public GameObject Get(ProbType type) { return(Get(type, Vector3.zero, Quaternion.identity)); }
private void Selected(ProbType probType, int index, int price) { OnProbSelected?.Invoke(probType, index, price); }
public void CreatPlayerList(int probType) { probType = Mathf.Clamp(probType, 0, 3); ShowCharacter.gameObject.SetActive(false); CharacterImage.gameObject.SetActive(false); ShowFlag.gameObject.SetActive(false); FlagImage.gameObject.SetActive(false); ShowPara.gameObject.SetActive(false); ParaImage.gameObject.SetActive(false); foreach (ProbSelectButton button in _activeButtons) { button.gameObject.SetActive(false); button.transform.SetParent(CacheContent); _deactiveButtons.Add(button); } _activeButtons.Clear(); _probsType = (ProbType)probType; switch (_probsType) { case ProbType.Character: _availableprobs = Profile.AvalableCharacters; _currentProb = _selectedCharacter; Manager.CharactersList.Characters[_currentProb].SetToCharacter(ShowCharacter); CharacterImage.gameObject.SetActive(true); ShowCharacter.gameObject.SetActive(true); _allProbs = Manager.CharactersList.Characters.Length; break; case ProbType.Para: _availableprobs = Profile.AvalableParas; _currentProb = _selectedPara; Manager.ParasList.Paras[_currentProb].SetToPara(ShowPara); ParaImage.gameObject.SetActive(true); ShowPara.gameObject.SetActive(true); _allProbs = Manager.ParasList.Paras.Length; break; case ProbType.Flag: _availableprobs = Profile.AvalableFlags; _currentProb = _selectedFlag; Manager.FlagsList.Flags[_currentProb].SetToFlag(ShowFlag); FlagImage.gameObject.SetActive(true); ShowFlag.gameObject.SetActive(true); _allProbs = Manager.FlagsList.Flags.Length; break; case ProbType.Emot: break; } for (int probIndex = 0; probIndex < _allProbs; probIndex++) { ProbSelectButton prefab = GetButton(); prefab.transform.SetParent(Panel); //prefab.gameObject.SetActive(true); prefab.transform.localScale = Vector3.one; prefab.SetProbButton( Manager.GetProbIcon(probIndex, _probsType), probIndex, this, _availableprobs.Contains(probIndex), _currentProb == probIndex ); } Invoke(nameof(InitiateScroll), .01f); }