public void AddPipeZoneFromMapData(PipeZoneTypeWrapper pipeZoneType, int x, int y) { double px = x * Block.BLOCK_WIDTH; double py = y * Block.BLOCK_HEIGHT; AddTrigger(pipeZoneType.Get(new Vec2i(x, y)), x, y); }
public void LoadMapFromResources(AbstractMarioPower p) { ImageMapParser parser = new ImageMapParser(new OpenRasterImage(ResourceAccessor.GetMap(mapWorld, mapLevel))); setSize(parser.GetWidth(), parser.GetHeight()); for (int x = 0; x < parser.GetWidth(); x++) { for (int y = 0; y < parser.GetHeight(); y++) { int imgX = x; int imgY = parser.GetHeight() - (1 + y); Color col_b = parser.map.GetColor(ImageMapParser.LAYER_BLOCKS, imgX, imgY); Color col_e = parser.map.GetColor(ImageMapParser.LAYER_ENTITIES, imgX, imgY); Color col_t = parser.map.GetColor(ImageMapParser.LAYER_TRIGGER, imgX, imgY); Color col_p = parser.map.GetColor(ImageMapParser.LAYER_PIPEZONES, imgX, imgY); Color col_v = parser.map.GetColor(ImageMapParser.LAYER_PLAYERVISION, imgX, imgY); Block block = parser.GetBlock(imgX, imgY); EntityTypeWrapper set = parser.GetEntity(imgX, imgY); AddTriggerType att = parser.GetTrigger(imgX, imgY); PipeZoneTypeWrapper pzt = parser.GetPipeZone(imgX, imgY); if (block == null) { throw new NotSupportedException(String.Format("Could not parse Block-Color in Map: {0} ({1}|{2})", col_b, x, y)); } else { AddBlock(block, x, y); } if (set == null) { } // No Entity else if (!set.IsSet()) { throw new NotSupportedException(String.Format("Could not parse SpawnEntity-Color in Map: {0} ({1}|{2})", col_e, x, y)); } else { SpawnEntityFromMapData(set, col_e, x, y); } if (att == AddTriggerType.UNKNOWN_TRIGGER) { throw new NotSupportedException(String.Format("Could not parse Trigger-Color in Map: {0} ({1}|{2})", col_t, x, y)); } else if (att != AddTriggerType.NO_TRIGGER) { AddTriggerFromMapData(att, col_t, x, y, p); } if (pzt == null) { } // No Zone else if (!pzt.IsSet()) { throw new NotSupportedException(String.Format("Could not parse PipeZone-Color in Map: {0} ({1}|{2})", col_p, x, y)); } else { AddPipeZoneFromMapData(pzt, x, y); } } } offset.AddVisionBoxes(parser.GetVisionZones()); //############# //AFTER MAP GEN //############# offset.Calculate(player.GetPosition(), viewPortWidth, viewPortHeight, mapRealWidth, mapRealHeight, false, false); foreach (DynamicEntity e in dynamicEntityList) { e.OnAfterMapGen(); } foreach (Trigger t in triggerList) { t.OnAfterMapGen(); } }