示例#1
0
        public override bool OnTransport(NPCInstance npc)
        {
            if (null == npc)
            {
                return(false);
            }

            if (npc.IsMoving)
            {
                return(false);
            }

            TriggerInstance trigger = npc.HostMap.InTriggerRange(npc);

            if (null == trigger)
            {
                npc.ChangeState(eNPCState.Pause);
                mPathNodes.CleanUp();
                npc.OnLeaveMap();
            }
            else
            {
                if (!mPathNodes.NextTargetPos())
                {
                    npc.ChangeState(eNPCState.Pause);
                    return(false);
                }

                npc.Trigger = trigger;
                npc.OnJumpToMap();
                npc.ChangeState(eNPCState.WaitJumpMap);
            }

            return(true);
        }
示例#2
0
        public override bool FollowTarget(NPCInstance npc, RoleActor target)
        {
            if (!base.FollowTarget(npc, target))
            {
                return(false);
            }

            Vector3 standPos = target.GetSurroundPosition(npc.GetPosition(), (int)npc.mCastSpellDistance, npc.Id);

            if (!Util.PassableForMod(npc.HostMap.Navigator, standPos))
            {
                if (!Util.PassableForMod(npc.HostMap.Navigator, target.GetPosition()))
                {
                    return(false);
                }
                standPos = target.GetPosition();
            }

            if (!npc.MoveTo(standPos))
            {
                return(false);
            }

            npc.ChangeState(eNPCState.FollowTarget);

            return(true);
        }
示例#3
0
        public virtual bool OnKilled(NPCInstance npc)
        {
            npc.ChangeState(eNPCState.Dead);
            npc.mAttackTarget = 0;

            return(true);
        }
示例#4
0
        public override bool FollowTarget(NPCInstance npc, RoleActor target)
        {
            if (!base.FollowTarget(npc, target))
            {
                return(false);
            }

            //超出追击范围
            if (Util.DistanceH(npc.GetPosition(), npc.mSpawnPoint) > npc.InMapData.followRange)
            {
                return(false);
            }

            npc.SelectSpell();

            if (npc.CanCastSpell())
            {
                //到释放技能距离
                npc.ChangeState(eNPCState.WaitCoolDown);
            }
            else
            {
                if (npc.InMapData.followRange > 0)
                {
                    Vector3 standPos = target.GetSurroundPosition(npc.GetPosition(), (int)npc.mCastSpellDistance, npc.Id);
                    if (!Util.PassableForMod(npc.HostMap.Navigator, standPos))
                    {
                        if (!Util.PassableForMod(npc.HostMap.Navigator, target.GetPosition()))
                        {
                            return(false);
                        }

                        standPos = target.GetPosition();
                    }

                    if (!npc.MoveTo(standPos))
                    {
                        return(false);
                    }
                }

                npc.ChangeState(eNPCState.FollowTarget);
            }

            return(true);
        }
示例#5
0
 public override bool OnPatrol(NPCInstance npc)
 {
     if (!npc.IsMoving)
     {
         npc.ChangeState(eNPCState.Idle);
     }
     return(true);
 }
示例#6
0
 public override bool OnWaitJumpMap(NPCInstance npc)
 {
     if (npc.mStateLastTime > 1000)
     {
         npc.ChangeState(eNPCState.Idle);
     }
     return(true);
 }
示例#7
0
 public override bool OnIdle(NPCInstance npc)
 {
     if (npc.mStateLastTime > GameSet.Instance.ChallengeWaitTime)
     {
         if (npc.SelectSpell())
         {
             npc.ChangeState(eNPCState.FollowTarget);
         }
     }
     return(true);
 }
示例#8
0
        public override bool OnFollowTarget(NPCInstance npc)
        {
            if (npc.IsMoving)
            {
                return(false);
            }

            if (npc.CanCastSpell())
            {
                //到释放技能距离
                npc.ChangeState(eNPCState.WaitCoolDown);
            }
            else
            {
                if (!npc.FollowTarget(npc.GetTarget(npc.mAttackTarget)))
                {
                    npc.ChangeState(eNPCState.Idle);
                    return(false);
                }
            }

            return(true);
        }
示例#9
0
        public override bool StartTransport(NPCInstance npc)
        {
            if (null == npc.HostMap)
            {
                return(false);
            }

            if (mPathNodes.targetPosNode.Count == 0)
            {
                var tplMapWay = CommonUtil.GetMapWayDataByType(npc.Camp, eCarType.FoodCar);
                if (null == tplMapWay)
                {
                    return(false);
                }

                mPathNodes.CleanUp();
                mPathNodes.targetPosNode.AddLast(tplMapWay.path1);
                mPathNodes.targetPosNode.AddLast(tplMapWay.path2);
                mPathNodes.targetPosNode.AddLast(tplMapWay.path3);
                mPathNodes.targetPosNode.AddLast(tplMapWay.path4);
                mPathNodes.targetPosNode.AddLast(tplMapWay.path5);
                mPathNodes.currNode = mPathNodes.targetPosNode.First;
            }

            int targetPath = 0;

            if (!mPathNodes.GetCurTargetPos(ref targetPath))
            {
                return(false);
            }

            List <UInt64>        wayPoints = npc.HostMap.GetWayPointList(targetPath);
            LinkedList <Vector3> nodes     = new LinkedList <Vector3>();

            foreach (var id in wayPoints)
            {
                WayPoint wp = npc.HostMap.GetWayPoint(id);
                if (null == wp)
                {
                    continue;
                }
                nodes.AddLast(wp.GetPosition());
            }
            npc.SetMoveNodes(nodes);

            npc.ChangeState(eNPCState.Transport);

            return(true);
        }
示例#10
0
 public override bool OnIdle(NPCInstance npc)
 {
     if (npc.mNextPatrolTime == 0)
     {
         int minMillisecond = (int)npc.InMapData.patrolInternalMin * 1000;
         int maxMillisecond = (int)npc.InMapData.patrolInternalMax * 1000;
         npc.mNextPatrolTime = (uint)Util.Rand.Next(minMillisecond, maxMillisecond);
     }
     if (npc.mStateLastTime > npc.mNextPatrolTime)
     {
         if (!StartPatrol(npc))
         {
             npc.ChangeState(eNPCState.Idle);
         }
         npc.mNextPatrolTime = 0;
     }
     return(true);
 }
示例#11
0
        public override bool StartPatrol(NPCInstance npc)
        {
            if (npc.InMapData.patrolRange <= 0)
            {
                return(false);
            }

            Vector3 randPos = new Vector3();

            //Vector3 randPos = Util.RandInRadius(npc.mSpawnPoint, npc.InMapData.patrolRange);
            //if (Util.PassableForMod(npc.HostMap.Navigator, randPos))
            if (Util.FindRandomPoint(npc.HostMap.Navigator, npc.GetPosition(), npc.mSpawnPoint, npc.InMapData.patrolRange, ref randPos))
            {
                if (npc.MoveTo(randPos))
                {
                    npc.ChangeState(eNPCState.Patrol);
                    return(true);
                }
            }
            return(false);
        }