예제 #1
0
파일: Impact.cs 프로젝트: 372285834/GServer
        /// <summary>
        /// 运行攻击
        /// </summary>
        public void Run(bool isBroadCast = true)
        {
            if (null == mOwner || null == mTarget)
            {
                return;
            }

            //战斗状态

            //pk状态

            //pk保护

            //开始攻击
            mOwner.OnAttack();

            //开始计算伤害
            mTarget.OnImpactBegin(this);

            //计算伤害
            ComputeImpact();

            //计算仇恨
            ComputeHatred();

            //结束计算伤害
            mTarget.OnImpactEnd();

            //结束攻击
            mTarget.OnImpacted(isBroadCast);

            if (mKilled)
            {
                //触发击杀事件
                if (mTarget.GameType == eActorGameType.Npc)
                {
                    if (mOwner.GameType == eActorGameType.Player)
                    {
                        mOwner.DispatchEvent(EventType.Kill, mTarget);
                    }
                    else if (mOwner.GameType == eActorGameType.Npc)
                    {
                        Owner.HostMap.Owner.DispatchEvent(EventType.Kill, mTarget);
                    }
                }
                mOwner.OnKillActor(mTarget);
                mOwner.KickOneFromEnmityList(mTarget.Id);
            }
        }