Ejemplo n.º 1
0
    /// <summary>
    /// On button press, start tower defence mode
    /// </summary>
    public void OnButtonPress()
    {
        m_timeManager.ChangeTime(TimeOfDay.night);
        m_teleportToArea.EnterRegion(Player.instance.gameObject);

        UnitManager.Instance.CreateUnits();
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Changes endgame text and moves the player
    /// </summary>
    private void EndGameWin()
    {
        TeleportToArea _tp = GetComponent <TeleportToArea>();

        _tp.EnterRegion();
        m_endText.text = "You won. Thanks for playing,  Add the potion to go back to the main menu.";
    }
Ejemplo n.º 3
0
    /// <summary>
    /// Changes endgame text and moves the player
    /// </summary>
    private void EndGameLoss()
    {
        Debug.Log("Lost Game");
        TeleportToArea _tp = GetComponent <TeleportToArea>();

        _tp.EnterRegion();
        m_endText.text = "You lost. Thanks for playing, add the potion to go back to the main menu...";
    }
Ejemplo n.º 4
0
    /// <summary>
    /// Moves the guard between each point in his patrol points array, by moving to the goal index.
    /// </summary>
    /// <param name="_goalIndex"></param>
    private void MoveBetweenPoints(int _goalIndex)
    {
        Transform _goal = m_patrolPoints[_goalIndex].transform;



        if (CheckForPoi() != null)
        {
            GameObject _poi = CheckForPoi();
            _goal           = _poi.transform;
            m_movementSpeed = m_highAlertSpeed;
        }
        else
        {
            m_movementSpeed = m_baseMovementSpeed;
        }

        Vector3 _moveVector = _goal.position - transform.position;

        if (!m_cc.isGrounded)
        {
            _moveVector += Physics.gravity;
        }
        _moveVector = _moveVector.normalized * m_movementSpeed;
        if (Vector3.Distance(gameObject.transform.position, _goal.position) > 1f)
        {
            m_cc.Move(_moveVector * Time.deltaTime);
            transform.LookAt(_goal);
        }

        else if (Vector3.Distance(gameObject.transform.position, _goal.position) < 2f)
        {
            //check if its a player

            if (_goal.gameObject.tag == "Player")
            {
                m_tp.EnterRegion();
            }
            else if (m_currentState < m_patrolPoints.Length - 1)
            {
                m_currentState++;
                m_textCanvas.enabled = false;
            }
            else
            {
                m_currentState       = 0;
                m_textCanvas.enabled = false;
            }
        }
    }