/** * Instance constructor. * Creates a new instance from the specified JSON file. */ public RallyConfiguration(string _jsonFile_) { string jsonString = GeneralUtils.ReadContentFromFile(_jsonFile_); RallyConfiguration rcfg = JsonConvert.DeserializeObject <RallyConfiguration> (jsonString); this.m_LMax = rcfg.m_LMax; this.m_LMin = rcfg.m_LMin; this.m_VMax = rcfg.m_VMax; }
/** * Static constructor. */ public static void InitGeneralUtils() { BallUtils.InitBallUtilities(); NetUtils.InitNetUtils(); m_mainScript = GameObject.Find("ScriptHub").GetComponent <Main>(); m_agentScript = GameObject.Find("Agent").GetComponent <AgentInput>(); m_humanScript = GameObject.Find("P1").GetComponent <HumanInput>(); m_sessionScript = GameObject.Find("ScriptHub").GetComponent <SessionBehavior>(); m_menuScript = GameObject.Find("ScriptHub").GetComponent <MenuBehavior>(); m_ballScript = GameObject.Find("Ball").GetComponent <BallBehavior>(); m_dataScript = GameObject.Find("ScriptHub").GetComponent <DataManger>(); ROLE_SERVER = 0; ROLE_CLIENT = 1; HUMAN_ID = 0; HUMAN_LEFT = 2; HUMAN_RIGHT = 3; AGENT_ID = 1; AGENT_SKILL_RANDOM = 0; AGENT_SKILL_NORMAL = 1; AGENT_SKILL_FAST = 2; RALLY_ID = 2; UNASSIGNED = 10; INPUT_KEYBOARD = 0; INPUT_MOUSE = 1; INPUT_HYDRA = 2; BALL_RADIUS_LARGE = 2; BALL_RADIUS_MEDIUM = 1; BALL_RADIUS_SMALL = 0.5F; PADDLE_SIZE_LARGE = 9.0757605F; //150% PADDLE_SIZE_MEDIUM = 6.050507F; //100% PADDLE_SIZE_SMALL = 4.53788025F; //75% PADDLE_WIDTH_MEDIUM = 7.41716F; RASyN_IP = "127.0.0.1"; RASyN_PORT_MAP = new Dictionary <string, int> (); PONG_SERVER_ID = "PongServer"; PONG_CLIENT1_ID = "PongClient1"; PONG_CLIENT2_ID = "PongClient2"; ASSIGNED_PONG_CLIENT_ID = "NULL"; RASyN_PORT_MAP.Add(PONG_SERVER_ID, 19000); RASyN_PORT_MAP.Add(PONG_CLIENT1_ID, 19011); RASyN_PORT_MAP.Add(PONG_CLIENT2_ID, 19012); jss = new JsonSerializerSettings(); jss.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; jss.MissingMemberHandling = MissingMemberHandling.Ignore; //jss.PreserveReferencesHandling = PreserveReferencesHandling.Objects; DRAW_TIMEOUT = 1000 * 60; //60 second timeout in milliseconds BallUtils.InitBallUtilities(); NetUtils.InitNetUtils(); rallyCfg = new RallyConfiguration(Application.dataPath + "/Config/RallyConfiguration.json"); }