Beispiel #1
0
    public void AdicionarObjeto(char tipo, int x, int y, int z, bool editor = false)
    {
        Bloco toInstantiate;

        if (tipo == '9')
        {
            posicaoInicial = new Vector3(x, y, z);
            kevin          = Instantiate <Player> (kevinScript, new Vector3(-posicaoInicial.x * tamanho_x_bloco + posicaoInicial.z * tamanho_x_bloco, posicaoInicial.y * tamanho_y_bloco + posicaoInicial.x * tamanho_y_bloco / 2 + posicaoInicial.z * tamanho_y_bloco / 2, 0f), Quaternion.identity);
            kevin.Iniciar();
            kevin.DefinirRetorno(posicaoInicial);
            kevin.animator.SetTrigger("nascer");
            return;
        }
        else if (tipo == '6')
        {
            toInstantiate = blocos [1];
        }
        else if (tipo == '2')
        {
            toInstantiate = blocos [2];
        }
        else if (tipo == ':')
        {
            toInstantiate = blocos [3];
        }
        else if (tipo == ';')
        {
            toInstantiate = blocos [4];
        }
        else if (tipo == '3')
        {
            toInstantiate = blocos [5];
        }
        else if (tipo == '5')
        {
            toInstantiate = blocos [6];
        }
        else if (tipo == '=')
        {
            //Cobra
            //toInstantiate = blocos [0];//TODO Arrumar isso aqui
            toInstantiate = blocos [7];
        }
        else if (tipo == '>')
        {
            toInstantiate = blocos [8];
        }
        else if (tipo == '4')
        {
            //BlocoInfo
            //toInstantiate = blocos [0];//TODO Arrumar isso aqui
            toInstantiate = blocos [9];
        }
        else if (tipo == 'D')
        {
            //Desativado
            toInstantiate = blocos [0];
        }
        else if (tipo != '0')
        {
            toInstantiate = blocos [0];
        }
        else
        {
            return;
        }

        Bloco instance = Instantiate(toInstantiate, new Vector3(-x * tamanho_x_bloco + z * tamanho_x_bloco, y * tamanho_y_bloco + x * tamanho_y_bloco / 2 + z * tamanho_y_bloco / 2, 0f), Quaternion.identity) as Bloco;

        Vector3 local = new Vector3(x, y, z);

        instance.iniciar(-x - z * columns + num_base + y * columns * matrixes, local, fase);

        if (tipo == '4')
        {
            if (GameManager.instance.editor)
            {
                ((BlocoInfo)instance).ReceberInfo(EditorManager.instance.info);
            }
            else
            {
                ((BlocoInfo)instance).LerInfo(numInfo);
            }
            numInfo++;
        }

        if (tipo == 'D')
        {
            instance.Desativar();
        }

        instance.transform.SetParent(boardHolder);

        mapa.Add(local, instance);

        if (editor)
        {
            instance.ModoEditor();
        }
    }