Ejemplo n.º 1
0
 /// <summary>
 /// 注册一个技能控制器的特效
 /// </summary>
 /// <param name="skill">技能控制器</param>
 public void RegisterSkillEffect(BaseSkill skill)
 {
     if (skill.SkillEffects.Count > 0 && !_SkillEffect.ContainsKey(skill.GetSkillIDAndLevel()))
     {
         Transform obj = null;
         for (int i = 0; i < skill.SkillEffects.Count; i++)
         {
             if (UnityStaticTool.CreateObjectTo <Transform>(skill.SkillEffects[i], this.transform, Vector3.zero, out obj))
             {
                 obj.gameObject.SetActive(false);
                 if (_SkillEffect.ContainsKey(skill.GetSkillIDAndLevel()))
                 {
                     _SkillEffect[skill.GetSkillIDAndLevel()].Add(obj.gameObject);
                 }
                 else
                 {
                     _SkillEffect.Add(skill.GetSkillIDAndLevel(), new List <GameObject>()
                     {
                         obj.gameObject
                     });
                 }
             }
         }
     }
     else
     {
         BattleController.Instance.DebugLog(LogType.ERROR, "Skill effect register failed! No effect found or effect is exist!");
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 每个回合行动中调用
        /// </summary>
        void Actioning()
        {
            //出去当前英雄的其他英雄所有技能CD和蓄力进行减少
            //for (int i = 0; i < _PlayerTeam.Count; i++)
            //{
            //    if (_PlayerTeam[i] != _CurTurnHero)
            //    {
            //        _PlayerTeam[i].CoolDownSkillCD(1);
            //        _PlayerTeam[i].CoolDownSkillDelay(1);
            //    }
            //}
            //for (int i = 0; i < _EnemyTeam.Count; i++)
            //{
            //    if (_EnemyTeam[i] != _CurTurnHero)
            //    {
            //        _EnemyTeam[i].CoolDownSkillCD(1);
            //        _EnemyTeam[i].CoolDownSkillDelay(1);
            //    }
            //}
            //冷却一回合技能CD或者蓄力冷却一回合
            _CurTurnHero.CoolDownSkillCD(1);
            BaseSkill skill = _CurTurnHero.CoolDownSkillDelay(1);

            if (skill != null)
            {
                if (skill.CurrentDelayTurn > 0)
                {
                    //蓄力或者使用这个技能
                    _CurTurnHero.Attack(skill.SkillType);
                }
                else
                {
                    //直接使用这个技能
                    _CurTurnHero.ExcuteSkill(skill.SkillType);
                }
            }
            else
            {
                //如果当前没有蓄力技能释放
                //如果是玩家的回合,并且不是自动战斗,则将操作交给玩家
                if (_CurTurnHero.IsPlayerHero && !IsAutoBattle)
                {
                    //等待玩家的输入
                    CurrentInputController.WaitForInput(_CurTurnHero);
                }
                else
                {
                    //如果可以施放技能,就施放技能
                    _CurTurnHero.AutoExcuteSkill();
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 为英雄添加技能
        /// </summary>
        /// <param name="skill">要添加的技能</param>
        /// <param name="hero">技能所属的英雄对象</param>
        /// <returns>返回创建的技能对象</returns>
        public BaseSkill CreateSkillTo(Skill skill, HeroMono hero)
        {
            BaseSkill result = null;

            System.Type type = System.Reflection.Assembly.GetExecutingAssembly().GetType("King.TurnBasedCombat." + skill.SkillMono);
            result = hero.gameObject.AddComponent(type) as BaseSkill;
            if (result == null)
            {
                BattleController.Instance.DebugLog(LogType.ERROR, skill.SkillMono + " Can't find,Please Check SkillMono is vaild or not!");
                return(null);
            }
            result.Init(skill, hero);
            return(result);
        }
Ejemplo n.º 4
0
 public void Init(Hero hero, bool isPlayer)
 {
     _Hero = hero;
     //获取动画控制器
     Animator = GetComponent <Animator>();
     //获取英雄的图像
     Img            = GetComponentInChildren <Image>();
     CurrentTargets = new List <HeroMono>();
     IsPlayerHero   = isPlayer;
     //翻转对象
     if (IsPlayerHero)
     {
         //AttackPosition.localPosition = new Vector3(AttackPosition.localPosition.x * -1f, AttackPosition.localPosition.y, AttackPosition.localPosition.z);
         Img.transform.localScale = new Vector3(-1f, 1f, 1f);
     }
     else
     {
         //AttackPosition.localPosition = new Vector3(AttackPosition.localPosition.x * -1f, AttackPosition.localPosition.y, AttackPosition.localPosition.z);
         Img.transform.localScale = new Vector3(1f, 1f, 1f);
     }
     //初始化buff debuff列表
     _BuffList   = new List <Buff>();
     _DebuffList = new List <Buff>();
     //初始化数据
     _CurrentHero = new HeroProperty(_Hero, SystemSetting.HeroSpeedMix);
     //创建一个血量和提示变化用的对象池
     ObjectPool.Instance.InitComponentPools <BattleHeroHub>(Name + "_Hub", HeroHubPrefab, 1);
     //注册这个英雄的UI信息
     if (IsPlayerHero)
     {
         BattleController.Instance.CurrentBattleUI.RegisterPlayerHero(this);
     }
     else
     {
         BattleController.Instance.CurrentBattleUI.RegisterEnemyHero(this);
     }
     //向SkillController注册技能
     _Skills = new Dictionary <Global.SkillType, BaseSkill>();
     for (int i = 0; i < _Hero.Skills.Count; i++)
     {
         BaseSkill skill = SkillController.Instance.CreateSkillTo(_Hero.Skills[i], this);
         if (skill != null)
         {
             _Skills.Add(_Hero.Skills[i].SkillType, skill);
         }
     }
 }