/// <summary> /// 初始化 /// </summary> public override void Initialize(string s) { m_RootUI = UnityTool.FindGameObject(s); bagBtn = UITool.GetUIComponent <Button>(m_RootUI, "UIBagBtn"); Hp = UITool.GetUIComponent <Slider>(m_RootUI, "HP"); Mp = UITool.GetUIComponent <Slider>(m_RootUI, "MP"); HPText = UITool.GetUIComponent <Text>(m_RootUI, "HPText"); MPText = UITool.GetUIComponent <Text>(m_RootUI, "MPText"); SkillContent = UITool.GetUIComponent <Transform>(m_RootUI, "SkillContent"); bagBtn.onClick.AddListener(_ctrl.OnBagBtnClick); for (int i = 0; i < SkillContent.childCount; i++) { int k = i; Transform obj = SkillContent.GetChild(i); obj.GetComponent <Button>().onClick.RemoveAllListeners(); obj.GetComponent <Button>().onClick.AddListener(() => { _ctrl.UseSkill(k, obj); }); } }
public void SetDoor() { if (m_Soldier != null) { m_Soldier.SetDoor(UnityTool.FindChildGameObject(UnityTool.FindGameObject("Door"), "Point").transform); } }
public override void Initialize(string s) { m_RootUI = UnityTool.FindGameObject(s); closeBtn = UITool.GetUIComponent <Button>(m_RootUI, "CloseBtn"); closeBtn.onClick.AddListener(_ctrl.OnCloseBtnClick); }
// 取得集合点 private Vector3 GetTrainPoint(string GameObjectName) { // 取得物件 GameObject theCamp = UnityTool.FindGameObject(GameObjectName); // 取得集合点 GameObject theTrainPoint = UnityTool.FindChildGameObject(theCamp, "TrainPoint"); theTrainPoint.SetActive(false); return(theTrainPoint.transform.position); }
// Use this for initialization void Start() { image = UnityTool.FindGameObject(gameObject, "SliderImage").GetComponent <Image>(); loadingText = UnityTool.FindGameObject(gameObject, "num").GetComponent <Text>(); image.fillAmount = 0.0f; if (SceneManager.GetActiveScene().name == "main") { //启动协程 StartCoroutine(AsyncLoading()); } }
// 查找UI界面,在制定Canvas下 public static GameObject FindUIGameObject(string UIName) { if (m_CanvasObj == null) { m_CanvasObj = UnityTool.FindGameObject("Canvas"); } if (m_CanvasObj == null) { return(null); } return(UnityTool.FindChildGameObject(m_CanvasObj, UIName)); }
// 开始 public override void StateBegin() { UIManage.Instance.AddUI(UIType.MainUI, typeof(MainBace)); UIManage.Instance.Show(UIType.MainUI); GameObject scenery = UnityTool.FindGameObject("scenery"); foreach (Transform item in scenery.transform) { EventListener.Add(item.gameObject) .AddListener(EventTriggerType.PointerClick, ClickCustom); } }
public override void Initialize(string s) { m_RootUI = UnityTool.FindGameObject(s); closeBtn = UITool.GetUIComponent <Button>(m_RootUI, "SelectStageCloseBtn"); item = UnityTool.FindChildGameObject(m_RootUI, "Item"); content = UITool.GetUIComponent <Transform>(m_RootUI, "Content"); closeBtn.onClick.AddListener(() => { _ctrl.OnCloseBtnClick(); }); }
public override void Initialize(string s) { m_RootUI = UnityTool.FindGameObject(s); // 查找开始按钮 StartGameBtn = UnityTool.FindChildGameObject(m_RootUI, "StartGameBtn").GetComponent <Button>(); if (StartGameBtn != null) { StartGameBtn.onClick.AddListener(() => _ctrl.OnStartGameBtnClick(StartGameBtn)); } }
// 取得场景中的兵营 private SoldierCamp SoldierCampFactory(ENUM_Soldier emSoldier) { string GameObjectName = "SoldierCamp_"; float CoolDown = 0; string CampName = ""; string IconSprite = ""; switch (emSoldier) { case ENUM_Soldier.Rookie: GameObjectName += "Rookie"; CoolDown = 3; CampName = "菜鳥兵营"; IconSprite = "RookieCamp"; break; case ENUM_Soldier.Sergeant: GameObjectName += "Sergeant"; CoolDown = 4; CampName = "中士兵营"; IconSprite = "SergeantCamp"; break; case ENUM_Soldier.Captain: GameObjectName += "Captain"; CoolDown = 5; CampName = "上尉兵营"; IconSprite = "CaptainCamp"; break; default: Debug.Log("沒有指定[" + emSoldier + "]要取得的场景物件名称"); break; } // 取得物件 GameObject theGameObject = UnityTool.FindGameObject(GameObjectName); // 取得集合点 Vector3 TrainPoint = GetTrainPoint(GameObjectName); // 产生兵营 SoldierCamp NewCamp = new SoldierCamp(theGameObject, emSoldier, CampName, IconSprite, CoolDown, TrainPoint); NewCamp.SetPBaseDefenseGame(m_PBDGame); // 设定兵营使用的Script AddCampScript(theGameObject, NewCamp); return(NewCamp); }
public override void Initialize(string s) { m_RootUI = UnityTool.FindGameObject(s); tips = UnityTool.FindChildGameObject(m_RootUI, "Tips"); item = UnityTool.FindChildGameObject(m_RootUI, "CreateRoleItemBtn"); pop = UnityTool.FindChildGameObject(m_RootUI, "Pop"); GoBackBtn = UITool.GetUIComponent <Button>(m_RootUI, "GoBackBtn"); RepeatBtn = UITool.GetUIComponent <Button>(m_RootUI, "RepeatBtn"); ConfirmBtn = UITool.GetUIComponent <Button>(m_RootUI, "ConfirmBtn"); CancelBtn = UITool.GetUIComponent <Button>(m_RootUI, "CancelBtn"); showRole = UITool.GetUIComponent <Image>(m_RootUI, "ShowRole"); input = UITool.GetUIComponent <InputField>(m_RootUI, "InputField"); content = UITool.GetUIComponent <Transform>(m_RootUI, "CreateContent"); pop.SetActive(false); //根据基础信息生成可以创建的角色 List <RoleBasicInfo> roleBasicInfoList = _model.GetRoleBasicInfoConfig(); for (int i = 0; i < roleBasicInfoList.Count; i++) { int k = i; GameObject clone = GameObject.Instantiate(item, content, false); clone.GetComponentInChildren <Text>().text = roleBasicInfoList[k].name; clone.GetComponent <Button>().onClick.AddListener(() => { tips.SetActive(true); showRole.sprite = Resources.Load <Sprite>("RoleShow/" + roleBasicInfoList[k].model); currentType = roleBasicInfoList[k].roleType; }); } currentType = roleBasicInfoList[0].roleType; GoBackBtn.onClick.AddListener(() => { _ctrl.SwitchChooseRolePanel(); }); RepeatBtn.onClick.AddListener(() => { _ctrl.OnRepeatBtnClick(input.text); }); ConfirmBtn.onClick.AddListener(() => { _ctrl.OnConfirmBtnClick(input.text); }); CancelBtn.onClick.AddListener(() => { _ctrl.OnCancelBtnClick(); }); }
public override void Initialize(string s) { m_RootUI = UnityTool.FindGameObject(s); //UITool默认找的是UIRoot下的,刚生成界面的时候,不在Root下 item = UnityTool.FindChildGameObject(m_RootUI, "ChooseRoleItem"); content = UITool.GetUIComponent <Transform>(m_RootUI, "ChooseContent"); CreateRoleBtn = UITool.GetUIComponent <Button>(m_RootUI, "CreateRoleBtn"); CreateRoleBtn.onClick.AddListener(() => { _ctrl.SwitchCreateRolePanel(); }); }
// 取得攻擊點 private Vector3 GetAttackPosition() { if (m_AttackPos == Vector3.zero) { GameObject tempObj = UnityTool.FindGameObject("EnemyAttackPosition"); if (tempObj == null) { return(Vector3.zero); } tempObj.SetActive(false); m_AttackPos = tempObj.transform.position; } return(m_AttackPos); }
public IUserInterfaceManager() { UI_Root = UnityTool.FindGameObject("UIRoot").transform; Normal = UnityTool.FindChildGameObject(UI_Root.gameObject, "Normal").transform; Fixed = UnityTool.FindChildGameObject(UI_Root.gameObject, "Fixed").transform; PopUp = UnityTool.FindChildGameObject(UI_Root.gameObject, "PopUp").transform; uiCache = new Dictionary <Type, IUserInterfaceConfig>(); uiShowCache = new Dictionary <Type, IUserInterface>(); }
//开始 public override void StateBegin() { //BGM切换 GameObject gameloop = UnityTool.FindGameObject("GameLoop"); GameLoop gameLoopScript = gameloop.GetComponent <GameLoop>(); AudioSource audio = gameloop.GetComponent <AudioSource>(); if (audio.clip != gameLoopScript.start) { audio.clip = gameLoopScript.start; audio.Play(); } //按钮监听 Button btnStartGame = UITool.GetButton("StartGameButton"); btnStartGame.onClick.AddListener(() => OnStartGameBtnClick(btnStartGame)); Button btnBack = UITool.GetButton("BackButton"); btnBack.onClick.AddListener(() => OnBackBtnClick(btnBack)); Button btnStartMultiplayerGame = UITool.GetButton("StartMultiplayerGameButton"); btnStartMultiplayerGame.onClick.AddListener(() => OnStartMultiplayerBtnClick(btnStartMultiplayerGame)); Button btnAbout = UITool.GetButton("AboutButton"); btnAbout.onClick.AddListener(() => OnAboutBtnClick(btnAbout)); Button btnOk = UITool.GetButton("OkButton"); btnOk.onClick.AddListener(() => OnOkBtnClick(btnOk)); Button btnExitGame = UITool.GetButton("ExitGameButton"); btnExitGame.onClick.AddListener(() => OnExitGameBtnClick(btnExitGame)); Button btnAudio = UITool.GetButton("AudioButton"); btnAudio.onClick.AddListener(() => OnAudioBtnClick(btnAudio)); Button btnCloseAudio = UITool.GetButton("CloseButton"); btnCloseAudio.onClick.AddListener(() => OnCloseAudioManagerBtnClick(btnCloseAudio)); }
// 取得场景中的俘兵营 private CaptiveCamp CaptiveCampFactory(ENUM_Enemy emEnemy) { string GameObjectName = "CaptiveCamp_"; float CoolDown = 0; string CampName = ""; string IconSprite = ""; switch (emEnemy) { case ENUM_Enemy.Elf: GameObjectName += "Elf"; CoolDown = 3; CampName = "精灵俘兵营"; IconSprite = "CaptiveCamp"; break; default: Debug.Log("沒有指定[" + emEnemy + "]要取得的场景物件名称"); break; } // 取得物件 GameObject theGameObject = UnityTool.FindGameObject(GameObjectName); // 取得集合点 Vector3 TrainPoint = GetTrainPoint(GameObjectName); // 产生兵营 CaptiveCamp NewCamp = new CaptiveCamp(theGameObject, emEnemy, CampName, IconSprite, CoolDown, TrainPoint); NewCamp.SetPBaseDefenseGame(m_PBDGame); // 设定兵营使用的Script AddCampScript(theGameObject, NewCamp); // 先隱藏 NewCamp.SetVisible(false); // 回传 return(NewCamp); }
public override void StateBegin() { //BGM切换 GameObject gameloop = UnityTool.FindGameObject("GameLoop"); GameLoop gameLoopScript = gameloop.GetComponent <GameLoop>(); AudioSource audio = gameloop.GetComponent <AudioSource>(); audio.clip = gameLoopScript.battleGame; audio.Play(); GameObject canvas = UITool.FindUIGameObject("Canvas"); canvasRectTransform = canvas.GetComponent <RectTransform>(); GameObject menuPanel = UITool.FindUIGameObject("MenuPanel"); menuPanelRectTransform = menuPanel.GetComponent <RectTransform>(); //按键绑定 Button btnResumeGame = UITool.GetButton("ResumeGameButton"); btnResumeGame.onClick.AddListener(() => ResumeGame(btnResumeGame)); Button btnBackToMainMenu = UITool.GetButton("BackToMainMenuButton"); btnBackToMainMenu.onClick.AddListener(() => BackToMainMenu(btnBackToMainMenu)); Button btnExitGame = UITool.GetButton("ExitGameButton"); btnExitGame.onClick.AddListener(() => ExitGame(btnExitGame)); Button btnEndTurn = UITool.GetButton("EndTurnButton"); btnEndTurn.onClick.AddListener(() => EndTurn(btnEndTurn)); Button btnBackToMainMenu2 = UITool.GetButton("BackToMainMenuButton2"); btnBackToMainMenu2.onClick.AddListener(() => BackToMainMenu2(btnBackToMainMenu2)); }
// 取得出生點 private Vector3 GetSpawnPosition() { if (m_SpawnPosition == null) { m_SpawnPosition = new List <Vector3>(); for (int i = 1; i <= 3; ++i) { string name = string.Format("EnemySpawnPosition{0}", i); GameObject tempObj = UnityTool.FindGameObject(name); if (tempObj == null) { continue; } tempObj.SetActive(false); m_SpawnPosition.Add(tempObj.transform.position); } } // 隨機傳回 int index = UnityEngine.Random.Range(0, m_SpawnPosition.Count - 1); return(m_SpawnPosition[index]); }
/// <summary> /// 初始化 /// </summary> private void Initialize() { m_Canvas = UnityTool.FindGameObject("Canvas"); }
public override void Initialize(string s) { m_RootUI = UnityTool.FindGameObject(s); currentSlider = UITool.GetUIComponent <Slider>(m_RootUI, "Slider"); }