示例#1
0
 /// <summary>
 /// 初始化UI控制器
 /// </summary>
 public override void Init()
 {
     _HeroUI = new Dictionary <HeroMono, BattleHeroUI>();
     //清空玩家和敌人列表
     UnityStaticTool.DestoryChilds(PlayerHeroParent.gameObject, true);
     UnityStaticTool.DestoryChilds(EnemyHeroParent.gameObject, true);
 }
示例#2
0
 /// <summary>
 /// 关闭输入UI
 /// </summary>
 public void DisappearInputUI()
 {
     UnityStaticTool.DestoryChilds(FirstMenuGrid.gameObject, true);
     UnityStaticTool.DestoryChilds(SecondMenuGrid.gameObject, true);
     UnityStaticTool.DestoryChilds(ThirdMenuGrid.gameObject, true);
     TextTip.text = "";
 }
示例#3
0
 /// <summary>
 /// 点击了技能菜单
 /// </summary>
 void OnSkillButtonClick()
 {
     //首先关闭二级菜单和三级菜单
     UnityStaticTool.DestoryChilds(SecondMenuGrid.gameObject, true);
     UnityStaticTool.DestoryChilds(ThirdMenuGrid.gameObject, true);
     //然后创建新的二级菜单
     foreach (BaseSkill skill in _CurHero.Skills.Values)
     {
         if (skill.IsPassiveSkill)
         {
             continue;
         }
         Button button = null;
         if (UnityStaticTool.CreateObjectReletiveTo <Button>(ButtonPrefab, SecondMenuGrid.transform, out button))
         {
             button.name = skill.Name;
             button.GetComponentInChildren <Text>().text = skill.Name;
             if (!skill.CanUseSkill())
             {
                 button.interactable = false;
                 continue;
             }
             button.onClick.AddListener(delegate { this.OnSkillChooseClick(button.gameObject); });
         }
     }
 }
示例#4
0
 /// <summary>
 /// 退出系统的时候调用
 /// </summary>
 public override void Clear()
 {
     //清除玩家队列
     UnityStaticTool.DestoryChilds(PlayerTeam.gameObject, true);
     //清除敌人队列
     UnityStaticTool.DestoryChilds(EnemyTeam.gameObject, true);
     //清除玩家UI
     UnityStaticTool.DestoryChilds(PlayerHeroParent.gameObject, true);
     //清除敌人UI
     UnityStaticTool.DestoryChilds(EnemyHeroParent.gameObject, true);
     //清除关联字典
     _HeroUI.Clear();
 }
示例#5
0
 /// <summary>
 /// 创建UI上的所有参与战斗的英雄Mono对象并向BattleController注册这个对象
 /// </summary>
 /// <param name="player">玩家队伍数据</param>
 /// <param name="enemy">敌人队伍数据</param>
 public override void CreateHeros(List <Hero> player, List <Hero> enemy)
 {
     //清除玩家和敌人队列的所有数据
     UnityStaticTool.DestoryChilds(PlayerTeam.gameObject, true);
     UnityStaticTool.DestoryChilds(EnemyTeam.gameObject, true);
     //创建玩家的英雄对象
     for (int i = 0; i < player.Count; i++)
     {
         HeroMono   hero_temp = null;
         GameObject prefab    = Resources.Load <GameObject>("Hero/" + player[i].ID);
         if (UnityStaticTool.CreateObjectReletiveTo <HeroMono>((prefab == null ? HeroPrefab : prefab), PlayerTeam, out hero_temp))
         {
             hero_temp.Init(player[i], true);
             hero_temp.transform.position = PlayerTeamPos[i].position;
             //记录英雄坐标
             hero_temp.HeroPosition = PlayerTeamPos[i].position;
             //记录这个英雄的对象引用
             BattleController.Instance.RegisterPlayerHeroMono(hero_temp);
         }
     }
     //创建传入进来的敌人对象
     for (int i = 0; i < enemy.Count; i++)
     {
         HeroMono   enemy_temp = null;
         GameObject prefab     = Resources.Load <GameObject>("Hero/" + player[i].ID);
         if (UnityStaticTool.CreateObjectReletiveTo <HeroMono>((prefab == null ? HeroPrefab : prefab), EnemyTeam, out enemy_temp))
         {
             enemy_temp.Init(enemy[i], false);
             enemy_temp.transform.position = EnemyTeamPos[i].position;
             //记录英雄的坐标
             enemy_temp.HeroPosition = EnemyTeamPos[i].position;
             //记录这个敌人英雄的对象引用
             BattleController.Instance.RegisterEnemyHeroMono(enemy_temp);
         }
     }
 }