Example #1
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            switch (version)
            {
            case 14:
            {
                //version 14
                m_Coords    = ReadRect3DArray(reader);
                m_InnBounds = ReadRect3DArray(reader);
                goto case 13;
            }

            case 13:
            {
                m_TargetMap  = reader.ReadMap();
                m_GoLocation = reader.ReadPoint3D();
                m_MinZ       = reader.ReadInt();
                m_MaxZ       = reader.ReadInt();
                goto case 12;
            }

            case 12:
            {
                m_Enabled = reader.ReadBool();
                goto case 11;
            }

            case 11:
            {
                int size = reader.ReadInt();
                m_Types = new ArrayList(size);

                for (int i = 0; i < size; ++i)
                {
                    string typeName = reader.ReadString();
                    m_Types.Add(typeName);
                }
                goto case 10;
            }

            case 10:
            {
                m_MaxFollowers = reader.ReadInt();
                goto case 9;
            }

            case 9:
            {
                m_RestrictedMagicMsg = reader.ReadString();
                goto case 8;
            }

            case 8:
            {
                m_Music = (MusicName)reader.ReadInt();
                goto case 7;
            }

            case 7:
            {
                if (m_InnBounds == null)
                {
                    m_InnBounds = ReadRect2DArray(reader);
                }
                else
                {
                    m_InnBounds.AddRange(ReadRect2DArray(reader));
                }
                m_InnLogoutDelay = reader.ReadTimeSpan();

                goto case 6;
            }

            case 6:
            {
                m_PlayerLogoutDelay = reader.ReadTimeSpan();
                goto case 5;
            }

            case 5:
            {
                if (version < 13)
                {                                       // converted to a flag
                    bool m_IsDungeon = (bool)reader.ReadBool();
                    IsDungeon = m_IsDungeon;
                }
                goto case 4;
            }

            case 4:
            {
                m_IOBAlignment = (IOBAlignment)reader.ReadInt();
                goto case 3;
            }

            case 3:
            {
                m_LightLevel = reader.ReadInt();
                goto case 2;
            }

            case 2:
            {
                goto case 1;
            }

            case 1:
            {
                if (Coords == null)
                {
                    Coords = ReadRect2DArray(reader);
                }
                else
                {
                    Coords.AddRange(ReadRect2DArray(reader));
                }
                m_Priority = (CustomRegionPriority)reader.ReadInt();

                m_RestrictedSpells = ReadBitArray(reader);
                m_RestrictedSkills = ReadBitArray(reader);

                m_Flags = (RegionFlag)reader.ReadInt();

                m_RegionName = reader.ReadString();
                break;
            }

            case 0:
            {
                Coords = new ArrayList();

                Coords.Add(reader.ReadRect2D());
                m_RestrictedSpells = ReadBitArray(reader);
                m_RestrictedSkills = ReadBitArray(reader);

                m_Flags = (RegionFlag)reader.ReadInt();

                m_RegionName = reader.ReadString();
                break;
            }
            }
            if (version < 12)
            {
                m_Enabled = true;
            }

            if (version < 11)
            {
                m_Types = new ArrayList();
            }

            if (version < 8)
            {
                m_Music = MusicName.Invalid;
            }

            // fixup this table if Skills have been added or removed.
            if (SkillInfo.Table.Length != m_RestrictedSkills.Count)
            {
                BitArray temp          = new BitArray(SkillInfo.Table.Length);
                int      MaxIterations = Math.Min(temp.Length, m_RestrictedSkills.Count);
                for (int ix = 0; ix < MaxIterations; ix++)
                {
                    temp[ix] = m_RestrictedSkills[ix];
                }

                m_RestrictedSkills = temp;
            }

            // fixup this table if Spells have been added or removed.
            if (SpellRegistry.Types.Length != m_RestrictedSpells.Count)
            {
                BitArray temp          = new BitArray(SpellRegistry.Types.Length);
                int      MaxIterations = Math.Min(temp.Length, m_RestrictedSpells.Count);
                for (int ix = 0; ix < MaxIterations; ix++)
                {
                    temp[ix] = m_RestrictedSpells[ix];
                }

                m_RestrictedSkills = temp;
            }

            UpdateRegion();
        }
Example #2
0
        /// <summary>
        /// 播放轨迹
        /// </summary>
        private void Projection()
        {
            if (!IsPlayed)
            {
                IsPlayed      = true;
                btnTrack.Text = "&#xf04d;";
                //============================
                //生成坐标点
                map.ClearOverlay = true;

                Task.Run(() =>
                {
                    try
                    {
                        if (ViewModel != null)
                        {
                            var select = ViewModel.BusinessUsers.Where(s => s.Selected).FirstOrDefault();
                            if (select != null)
                            {
                                //跟踪轨迹,包含拜访轨迹
                                Coords = select.RealTimeTracks.Select(b =>
                                {
                                    return(new Coordinate(b.Latitude ?? 0, b.Longitude ?? 0, int.Parse(b.Ctype)));
                                }).ToList();

                                //拜访路线
                                CPoints = select.VisitRecords.Select(b =>
                                {
                                    return(new Coordinate(b.Latitude ?? 0, b.Longitude ?? 0, 1));
                                }).ToList();


                                if (Coords.Count >= 2)
                                {
                                    //轨迹细化
                                    var lastPoints = new Coordinate();
                                    for (int j = 0; j < Coords.Count; j++)
                                    {
                                        lastPoints = Coords[j];
                                        if (j > 0)
                                        {
                                            var dist = calc.CalculateDistance(Coords[j], lastPoints);
                                            if (dist > 3) //两点之间的距离大于3米
                                            {
                                                Coords.AddRange(addLatLng(Coords[j], lastPoints, dist));
                                            }
                                        }
                                    }

                                    //var dist = calc.CalculateDistance(Coords[0], Coords[Coords.Count-1]);
                                    //GetLevel(calc.CalculateDistance(Coords[0], Coords[Coords.Count - 1])); //缩放地图

                                    Coords = DouglasPeucker(Coords, 10); //轨迹抽稀
                                    Coords = OptimizePoints(Coords);     //轨迹优化;


                                    //画线1
                                    map.Polylines.Add(new BaiduMaps.Polyline
                                    {
                                        Points = new ObservableCollection <Coordinate>(Coords.Take(2)),
                                        //Color = Color.FromHex("#8cabe1"),
                                        Color = Color.FromHex("#53a245"),
                                        Width = 15
                                    });

                                    for (int i = 0; i < Coords.Count; i++)
                                    {
                                        Task.Delay(1000).Wait();

                                        lastPoints = Coords[i];

                                        if (i == 0)
                                        {
                                            AddOverlay(Coords[i], "q10660.png");//起点
                                        }
                                        else if (i == Coords.Count - 1)
                                        {
                                            AddOverlay(Coords[i], "z10660.png");//终点
                                        }
                                        else if (Coords[i].Ctype == 1)
                                        {
                                            //当前标注
                                            AddOverlay(Coords[i], "red_location.png");
                                        }

                                        map.Polylines[0].Points.Add(Coords[i]);
                                        //移动地图
                                        map.Center = Coords[i];
                                    }

                                    //轨迹2
                                    //map.Polylines.Add(new BaiduMaps.Polyline
                                    //{
                                    //    Points = new ObservableCollection<Coordinate>(CPoints.Take(2)),
                                    //    Color = Color.FromHex("#53a245"),
                                    //    Width = 10
                                    //});

                                    //for (int i = 0; i < CPoints.Count; i++)
                                    //{
                                    //    Task.Delay(1000).Wait();

                                    //    if (i == 0)
                                    //    {
                                    //        AddOverlay(CPoints[i], "q10660.png");//起点
                                    //    }
                                    //    else if (i == CPoints.Count - 1)
                                    //    {
                                    //        AddOverlay(CPoints[i], "z10660.png");//终点
                                    //    }
                                    //    else
                                    //    {
                                    //        //当前标注
                                    //        AddOverlay(CPoints[i], "red_location.png");
                                    //    }

                                    //    map.Polylines[1].Points.Add(CPoints[i]);
                                    //    //移动地图
                                    //    map.Center = CPoints[i];
                                    //}
                                }
                                else
                                {
                                    ViewModel.Alert($"回放失败,业务员{select.BusinessUserName},无拜访轨迹.");
                                }
                            }
                            else
                            {
                                ViewModel.Alert("请选择业务员!");
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Write(ex);
                    }
                });

                //============================
                btnTrack.Text = "&#xf04b;";
                IsPlayed      = false;
            }
        }