Ejemplo n.º 1
0
    public void Execuete(GameCmd.stReturnObjectPosMagicUserCmd_S cmd)
    {
        //冲锋应该是goto  瞬移应该是enumMoveType_Immediate  此处待后台修改 前台先山寨一下
        if (cmd.byMoveType == stReturnObjectPosMagicUserCmd_S.enumMoveType.enumMoveType_GoTo || cmd.byMoveType == stReturnObjectPosMagicUserCmd_S.enumMoveType.enumMoveType_Immediate)
        {
            IEntitySystem es = ClientGlobal.Instance().GetEntitySystem();
            if (es == null)
            {
                Engine.Utility.Log.Error("GetEntitySystem failed!");
                return;
            }

            stEntryPosition userPos = cmd.userpos;
            if (userPos != null)
            {
                IEntity player = es.FindEntity <IPlayer>(userPos.dwTempID);
                if (player != null)
                {
                    //MapVector2 mapPos = MapVector2.FromCoordinate(userPos.x, userPos.y);
                    Vector3    pos       = new Vector3(userPos.cur_pos.x * 0.01f, 0, -userPos.cur_pos.y * 0.01f); // 服务器到客户端坐标转换
                    ISkillPart skillPart = SkillHelper.GetSkillPart(userPos.dwTempID, EntityType.EntityType_Player);

                    if (skillPart != null)
                    {
                        if (skillPart.IsFastMove())
                        {
                            Move move = new Move();
                            move.m_target      = pos;
                            move.m_ignoreStand = true;
                            player.SendMessage(EntityMessage.EntityCommand_MoveTo, (object)move);
                        }
                        else
                        {
                            //不是在释放快速移动技能 立刻设置位置 否则延迟设置

                            player.SendMessage(EntityMessage.EntityCommand_SetPos, (object)pos);
                            //Vector3 rot = GameUtil.S2CDirection(userPos.byDir);
                            //player.SendMessage(EntityMessage.EntityCommand_SetRotate, (object)rot);
                        }
                        IEntity skillTarget = skillPart.GetSkillTarget();
                        if (skillTarget != null && skillTarget.GetUID() != player.GetUID())
                        {
                            SkillDatabase db = skillPart.GetCurSkillDataBase();
                            if (db != null)
                            {
                                if (db.targetType == (int)SkillTargetType.TargetForwardPoint)
                                {
                                    return;
                                }
                            }
                            player.SendMessage(EntityMessage.EntityCommand_LookTarget, skillTarget.GetPos());
                        }
                    }
                }
            }

            if (cmd.npcpos != null)
            {
                INPC npc = es.FindEntity <INPC>(cmd.npcpos.dwTempID);
                if (npc != null)
                {
                    //MapVector2 mapPos = MapVector2.FromCoordinate(cmd.npcpos.x, cmd.npcpos.y);
                    Vector3    pos       = new Vector3(cmd.npcpos.cur_pos.x * 0.01f, 0, -cmd.npcpos.cur_pos.y * 0.01f); // 服务器到客户端坐标转换
                    ISkillPart skillPart = SkillHelper.GetSkillPart(cmd.npcpos.dwTempID, EntityType.EntityType_NPC);

                    if (skillPart != null)
                    {  //不是在释放快速移动技能 立刻设置位置 否则延迟设置
                        npc.SendMessage(EntityMessage.EntityCommand_StopMove, (object)pos);
                    }
                }
            }

            EventEngine.Instance().DispatchEvent((int)GameEventID.CAMERA_MOVE_END);
        }
    }