Has Issue in My C # Nils Video Script (On Board Manager)

0

Nils, or someone who knows how to respond to me, there are several errors here on my console tab, I'm new to this area and are talking about errors with)]} and basic programming stuff! please help me solve this! I need a lot.

This is the video Concerning such a C # Script .

IwillalsosendallthescriptIhavedonehere.

usingUnityEngine;usingSystem;//Atributoserializable-comoaparecemasvariaveisnoinspectorenoeditorusingSystem.Collections.Generic;//usarLists.usingRandom=UnityEngine.Random;//GerarnumerosaleatoriospublicclassBoardManager:MonoBehaviour{[Serializable]publicclassCount{publicintminimum;publicintmaximum;publicCount(intmin,intmax){minimum=min;maximum=max;}}publicintcolumns=8;//QuantidadedeColunasdoTabuleiropublicintrows=8;//linhasnotabuleiropublicCountwallCount=newCount(5,9);//QuantidadealeatoriadenumerosinternospublicCountfoodCount=newCount(1,5);//Quantidadealeatoriadecomida(NaoireiUtilizar)publicGameObjectexit;publicGameObject[]floorTiles;//ChaopublicGameObject[]WallTile;//MurospublicGameObject[]foodTiles;//ComidaspublicGameObject[]enemyTile;//inimigospublicGameObject[]outerWallsTiles;//MurosExternosprivateTransformboardHolder;//VariavelparapendurartodomundodotabuleiroprivateList<Vector3>gridPosition=newList<Vector3>();//ListadePossiveisPosiçoesparaostiles//LimparlistadogrideprepararparagararumnovotabuleirovoidinitialiseList(){//LimpaasposiçoesgridPosition.Clear();//loopparanavegarascolunasfor(intx=1;x<columns-1;x++){for(inty=1;y<rows-1;y++){gridPosition.Add(newVector3(x,y,0f));}}}//configurarbackgroundemurosexternosvoidBoardSetup(){//inicializaotabuleiroeatribiuseutransformboardHolder=newGameObject("Board").transform;

        for(int x = -1, x < columns + 1;x++);
        for(int y = -1, y < columns + 1;y++);
                //Pegar tile aleatorio para fazer parte do chao
                GameObject toInstatiate = floorTiles[Random.Range(0,floorTiles.Length)];

                //verificar se e muro externo
        if( x == -1 || y == -1 || x == columns || y == rows );
                {
                    toInstatiate = outerWallsTiles[Random.Range[0,outerWallsTiles.Length]];


                GameObject instance = Instantiate(toInstatiate, new Vector3(x,y,0f),Quaternion.identity)as GameObject;

                instance.transform.SetParent (boardHolder);
                }
    }

    //Rertorna um valor aleatorio da nossa gridposition
    Vector3 RandomPosition()
    {
        int randomIndex = Random.Range (0, gridPosition.Count);

        Vector3 randomPosition = gridPosition [randomIndex];

        gridPosition.RemoveAt (randomIndex);

        return randomPosition;

    }

    //pega o array de objetos que passar, junto com o valor minimo e maximo que voce vai adicionar daaquele numero de objeto.
    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)
    {
        //colocou os quadradinhos do tabuleiro
        BoardSetup ();
        //inicializou o grid
        initialiseList ();

        //instanciar um numero aleatorio de muros internos
        LayoutObjectAtRandom(WallTile wallCount.minimum, wallCount.maximum);

        //instanciar um numero aleatorio de comidas
        LayoutObjectAtRandom (foodTiles, foodCount.minimum, foodCount.maximum);

        //instanciar o numero decimal inimigos baseado No level
        int enemyCount = (int)Mathf.Log(level, 2f);
        LayoutObjectAtRandom (enemyTile, enemyCount, enemyCount);

        //instanciar a saida
        Instantiate (exit, new Vector3 (columns-1,rows-1,0f),Quaternion.identity);

    }


    }


    // Use this for initialization
    void Start () {

    }

I await your response. Thank you in advance.

    
asked by anonymous 22.07.2015 / 05:49

1 answer

3

These errors must be occurring because you are not closing classe and namespace correctly.

The codes below this line are not in the scope of classe .

 public int columns = 8; //Quantidade de Colunas do Tabuleiro

From a verified where the opening of your classe is and where the closing is.

I've set the code, look at your code and compare it with the one below, especially pay attention to the { and } openings of the keys.

using UnityEngine;
using System; //Atributo serializable - como aparecem as variaveis no inspector e no editor
using System.Collections.Generic; //usar Lists.
using Random = UnityEngine.Random; //Gerar numeros aleatorios

public class BoardManager : MonoBehaviour {
    [Serializable]
    public class Count
    {
        public int minimum;
        public int maximum;

        public Count (int min, int max)
        {
            minimum = min;
            maximum = max;
        }

// Você estava fechando a classe nesta linha

        public int columns = 8; //Quantidade de Colunas do Tabuleiro
        public int rows = 8; //linhas no tabuleiro
        public Count wallCount = new Count (5,9); //Quantidade aleatoria de numeros internos
        public Count foodCount = new Count (1,5); //Quantidade aleatoria de comida(Nao irei Utilizar)
        public GameObject exit;
        public GameObject[] floorTiles; //Chao
        public GameObject[] WallTile; //Muros
        public GameObject[] foodTiles; //Comidas
        public GameObject[] enemyTile; //inimigos
        public GameObject[] outerWallsTiles; //Muros Externos

        private Transform boardHolder; //Variavel para pendurar todo mundo do tabuleiro
        private List <Vector3> gridPosition = new List<Vector3>(); //Lista de Possiveis Posiçoes para os tiles


        //Limpar lista do grid e preparar para garar um novo tabuleiro
        void initialiseList()
        {
            //Limpa as posiçoes
            gridPosition.Clear ();

            //loop para navegar as colunas
            for (int x = 1; x < columns -1; x++)
            {
                for(int y = 1; y<rows-1;y++)
                {
                    gridPosition.Add(new Vector3(x,y,0f));
                }
            }
        }

        //configurar background e muros externos
        void BoardSetup()
        {
            //inicializa o tabuleiro e atribiu seu transform
            boardHolder = new GameObject ("Board").transform;

            for(int x = -1, x < columns + 1;x++);
            for(int y = -1, y < columns + 1;y++);

            //Pegar tile aleatorio para fazer parte do chao
            GameObject toInstatiate = floorTiles[Random.Range(0,floorTiles.Length)];

            //verificar se e muro externo
            if( x == -1 || y == -1 || x == columns || y == rows );
            {
                toInstatiate = outerWallsTiles[Random.Range[0,outerWallsTiles.Length]];

                GameObject instance = Instantiate(toInstatiate, new Vector3(x,y,0f),Quaternion.identity)as GameObject;

                instance.transform.SetParent (boardHolder);
            }
        }

        //Rertorna um valor aleatorio da nossa gridposition
        Vector3 RandomPosition()
        {
            int randomIndex = Random.Range (0, gridPosition.Count);

            Vector3 randomPosition = gridPosition [randomIndex];

            gridPosition.RemoveAt (randomIndex);

            return randomPosition;
        }

        //pega o array de objetos que passar, junto com o valor minimo e maximo que voce vai adicionar daaquele numero de objeto.
        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)
        {
            //colocou os quadradinhos do tabuleiro
            BoardSetup ();
            //inicializou o grid
            initialiseList ();

            //instanciar um numero aleatorio de muros internos
            LayoutObjectAtRandom(WallTile wallCount.minimum, wallCount.maximum);

            //instanciar um numero aleatorio de comidas
            LayoutObjectAtRandom (foodTiles, foodCount.minimum, foodCount.maximum);

            //instanciar o numero decimal inimigos baseado No level
            int enemyCount = (int)Mathf.Log(level, 2f);
            LayoutObjectAtRandom (enemyTile, enemyCount, enemyCount);

            //instanciar a saida
            Instantiate (exit, new Vector3 (columns-1,rows-1,0f),Quaternion.identity);
        }

        // e o namespace aqui...

        // Use this for initialization
        void Start () {

        }

    }// fecha a classe
}// fecha o namespace

Always pay attention to these details. Arrange this, and see if it will work.

    
22.07.2015 / 14:30