Ejemplo n.º 1
0
        public NWField(NWGameSpace space, NWLayer layer, ExtPoint coords)
            : base(StaticData.FieldWidth, StaticData.FieldHeight)
        {
            fSpace  = space;
            fLayer  = layer;
            fCoords = coords;

            fCreatures     = new CreaturesList(this, true);
            fItems         = new ItemsList(this, true);
            fEffects       = new EffectsList(this, true);
            fEmitters      = new EmitterList();
            ValidCreatures = new List <int>();

            if (Layer != null)
            {
                LayerEntry layerEntry = (LayerEntry)GlobalVars.nwrDB.GetEntry(Layer.EntryID);
                fEntry = layerEntry.GetFieldEntry(fCoords.X, fCoords.Y);

                EntryID = fEntry.GUID;

                fLandEntry = (LandEntry)GlobalVars.nwrDB.FindEntryBySign(fEntry.LandSign);
                LandID     = fLandEntry.GUID;

                PrepareCreatures();
            }
            else
            {
                fEntry     = null;
                EntryID    = -1;
                fLandEntry = null;
                LandID     = -1;
            }
        }
        private void UpdateList()
        {
            Player player = new Player(null, null);

            try {
                for (int i = 0; i < MaxList; i++)
                {
                    string fn = NWGameSpace.GetSaveFile(NWGameSpace.SAVEFILE_PLAYER, i);

                    fFiles[i]       = new GameFile();
                    fFiles[i].Exist = File.Exists(fn);
                    if (fFiles[i].Exist)
                    {
                        fFiles[i].SaveTime = File.GetLastWriteTime(fn);

                        try {
                            NWGameSpace.LoadPlayer(i, player);

                            fFiles[i].PlayerName = player.Name;

                            int fx = player.Field.X;
                            int fy = player.Field.Y;

                            LayerEntry layer    = (LayerEntry)GlobalVars.nwrDB.GetEntry(player.LayerID);
                            string     landSign = layer.GetFieldEntry(fx, fy).LandSign;

                            LandEntry land = (LandEntry)GlobalVars.nwrDB.FindEntryBySign(landSign);
                            fFiles[i].LandName = land.Name;
                        } catch (Exception ex) {
                            Logger.Write("FilesWindow.refreshList.PlayerLoad(" + fn + "): " + ex.Message);
                            fFiles[i].PlayerName = "<error>";
                            fFiles[i].LandName   = "<error>";
                        }
                    }
                    else
                    {
                        fFiles[i].PlayerName = BaseLocale.GetStr(RS.rs_PlayerUnknown);
                        fFiles[i].LandName   = "-";
                        fFiles[i].SaveTime   = new DateTime();
                    }
                }
            } finally {
                player.Dispose();
            }
        }