예제 #1
0
    public void SetupMuro(BGameManager manager)
    {
        active      = true;
        boardScript = manager.GetActiveBoard();

        gameManager = manager;
    }
예제 #2
0
파일: BPlayer.cs 프로젝트: rubohex/V1Rus
    public void SetupPlayer(BGameManager manager, DPlayerInfo playerInfo, List <int> endIndex)
    {
        // Cargamos los datos basicos del jugador
        rotateLeft   = playerInfo.rotateLeft;
        rotateRight  = playerInfo.rotateRight;
        move         = playerInfo.move;
        rotationTime = playerInfo.rotationTime;
        moveTime     = playerInfo.moveTime;
        recogerCable = playerInfo.recogerCable;

        // Cargamos el manager del nivel
        gameManager = manager;

        // Obtenemos el tablero
        board = gameManager.GetActiveBoard();

        // Actualizamos los Ap que tenemos para el nivel
        Ap = maxAP = board.GetBoardAp();

        // Colocamos al jugador en la casilla de salida y guardamos su indice
        tileIndex = board.PositionToIndex(transform.position);

        // Guardamos los indices finales
        this.endIndex = endIndex;

        // Inicializa el camino
        RestartPath();

        // Temporal
        textAp      = GameObject.Find("TextApPrueba").GetComponent <Text>();
        textAp.text = "AP: " + Ap;
    }
예제 #3
0
파일: BPuerta.cs 프로젝트: rubohex/V1Rus
    public void SetupDoor(BGameManager manager)
    {
        active = true;

        gameManager = manager;
        boardScript = manager.GetActiveBoard();

        setEdges(abierta);
    }
예제 #4
0
파일: BBaliza.cs 프로젝트: rubohex/V1Rus
    public void SetupBaliza(BGameManager manager)
    {
        boardScript = manager.GetActiveBoard();
        gameManager = manager;

        pantalla1 = this.transform.Find("Pantalla").gameObject;

        testPantalla = this.transform.Find("CanvasPrueba2/Pantalla").gameObject;
        testPantalla.SetActive(false);
    }
예제 #5
0
파일: BTerminal.cs 프로젝트: rubohex/V1Rus
    public void SetupTerminal(BGameManager manager)
    {
        active      = true;
        boardScript = manager.GetActiveBoard();

        gameManager = manager;

        pantalla1 = this.transform.Find("Pantalla").gameObject;

        mensaje1 = ("NIVEL TERMINAL " + Nivel);
        mensaje2 = ("Proceso " + numInteracciones / Nivel * 100 + "%");

        hackeable = false;

        testPantalla = this.transform.Find("CanvasPrueba2/Pantalla").gameObject;
        testPantalla.SetActive(false);

        objetoHackeado = this.GetComponent <BTerminal>().objetoHackeado;
        hackAction     = EAccionHack.Door;
    }
예제 #6
0
파일: BEnemy.cs 프로젝트: rubohex/V1Rus
    public void SetupEnemy(BGameManager gameManager)
    {
        // Guardamos el gameManager
        this.gameManager = gameManager;

        // Obtenemos el tablero
        board = gameManager.GetActiveBoard();

        // Obtenemos el vector hacia arriba del tablero
        boardUP = board.GetBoardUp();

        // Posicion inicial del jugador en el waypoint 0
        transform.position = board.GetEnemySpawnPos(wayPoints[0].position, GetEnemyBounds().size);

        // Obtenemos el camino que tendra que recorrer el enemigo
        CreatePath();

        // Rotacion inicial mirando hacia el waypoint 1
        transform.rotation = Quaternion.LookRotation(path[1] - path[0], boardUP);

        // Activamos la colision
        GetComponent <CapsuleCollider>().enabled = true;

        // Obtenemos el indice del tablero en el que estamos
        boardIndex = board.PositionToIndex(transform.position);

        // Obtenemos el indice del array de waypoints en el que estamos
        pathIndex = 0;

        // Iniciamos la variable del pathDirection
        pathDirection = 1;

        // Definimos que el enemigo no se esta moviendo
        isMoving = false;

        // Definimos que la partida no se ha acabado todavia
        gameOver = false;
    }
예제 #7
0
    public void SetupCamera(BGameManager manager, DCameraInfo cameraInfo)
    {
        // Inicializamos los valores en funcion de los datos
        rotateLeft         = cameraInfo.rotateLeft;
        rotateRight        = cameraInfo.rotateRight;
        moveUp             = cameraInfo.moveUp;
        moveDown           = cameraInfo.moveDown;
        moveLeft           = cameraInfo.moveLeft;
        moveRight          = cameraInfo.moveRight;
        cameraMoveSpeed    = cameraInfo.cameraSpeed;
        cameraRotationTime = cameraInfo.rotationTime;
        cameraOrtoMax      = cameraInfo.farZoomClamp;

        // Guardamos el target
        parentT = transform.parent;

        // Hacemos que la camara se centre en el target
        transform.LookAt(parentT);

        // Obtenemos el tablero
        BBoard board = manager.GetActiveBoard();

        // Obtenemos los limites del tablero
        Vector4 aux = board.GetBoardLimits();

        min1 = aux.x;
        max1 = aux.y;
        min2 = aux.z;
        max2 = aux.w;

        // Colocamos la camara con la posicion inicial
        parentT.position = board.GetPlayerSpawnPos(0f);
        parentT.rotation = board.GetPlayerSpawnRot();

        // Obtenemos el sistema de coordenadas
        coordSys = board.GetCoordSys();
    }
예제 #8
0
    /// <summary>
    /// Funcion encargada de hacer el Setup del Board iniciando todas sus estructuras logicas
    /// </summary>
    /// <param name="manager">Manager del cubo</param>
    /// <param name="playableLevel">Indica si el nivel es de paso o de juego</param>
    public void SetupBoard(BGameManager manager, bool playableLevel)
    {
        // GUardamos el manager
        gameManager = manager;

        // Primero observamos el sistema de coordenadas que vamos a utilizar
        // El sistema elegido dependera de las coordenadas que provengan del boardInfo
        if (boardInfo.x && boardInfo.y)
        {
            coordSys = ECord.XY;
        }
        else if (boardInfo.x && boardInfo.z)
        {
            coordSys = ECord.XZ;
        }
        else if (boardInfo.y && boardInfo.z)
        {
            coordSys = ECord.YZ;
        }
        else
        {
            Debug.LogError("Por favor indique en la informacion del tablero dos coordenadas para el systema de coordenadas");
        }

        // Obtenemos el tamaño de la casilla base y lo guardamos para usarlo mas tarde
        Vector3 tileSize = Tile.GetComponent <Renderer>().bounds.size;

        tileSize1 = (int)tileSize.x;
        tileSize2 = (int)tileSize.z;
        tileSize3 = tileSize.y;

        // Obtenemos todas las casillas de la escena activas
        Object[] boardTiles = GetComponentsInChildren <BTile>();

        // Obtenemos la coordenada de la superficie para poder spawnear particulas mas tarde en esta
        BTile aux = (BTile)boardTiles[0];

        switch (coordSys)
        {
        case ECord.XY:
            surfaceCoord = aux.gameObject.transform.position.z + aux.transform.up.z * tileSize3 / 2;
            break;

        case ECord.XZ:
            surfaceCoord = aux.gameObject.transform.position.y + aux.transform.up.y * tileSize3 / 2;
            break;

        case ECord.YZ:
            surfaceCoord = aux.gameObject.transform.position.x + aux.transform.up.x * tileSize3 / 2;
            break;

        default:
            break;
        }

        // A partir de todas estas casillas obtenemos sus posiciones en el sistema
        List <float> firstPositions  = new List <float>();
        List <float> secondPositions = new List <float>();

        foreach (BTile item in boardTiles)
        {
            // Dependiendo del sistema de coordenadas guardamos unos valores diferentes
            switch (coordSys)
            {
            case ECord.XY:
                firstPositions.Add(item.gameObject.transform.position.x);
                secondPositions.Add(item.gameObject.transform.position.y);
                break;

            case ECord.XZ:
                firstPositions.Add(item.gameObject.transform.position.x);
                secondPositions.Add(item.gameObject.transform.position.z);
                break;

            case ECord.YZ:
                firstPositions.Add(item.gameObject.transform.position.y);
                secondPositions.Add(item.gameObject.transform.position.z);
                break;

            default:
                break;
            }
        }

        // Guardamos la posicion minima para usarla mas tarde
        min1 = firstPositions.Min();
        min2 = secondPositions.Min();
        max1 = firstPositions.Max();
        max2 = secondPositions.Max();

        // Calculamos el tamaño del tablero a partir de las posiciones y de los tamaños
        size1 = Mathf.RoundToInt((max1 - min1) / tileSize1) + 1;
        size2 = Mathf.RoundToInt((max2 - min2) / tileSize2) + 1;

        // Spawneamos el plano de collision para detectar los clicks
        SpawnCollisionPlane();

        // Premaramos el diccionario con las diferentes direcciones
        indexDirections.Add("Up", size1);
        indexDirections.Add("Down", -size1);
        indexDirections.Add("Left", -1);
        indexDirections.Add("Right", 1);

        //Para cada casilla almacenamos su posicion y como referente guardamos su indice en el array
        foreach (BTile item in boardTiles)
        {
            //Calculamos el nuevo indice para guardar en el diccionario de localizaciones
            Vector3 position    = item.gameObject.transform.position;
            int     firstIndex  = 0;
            int     secondIndex = 0;

            switch (coordSys)
            {
            case ECord.XY:

                // Calculamos los indices respecto a las posiciones
                firstIndex  = Mathf.RoundToInt((position.x - min1) / tileSize1);
                secondIndex = Mathf.RoundToInt((position.y - min2) / tileSize2) * size1;
                // Guardamos en el diccionario el index con su respectiva posicion
                locations.Add((firstIndex + secondIndex), new Vector2(position.x, position.y));
                tiles.Add((firstIndex + secondIndex), item);
                break;

            case ECord.XZ:

                // Calculamos los indices respecto a las posiciones
                firstIndex  = Mathf.RoundToInt((position.x - min1) / tileSize1);
                secondIndex = Mathf.RoundToInt((position.z - min2) / tileSize2) * size1;
                // Guardamos en el diccionario el index con su respectiva posicion
                locations.Add((firstIndex + secondIndex), new Vector2(position.x, position.z));
                tiles.Add((firstIndex + secondIndex), item);
                break;

            case ECord.YZ:

                // Calculamos los indices respecto a las posiciones
                firstIndex  = Mathf.RoundToInt((position.y - min1) / tileSize1);
                secondIndex = Mathf.RoundToInt((position.z - min2) / tileSize2) * size1;
                // Guardamos en el diccionario el index con su respectiva posicion
                locations.Add((firstIndex + secondIndex), new Vector2(position.y, position.z));
                tiles.Add((firstIndex + secondIndex), item);
                break;

            default:
                break;
            }

            //Guardamos el indice de la casilla inicial y final
            if (item.currentState == BTile.ETileState.Start)
            {
                startIndex = firstIndex + secondIndex;
            }
            else if (item.currentState == BTile.ETileState.End)
            {
                endIndex.Add(firstIndex + secondIndex);
            }
        }

        // Para cada casilla almacenamos sus bordes usando como referente su indice en el array
        foreach (int index in locations.Keys)
        {
            // Llamamos a la funcion CreateLocalEdges que nos devuelve los bordes del indice
            edges.Add(index, CreateLocalEdges(index));
        }

        // Añadimos los bordes de las paredes
        AddWallsEdges();

        // Ponemos a 0 los bordes del tablero
        SetBorderEdges();


        // Obtenemos la posicion y rotacion para instanciar al jugador
        Vector3 playerPos = GetPlayerSpawnPos(boardInfo.player.GetComponent <Renderer>().bounds.size.y);

        Quaternion playerRot = GetPlayerSpawnRot();

        // Instanciamos al jugador
        GameObject playerGO = Instantiate(boardInfo.player, playerPos, playerRot);

        // Obtenemos el script del jugador y lo guardamos
        player = playerGO.GetComponent <BPlayer>();

        player.transform.parent = this.transform;

        // Hacemos el setup del jugador
        player.SetupPlayer(manager, playerInfo, endIndex);

        // Obtenemos la roatacion de los elementos del tablero para cuando spawneemos particulas
        spawnRotation = player.transform.rotation;

        if (playableLevel)
        {
            // Obtenemos todos los enemigos y los guardamos en la lista
            foreach (BEnemy enemy in GetComponentsInChildren <BEnemy>())
            {
                enemy.SetupEnemy(manager);
                enemiesPos.Add(enemy.GetEnemyIndex());
            }

            // Iniciamos las puertas del nivel
            foreach (BPuerta puerta in GetComponentsInChildren <BPuerta>())
            {
                puerta.SetupDoor(manager);
            }

            foreach (BTerminal terminal in GetComponentsInChildren <BTerminal>())
            {
                terminal.SetupTerminal(manager);
            }

            foreach (BBaliza baliza in GetComponentsInChildren <BBaliza>())
            {
                baliza.SetupBaliza(manager);
            }
        }
        else
        {
            // Obtenemos todos los enemigos y los desactivamos
            foreach (BEnemy enemy in GetComponentsInChildren <BEnemy>())
            {
                enemy.EndEnemy();
            }
        }

        // Spawneamos el target de la camara y lo colocamos en el centro
        GameObject target = new GameObject("Camera Target");

        target.transform.position = Vector3.zero;
        target.transform.rotation = Quaternion.identity;

        target.transform.parent = this.transform;

        // Instanciamos la camara
        GameObject cameraGO = Instantiate(boardInfo.camera, cameraInfo.position, Quaternion.Euler(cameraInfo.rotation));

        cameraGO.transform.parent = target.transform;

        // Guardamos el script de la camara
        camera = cameraGO.GetComponent <BCameraController>();

        // Ejecutamos el Setup
        camera.SetupCamera(manager, cameraInfo);
    }