Beispiel #1
0
    void Update()
    {
        // Doing setup in Update because scene not fully created in Start()
        if (!m_IsSetup)
        {
            DoSetup();
            m_IsSetup = true;
            return;
        }

        if (m_IsInGoalScoredCooldown)
        {
            m_timeUntilScoreCooldownFinished -= Time.deltaTime;

            if (m_timeUntilScoreCooldownFinished <= 0.0f)
            {
                m_IsInGoalScoredCooldown = false;

                m_Football.GetComponent <Rigidbody> ().transform.position = m_Football.m_InitialPosition;
            }
        }

        if (mFriendlyTeam.Count == 0 || mOppositionTeam.Count == 0)
        {
            // intitial build
            RebuildTeams();

            m_CurrentSelectedPlayer = GetClosestFriendlyPlayerToBall();

            if (m_CurrentSelectedPlayer)
            {
                m_CurrentSelectedPlayer.SetPlayerControlled(true);
            }

            m_CurrentOppositionPlayer = GetClosestOppositionPlayerToBall();

            if (m_CurrentOppositionPlayer)
            {
                m_CurrentOppositionPlayer.SetIsAIControlled(true);
            }
        }

        TakeInput();

        UpdateCamera();

        ApplyBallControlAid();

        UpdateCurrentPlayer();

        UpdateCurrentOppositionPlayer();

        UpdateAIPositions();
    }