Ejemplo n.º 1
0
        private void ExecuteAction(NSkillCastInfo cast)
        {
            BattleContext context = new BattleContext(this);

            context.Caster    = EntityManager.Instance.GetCreature(cast.casterId);
            context.Target    = EntityManager.Instance.GetCreature(cast.targetId);
            context.CastSkill = cast;
            // context.Position = cast.Postion;

            if (context.Caster != null)
            {
                this.JoinBattle(context.Caster);
            }
            if (context.Target != null)
            {
                this.JoinBattle(context.Target);
            }

            context.Caster.CastSkill(context, cast.skillId);//执行到帧update执行发送消息
        }
Ejemplo n.º 2
0
        public SkillResult CanCast(BattleContext context)
        {
            if (this.Status != SkillStatus.None)
            {
                return(SkillResult.Casting);
            }
            if (this.Define.CastTarget == TargetType.Target)
            {
                if (context.Target == null || context.Target == this.Owner)
                {
                    return(SkillResult.InvalidTarget);
                }
                int distance = this.Owner.Distance(context.Target);
                if (distance > this.Define.CastRange)
                {
                    return(SkillResult.OutOfRange);
                }
            }

            if (this.Define.CastTarget == TargetType.Position)
            {
                if (context.CastSkill.Position == null)
                {
                    return(SkillResult.InvalidTarget);
                }
                if (this.Owner.Distance(context.Position) > this.Define.CastRange)
                {
                    return(SkillResult.OutOfRange);
                }
            }
            if (this.Owner.Attributes.MP < this.Define.MPCost)
            {
                return(SkillResult.OutOfMp);
            }
            if (this.cd > 0)
            {
                return(SkillResult.CoolDown);
            }
            return(SkillResult.Ok);
        }
Ejemplo n.º 3
0
        internal SkillResult Cast(BattleContext context)
        {
            SkillResult result = this.CanCast(context);

            if (result == SkillResult.Ok)
            {
                this.Hit         = 0;
                this.castingTime = 0;
                this.skillTime   = 0;
                this.cd          = this.Define.Cd;
                this.Context     = context;
                this.Bullets.Clear();
                this.AddBuff(TriggerType.SkillCast, this.Context.Target);
                if (this.Instant)
                {
                    this.DoHit();
                }
                else
                {
                    if (this.Define.CastTime > 0)
                    {
                        this.Status = SkillStatus.Casting;
                    }
                    else
                    {
                        this.Status = SkillStatus.Runing;
                    }
                }
                //if (context.Target != null)
                //{
                //    this.DoSkillDamage(context);
                //}
            }
            // this.cd = this.Define.Cd;
            return(result);
        }
Ejemplo n.º 4
0
        internal void AddBuff(BattleContext context, BuffDefine define)
        {
            Buff buff = new Buff(this.BuffID, this.Owner, define, context);

            this.Buffs.Add(buff);
        }