예제 #1
0
        private AiData_PveNpc_General GetAiData(NpcInfo npc)
        {
            AiData_PveNpc_General data = npc.GetAiStateInfo().AiDatas.GetData <AiData_PveNpc_General>();

            if (null == data)
            {
                data = new AiData_PveNpc_General();
                npc.GetAiStateInfo().AiDatas.AddData(data);
            }
            return(data);
        }
예제 #2
0
        private AiData_Demo_Melee GetAiData(NpcInfo npc)
        {
            AiData_Demo_Melee data = npc.GetAiStateInfo().AiDatas.GetData <AiData_Demo_Melee>();

            if (null == data)
            {
                data = new AiData_Demo_Melee();
                npc.GetAiStateInfo().AiDatas.AddData(data);
            }
            return(data);
        }
예제 #3
0
        private void InitPatrolData(NpcInfo npc)
        {
            AiData_ForPatrolCommand data = new AiData_ForPatrolCommand();

            data.IsLoopPatrol = true;
            List <Vector3> path = new List <Vector3>();
            NpcAiStateInfo info = npc.GetAiStateInfo();

            path = Converter.ConvertVector3DList(info.AiParam[1]);
            data.PatrolPath.SetPathPoints(npc.GetAiStateInfo().HomePos, path);
            npc.GetAiStateInfo().AiDatas.AddData <AiData_ForPatrolCommand>(data);
            AiData_Demo_Melee aiData = GetAiData(npc);

            aiData.HasPatrolData = true;
        }
예제 #4
0
        internal static Msg_RC_NpcMove BuildNpcMoveMessage(NpcInfo npc)
        {
            Msg_RC_NpcMove npcMoveBuilder = new Msg_RC_NpcMove();

            if (npc.GetMovementStateInfo().IsMoving)
            {
                npcMoveBuilder.npc_id         = npc.GetId();
                npcMoveBuilder.is_moving      = true;
                npcMoveBuilder.move_direction = (float)npc.GetMovementStateInfo().GetMoveDir();
                npcMoveBuilder.face_direction = (float)npc.GetMovementStateInfo().GetFaceDir();
                npcMoveBuilder.cur_pos_x      = npc.GetMovementStateInfo().GetPosition3D().X;
                npcMoveBuilder.cur_pos_z      = npc.GetMovementStateInfo().GetPosition3D().Z;
                NpcAiStateInfo data = npc.GetAiStateInfo();
                npcMoveBuilder.target_pos_x         = npc.GetMovementStateInfo().TargetPosition.X;
                npcMoveBuilder.target_pos_z         = npc.GetMovementStateInfo().TargetPosition.Z;
                npcMoveBuilder.velocity_coefficient = (float)npc.VelocityCoefficient;
                npcMoveBuilder.velocity             = npc.GetActualProperty().MoveSpeed;
                npcMoveBuilder.move_mode            = (int)npc.GetMovementStateInfo().MovementMode;
            }
            else
            {
                npcMoveBuilder.npc_id    = npc.GetId();
                npcMoveBuilder.is_moving = false;
                npcMoveBuilder.cur_pos_x = npc.GetMovementStateInfo().GetPosition3D().X;
                npcMoveBuilder.cur_pos_z = npc.GetMovementStateInfo().GetPosition3D().Z;
            }
            return(npcMoveBuilder);
        }
예제 #5
0
        private void IdleHandler(NpcInfo npc, AiCommandDispatcher aiCmdDispatcher, long deltaTime)
        {
            if (npc.IsDead())
            {
                return;
            }
            NpcAiStateInfo info = npc.GetAiStateInfo();

            info.Time += deltaTime;
            if (info.Time > 100)
            {
                info.Time = 0;
                CharacterInfo target = AiLogicUtility.GetNearstTargetHelper(npc, CharacterRelation.RELATION_ENEMY);
                if (null != target)
                {
                    npc.GetMovementStateInfo().IsMoving = false;
                    info.Time   = 0;
                    info.Target = target.GetId();
                    ChangeToState(npc, (int)AiStateId.Combat);
                    NotifyNpcTargetChange(npc);
                }
                else
                {
                }
            }
        }
예제 #6
0
        private AiData_PveNpc_Monster_CloseCombat GetAiData(NpcInfo npc)
        {
            AiData_PveNpc_Monster_CloseCombat data = npc.GetAiStateInfo().AiDatas.GetData <AiData_PveNpc_Monster_CloseCombat>();

            if (null == data)
            {
                NpcAiStateInfo info = npc.GetAiStateInfo();
                data = new AiData_PveNpc_Monster_CloseCombat();
                data.FastMoveImpact     = int.Parse(info.AiParam[0]);
                data.PreAttackImpact    = int.Parse(info.AiParam[1]);
                data.PreAttackDistance  = int.Parse(info.AiParam[2]);
                data.StandShootDistance = int.Parse(info.AiParam[3]);
                npc.GetAiStateInfo().AiDatas.AddData(data);
            }
            return(data);
        }
예제 #7
0
 public void Execute(NpcInfo npc, AiCommandDispatcher aiCmdDispatcher, long deltaTime)
 {
     if (npc.GetAIEnable())
     {
         NpcAiStateInfo npcAi = npc.GetAiStateInfo();
         if (npcAi.CommandQueue.Count <= 0)
         {
             int curState = npcAi.CurState;
             if (curState > (int)AiStateId.Invalid && curState < (int)AiStateId.MaxNum)
             {
                 if (m_Handlers.ContainsKey(curState))
                 {
                     NpcAiStateHandler handler = m_Handlers[curState];
                     if (null != handler)
                     {
                         handler(npc, aiCmdDispatcher, deltaTime);
                     }
                 }
                 else
                 {
                     LogSystem.Error("Illegal ai state: " + curState + " npc:" + npc.GetId());
                 }
             }
             else
             {
                 OnStateLogicInit(npc, aiCmdDispatcher, deltaTime);
                 ChangeToState(npc, (int)AiStateId.Idle);
             }
         }
         ExecuteCommandQueue(npc, deltaTime);
     }
 }
예제 #8
0
        private void MoveHandler(NpcInfo npc, AiCommandDispatcher aiCmdDispatcher, long deltaTime)
        {
            if (npc.IsDead())
            {
                npc.GetMovementStateInfo().IsMoving = false;
                ChangeToState(npc, (int)AiStateId.Wait);
                return;
            }
            NpcAiStateInfo info = npc.GetAiStateInfo();

            info.Time += deltaTime;
            if (info.Time > 10)
            {
                info.Time = 0;
                Vector3 srcPos    = npc.GetMovementStateInfo().GetPosition3D();
                Vector3 startPos  = info.HomePos;
                Vector3 targetPos = npc.GetMovementStateInfo().TargetPosition;
                if (!IsReached(srcPos, targetPos))
                {
                    float angle = Geometry.GetYAngle(new Vector2(srcPos.X, srcPos.Z), new Vector2(targetPos.X, targetPos.Z));
                    npc.GetMovementStateInfo().SetMoveDir(angle);
                    npc.GetMovementStateInfo().IsMoving = true;
                }
            }
        }
예제 #9
0
        private void IdleHandler(NpcInfo npc, AiCommandDispatcher aiCmdDispatcher, long deltaTime)
        {
            NpcAiStateInfo info = npc.GetAiStateInfo();

            npc.GetMovementStateInfo().IsMoving = false;
            ChangeToState(npc, (int)AiStateId.Wait);
        }
예제 #10
0
        public static void DoMoveCommandState(NpcInfo npc, AiCommandDispatcher aiCmdDispatcher, long deltaTime)
        {
            //执行状态处理
            AiData_ForMoveCommand data = GetAiDataForMoveCommand(npc);

            if (null == data)
            {
                return;
            }

            if (!data.IsFinish)
            {
                if (WayPointArrived(npc, data))
                {
                    MoveToNext(npc, data);
                }
            }

            //判断是否状态结束并执行相应处理
            if (null != data && data.IsFinish)
            {
                npc.GetMovementStateInfo().IsMoving = false;
                npc.GetAiStateInfo().PopState();
            }
        }
예제 #11
0
        internal static void Execute(object msg, User user)
        {
            Msg_CR_PickUpNpc pickUpNpcMsg = msg as Msg_CR_PickUpNpc;

            if (null != pickUpNpcMsg)
            {
                UserInfo userInfo = user.Info;
                if (null != userInfo)
                {
                    Scene scene = user.OwnRoom.GetActiveScene();
                    if (null != scene)
                    {
                        NpcInfo npc = scene.SceneContext.GetCharacterInfoById(pickUpNpcMsg.npc_id) as NpcInfo;
                        if (null != npc && npc.OwnerId == userInfo.GetId())
                        {
                            npc.NeedDelete = true;
                            DropOutInfo info = npc.GetAiStateInfo().AiDatas.GetData <DropOutInfo>();
                            if (null != info)
                            {
                                userInfo.Money += info.Value;
                            }
                        }
                    }
                }
            }
        }
예제 #12
0
        private void IdleHandler(NpcInfo npc, AiCommandDispatcher aiCmdDispatcher, long deltaTime)
        {
            if (npc.IsDead())
            {
                return;
            }
            NpcAiStateInfo        info = npc.GetAiStateInfo();
            AiData_PvpNpc_General data = GetAiData(npc);

            if (null != data)
            {
                npc.GetMovementStateInfo().IsMoving = false;
                if (data.PatrolPath.HavePathPoint)
                {
                    info.HomePos = npc.GetMovementStateInfo().GetPosition3D();
                    info.Time    = 0;
                    data.FoundPath.Clear();
                    ChangeToState(npc, (int)AiStateId.Patrol);
                }
                else
                {
                    ChangeToState(npc, (int)AiStateId.Combat);
                }
            }
        }
예제 #13
0
        private void GoHomeHandler(NpcInfo npc, AiCommandDispatcher aiCmdDispatcher, long deltaTime)
        {
            if (npc.IsDead())
            {
                return;
            }
            ChangeToState(npc, (int)AiStateId.Idle);
            NpcAiStateInfo info = npc.GetAiStateInfo();

            info.Time += deltaTime;
            if (info.Time > m_IntervalTime)
            {
                info.Time = 0;
                AiData_Demo_Melee data = GetAiData(npc);
                if (null != data)
                {
                    Vector3 targetPos            = info.HomePos;
                    ScriptRuntime.Vector3 srcPos = npc.GetMovementStateInfo().GetPosition3D();
                    float powDistToHome          = Geometry.DistanceSquare(srcPos, info.HomePos);
                    if (powDistToHome <= 1)
                    {
                        npc.GetMovementStateInfo().IsMoving = false;
                        info.Time = 0;
                        ChangeToState(npc, (int)AiStateId.Idle);
                    }
                    else
                    {
                        AiLogicUtility.PathToTargetWithoutObstacle(npc, data.FoundPath, targetPos, 100, true, this);
                    }
                }
            }
        }
예제 #14
0
        private void TickNpc(NpcInfo npc, long delta)
        {
            INpcStateLogic logic = AiLogicManager.Instance.GetNpcStateLogic(npc.GetAiStateInfo().AiLogic);

            if (null != logic)
            {
                logic.Execute(npc, m_AiCommandDispatcher, delta);
            }
        }
예제 #15
0
        private void PursuitHandler(NpcInfo npc, AiCommandDispatcher aiCmdDispatcher, long deltaTime)
        {
            if (npc.IsDead())
            {
                return;
            }
            NpcAiStateInfo        info   = npc.GetAiStateInfo();
            bool                  goHome = false;
            AiData_PveNpc_General data   = GetAiData(npc);

            if (null != data)
            {
                CharacterInfo target = AiLogicUtility.GetLivingCharacterInfoHelper(npc, info.Target);
                if (null != target)
                {
                    float   dist                 = (float)npc.GetActualProperty().AttackRange;
                    float   distGoHome           = (float)npc.GohomeRange;
                    Vector3 targetPos            = target.GetMovementStateInfo().GetPosition3D();
                    ScriptRuntime.Vector3 srcPos = npc.GetMovementStateInfo().GetPosition3D();
                    float powDist                = Geometry.DistanceSquare(srcPos, targetPos);
                    float powDistToHome          = Geometry.DistanceSquare(srcPos, info.HomePos);
                    if (powDist < dist * dist)
                    {
                        npc.GetMovementStateInfo().IsMoving = false;
                        info.Time = 0;
                        data.Time = 0;
                        ChangeToState(npc, (int)AiStateId.Combat);
                        NotifyNpcMove(npc);
                    }
                    else if (true) // 目标存活的情况下屏蔽掉gohome。
                    {
                        info.Time += deltaTime;
                        if (info.Time > m_IntervalTime)
                        {
                            info.Time = 0;
                            AiLogicUtility.PathToTargetWithoutObstacle(npc, data.FoundPath, targetPos, m_IntervalTime, true, this);
                        }
                    }
                    else
                    {
                        goHome = true;
                    }
                }
                else
                {
                    goHome = true;
                }
                if (goHome)
                {
                    npc.GetMovementStateInfo().IsMoving = false;
                    NotifyNpcMove(npc);
                    info.Time = 0;
                    data.Time = 0;
                    ChangeToState(npc, (int)AiStateId.GoHome);
                }
            }
        }
예제 #16
0
        protected override void OnStateLogicInit(NpcInfo npc, AiCommandDispatcher aiCmdDispatcher, long deltaTime)
        {
            NpcAiStateInfo info = npc.GetAiStateInfo();

            info.HomePos = npc.GetMovementStateInfo().GetPosition3D();
            info.Time    = 0;
            info.Target  = 0;
            npc.GetMovementStateInfo().IsMoving = false;
        }
예제 #17
0
        private AiData_PveNpc_Monster GetAiData(NpcInfo npc)
        {
            AiData_PveNpc_Monster data = npc.GetAiStateInfo().AiDatas.GetData <AiData_PveNpc_Monster>();

            if (null == data)
            {
                NpcAiStateInfo info = npc.GetAiStateInfo();
                data = new AiData_PveNpc_Monster();
                SkillInfo skillInfo = npc.GetSkillStateInfo().GetSkillInfoByIndex(0);
                if (null != skillInfo)
                {
                    data.Skill = skillInfo.SkillId;
                }
                data.ShootDistance = int.Parse(info.AiParam[0]);
                npc.GetAiStateInfo().AiDatas.AddData(data);
            }
            return(data);
        }
예제 #18
0
        private AiData_PveNpc_Trap GetAiData(NpcInfo npc)
        {
            AiData_PveNpc_Trap data = npc.GetAiStateInfo().AiDatas.GetData <AiData_PveNpc_Trap>();

            if (null == data)
            {
                NpcAiStateInfo info = npc.GetAiStateInfo();
                data = new AiData_PveNpc_Trap();
                data.RadiusOfTrigger = int.Parse(info.AiParam[0]);
                data.RadiusOfDamage  = int.Parse(info.AiParam[1]);
                data.DamageCount     = int.Parse(info.AiParam[2]);
                data.ImpactToMyself  = int.Parse(info.AiParam[3]);
                data.Impact1ToTarget = int.Parse(info.AiParam[4]);
                data.Impact2ToTarget = int.Parse(info.AiParam[5]);
                data.HideImpact      = int.Parse(info.AiParam[6]);
                npc.GetAiStateInfo().AiDatas.AddData(data);
            }
            return(data);
        }
예제 #19
0
        public void NpcFace(NpcInfo npc, AbstractNpcStateLogic logic)
        {
            NpcFaceCommand cmd = m_NpcFaceCommandPool.Alloc();

            if (null != cmd)
            {
                cmd.SetContext(npc, logic);
                cmd.Init();
                npc.GetAiStateInfo().CommandQueue.Enqueue(cmd);
            }
        }
예제 #20
0
        public void NpcSkill(NpcInfo npc, AbstractNpcStateLogic logic, int skillId, int targetId, ScriptRuntime.Vector3 targetPos, float targetAngle)
        {
            NpcSkillCommand cmd = m_NpcSkillCommandPool.Alloc();

            if (null != cmd)
            {
                cmd.SetContext(npc, logic);
                cmd.Init(skillId, targetId, targetPos, targetAngle);
                npc.GetAiStateInfo().CommandQueue.Enqueue(cmd);
            }
        }
예제 #21
0
        internal static Msg_RC_NpcTarget BuildNpcTargetMessage(NpcInfo npc)
        {
            Msg_RC_NpcTarget npcFaceTargetBuilder = null;
            NpcAiStateInfo   data = npc.GetAiStateInfo();

            if (null != data && data.Target > 0)
            {
                npcFaceTargetBuilder           = new Msg_RC_NpcTarget();
                npcFaceTargetBuilder.npc_id    = npc.GetId();
                npcFaceTargetBuilder.target_id = data.Target;
            }
            return(npcFaceTargetBuilder);
        }
예제 #22
0
        protected override void OnStateLogicInit(NpcInfo npc, AiCommandDispatcher aiCmdDispatcher, long deltaTime)
        {
            NpcAiStateInfo        info = npc.GetAiStateInfo();
            AiData_PvpNpc_General data = GetAiData(npc);

            if (null != data)
            {
                info.Time = 0;
                npc.GetMovementStateInfo().IsMoving = false;
                info.HomePos = npc.GetMovementStateInfo().GetPosition3D();
                info.Target  = 0;
            }
        }
예제 #23
0
        private void IdleHandler(NpcInfo npc, AiCommandDispatcher aiCmdDispatcher, long deltaTime)
        {
            if (npc.IsDead())
            {
                return;
            }
            NpcAiStateInfo info = npc.GetAiStateInfo();

            info.Time += deltaTime;
            if (info.Time > 100)
            {
                info.Time = 0;
                if (GetAiData(npc).HasPatrolData)
                {
                    npc.GetMovementStateInfo().IsMoving = false;
                    ChangeToState(npc, (int)AiStateId.PatrolCommand);
                }
                else
                {
                    CharacterInfo target = null;
                    if (info.IsExternalTarget)
                    {
                        target = AiLogicUtility.GetSeeingLivingCharacterInfoHelper(npc, info.Target);
                        if (null == target)
                        {
                            target = AiLogicUtility.GetNearstTargetHelper(npc, CharacterRelation.RELATION_ENEMY);
                            if (null != target)
                            {
                                info.Target = target.GetId();
                            }
                        }
                    }
                    else
                    {
                        target = AiLogicUtility.GetNearstTargetHelper(npc, CharacterRelation.RELATION_ENEMY);
                        if (null != target)
                        {
                            info.Target = target.GetId();
                        }
                    }
                    if (null != target)
                    {
                        NotifyNpcTargetChange(npc);
                        npc.GetMovementStateInfo().IsMoving = false;
                        NotifyNpcMove(npc);
                        info.Time = 0;
                        ChangeToState(npc, (int)AiStateId.Pursuit);
                    }
                }
            }
        }
예제 #24
0
        private void CombatHandler(NpcInfo npc, AiCommandDispatcher aiCmdDispatcher, long deltaTime)
        {
            if (npc.IsDead())
            {
                return;
            }
            NpcAiStateInfo info = npc.GetAiStateInfo();

            info.Time += deltaTime;
            float rps = npc.GetActualProperty().Rps;

            if (rps > 0.001f && info.Time > 1000 / rps)
            {
                info.Time = 0;
                bool          toIdle = false;
                CharacterInfo target = AiLogicUtility.GetSeeingLivingCharacterInfoHelper(npc, info.Target);
                if (null != target && npc.SpatialSystem.CanShoot(npc.SpaceObject, target.GetMovementStateInfo().GetPosition3D()))
                {
                    ScriptRuntime.Vector3 targetPos = target.GetMovementStateInfo().GetPosition3D();
                    ScriptRuntime.Vector3 srcPos    = npc.GetMovementStateInfo().GetPosition3D();
                    float powDist  = Geometry.DistanceSquare(srcPos, targetPos);
                    float dist     = (float)npc.GetActualProperty().AttackRange;
                    float distView = (float)npc.ViewRange;
                    if (powDist < dist * dist)
                    {
                        npc.GetMovementStateInfo().IsMoving = false;
                    }
                    else if (powDist < distView * distView)
                    {
                        npc.GetMovementStateInfo().IsMoving = false;
                    }
                    else
                    {
                        toIdle = true;
                    }
                }
                else
                {
                    toIdle = true;
                }
                if (toIdle)
                {
                    info.Time = 0;
                    npc.GetMovementStateInfo().IsMoving = false;
                    ChangeToState(npc, (int)AiStateId.Idle);
                }
            }
        }
예제 #25
0
        private void IdleHandler(NpcInfo npc, AiCommandDispatcher aiCmdDispatcher, long deltaTime)
        {
            if (npc.IsDead())
            {
                return;
            }
            NpcAiStateInfo info = npc.GetAiStateInfo();

            info.Time += deltaTime;
            if (info.Time > 100)
            {
                info.Time = 0;
                npc.GetMovementStateInfo().IsMoving = false;
                ChangeToState(npc, (int)AiStateId.PatrolCommand);
            }
        }
예제 #26
0
        private void PatrolHandler(NpcInfo npc, AiCommandDispatcher aiCmdDispatcher, long deltaTime)
        {
            if (npc.IsDead())
            {
                return;
            }
            NpcAiStateInfo info = npc.GetAiStateInfo();

            info.Time += deltaTime;
            if (info.Time > 100)
            {
                info.Time = 0;
                AiData_PvpNpc_General data = GetAiData(npc);
                if (null != data)
                {
                    CharacterInfo interestestTarget = GetInterestestTargetHelper(npc, CharacterRelation.RELATION_ENEMY);
                    if (null != interestestTarget)
                    {
                        npc.GetMovementStateInfo().IsMoving = false;
                        NotifyNpcMove(npc);
                        info.Time   = 0;
                        info.Target = interestestTarget.GetId();
                        data.FoundPath.Clear();
                        ChangeToState(npc, (int)AiStateId.Pursuit);
                    }
                    else
                    {
                        ScriptRuntime.Vector3 srcPos = npc.GetMovementStateInfo().GetPosition3D();
                        if (!data.PatrolPath.IsReached(srcPos))
                        {
                            PathToTargetWithoutObstacle(npc, data.FoundPath, data.PatrolPath.CurPathPoint, 100);
                        }
                        else
                        {
                            data.PatrolPath.UseNextPathPoint();
                            data.FoundPath.Clear();
                            if (!data.PatrolPath.HavePathPoint)
                            {
                                info.Time = 0;
                                ChangeToState(npc, (int)AiStateId.Idle);
                            }
                        }
                        info.HomePos = npc.GetMovementStateInfo().GetPosition3D();
                    }
                }
            }
        }
예제 #27
0
        private void ExecuteCommandQueue(NpcInfo npc, long deltaTime)
        {
            NpcAiStateInfo npcAi = npc.GetAiStateInfo();

            while (npcAi.CommandQueue.Count > 0)
            {
                IAiCommand cmd = npcAi.CommandQueue.Peek();
                if (cmd.Execute(deltaTime))
                {
                    npcAi.CommandQueue.Dequeue();
                }
                else
                {
                    break;
                }
            }
        }
예제 #28
0
        private void IdleHandler(NpcInfo npc, AiCommandDispatcher aiCmdDispatcher, long deltaTime)
        {
            if (npc.IsDead())
            {
                return;
            }
            NpcAiStateInfo     info = npc.GetAiStateInfo();
            AiData_PveNpc_Trap data = GetAiData(npc);

            if (null != data)
            {
                info.Time += deltaTime;
                if (info.Time > 100)
                {
                    info.Time = 0;
                    if (data.HideImpact > 0)
                    {
                        ImpactInfo impactInfo = npc.GetSkillStateInfo().GetImpactInfoById(data.HideImpact);
                        if (null == impactInfo)
                        {
                            ServerNpcImpact(npc, data.HideImpact, npc);
                        }
                    }
                    IList <ISpaceObject> objs = npc.SpatialSystem.GetObjectInCircle(npc.GetMovementStateInfo().GetPosition3D(), data.RadiusOfTrigger);
                    foreach (ISpaceObject obj in objs)
                    {
                        if (obj.GetObjType() == SpatialObjType.kNPC || obj.GetObjType() == SpatialObjType.kUser)
                        {
                            CharacterInfo charInfo = obj.RealObject as CharacterInfo;
                            if (null != charInfo)
                            {
                                if (CharacterInfo.GetRelation(npc, charInfo) == CharacterRelation.RELATION_ENEMY)
                                {
                                    info.Time   = 0;
                                    info.Target = charInfo.GetId();
                                    ChangeToState(npc, (int)AiStateId.Combat);
                                    NotifyNpcTargetChange(npc);
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #29
0
        private void DropNpc(Vector3 pos, int money, string model, string particle)
        {
            //给每个玩家掉落一个
            Data_Unit unit = new Data_Unit();

            unit.m_Id       = -1;
            unit.m_LinkId   = 100001;
            unit.m_AiLogic  = (int)AiStateLogicId.DropOut_AutoPick;
            unit.m_RotAngle = 0;
            for (LinkedListNode <UserInfo> linkNode = UserManager.Users.FirstValue; null != linkNode; linkNode = linkNode.Next)
            {
                UserInfo userInfo = linkNode.Value;
                if (null != userInfo)
                {
                    float x = CrossEngineHelper.Random.NextFloat() * 4 - 2;
                    float z = CrossEngineHelper.Random.NextFloat() * 4 - 2;
                    pos.X += x;
                    pos.Z += z;

                    NpcInfo npcInfo = NpcManager.AddNpc(unit);
                    npcInfo.GetMovementStateInfo().SetPosition(pos);
                    npcInfo.GetMovementStateInfo().SetFaceDir(0);
                    npcInfo.GetMovementStateInfo().IsMoving = false;
                    npcInfo.SetAIEnable(true);
                    npcInfo.SetCampId((int)CampIdEnum.Friendly);
                    npcInfo.OwnerId   = userInfo.GetId();
                    npcInfo.DropMoney = money;

                    DropOutInfo dropInfo = new DropOutInfo();
                    dropInfo.DropType = DropOutType.GOLD;
                    dropInfo.Value    = money;
                    dropInfo.Model    = model;
                    dropInfo.Particle = particle;
                    npcInfo.GetAiStateInfo().AiDatas.AddData <DropOutInfo>(dropInfo);
                    npcInfo.SetModel(dropInfo.Model);

                    User us = userInfo.CustomData as User;
                    if (null != us)
                    {
                        Msg_RC_CreateNpc builder = DataSyncUtility.BuildCreateNpcMessage(npcInfo);
                        us.SendMessage(builder);
                    }
                }
            }
        }
예제 #30
0
        private void InitIdleAnim(NpcInfo npc)
        {
            NpcAiStateInfo info = npc.GetAiStateInfo();

            if (null != info)
            {
                List <int> anims = Converter.ConvertNumericList <int>(info.AiParam[1]);
                if (null != OnSetNpcIdleAnim)
                {
                    OnSetNpcIdleAnim(npc, anims);
                }
                if (!string.IsNullOrEmpty(info.AiParam[2]))
                {
                    AiData_Demo_Melee aiData = GetAiData(npc);
                    aiData.MeetEnemyAnim = (Animation_Type)int.Parse(info.AiParam[2]);
                }
            }
        }