コード例 #1
0
        public void ChangeMap(int pMapId, Portal pTo)
        {
            Map Map = ChannelMaps[MapId];
            Map NewMap = ChannelMaps[pMapId];

            Map.RemovePlayer(this);
            PortalCount++;
            MapId = pMapId;

            MapPosition = pTo.ID;

            Position = new Pos(pTo.X, (short)(pTo.Y - 40));
            Stance = 0;
            Foothold = 0;

            Client.SendPacket(MapPacket.EnterField(this));

            NewMap.AddPlayer(this);
        }
コード例 #2
0
        public void LoadMaps()
        {
            if (MapNX == null)
            {
                Logger.WriteLog(Logger.LogTypes.Error, "Unable to load Map NX file.");
                return;
            }

            foreach (NXNode baseNode in MapNX.BaseNode)
            {
                if (baseNode.Name == "Map")
                {
                    foreach (NXNode Map in baseNode)
                    {
                        if (Map.Name.Contains("Map"))
                        {
                            foreach (NXNode MapNode in Map)
                            {
                                NXNode info = MapNode["info"];

                                Map map = new Map(int.Parse(MapNode.Name.Replace(".img", "")));
                                if (info.ContainsChild("fly"))
                                    map.Fly = info["fly"].ValueOrDefault<int>(0) > 0;
                                if (info.ContainsChild("forcedReturn"))
                                    map.ForcedReturn = info["forcedReturn"].ValueOrDefault<int>(999999999);
                                if (info.ContainsChild("onFirstUserEnter"))
                                    map.OnFirstUserEnter = info["onFirstUserEnter"].ValueOrDefault<string>(null);
                                if (info.ContainsChild("onUserEnter"))
                                    map.OnUserEnter = info["onUserEnter"].ValueOrDefault<string>(null);
                                if (info.ContainsChild("swim"))
                                    map.Swim = info["swim"].ValueOrDefault<int>(0) > 0;

                                if (MapNode.ContainsChild("life"))
                                {
                                    foreach (NXNode LifeNode in MapNode["life"])
                                    {
                                        Life lf = new Life();
                                        if (LifeNode.ContainsChild("id"))
                                            lf.ID = int.Parse(LifeNode["id"].ValueOrDefault<string>(null));
                                        if (LifeNode.ContainsChild("x"))
                                            lf.X = (Int16)LifeNode["x"].ValueOrDefault<Int64>(0);
                                        if (LifeNode.ContainsChild("y"))
                                            lf.Y = (Int16)LifeNode["y"].ValueOrDefault<Int64>(0);
                                        if (LifeNode.ContainsChild("cy"))
                                            lf.Cy = (Int16)LifeNode["cy"].ValueOrDefault<Int64>(0);
                                        if (LifeNode.ContainsChild("fh"))
                                            lf.Foothold = (UInt16)LifeNode["fh"].ValueOrDefault<Int64>(0);
                                        if (LifeNode.ContainsChild("rx0"))
                                            lf.Rx0 = (Int16)LifeNode["rx0"].ValueOrDefault<Int64>(0);
                                        if (LifeNode.ContainsChild("rx1"))
                                            lf.Rx0 = (Int16)LifeNode["rx1"].ValueOrDefault<Int64>(0);
                                        if (LifeNode.ContainsChild("type"))
                                            lf.Type = (LifeNode["type"].ValueOrDefault<string>(null));
                                        if (LifeNode.ContainsChild("f"))
                                            lf.FacesLeft = Convert.ToBoolean(LifeNode["f"].ValueOrDefault<Int64>(0));
                                        if (LifeNode.ContainsChild("mobTime"))
                                            lf.RespawnTime = (int)LifeNode["mobTime"].ValueOrDefault<Int64>(0);
                                        if (LifeNode.ContainsChild("hide"))
                                            lf.Hide = Convert.ToByte(LifeNode["hide"].ValueOrDefault<Int64>(0));

                                        if (lf.ID != 0)
                                            map.AddLife(lf);
                                    }
                                }

                                if (MapNode.ContainsChild("portal"))
                                {
                                    foreach (NXNode PortalNode in MapNode["portal"])
                                    {
                                        Portal pt = new Portal();
                                        pt.ID = byte.Parse(PortalNode.Name);
                                        pt.Name = PortalNode["pn"].ValueOrDefault<string>(null);
                                        pt.ToMapID = (int)PortalNode["tm"].ValueOrDefault<Int64>(999999999);
                                        pt.ToName = PortalNode["tn"].ValueOrDefault<string>(null);
                                        pt.X = (short)PortalNode["x"].ValueOrDefault<Int64>(0);
                                        pt.Y = (short)PortalNode["y"].ValueOrDefault<Int64>(0);

                                        map.AddPortal(pt);
                                    }
                                }

                                Maps.Add(map.ID, map);
                            }
                        }
                    }
                }
            }
        }
コード例 #3
0
ファイル: Map.cs プロジェクト: DragonNeos/serenity-maple
 public void AddPortal(Portal PT)
 {
     if (PT.Name == "sp")
     {
         _SpawnPoints.Add(PT.ID, PT);
     }
     else if (PT.Name == "tp")
     {
         // TownPortal: Mystic Door?
     }
     else
     {
         if (_Portal.ContainsKey(PT.Name))
         {
             Logger.WriteLog(Logger.LogTypes.Warning, "Duplicate portal, Name {0}, Map ID: {1}.", PT.Name, ID);
         }
         else
         {
             _Portal.Add(PT.Name, PT);
         }
     }
 }