Esempio n. 1
0
    private IEnumerator PlayTurnRoutine()
    {
        if (m_gameManager != null)
        {
            if (!m_gameManager.IsGameOver)
            {
                m_enemySensor.UpdateSensor(m_enemyMover.CurrentNode);

                yield return(new WaitForSeconds(0.0f));

                if (m_enemySensor.FoundPlayer)
                {
                    m_gameManager.LoseLevel();

                    Vector3 playerPosition = new Vector3(m_board.PlayerNode.Coordinate.x, 0.0f, m_board.PlayerNode.Coordinate.y);
                    m_enemyMover.Move(playerPosition, 0.0f);

                    while (m_enemyMover.isMoving)
                    {
                        yield return(null);
                    }

                    m_enemyAttack.Attack();
                }
                else
                {
                    m_enemyMover.MoveOneTurn();
                }
            }
        }
    }
Esempio n. 2
0
    IEnumerator PlayTurnRoutine()
    {
        if (m_gameManager != null && m_gameManager.IsGameOver)
        {
            // detect player
            m_enemySensor.UpdateSensor(m_enemyMover.CurrentNode);

            // wait
            yield return(new WaitForSeconds(0f));

            if (m_enemySensor.FoundPlayer)
            {
                // notify the GameManager to lose the level
                m_gameManager.LoseLevel();

                Vector3 playerPosition = new Vector3(m_board.PlayerNode.Coordinate.x, 0f,
                                                     m_board.PlayerNode.Coordinate.y);

                m_enemyMover.Move(playerPosition, 0f);

                while (m_enemyMover.isMoving)
                {
                    yield return(null);
                }

                // attack player
                m_enemyAttack.Attack();
            }
            else
            {
                //movement
                m_enemyMover.MoveOneTurn();
            }
        }
    }
Esempio n. 3
0
    IEnumerator PlayTurnRoutine()
    {
        if (_gameManager != null && !_gameManager.IsGameOver)
        {
            _enemySensor.UpdateSensor(_enemyMove.CurrentNode);
            yield return(new WaitForSeconds(.5f));

            if (_enemySensor.FoundPlayer)
            {
                _gameManager.LoseLevel();

                Vector3 playerPosition = new Vector3(_gameBoard.PlayerNode.Coordinate.x, 0f,
                                                     _gameBoard.PlayerNode.Coordinate.y);
                _enemyMove.Move(playerPosition, 0f);
                while (_enemyMove.isMoving)
                {
                    yield return(null);
                }
                _enemyAttack.Attack();
            }
            //attack player

            //movement
            else
            {
                _enemyMove.MoveOneTurn();
            }
        }
        //wait
    }
    IEnumerator PlayTurnRoutine()
    {
        if (gameManager != null && !gameManager.IsGameOver)
        {
            enemySensor.UpdateSensor(CurrentNode);

            yield return(new WaitForSeconds(endTurnDelay));

            Debug.Log(enemySensor.FoundPlayer);
            if (enemySensor.FoundPlayer)
            {
                gameManager.LoseLevel();

                Vector3 playerPos = board.PlayerNode.transform.position;
                enemyMover.Move(playerPos, 0f);
                while (enemyMover.IsMoving)
                {
                    yield return(null);
                }

                enemyAttack.Attack();
            }
            else
            {
                enemyMover.MoveOneTurn();
            }
        }
    }
    IEnumerator PlayTurnRoutine()
    {
        if (_gameManager != null && !_gameManager.IsGameOver)
        {
            //detect player
            _enemySensor.UpdateSensor(_enemyMover.CurrentNode);

            //wait
            yield return(new WaitForSeconds(0f));

            if (_enemySensor.FoundPlayer)
            {
                //notify GameManager to lose event
                _gameManager.LoseLevel();

                Vector3 playerPosition = _board.PlayerNode.coordinate;
                _enemyMover.Move(playerPosition);

                while (_enemyMover.isMoving)
                {
                    yield return(null);
                }
                //attack player
                _enemyAttack.Attack();
            }
            else
            {
                //move
                _enemyMover.MoveOneTurn();
            }
        }
    }
Esempio n. 6
0
    IEnumerator PlayTurnRoutine()
    {
        if (m_gameManager != null && !m_gameManager.IsGameOver)
        {
            m_enemySensor.UpdateSensor();

            yield return(new WaitForSeconds(0f));

            if (m_enemySensor.FoundPlayer)
            {
                if (godMode == null || (godMode != null && !godMode.IsGodModeActive))
                {
                    m_gameManager.LoseLevel();
                }

                Vector3 playerPosition = new Vector3(m_board.PlayerNode.Coordinate.x, 0f, m_board.PlayerNode.Coordinate.y);
                m_enemyMover.Move(playerPosition, 0f);

                while (m_enemyMover.isMoving)
                {
                    yield return(null);
                }
                if (godMode == null || (godMode != null && !godMode.IsGodModeActive))
                {
                    m_enemyAttack.Attack();
                }
                if (godMode != null && godMode.IsGodModeActive)
                {
                    m_enemyMover.Stand();
                }
            }
            else
            {
                m_enemyMover.MoveOneTurn();
            }
        }
    }
Esempio n. 7
0
    private IEnumerator PlayTurnRoutine()
    {
        if (gameManager != null && !gameManager.IsGameOver)
        {
            enemieSensor.UpdateSensor();

            yield return(null);

            if (enemieSensor.FoundPlayer)
            {
                yield return(StartCoroutine(Kill()));
            }
            else
            {
                enemyMover.MoveOneTurn();
            }
        }
    }
Esempio n. 8
0
    private IEnumerator PlayTurnRoutine()
    {
        if (m_gameManager != null && m_gameManager.IsGameOver)
        {
            m_enemySenor.UpdateSensor();

            yield return(new WaitForSeconds(0f));

            if (m_enemySenor.FoundPlayer)
            {
                //attack

                m_gameManager.LoseLevel();
            }
            else
            {
                m_enemyMover.MoveOneTurn();
            }
        }
    }
Esempio n. 9
0
    // emeny's main routine. if its possible to attack the player, move then wait
    IEnumerator PlayTurnRoutine()
    {
        if (m_gameManager != null && !m_gameManager.IsGameOver)
        {
            // sense for the player
            m_enemySensor.UpdateSensor();

            // wait
            yield return(new WaitForSeconds(0f));

            if (m_enemySensor.FoundPlayer)
            {
                // signal to the game manager to run the lose level event
                m_gameManager.LoseLevel();

                // the player's position at this point
                Vector3 playerPosition = new Vector3(m_board.PlayerNode.Coordinate.x, 0f,
                                                     m_board.PlayerNode.Coordinate.y);

                // move to where the Player currently is
                m_enemyMover.Move(playerPosition, 0f);

                // wait until the end of the enemy iTween animation
                while (m_enemyMover.isMoving)
                {
                    yield return(null);
                }

                // lunge at the player
                m_enemyAttack.Attack();
            }
            else
            {
                // carry out movement
                m_enemyMover.MoveOneTurn();
            }
        }
    }
Esempio n. 10
0
    IEnumerator PlayTurnRoutine()
    {
        if (m_gameManager != null && !m_gameManager.IsGameOver)
        {
            //detect player
            m_enemySensor.UpdateSensor(m_enemyMover.CurrentNode);

            yield return(new WaitForSeconds(0f));

            if (m_enemySensor.FoundPlayer && isScared == false)
            {
                //attack player
                //notify the GM to lose the level

                m_gameManager.LoseLevel();
            }
            else
            {
                // movement
                m_enemyMover.MoveOneTurn(); // --> finishMovementEvent.Invoke()
            }
        }
    }
Esempio n. 11
0
    protected virtual IEnumerator MoveToTargetRoutine()
    {
        if (!HaveLink(pathToTarget[currentPathIndex].transform.position))
        {
            LostPlayer();
        }
        else
        {
            var startPos = new Vector3(currentNode.Coordinate.x, 0f, currentNode.Coordinate.y);
            var newDest  = pathToTarget[currentPathIndex].transform.position;

            destination = newDest;
            FaceDestination();

            yield return(new WaitForSeconds(rotateTime + 0.1f));

            sensor.UpdateSensor();

            if (sensor.FoundPlayer)
            {
                yield return(StartCoroutine(GetComponent <EnemyManager>().Kill()));
            }
            else
            {
                Move(newDest, 0f);

                while (isMoving)
                {
                    yield return(null);
                }

                IncrementPathIndex();

                base.FinishMovementEvent.Invoke();
            }
        }
    }
Esempio n. 12
0
    // main enemy routine: detect/attack Player if possible...then move/wait
    IEnumerator PlayTurnRoutine()
    {
        if (m_gameManager != null && !m_gameManager.IsGameOver)
        {
            // detect player
            m_enemySensor.UpdateSensor();

            // wait
            yield return(new WaitForSeconds(0f));

            if (m_enemySensor.FoundPlayer)
            {
                // notify the GameManager to lose the level
                m_gameManager.LoseLevel();

                // the player's position
                Vector3 playerPosition = new Vector3(m_board.PlayerNode.Coordinate.x, 0f,
                                                     m_board.PlayerNode.Coordinate.y);
                // move to the Player's position
                m_enemyMover.Move(playerPosition, 0f);

                // wait for the enemy iTween animation to finish
                while (m_enemyMover.isMoving)
                {
                    yield return(null);
                }

                // attack/kill player
                m_enemyAttack.Attack();
            }
            else
            {
                // movement
                m_enemyMover.MoveOneTurn();
            }
        }
    }
Esempio n. 13
0
    IEnumerator PlayTurnRoutine()
    {
        if (m_gameManager != null && !m_gameManager.IsGameOver)
        {
            //detect player
            m_enemySensor.UpdateSensor(m_enemyMover.CurrentNode);

            yield return(new WaitForSeconds(0f));

            if (m_enemySensor.FoundPlayer && isOff == false)
            {
                //attack player
                //notify the GM to lose the level
                //lr.transform.gameObject.SetActive(true);
                Debug.Log(this.name + "MORTE");
                m_gameManager.LoseLevel();
            }
            else
            {
                // movement
                m_enemyMover.MoveOneTurn(); // --> finishMovementEvent.Invoke()
            }
        }
    }