1
I was following the fourth video tutorials of Roguelike scavengers, and I came across these errors when I finished. In the fifth video it fixes some, but these continued, I am using the latest version of Unity (5.1f1
I don’t know what else).
He says that the 3 variables in red in the image do not exist in that context, and the other error he points to a line that appears to be normal.
Very good the videos that have excited me enough to start my project!
Here’s the whole code:
using UnityEngine;
using System; //Atributo Serializable - aplica variaveis no inspector e editor
using System.Collections.Generic; //Usar lists
using Random = UnityEngine.Random; //Gerar Numeros Aleatorios
public class BoardManager : MonoBehaviour { //padrao
[Serializable] //tipo de variavel
public class Count
{
public int minimum;
public int maximum;
public Count (int min, int max)
{
minimum = min;
maximum = max;
}
}
public int columns = 8; //Quantidade de colunas do mapa
public int rows = 8; //Quantidade de Linhas do mapa
public Count wallCount = new Count (5,9); //quantidade aleatoria de numeros internos
public Count foodCount = new Count (1,5); //quantidade aleatoria de comida
public GameObject exit; //objetos do jogo, q vao aparecer no mapa ->
public GameObject [] floorTiles;
public GameObject [] wallTiles;
public GameObject [] foodTiles;
public GameObject [] enemyTiles;
public GameObject [] outerWallTiles; // <-
private Transform boardHolder; //segura tds os objetos no mapa
private List <Vector2> gridPosition = new List<Vector2> (); //lista de posiscoes possiveis no mapa
void initialiseList () //limpar a lista do grid e preparar para gerar novo mapa
{
gridPosition.Clear (); //limpa o mapa
for (int x=1; x<columns-1; x++) //loop navega pelas colunas
{
for (int y=1; y<rows-1; y++)
{
gridPosition.Add (new Vector2(x,y));
}
}
}
void BoardSetup ()
{
//starta o mapa e atribui o transform
boardHolder = new GameObject ("Board").transform;
for (int x=-1; x<columns+1; x++)
{
for (int y=-1; y<rows+1; y++)
{
//seleciona um tile para aplicar no mapa
GameObject toInstantiate = floorTiles(Random.Range(0,floorTiles.Length));
//verifica se e muro externo
if (x == -1 || y == -1 || x == columns || y == rows)
{
toInstantiate = outerWallTiles(Random.Range(0,outerWallTiles.Length));
}
GameObject instance = Instantiate (toInstantiate, new Vector2(x,y), Quaternion.identity) as GameObject;
instance.transform.SetParent (boardHolder);
}
}
}
//retorna valor para grid position
Vector2 RandomPosition()
{
int randomIndex = Random.Range (0, gridPosition.Count);
Vector2 randomPosition = gridPosition (randomIndex);
gridPosition.RemoveAt (randomIndex);
return randomPosition;
}
void LayoutObjectAtRandom(GameObject[] tileArray, int minimum, int maximum)
{
int objectCount = Random.Range (minimum, maximum);
for (int i = 0; i < objectCount; i++)
{
Vector3 randomPosition = RandomPosition();
GameObject tileChoice = tileArray(Random.Range(0,tileArray.Length));
Instantiate(tileChoice, randomPosition, Quaternion.identity);
}
}
public void SetupScene (int Level)
{
BoardSetup (); //starta o mapa
initialiseList (); //starta o grid
//instancia numeros aleatorios de muros internos
LayoutObjectAtRandom (wallTiles, wallCount.minimum, wallCount.maximum);
//instancia o numero aleatorio de comida
LayoutObjectAtRandom (foodTiles, foodCount.minimum, foodCount.maximum);
//seta o numero de enemys baseado no lvl
int enemyCount = (int)Mathf.Log (Level, 2f);
LayoutObjectAtRandom (enemyTiles, enemyCount, enemyCount);
//
Instantiate (exit, new Vector2 (columns-1, rows-1), Quaternion.identity);
}
}
Who is Nils? What videos? This seems to be a question directed to a specific person. And the Stack Overflow is a community! If you are looking for help from a certain person, it would be best to contact them directly through other means. But if you’re looking for help from the community, then you should edit and reshape your question so that it’s directed to the community and not just one person, so we can help you.
– Chun
https://www.youtube.com/playlist?list=PLa2bQ5uCFWA15RYHCnhjSbf_LiC4eFEQ0 this is nills !! He teaches to make games and recommended to ask questions here !! kkkkk mals you’re right, I went to think about it later only and left the question so msm, pardon !!
– user27399