private void GenerateMap() { //setando custo int costForEnemies = globalMapSettings.totalEntitiesCost; //limpar mapa antigo se houver if (roomParent != null) { Destroy(roomParent); } roomParent = new GameObject("RoomRoot"); roomParent.transform.position = Vector3.zero; MapRoom targetRoom = null; //colocando base if (currentRoomIndex < (float)(globalMapSettings.numberOfRooms) / 2.00f) { targetRoom = globalMapSettings.startRoomSet.GetRandomRoom(); } else { targetRoom = globalMapSettings.endRoomSet.GetRandomRoom(); } //se currentIndex = 2, usar sala quest[0], se quest.count = 10, ultima quest fica em quest[9], valor maximo pro curIndex de quest seria entao 11 if (currentRoomIndex >= 2 && currentRoomIndex <= questRooms.Count + 1) { targetRoom = questRooms[currentRoomIndex - 2]; } GameObject roomBase = Instantiate(targetRoom.roomBase, Vector3.zero, Quaternion.identity, roomParent.transform); //escolhendo e colocando decoracao MapDecoration decoration = Instantiate <MapDecoration>(targetRoom.GetRandomDecoration(), Vector3.zero, Quaternion.identity, roomParent.transform); decoration.ClearPointers(); currentDeco = decoration; //configurando portas if (decoration.doors == null) { decoration.doors = new MapDoor[0]; } for (int i = 0; i < decoration.doors.Length; i++) { decoration.doors[i].SetLocked(true); decoration.doors[i].SetupDoor(this, GetRandomReward()); } //spawn de inimigos MapEnemySet targetSet = currentRoomIndex <= (float)globalMapSettings.numberOfRooms / 2 ? globalMapSettings.startEnemySet : globalMapSettings.endEnemySet; if (decoration.pointers == null) { decoration.pointers = new MapPointer[0]; } for (int i = 0; i < decoration.pointers.Length; i++) { MapPointer randomPointer = decoration.GetRandomAvailablePointer(); //verifica todos inimigos possiveis para esse ponto e pega um aleatorio if (randomPointer == null) { break; //sair do for por falta de pontos } MapEntity targetEntity = targetSet.GetRandomEntity(globalMapSettings.mapDifficulty, randomPointer.pointSize, costForEnemies); if (targetEntity != null) { costForEnemies -= targetEntity.entityCost; MapEntity spawnedEntity = Instantiate <MapEntity>(targetEntity, randomPointer.transform.position, Quaternion.identity, roomParent.transform); randomPointer.used = true; } } playerObject.transform.position = decoration.playerSpawn.position; UpdateRoomCounter(); path.Scan(); }
private int getCollisionPointerListsAndIndex() { bank1Maps = new List <MapPointer>(); bank2Maps = new List <MapPointer>(); MapPointer cMapPointer = new MapPointer();//Current map pointers int map = 0; int index; if (LAGame.dungeon == 0xFF) { for (int i = 0; i < 0x16; i++) { MapPointer pointer = new MapPointer(); pointer.map = map; pointer.specialAddress = false; int pointerToBe; pointerToBe = (0x2BB77 + (map * 2)); pointer.mapAddress = LAGame.gbROM.Get2BytePointerAtAddress(pointerToBe); if (map == LAGame.map && LAGame.specialFlag == false) { cMapPointer = pointer; } bank1Maps.Add(pointer); map++; } } else { for (int i = 0; i < 256; i++) { MapPointer pointer = new MapPointer(); pointer.map = map; pointer.specialAddress = false; int pointerToBe; if (LAGame.overworldFlag) { pointerToBe = 0x24000 + (map * 2); pointerToBe = LAGame.gbROM.Get2BytePointerAtAddress(pointerToBe); if (map > 0x7F) { pointerToBe = 0x68000 + (pointerToBe - 0x24000); } pointer.mapAddress = pointerToBe; if (map == LAGame.map && LAGame.specialFlag == false) { cMapPointer = pointer; } if (map < 0x80) { bank1Maps.Add(pointer); } else { bank2Maps.Add(pointer); } int specialBufferAddress = 0; switch (map) { case 0x06: specialBufferAddress = 0x31F4; break; case 0x0E: specialBufferAddress = 0x31C4; break; case 0x1B: specialBufferAddress = 0x3204; break; case 0x2B: specialBufferAddress = 0x3214; break; case 0x79: specialBufferAddress = 0x31E4; break; case 0x8C: specialBufferAddress = 0x31D4; break; } if (specialBufferAddress > 0) { MapPointer specialMapPointer = new MapPointer(); specialMapPointer.map = map; specialMapPointer.specialAddress = true; pointerToBe = LAGame.gbROM.Get2BytePointerAtAddress(specialBufferAddress); if (map > 0x7F) { pointerToBe += 0x68000; } else { pointerToBe += 0x24000; } specialMapPointer.mapAddress = pointerToBe; if (map == LAGame.map && LAGame.specialFlag == true) { cMapPointer = specialMapPointer; } if (map < 0x80) { bank1Maps.Add(specialMapPointer); } else { bank2Maps.Add(specialMapPointer); } } map++; } else { pointerToBe = (0x28000 + (map * 2)); if (LAGame.dungeon >= 6 && LAGame.dungeon < 0x1A) { pointerToBe += 0x4000; } pointer.mapAddress = LAGame.gbROM.Get2BytePointerAtAddress(pointerToBe); if (map == LAGame.map && LAGame.specialFlag == false) { cMapPointer = pointer; } bank1Maps.Add(pointer); if (LAGame.dungeon >= 0x1A || LAGame.dungeon < 6) { int specialBufferAddress = 0; switch (map) { case 0xF5: specialBufferAddress = 0x3198; break; } if (specialBufferAddress > 0) { MapPointer specialMapPointer = new MapPointer(); specialMapPointer.map = map; specialMapPointer.specialAddress = true; pointerToBe = LAGame.gbROM.Get2BytePointerAtAddress(specialBufferAddress); pointerToBe += 0x28000; specialMapPointer.mapAddress = pointerToBe; if (map == LAGame.map && LAGame.specialFlag == true) { cMapPointer = specialMapPointer; } bank1Maps.Add(specialMapPointer); } } map++; } } } bank1Maps.Sort(); bank2Maps.Sort(); if (LAGame.overworldFlag) { if (LAGame.map < 0x80) { index = bank1Maps.IndexOf(cMapPointer); } else { index = bank2Maps.IndexOf(cMapPointer); } } else { index = bank1Maps.IndexOf(cMapPointer); } return(index); }
public void repointNextMap(GameMapData mapData, MapPointer nextMapPointer) { int mapAddressToRepoint; if (LAGame.overworldFlag) { mapAddressToRepoint = getCollisionDataOverworldOffset(mapData) + spaceCalculator.getUsedSpaceCollisions(mapData.collisionObjects, mapData.warpObjects) + 3; } else { mapAddressToRepoint = getCollisionDataDungeonOffset(mapData) + spaceCalculator.getUsedSpaceCollisions(mapData.collisionObjects, mapData.warpObjects) + 3; } //Plus 1 for animation, 1 for tile preset and 1 for 0xFE room ending byte if (LAGame.overworldFlag) { if (mapData.map == 0xFF || mapData.map == 0x7F) { mapAddressToRepoint = getCollisionDataOverworldOffset(mapData); } } else { if (mapData.map == 0xFF && LAGame.dungeon != 0xFF || (LAGame.map == 0x15 && LAGame.dungeon == 0xFF)) { mapAddressToRepoint = getCollisionDataDungeonOffset(mapData); } } if (LAGame.overworldFlag) { if (mapData.map < 0x80 && mapAddressToRepoint >= 0x2668D) { mapAddressToRepoint = 0x2668B; } else if (mapData.map > 0x7F && mapAddressToRepoint >= 0x69E75) { mapAddressToRepoint = 0x69E73; } } else { if (LAGame.dungeon == 0xFF && mapAddressToRepoint >= 0x2BF43) { mapAddressToRepoint = 0x2BF41; } else if ((LAGame.dungeon >= 6 && LAGame.dungeon < 0x1A) && mapAddressToRepoint >= 0x2FFFF && LAGame.dungeon != 0xFF) { mapAddressToRepoint = 0x2FFFD; } else if ((LAGame.dungeon < 6 || LAGame.dungeon >= 0x1A) && mapAddressToRepoint >= 0x2BB77 && LAGame.dungeon != 0xFF) { mapAddressToRepoint = 0x2BB75; } } if (nextMapPointer != null) { nextMapPointer.mapAddress = mapAddressToRepoint; } else { nextMapPointer = new MapPointer(); nextMapPointer.mapAddress = mapAddressToRepoint; nextMapPointer.map = mapData.map; nextMapPointer.specialAddress = mapData.specialFlag; } repointMapCollisions(nextMapPointer); }
private int getEntityPointerListsAndIndex() { mapPointerList = new List <MapPointer>(); MapPointer cMapPointer = new MapPointer();//Current map pointers int map = 0; int index; if (LAGame.dungeon == 0xFF) { for (int i = 0; i < 0x16; i++) { MapPointer pointer = new MapPointer(); pointer.map = map; int pointerToBe; pointerToBe = (0x58600 + (map * 2)); pointer.mapAddress = LAGame.gbROM.Get2BytePointerAtAddress(pointerToBe); if (map == LAGame.map && LAGame.specialFlag == false) { cMapPointer = pointer; } mapPointerList.Add(pointer); map++; } } else { for (int i = 0; i < 256; i++) { MapPointer pointer = new MapPointer(); pointer.map = map; int pointerToBe; if (LAGame.overworldFlag) { pointerToBe = 0x58000 + map * 2; } else { pointerToBe = 0x58200 + map * 2;; if (LAGame.dungeon >= 6 && LAGame.dungeon < 0x1A) { pointerToBe = 0x58400 + (map * 2); } } pointer.mapAddress = LAGame.gbROM.Get2BytePointerAtAddress(pointerToBe); if (map == LAGame.map) { cMapPointer = pointer; } mapPointerList.Add(pointer); map++; } } mapPointerList.Sort(); index = mapPointerList.IndexOf(cMapPointer); return(index); }