예제 #1
0
    /// <summary>
    /// Actualiza todos los objetos que estan activos actualmente en escena
    /// </summary>
    private void UpdateActive(bool playableLevel)
    {
        activeEnemies.Clear();

        activeWalls.Clear();

        activeTerminals.Clear();

        activeDoors.Clear();


        if (playableLevel)
        {
            // Guardamos los enemigos
            activeEnemies.AddRange(activeBoard.GetBoardEnemies());

            // Guardamos los muros
            activeWalls.AddRange(activeBoard.GetBoardWalls());

            // Guardamos las terminales
            activeTerminals.AddRange(activeBoard.GetBoardTerminals());

            // Guardamos las puertas
            activeDoors.AddRange(activeBoard.GetBoardDoors());
        }

        // Guardamos el jugador
        activePlayer = activeBoard.GetPlayer();

        // Guardamos la camara
        activeCamera = activeBoard.GetCamera();
    }
예제 #2
0
파일: BEnemy.cs 프로젝트: rubohex/V1Rus
    /// <summary>
    /// Cuando se llama a este metodo el enemigo hace su siguiente movimiento mirando al siguiente wayPoint
    /// </summary>
    public IEnumerator NextMovement()
    {
        if (!gameOver)
        {
            // Cambiamos el material de las celdas de vision
            ResetVisionRange();

            // Obtenemos el vector al que miraremos
            Vector3 lookAt = path[ComputeNextPathIndex(pathIndex)];

            // Actualizamos la variable para indicar que el enemigo esta rotando
            isMoving = true;

            // Iniciamos una corutina que se encargara de hacer rotar al enemigo
            if (Vector3.Distance(transform.position + transform.forward, lookAt) > 0.001f)
            {
                yield return(StartCoroutine(RotateOverTimeCoroutine(this.gameObject, rotationTime, transform.rotation, Quaternion.LookRotation(lookAt - path[pathIndex], boardUP))));
            }

            // Obtenemos el Indice al que queremos movernos
            pathIndex = ComputeNextPathIndex(pathIndex);

            // Obtenemos el indice del tablero al que nos moveremos
            boardIndex = board.PositionToIndex(path[pathIndex]);

            //Comprobamos si vamos a chocarnos con un jugador
            if (board.GetPlayer().GetIndex() == boardIndex)
            {
                StartCoroutine(gameManager.ResetBoard());
            }

            // Actualizamos la posicion del enemigo
            board.UpdateEnemy(board.PositionToIndex(transform.position), boardIndex);

            // Una vez terminada la rotacion iniciamos una corutina para que el jugador se mueva
            yield return(StartCoroutine(MoveOverTimeCoroutine(gameObject, moveTime, transform.position, board.IndexToPosition(boardIndex, gameObject))));

            SetupEnemyVision();
        }

        yield return(null);
    }