Exemplo n.º 1
0
        private void StoreCoords(int address, SCCoords coords)
        {
            var X = coords.X;
            var Y = coords.Y;

            rom.Put(address, new byte[] { (byte)(((int)X - 7) & 0xFF), (byte)(((int)Y - 7) & 0xFF) });
        }
Exemplo n.º 2
0
 private void SetShipDock(SCCoords coords)
 {
     if ((Main.Overworld.Tiles[coords.X, coords.Y].Tile & SCBitFlags.ShipDock) > 0)
     {
         shipDockAreaIndex = Main.Overworld.Tiles[coords.X, coords.Y].Area;
     }
 }
Exemplo n.º 3
0
        public void SetStartingLocation(SCCoords coords)
        {
            locations.LoadData();

            locations.StartingLocation = coords;

            locations.StoreData();
        }
Exemplo n.º 4
0
        public void SetAirshipLocation(SCCoords coords)
        {
            locations.LoadData();

            locations.AirShipLocation = coords;

            locations.StoreData();
        }
Exemplo n.º 5
0
 public void LoadData()
 {
     StartingLocation = LoadCoords(0x3000 + UnsramIndex.OverworldScrollX);
     ShipLocation     = LoadCoords2(0x3000 + UnsramIndex.ShipX);
     AirShipLocation  = LoadCoords2(0x3000 + UnsramIndex.AirshipX);
     BridgeLocation   = LoadCoords2(0x3000 + UnsramIndex.BridgeX);
     CanalLocation    = LoadCoords2(0x3000 + UnsramIndex.CanalX);
 }
        byte CheckSalient(byte[,] tilemap, int x, int y)
        {
            // Salients are single-tile bits that stick out,
            // they don't play well with with border tiles.

            var regionType = this.regionTypeMap[tilemap[y, x]];

            var p        = new SCCoords(x, y);
            var adjacent = new SCCoords[] { p.OwUp, p.OwRight, p.OwDown, p.OwLeft };

            int[] counts = new int[4] {
                0, 0, 0, 0
            };
            int[] countedTypes = new int[4] {
                -1, -1, -1, -1
            };

            foreach (var t in adjacent)
            {
                var adjRegionType = this.regionTypeMap[tilemap[t.Y, t.X]];
                for (int i = 0; i < 4; i++)
                {
                    if (countedTypes[i] == -1)
                    {
                        countedTypes[i] = adjRegionType;
                    }
                    if (countedTypes[i] == adjRegionType)
                    {
                        counts[i] += 1;
                        break;
                    }
                }
            }

            for (int i = 0; i < 4; i++)
            {
                if (counts[i] >= 3 && countedTypes[i] != regionType)
                {
                    // surrounded on 3 or 4 sides, convert it to the tile type surrounding it
                    return(regionTypeList[countedTypes[i]][0]);
                }
            }

            return(0xFF);
        }
Exemplo n.º 7
0
 private void StoreCoords2(int address, SCCoords coords)
 {
     rom.Put(address, new byte[] { coords.X, coords.Y });
 }
Exemplo n.º 8
0
        public bool DockPlacement(OwRegion region)
        {
            var points = new List <SCCoords>(region.Points);

            points.Shuffle(this.rng);
            OwFeature placed   = null;
            SCCoords  placedAt = new SCCoords(0, 0);

            foreach (var p in points)
            {
                var np = p.OwUp;
                if (this.Traversable_regionmap[np.Y, np.X] == OverworldTiles.MainOceanRegionId)
                {
                    var r = this.PlaceFeatureAt(this.Traversable_regionmap, region,
                                                new SCCoords(p.X - 2, p.Y),
                                                OverworldTiles.N_DOCK_STRUCTURE, true);
                    if (r.Item1)
                    {
                        placedAt = p;
                        placed   = OverworldTiles.N_DOCK_STRUCTURE;
                        break;
                    }
                }

                var ep = p.OwRight;
                if (this.Traversable_regionmap[ep.Y, ep.X] == OverworldTiles.MainOceanRegionId)
                {
                    var r = this.PlaceFeatureAt(this.Traversable_regionmap, region,
                                                new SCCoords(p.X - 3, p.Y - 2),
                                                OverworldTiles.E_DOCK_STRUCTURE, true);
                    if (r.Item1)
                    {
                        placedAt = p;
                        placed   = OverworldTiles.E_DOCK_STRUCTURE;
                        break;
                    }
                }

                var sp = p.OwDown;
                if (this.Traversable_regionmap[sp.Y, sp.X] == OverworldTiles.MainOceanRegionId)
                {
                    var r = this.PlaceFeatureAt(this.Traversable_regionmap, region,
                                                new SCCoords(p.X - 2, p.Y - 2),
                                                OverworldTiles.S_DOCK_STRUCTURE, true);
                    if (r.Item1)
                    {
                        placedAt = p;
                        placed   = OverworldTiles.S_DOCK_STRUCTURE;
                        break;
                    }
                }

                var wp = p.OwLeft;
                if (this.Traversable_regionmap[wp.Y, wp.X] == OverworldTiles.MainOceanRegionId)
                {
                    var r = this.PlaceFeatureAt(this.Traversable_regionmap, region,
                                                new SCCoords(p.X, p.Y - 2),
                                                OverworldTiles.W_DOCK_STRUCTURE, true);
                    if (r.Item1)
                    {
                        placedAt = p;
                        placed   = OverworldTiles.W_DOCK_STRUCTURE;
                        break;
                    }
                }
            }

            if (placed != null)
            {
                this.OwnPlacements();
                var s = placed.Entrances["Ship"];
                this.DockPlacements.Add(new ValueTuple <short, SCCoords>(region.RegionId, new SCCoords(placedAt.X + s.X, placedAt.Y + s.Y)));
                if (!this.Reachable_regions.Contains(region.RegionId))
                {
                    this.Reachable_regions.Add(region.RegionId);
                }
                return(true);
            }
            return(false);
        }
Exemplo n.º 9
0
 public async Task <Result> PreventAirshipLanding()
 {
     this.OwnTilemap();
     foreach (var er in Exclude_airship)
     {
         var region = this.Traversable_regionlist[er];
         foreach (var p in region.Points)
         {
             bool adjMarsh    = false;
             bool adjDesert   = false;
             bool adjRiver    = false;
             bool adjEntrance = false;
             var  adjCoors    = new SCCoords[] {
                 p, p.OwUp, p.OwRight, p.OwDown, p.OwLeft
             };
             foreach (var adj in adjCoors)
             {
                 if (this.Tilemap[adj.Y, adj.X] == OverworldTiles.MARSH)
                 {
                     adjMarsh = true;
                 }
                 if (this.Tilemap[adj.Y, adj.X] == OverworldTiles.DESERT)
                 {
                     adjDesert = true;
                 }
                 if (this.Tilemap[adj.Y, adj.X] == OverworldTiles.RIVER)
                 {
                     adjRiver = true;
                 }
                 if (OverworldTiles.Entrances.Contains(this.Tilemap[adj.Y, adj.X]))
                 {
                     adjEntrance = true;
                 }
             }
             foreach (var adj in adjCoors)
             {
                 if (this.Tilemap[adj.Y, adj.X] == OverworldTiles.LAND ||
                     this.Tilemap[adj.Y, adj.X] == OverworldTiles.GRASS)
                 {
                     if (adjMarsh)
                     {
                         this.Tilemap[adj.Y, adj.X] = OverworldTiles.MARSH;
                     }
                     else if (adjDesert)
                     {
                         this.Tilemap[adj.Y, adj.X] = OverworldTiles.DESERT;
                     }
                     else if (adjRiver && !adjEntrance)
                     {
                         this.Tilemap[adj.Y, adj.X] = OverworldTiles.RIVER;
                     }
                     else
                     {
                         this.Tilemap[adj.Y, adj.X] = OverworldTiles.MARSH;
                     }
                 }
             }
         }
     }
     return(await this.NextStep());
 }