void SpawnDeRecompensasSalas(Area areaPai, int linha, int coluna) { for (int i = 0; i < areaPai.dungeonInserida.numeroSalas; i++) { int contAntibug = 0; Database scriptDatabase = GetComponent <Database>(); System.Random rnd = new System.Random(Guid.NewGuid().GetHashCode()); rnd = new System.Random(Guid.NewGuid().GetHashCode()); int faixaTipo = rnd.Next(1, 100 + 1); int tipo = 1; //chances de tipo, a depender da area e da sala: if (areaPai.secreta == true)//secreta com chave { if (areaPai.dungeonInserida.salas[i].chave == true) { if (faixaTipo >= 79 && faixaTipo <= 93) // Bau { tipo = 2; } if (faixaTipo >= 1 && faixaTipo <= 79) // NPC { tipo = 3; } if (faixaTipo >= 94 && faixaTipo <= 99) //Bau { tipo = 2; } if (faixaTipo >= 100) //NPC { tipo = 3; } } else //secreta sem chave { if (faixaTipo >= 79 && faixaTipo <= 93) // Consumivel { tipo = 0; } if (faixaTipo >= 1 && faixaTipo <= 79) // Bau { tipo = 2; } if (faixaTipo >= 94 && faixaTipo <= 99) //NPC { tipo = 2; } if (faixaTipo >= 100) //Nada { continue; } } } else { if (areaPai.dungeonInserida.salas[i].chave == true) //não secreta, com chave { if (faixaTipo >= 79 && faixaTipo <= 93) // Consumivel { tipo = 0; } if (faixaTipo >= 1 && faixaTipo <= 79) // Bau { tipo = 2; } if (faixaTipo >= 94 && faixaTipo <= 96) //Nada { continue; } if (faixaTipo >= 97) //NPC { tipo = 3; } } else // não secreta, sem chave { if (faixaTipo >= 79 && faixaTipo <= 93) // Bau { tipo = 2; } if (faixaTipo >= 1 && faixaTipo <= 79) // Consumivel { tipo = 0; } if (faixaTipo >= 94 && faixaTipo <= 99) //Nada { continue; } if (faixaTipo >= 100) //NPC { tipo = 3; } } } // rnd = new System.Random(Guid.NewGuid().GetHashCode()); int faixaRaridade = rnd.Next(1, 2000 + 1); //não considera o spawn de boss. int raridade = 0; if (faixaRaridade >= 1 && faixaRaridade <= 1200) //Comum { raridade = 0; } if (faixaRaridade >= 1200 && faixaRaridade <= 1850)//Incomum { raridade = 1; } if (faixaRaridade >= 1851 && faixaRaridade <= 1970)//Raro { raridade = 2; } if (faixaRaridade >= 1971 && faixaRaridade <= 1990)//Epico { raridade = 3; } if (faixaRaridade >= 1991 && faixaRaridade <= 1999)//Lendario { raridade = 4; } if (faixaRaridade >= 2000)//Lendario { raridade = 4; } // metodo que escolhe um inimigo a partir da fase e da raridade e retorna. GameObject itemSpawnado = Database.BuscarItem(tipo, raridade); Dungeon dungeonInstanciada = areaPai.dungeonInserida; int xrand = 0, yrand = 0; bool permit = false; Celula cel = new Celula(new Vetor2(0, 0), ""); while (permit == false) { rnd = new System.Random(Guid.NewGuid().GetHashCode()); xrand = rnd.Next(1, dungeonInstanciada.salas[i].tamanhoSala.x - 1); rnd = new System.Random(Guid.NewGuid().GetHashCode()); yrand = rnd.Next(1, dungeonInstanciada.salas[i].tamanhoSala.y - 1); cel = dungeonInstanciada.salas[i].sala[xrand, yrand]; if (cel.tipoCelula != "chao" || Celula.ChecarTipoAreaAdjacente(cel, "pSala", 1) != 3 || cel.spawnItem == true) { permit = false; if (contAntibug >= 999999) { permit = true; print("usou antibug, recompensa de sala."); } contAntibug++;//declarado no inicio do for da sala, serve para caso não tenha mais espaço na sala para spawnar monstros. } else { permit = true; print("permitiu legitimamente, recompensa de sala"); } } tileCoord = new Vector3(linha * 2 * Config.tamanhoMaxDungeon.x * tileSize + cel.coordCelulaDun.x * tileSize, -1 * coluna * 2 * Config.tamanhoMaxDungeon.y * tileSize + cel.coordCelulaDun.y * -1 * tileSize, 0); Instantiate(itemSpawnado, tileCoord, Quaternion.identity); cel.spawnItem = true; } }
void SpawnDeInimigos(Area areaPai, int linha, int coluna) { Database scriptDatabase = GetComponent <Database>(); System.Random rnd = new System.Random(Guid.NewGuid().GetHashCode()); int pontosGerais = 0; switch (areaPai.dificuldade) { case 0: pontosGerais = rnd.Next(Config.pontoMf.x, Config.pontoMf.y + 1); break; case 1: pontosGerais = rnd.Next(Config.pontoN.x, Config.pontoN.y + 1); break; case 2: pontosGerais = rnd.Next(Config.pontoMd.x, Config.pontoMd.y + 1); break; case 3: pontosGerais = rnd.Next(Config.pontoD.x, Config.pontoD.y + 1); break; case 4: pontosGerais = rnd.Next(Config.pontoMuD.x, Config.pontoMuD.y + 1); break; case 5: pontosGerais = rnd.Next(Config.pontoI.x, Config.pontoI.y + 1); break; } int contAntibug = 0; while (pontosGerais > 0) { rnd = new System.Random(Guid.NewGuid().GetHashCode()); int faixaFase = rnd.Next(1, 100 + 1); int fase = 1; if (faixaFase >= 79 && faixaFase <= 94) // Anterior { rnd = new System.Random(Guid.NewGuid().GetHashCode()); fase = rnd.Next(Config.faseInicial, Config.faseAtual + 1); } if (faixaFase >= 1 && faixaFase <= 79) // Atual { fase = Config.faseAtual; } if (faixaFase >= 94 && faixaFase <= 99) //Posterior { rnd = new System.Random(Guid.NewGuid().GetHashCode()); fase = rnd.Next(Config.faseAtual, Config.faseFinal + 1); } if (faixaFase >= 100) //Sem Fase { fase = -1; } rnd = new System.Random(Guid.NewGuid().GetHashCode()); int faixaRaridade = rnd.Next(1, 2000 + 1); //não considera o spawn de boss. int raridade = 0; if (faixaRaridade >= 1 && faixaRaridade <= 1200) //Comum { raridade = 0; } if (faixaRaridade >= 1200 && faixaRaridade <= 1850)//Incomum { raridade = 1; } if (faixaRaridade >= 1851 && faixaRaridade <= 1970)//Raro { raridade = 2; } if (faixaRaridade >= 1971 && faixaRaridade <= 1990)//Epico { raridade = 3; } if (faixaRaridade >= 1991 && faixaRaridade <= 1999)//Lendario { raridade = 4; } if (faixaRaridade >= 2000)//Mini-Boss { raridade = 5; } //metodo que escolhe um inimigo a partir da fase e da raridade e retorna. GameObject inimigoSpawnado = Database.BuscarInimigo(fase, raridade); Dungeon dungeonInstanciada = areaPai.dungeonInserida; int xrand = 0, yrand = 0; bool permit = false; Celula cel = new Celula(new Vetor2(0, 0), ""); while (permit == false) { rnd = new System.Random(Guid.NewGuid().GetHashCode()); xrand = rnd.Next(1, dungeonInstanciada.tamanhoDungeon.x - 1); rnd = new System.Random(Guid.NewGuid().GetHashCode()); yrand = rnd.Next(1, dungeonInstanciada.tamanhoDungeon.y - 1); cel = dungeonInstanciada.dungeon[xrand, yrand]; if (cel.spawn == true || cel.subSpawn == true || cel.spawnMonstro == true || cel.tipoCelula != "caminho" || Celula.ChecarTipoAreaAdjacente(cel, "entrada", 2) != 0 || cel.spawnItem == true) { permit = false; if (contAntibug >= 999999) { permit = true; print("usou antibug, spawn de monstro geral."); } contAntibug++;//declarado no inicio do for da sala, serve para caso não tenha mais espaço na sala para spawnar monstros. } else { permit = true; print("pemitiu legitimamente, spawn de monstro geral."); } } tileCoord = new Vector3(linha * 2 * Config.tamanhoMaxDungeon.x * tileSize + cel.coordCelulaDun.x * tileSize, -1 * coluna * 2 * Config.tamanhoMaxDungeon.y * tileSize + cel.coordCelulaDun.y * -1 * tileSize, 0); Instantiate(inimigoSpawnado, tileCoord, Quaternion.identity); cel.spawnMonstro = true; pontosGerais = pontosGerais - inimigoSpawnado.GetComponent <Inimigo>().pontos; } }