Beispiel #1
0
 public static void CancelPreview(this SpellPreviewComponent self)
 {
     self.Previewing = false;
     if (self.CurSelect != null)
     {
         SelectEventSystem.Instance.Hide(self.CurSelect);
     }
 }
Beispiel #2
0
 /// <summary>
 /// 设置是否生效
 /// </summary>
 /// <param name="self"></param>
 /// <param name="enable"></param>
 public static void SetEnable(this SpellPreviewComponent self, bool enable)
 {
     if (self.Enable)
     {
         self.CancelPreview();
     }
     self.Enable = enable;
 }
Beispiel #3
0
        private static void OnInputDirect(this SpellPreviewComponent self, Vector3 point)
        {
            if (self.PreviewingSkill.SkillConfig.Mode == 0)
            {
#if SERVER //单机去掉
                self.SpellComp.SpellWithDirect(self.PreviewingSkill, point);
#else
                self.PreviewingSkill.UseSkill(point);
#endif
            }
            else
            {
                self.MoveAndSpellComp.SpellWithDirect(self.PreviewingSkill, point);
            }
        }
Beispiel #4
0
        private static void OnSelectedTarget(this SpellPreviewComponent self, Unit unit)
        {
            if (self.PreviewingSkill.SkillConfig.Mode == 0)
            {
#if SERVER //单机去掉
                self.MoveAndSpellComp.SpellWithTarget(self.PreviewingSkill, unit?.GetComponent <CombatUnitComponent>());
#else
                self.PreviewingSkill.UseSkill(Vector3.zero, unit.Id);
#endif
            }
            else
            {
                self.MoveAndSpellComp.SpellWithTarget(self.PreviewingSkill, unit?.GetComponent <CombatUnitComponent>());
            }
        }
Beispiel #5
0
 public override void Awake(SpellPreviewComponent self, Dictionary <int, int> info)
 {
     self.Enable = true;
     if (info != null)
     {
         var combatU = self.GetParent <CombatUnitComponent>();
         for (int i = 0; i < KeyCodeComponent.Instance.Skills.Length; i++)
         {
             var keyCode = KeyCodeComponent.Instance.Skills[i];
             if (info.ContainsKey(keyCode) && combatU.TryGetSkillAbility(info[keyCode], out var skill))
             {
                 self.BindSkillKeyCode(keyCode, skill);
             }
         }
     }
     else
     {
         self.BindSkillKeyDefault();
     }
 }
Beispiel #6
0
        /// <summary>
        /// 使用默认按键配置,技能绑定按键
        /// </summary>
        /// <param name="self"></param>
        public static void BindSkillKeyDefault(this SpellPreviewComponent self)
        {
            var combatU = self.GetParent <CombatUnitComponent>();

            Log.Info("使用默认按键配置,技能绑定按键");
            int i = 0;

            foreach (var item in combatU.IdSkillMap)
            {
                if (i < KeyCodeComponent.Instance.Skills.Length)
                {
                    var keyCode = KeyCodeComponent.Instance.Skills[i];
                    self.BindSkillKeyCode(keyCode, combatU.GetChild <SkillAbility>(item.Value));
                }
                else
                {
                    break;
                }

                i++;
            }
        }
Beispiel #7
0
 /// <summary>
 /// 绑定技能与按键
 /// </summary>
 /// <param name="self"></param>
 /// <param name="keyCode"></param>
 /// <param name="ability"></param>
 public static void BindSkillKeyCode(this SpellPreviewComponent self, int keyCode, SkillAbility ability)
 {
     self.InputSkills[keyCode] = ability;
 }
Beispiel #8
0
 public static void SelectTargetsWithDistance(this SpellPreviewComponent self, Vector3 point)
 {
 }
Beispiel #9
0
        /// <summary>
        /// 进入预览
        /// </summary>
        /// <param name="self"></param>
        public static void EnterPreview(this SpellPreviewComponent self)
        {
            if (!self.Enable)
            {
                return;
            }
            self.CancelPreview();
            self.Previewing = true;
            //伤害作用对象(0自身1己方2敌方)
            var affectTargetType = self.PreviewingSkill.SkillConfig.DamageTarget;
            //技能预览类型(0大圈选一个目标,1大圈选小圈)
            var previewType = self.PreviewingSkill.SkillConfig.PreviewType;

            // Log.Info("affectTargetType"+affectTargetType+" targetSelectType"+targetSelectType+" previewType"+previewType);

            //0大圈选一个目标
            if (previewType == SkillPreviewType.SelectTarget)
            {
                var comp = self.GetComponent <TargetSelectComponent>();
                if (comp == null)
                {
                    comp = self.AddComponent <TargetSelectComponent>();
                }
                comp.TargetLimitType = affectTargetType;
                comp.Mode            = self.PreviewingSkill.SkillConfig.Mode;
                SelectEventSystem.Instance.Show <Action <Unit>, int[]>(comp, (a) => { self.OnSelectedTarget(a); },
                                                                       self.PreviewingSkill.SkillConfig.PreviewRange).Coroutine();
                self.CurSelect = comp;
            }
            //1大圈选小圈
            else if (previewType == SkillPreviewType.SelectCircularInCircularArea)
            {
                var comp = self.GetComponent <PointSelectComponent>();
                if (comp == null)
                {
                    comp = self.AddComponent <PointSelectComponent>();
                }
                comp.Mode = self.PreviewingSkill.SkillConfig.Mode;
                SelectEventSystem.Instance.Show <Action <Vector3>, int[]>(comp, (a) => { self.OnInputPoint(a); },
                                                                          self.PreviewingSkill.SkillConfig.PreviewRange).Coroutine();
                self.CurSelect = comp;
            }
            //2矩形
            else if (previewType == SkillPreviewType.SelectRectangleArea)
            {
                var comp = self.GetComponent <DirectRectSelectComponent>();
                if (comp == null)
                {
                    comp = self.AddComponent <DirectRectSelectComponent>();
                }
                comp.Mode = self.PreviewingSkill.SkillConfig.Mode;
                SelectEventSystem.Instance.Show <Action <Vector3>, int[]>(comp, (a) => { self.OnInputDirect(a); },
                                                                          self.PreviewingSkill.SkillConfig.PreviewRange).Coroutine();
                self.CurSelect = comp;
            }
            //自动
            else
            {
                Log.Error("未处理的施法类型" + previewType);
            }
        }