Beispiel #1
0
    /**
     * This function sets the environment settings based on the EnvState object.
     * Only Client processes call this function.
     */
    public static void SetEnvState(EnvState envState)
    {
        m_sessionScript.LeftScore        = envState.leftScore;
        m_sessionScript.RightScore       = envState.rightScore;
        m_humanScript.transform.position = envState.humanPos.ToVector2();
        m_agentScript.transform.position = envState.agentPos.ToVector2();
        GeneralUtils.SetPaddleSize("leftPaddle", envState.leftPaddleLen, envState.leftPaddleWidth);
        GeneralUtils.SetPaddleSize("rightPaddle", envState.rightPaddleLen, envState.rightPaddleWidth);
        m_ballScript.transform.position    = envState.ballPos.ToVector2();
        m_ballScript.transform.eulerAngles = envState.ballOrientation.ToVector3();
        m_sessionScript.currMatch          = envState.currMatch;

        try{
            GeneralUtils.UpdateEnvironmentDifficulty(envState.currMatch.difficulty);
        }catch (Exception e) {}

        if (envState.extraInfo.Contains("ballHit"))
        {
            //play pong hit sound
            m_ballScript.PlayBallHitSound();
        }
    }