Esempio 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;
            }
        }
Esempio n. 2
0
        public override BaseTile GetTile(int x, int y)
        {
            BaseTile result = base.GetTile(x, y);

            if (result == null)
            {
                int fx = fCoords.X;
                int fy = fCoords.Y;
                int px = x;
                int py = y;

                if (x < 0 || x >= StaticData.FieldWidth)
                {
                    px = Math.Abs(Math.Abs(x) - StaticData.FieldWidth);
                }
                if (y < 0 || y >= StaticData.FieldHeight)
                {
                    py = Math.Abs(Math.Abs(y) - StaticData.FieldHeight);
                }
                if (x < 0)
                {
                    fx--;
                }
                if (x >= StaticData.FieldWidth)
                {
                    fx++;
                }
                if (y < 0)
                {
                    fy--;
                }
                if (y >= StaticData.FieldHeight)
                {
                    fy++;
                }

                NWLayer layer = Layer;

                if (layer != null)
                {
                    NWField fld = layer.GetField(fx, fy);
                    if (fld != null)
                    {
                        result = fld.GetTile(px, py);
                    }
                }
            }

            return(result);
        }
Esempio n. 3
0
        public void InitField()
        {
            try {
                NWLayer layer = Layer;
                if (fEntry != null && fEntry.Source == FieldSource.fsTemplate)
                {
                    LoadFromEntry(fEntry);
                    ProcessVariants();
                }
                else
                {
                    if (LandID == GlobalVars.Land_Armory || LandID == GlobalVars.Land_GrynrHalls)
                    {
                        UniverseBuilder.Build_Dungeon(this, AreaRect);
                    }
                    else
                    {
                        if (layer.EntryID != GlobalVars.Layer_Svartalfheim1 && layer.EntryID != GlobalVars.Layer_Svartalfheim2 && layer.EntryID != GlobalVars.Layer_Svartalfheim3)
                        {
                            Prepare(PlaceID.pid_Grass);
                        }
                    }
                }

                int defTS = 0;
                if (LandID == GlobalVars.Land_Bifrost || LandID == GlobalVars.Land_Crossroads)
                {
                    defTS = BaseTile.TS_VISITED;
                }

                for (int y = 0; y < StaticData.FieldHeight; y++)
                {
                    for (int x = 0; x < StaticData.FieldWidth; x++)
                    {
                        NWTile tile = (NWTile)GetTile(x, y);
                        tile.BackgroundExt = 0;
                        tile.ForegroundExt = 0;
                        tile.ScentAge      = 0;
                        tile.ScentTrail    = null;
                        tile.AddStates(defTS);
                    }
                }

                if (fLandEntry.Flags.Contains(LandFlags.lsHasForest))
                {
                    UniverseBuilder.Build_Forest(this);
                }
                if (fLandEntry.Flags.Contains(LandFlags.lsHasMountain))
                {
                    UniverseBuilder.Gen_RarelyMountains(this);
                }
                if (fLandEntry.Flags.Contains(LandFlags.lsHasItems))
                {
                    UniverseBuilder.Gen_Items(this, -1);
                }
                if (fLandEntry.Flags.Contains(LandFlags.lsIsCave))
                {
                    UniverseBuilder.Gen_CaveObjects(this);
                }

                if (LandID == GlobalVars.Land_Ocean)
                {
                    Prepare(PlaceID.pid_Water);
                }

                if (LandID == GlobalVars.Land_Vanaheim)
                {
                    UniverseBuilder.Build_Vanaheim(this);
                }
                if (LandID == GlobalVars.Land_Alfheim)
                {
                    UniverseBuilder.Build_Alfheim(this);
                }
                if (LandID == GlobalVars.Land_Wasteland)
                {
                    UniverseBuilder.Build_Wasteland(this);
                }
                if (LandID == GlobalVars.Land_Crossroads)
                {
                    UniverseBuilder.Build_Crossroads(this);
                }
                if (LandID == GlobalVars.Land_Village)
                {
                    UniverseBuilder.Build_Village(this);
                }
                if (LandID == GlobalVars.Land_MimerRealm)
                {
                    UniverseBuilder.Build_MimerRealm(this);
                }
                if (LandID == GlobalVars.Land_MimerWell)
                {
                    UniverseBuilder.Build_MimerWell(this);
                }
                if (LandID == GlobalVars.Land_GrynrHalls)
                {
                    UniverseBuilder.Build_GrynrHalls(this);
                }
                if (LandID == GlobalVars.Land_Bazaar)
                {
                    UniverseBuilder.Build_Bazaar(this);
                }
                if (LandID == GlobalVars.Land_Temple)
                {
                    UniverseBuilder.Build_VidurTemple(this);
                }
                if (LandID == GlobalVars.Land_GodsFortress)
                {
                    UniverseBuilder.Build_GodsFortress(this);
                }
                if (LandID == GlobalVars.Land_Valhalla)
                {
                    UniverseBuilder.Build_Valhalla(this);
                }
                if (LandID == GlobalVars.Land_Muspelheim)
                {
                    UniverseBuilder.Build_Muspelheim(this);
                }

                if (LandID == GlobalVars.Land_Ocean)
                {
                    UniverseBuilder.Build_Ocean(this);
                }
                else
                {
                    UniverseBuilder.Gen_Creatures(this, -1);
                    UniverseBuilder.Gen_Traps(this, -2);
                }
            } catch (Exception ex) {
                Logger.Write("NWField.InitField(" + DebugSign + "): " + ex.Message);
            }
        }