public void apply(string action) { // Get input from the server in the form "method value" // For example : "PH 5" or "PS -1" // Method code string[] method = action.Split(' '); Debug.Log("method: " + method[0] + ", value: " + method[1]); // Value for method argument double val = Double.Parse(method[1]); // Logic for separating out the method strings and calling // the given method with the value as an argument string caseSwitch = method[0]; if (caseSwitch.Contains("PH")) { playerHealth.changePHealth((int)val); } else if (caseSwitch.Contains("PS")) { playerMovement.changePSpeed((float)val); } else if (caseSwitch.Contains("ESR")) { enemyManager.changeESpawnRate((float)val); } else if (caseSwitch.Contains("PD")) { playerShooting.changePDamage((int)val); } else if (caseSwitch.Contains("ES")) { enemyManager.changeESpeed((float)val); } }