/// <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); });
         }
     }
 }
Beispiel #2
0
        /// <summary>
        /// 注册敌人英雄UI信息
        /// </summary>
        /// <param name="hero">注册的英雄对象</param>
        public override void RegisterEnemyHero(HeroMono hero)
        {
            BattleHeroUI hero_UI = null;

            if (UnityStaticTool.CreateObjectReletiveTo <BattleHeroUI>(BattleHeroUIPrefab, EnemyHeroParent, out hero_UI))
            {
                BattleController.Instance.DebugLog(LogType.INFO, "Register enemy hero in UI successfully!");
                hero_UI.Init(hero);
                _HeroUI.Add(hero, hero_UI);
            }
            else
            {
                BattleController.Instance.DebugLog(LogType.INFO, "Failed to register enemy hero!");
            }
        }
        /// <summary>
        /// 显示一个输入UI
        /// </summary>
        /// <param name="hero">传入当前回合的英雄</param>
        public void ShowInputUI(HeroMono hero)
        {
            //保存这个英雄的信息
            _CurHero = hero;
            FirstMenu.Clear();
            //设置tips
            TextTip.text = "当前英雄回合:" + hero.Name;
            Button button = null;

            if (UnityStaticTool.CreateObjectReletiveTo <Button>(ButtonPrefab, FirstMenuGrid.transform, out button))
            {
                button.GetComponentInChildren <Text>().text = "技能";
                button.onClick.AddListener(OnSkillButtonClick);
            }
        }
Beispiel #4
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);
         }
     }
 }