Exemplo 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();
            }
        }
Exemplo n.º 3
0
        private bool CheckDivinePower(int deityID)
        {
            bool result = true;

            CreatureEntry deity = (CreatureEntry)GlobalVars.nwrDB.GetEntry(deityID);
            NWField       fld   = fPlayer.CurrentField;

            if ((deity.Race == RaceID.crAesir && (fld.LandID == GlobalVars.Land_Muspelheim || fld.LandID == GlobalVars.Land_Niflheim || fld.LandID == GlobalVars.Land_Jotenheim)) || (deity.Race == RaceID.crEvilGod && (fld.LandID == GlobalVars.Land_Valhalla || fld.LandID == GlobalVars.Land_Vigrid || fld.LandID == GlobalVars.Land_Bifrost)))
            {
                LandEntry land = (LandEntry)GlobalVars.nwrDB.GetEntry(fld.LandID);
                ShowText(Locale.Format(RS.rs_WontHelp, new object[] {
                    land.GetNounDeclension(Number.nSingle, Case.cPrepositional),
                    deity.Name
                }));
                result = false;
            }

            return(result);
        }
Exemplo n.º 4
0
 public VmGeometry(LandEntry geometry, bool isCollision)
 {
     LandEntry   = geometry;
     IsCollision = isCollision;
 }
Exemplo n.º 5
0
        internal static (LandEntryRenderBatch opaque, LandEntryRenderBatch transparent, List <LandEntry> rendered) PrepareLandEntries(LandEntry[] entries, Camera camera, BufferingBridge bufferBridge)
        {
            // the output list. This contains all landentries that need to be rendered
            List <LandEntry> rendered = new();

            // the landentries to render are grouped by attach
            Dictionary <Attach, List <LandEntry> > toRender = new();

            for (int i = 0; i < entries.Length; i++)
            {
                LandEntry le = entries[i];
                // check if the entry can be rendered at all
                if (!camera.CanRender(le.ModelBounds))
                {
                    continue;
                }

                if (toRender.TryGetValue(le.Attach, out List <LandEntry> list))
                {
                    list.Add(le);
                }
                else
                {
                    // check if the attach is already buffered
                    if (!bufferBridge.IsBuffered(le.Attach.MeshData[0]))
                    {
                        bufferBridge.LoadToCache(le.Attach.MeshData, null, false);
                    }
                    toRender.Add(le.Attach, new() { le });
                }
                rendered.Add(le);
            }

            // Landentry Renderbatch structure:
            // <TextureIndex <Buffermesh, List<Matrices>>
            // So, each buffermesh has multiple render matrices to be rendered multiple times
            // and each of those lists belongs to a texture. That way textures dont need
            // to be swapped out so often

            LandEntryRenderBatch opaque      = new();
            LandEntryRenderBatch transparent = new();

            foreach (var t in toRender)
            {
                List <RenderMatrices> matrices = new();
                foreach (LandEntry le in t.Value)
                {
                    Matrix4        world = le.WorldMatrix;
                    RenderMatrices rm    = new(world, world *camera.ViewMatrix *camera.ProjectionMatrix);
                    matrices.Add(rm);
                }

                // check if attach is buffered


                foreach (BufferMesh bm in t.Key.MeshData)
                {
                    if (bm.Material == null)
                    {
                        continue;
                    }

                    int index = bm.Material.HasAttribute(MaterialAttributes.useTexture) ? (int)bm.Material.TextureIndex : -1;

                    Dictionary <BufferMesh, List <RenderMatrices> > buffers;
                    if (bm.Material.UseAlpha)
                    {
                        if (!transparent.TryGetValue(index, out buffers))
                        {
                            buffers = new();
                            transparent.Add(index, buffers);
                        }
                    }
                    else
                    {
                        if (!opaque.TryGetValue(index, out buffers))
                        {
                            buffers = new();
                            opaque.Add(index, buffers);
                        }
                    }
                    buffers.Add(bm, matrices);
                }
            }

            return(opaque, transparent, rendered);
        }