public override void Init() { base.Init(); GameObject canvas = GameObject.Find("Canvas"); mRootUI = UnityTools.FindChild(canvas, "GameStateUI"); GameObject heart1 = UnityTools.FindChild(mRootUI, "Heart1"); GameObject heart2 = UnityTools.FindChild(mRootUI, "Heart1"); GameObject heart3 = UnityTools.FindChild(mRootUI, "Heart2"); mHearts = new List <GameObject>(); mHearts.Add(heart1); mHearts.Add(heart2); mHearts.Add(heart3); mSoliderCount = UITools.FindChild <Text>(mRootUI, "SoldierCount"); mEnemyCount = UITools.FindChild <Text>(mRootUI, "EnemyCount"); mCurrentStage = UITools.FindChild <Text>(mRootUI, "StageCounter"); mPauseBtn = UITools.FindChild <Button>(mRootUI, "PauseBtn"); mGameOverUI = UnityTools.FindChild(mRootUI, "GameOver"); mBackMenuBtn = UITools.FindChild <Button>(mRootUI, "BackMenuBtn"); mMessage = UITools.FindChild <Text>(mRootUI, "Message"); mEnergySlider = UITools.FindChild <Slider>(mRootUI, "EnergySlider"); mEnergyText = UITools.FindChild <Text>(mRootUI, "EnergyText"); mMessage.text = ""; mGameOverUI.SetActive(false); }
public override void Init() { base.Init(); GameObject canvas = GameObject.Find("Canvas"); mRootUI = UnityTools.FindChild(canvas, "CampInfoUI"); mCampIcon = UITools.FindChild <Image>(mRootUI, "CampIcon"); mCampName = UITools.FindChild <Text>(mRootUI, "CampName"); mCampLevel = UITools.FindChild <Text>(mRootUI, "CampLv"); mWeaponLevel = UITools.FindChild <Text>(mRootUI, "WeaponLv"); mUpgradeCampBtn = UITools.FindChild <Button>(mRootUI, "CampUpgradeBtn"); mUpgradeWeaponBtn = UITools.FindChild <Button>(mRootUI, "WeaponUpgradeBtn"); mTrainBtn = UITools.FindChild <Button>(mRootUI, "TrainBtn"); mCancelTrainBtn = UITools.FindChild <Button>(mRootUI, "CancelTrainBtn"); mAliveCount = UITools.FindChild <Text>(mRootUI, "AliveCount"); mTrainningCount = UITools.FindChild <Text>(mRootUI, "TrainningCount"); mTrainTime = UITools.FindChild <Text>(mRootUI, "TrainTime"); mTrainBtnText = UITools.FindChild <Text>(mRootUI, "TrainBtnText"); mTrainBtn.onClick.AddListener(OnTrainClick); mCancelTrainBtn.onClick.AddListener(OnCancelTrainClick); mUpgradeCampBtn.onClick.AddListener(OnCampUpgradeClick); mUpgradeWeaponBtn.onClick.AddListener(OnWeaponUpgradeClick); Hide(); }
public void InitCamp(EnemyType enemyType) { GameObject gameObject = null; string gameObjectName = null; string name = null; string icon = null; Vector3 position = Vector3.zero; float trainTime = 0; switch (enemyType) { case EnemyType.Elf: gameObjectName = "CaptiveCamp_Elf"; name = "俘兵营"; icon = "CaptiveCamp"; trainTime = 3; break; default: Debug.LogError("无法根据敌人类型" + enemyType + "初始化俘兵营"); break; } gameObject = GameObject.Find(gameObjectName); position = UnityTools.FindChild(gameObject, "TrainPoint").transform.position; CaptiveCamp camp = new CaptiveCamp(gameObject, name, icon, enemyType, position, trainTime); gameObject.AddComponent <CampOnClick>().camp = camp; mCaptiveCamps.Add(enemyType, camp); }
private void Awake() { loadProcessBar = UnityTools.FindChild(transform, "bar").GetComponent <Slider>(); loadInfo = UnityTools.FindChild(transform, "info").GetComponent <Text>(); loadProcessValue = UnityTools.FindChild(transform, "value").GetComponent <Text>(); closeBtn = UnityTools.FindChild(transform, "btn").GetComponent <Button>(); Init(); }
public static T FindChild <T>(GameObject parent, string childName) { GameObject uiGO = UnityTools.FindChild(parent, childName); if (uiGO == null) { Debug.LogError("在游戏物理" + parent + "下面查找不到" + childName); return(default(T)); } return(uiGO.GetComponent <T>()); }
public override void Init() { base.Init(); GameObject canvas = GameObject.Find("Canvas"); mRootUI = UnityTools.FindChild(canvas, "GamePauseUI"); mCurrentStageLv = UITools.FindChild <Text>(mRootUI, "CurrentStageLv"); mContinueBtn = UITools.FindChild <Button>(mRootUI, "ContinueBtn"); mBackMenuBtn = UITools.FindChild <Button>(mRootUI, "BackMenuBtn"); Hide(); }
public void InitCamp(SoldierType soldierType) { GameObject gameObject = null; string gameObjectName = null; string name = null; string icon = null; Vector3 position = Vector3.zero; float trainTime = 0; switch (soldierType) { case SoldierType.Rookie: gameObjectName = "SoldierCamp_Rookie"; name = "新手兵营"; icon = "RookieCamp"; trainTime = 3; break; case SoldierType.Sergeant: gameObjectName = "SoldierCamp_Sergeant"; name = "中士兵营"; icon = "SergeantCamp"; trainTime = 4; break; case SoldierType.Captian: gameObjectName = "SoldierCamp_Captain"; name = "上尉兵营"; icon = "CaptainCamp"; trainTime = 5; break; default: Debug.LogError("无法根据战士类型" + soldierType + "初始化兵营"); break; } gameObject = GameObject.Find(gameObjectName); position = UnityTools.FindChild(gameObject, "TrainPoint").transform.position; SoldierCamp camp = new SoldierCamp(gameObject, name, icon, soldierType, position, trainTime); gameObject.AddComponent <CampOnClick>().camp = camp; mSoliderCamps.Add(soldierType, camp); }
public override void Init() { base.Init(); GameObject canvas = GameObject.Find("Canvas"); mRootUI = UnityTools.FindChild(canvas, "SoldierInfoUI"); mSoldierIcon = UITools.FindChild <Image>(mRootUI, "SoldierIcon"); mSoldierName = UITools.FindChild <Text>(mRootUI, "SoldierName"); mHPText = UITools.FindChild <Text>(mRootUI, "HPNumber"); mHPSlider = UITools.FindChild <Slider>(mRootUI, "HPSlider"); mLv = UITools.FindChild <Text>(mRootUI, "Level"); mAtk = UITools.FindChild <Text>(mRootUI, "Atk"); mAtkRange = UITools.FindChild <Text>(mRootUI, "AtkRange"); mMoveSpeed = UITools.FindChild <Text>(mRootUI, "MoveSpeed"); Hide(); }
public void ShowNetError() { UnityTools.FindChild(transform, "Tips").gameObject.SetActive(true); }