public void SetData(TowerData towerData, GameObject model, UIManager uiManager) { mTowerData = towerData; mUIManager = uiManager; if (!mUISetTowerObjectDictionary.ContainsKey(mTowerData.Towerkey)) { GameObject uiTower = Instantiate(model, mTowerObjectParent); UITowerRotation towrRotation = uiTower.GetComponent <UITowerRotation>(); uiTower.transform.localPosition = Vector3.up * mUITowerYPos; towrRotation.RotateTower(); mUISetTowerObjectDictionary.Add(mTowerData.Towerkey, uiTower); } else { GameObject towerObj = mUISetTowerObjectDictionary[mTowerData.Towerkey]; towerObj.SetActive(true); towerObj.GetComponent <UITowerRotation>().RotateTower(); } mTowerTitle.text = mTowerData.Modelname; StringBuilder sb = new StringBuilder(); sb.Append("Type : "); sb.AppendLine(GetTowerTypeToString(mTowerData.TOWERTYPE)); sb.Append("Price : "); sb.AppendLine(mTowerData.Price.ToString()); if (mTowerData.TOWERTYPE == TowerType.Attack) { sb.Append("Range : "); sb.AppendLine(mTowerData.Range.ToString()); sb.Append("Damage : "); sb.AppendLine(mTowerData.Damage.ToString()); sb.Append("AttackSpeed : "); sb.AppendLine(mTowerData.Attackspeed.ToString()); } else { sb.Append("Buff To :"); sb.AppendLine(GetBuffTypeToString(mTowerData.BUFFTYPE)); // TODO : SHOW Buff Area Image } mTowerDescription.text = sb.ToString(); mBuyButton.onClick.Add(new EventDelegate(BuyButton)); }
/// <summary> /// UI manager 초기화 함수. /// </summary> /// <returns></returns> private bool Initialize() { mPlayerInfo = GameManager.Instance.GetPlayerInfo(); if (mPlayerInfo == null) { Debug.Log("Failed Get PlayerInfo"); return(false); } mPlayerInfo = GameManager.Instance.GetPlayerInfo(); mPlayerInfo.AddObserver(mCoinLabel); mWaveManager = GameManager.Instance.GetWaveManager(); if (!mWaveManager) { Debug.Log("Failed Get Wave Manager"); return(false); } mSoundManager = GameManager.Instance.GetSoundManager(); if (!mSoundManager) { Debug.Log("Failed Get SoundManager"); return(false); } mMusicVolumeSlider.value = mSoundManager.MusicAudioSource.volume; mSfxVolumeSlider.value = mSoundManager.SfxAudioSource.volume; mPlayerInfo.AddObserver(mWaveLabel); mPlayerInfo.AddObserver(mLifeSet); mTouchGuard.gameObject.SetActive(false); Tower towerData = GameManager.Instance.GetObjectPool().GetTowerData(); mStoreGrid.repositionNow = true; mStoreGrid.gameObject.SetActive(false); GameObject setTower = Resources.Load("01.Prefabs/UI/Set Tower") as GameObject; if (setTower == null) { return(false); } for (int i = 0; i < towerData.dataArray.Length; i++) { GameObject uiSetTower = Instantiate(setTower, mStoreGrid.transform); string modelName = towerData.dataArray[i].Modelname; GameObject towerModel = Resources.Load("01.Prefabs/Tower/" + modelName) as GameObject; if (towerModel == null) { return(false); } GameObject tower = Instantiate(towerModel, uiSetTower.transform); tower.transform.GetChild(0).localScale = tower.transform.GetChild(0).localScale * 250.0f; tower.transform.localPosition = new Vector3(tower.transform.localPosition.x, mUITowerModelYPos, tower.transform.localPosition.z); UITowerRotation towerRotation = tower.AddComponent <UITowerRotation>(); uiTowerRotations.Add(towerRotation); Canon canon = tower.GetComponentInChildren <Canon>(); if (canon != null) { Destroy(canon); } UIButton btn = uiSetTower.GetComponentInChildren <UIButton>(); EventDelegate eventBtn = new EventDelegate(this, "OpenTowerBuyPanel"); eventBtn.parameters[0].value = towerData.dataArray[i]; eventBtn.parameters[1].value = uiTowerRotations[i].gameObject; btn.onClick.Add(eventBtn); btn.onClick.Add(new EventDelegate(ButtonClickSoundPlay)); GameManager.ChangeLayerMaskRecursively(tower.transform, "3D UI"); } mStoreGrid.Reposition(); for (int i = 0; i < 3; i++) { uiTowerRotations[i].RotateTower(); } mAdBtnCollider = mAdvertisementButton.GetComponent <BoxCollider2D>(); mReturnCollider = mReturnToBasicButton.GetComponent <BoxCollider2D>(); mReturnCollider.enabled = false; mDisapperRotation = new Vector3(0.0f, 90.0f, 0.0f); mReturnToBasicButton.transform.DOLocalRotate(mDisapperRotation, 0.0f); mTouchGuardOriginColor = mTouchGuard.GetComponentInChildren <UISprite>().color; return(true); }