// Base Color 111, 185, 66 // Trees Color 41, 98, 40 // water color 79, 117, 247 // cities color 255, 15, 15 // path, 147, 147, 147 public MapItem[,] GetMapData() { if (RawData == null) { return(null); } var map = new MapItem[RawData.Width, RawData.Height]; for (int x = 0; x < RawData.Width; x++) { for (int y = 0; y < RawData.Height; y++) { var color = RawData.GetPixel(x, y); if (IsTree(color)) { map[x, y] = new Tree() { X = x, Y = y }; } else if (IsWater(color)) { map[x, y] = new Water() { X = x, Y = y }; } else if (IsCity(color)) { bool found = false; for (int i = 0; i < Locations.Count; i++) { if (Locations[i].X == x && Locations[i].Y == y) { map[x, y] = Locations[i]; found = true; break; } } if (!found) { map[x, y] = new LocationSpot() { X = x, Y = y }; Locations.Add((LocationSpot)map[x, y]); } } else if (IsPath(color)) { map[x, y] = new Road() { X = x, Y = y }; } else { map[x, y] = new Ground() { X = x, Y = y }; } } } return(map); }
public void ProcessCommand(int x, int y) { if (ActiveHuman.Belt == null) { return; } var mapItem = ActiveWorld.GetMapItem(x, y); if (mapItem == null) { return; } if (mapItem is Tree) { if (ActiveHuman.Belt is WoodCutters_Axe) { mapItem = new Ground() { X = mapItem.X, Visible = true, Y = mapItem.Y }; ActiveHuman.Inventory.AddOrRemoveResourceItem(typeof(Wood), 1); if (ActiveWorld.Percent(25)) { ActiveHuman.Inventory.AddOrRemoveResourceItem(typeof(TreeSeeds), 1); } ActiveWorld.Map[x, y] = mapItem; ActiveWorld.IncrementTime(1, false); UpdateWorld(ActiveWorld); UpdateStats(ActiveHuman); } } else if (mapItem is Water) { if (ActiveHuman.Belt is Fishing_Rod) { // some kind of random event - to add fish if (ActiveWorld.Percent(25)) { ActiveHuman.Inventory.AddOrRemoveResourceItem(typeof(Fish), 1); } ActiveWorld.IncrementTime(3, false); UpdateStats(ActiveHuman); } else if (ActiveHuman.Belt is Hammer) { // do we have wood if (ActiveHuman.Inventory.CanIUseResource(typeof(Wood), 10)) { mapItem = new Road() { X = mapItem.X, Visible = true, Y = mapItem.Y }; ActiveHuman.Inventory.AddOrRemoveResourceItem(typeof(Wood), -10); ActiveWorld.Map[x, y] = mapItem; ActiveWorld.IncrementTime(10, false); UpdateWorld(ActiveWorld); UpdateStats(ActiveHuman); } } } }