static public PanzerCommandSender GetInstance() { if (_instance == null) { _instance = new PanzerCommandSender(); } return(_instance); }
// Start is called before the first frame update void Start() { Host = Config.ReadValue(CONFIG_SECTION, "Host", Host); Port = int.Parse(Config.ReadValue(CONFIG_SECTION, "Port", Port.ToString())); ThrottleInterval = int.Parse(Config.ReadValue(CONFIG_SECTION, "ThrottleInterval", ThrottleInterval.ToString())); this.panzerCommandSender = PanzerCommandSender.withConnection(Host, Port, ThrottleInterval); }
// Update is called once per frame void Update() { this.PingPongThrottle.Run(() => { try { PanzerCommandSender.PingPong(); this.IsConnected = true; } catch (System.Exception e) { // Debug.LogException(e, this); this.IsConnected = false; } finally { EventBus.Instance.NotifyPingPong(this.IsConnected); } Debug.Log("ping pong throttle: " + this.IsConnected); }); }
// Update is called once per frame void Update() { Vector2 stickL = OVRInput.Get(OVRInput.RawAxis2D.LThumbstick); Vector2 stickR = OVRInput.Get(OVRInput.RawAxis2D.RThumbstick); Vector3 direction = StickWithCameraDirection ? Camera.main.transform.forward : Vector3.forward; float leftLevel = leftInputProcessor.GetLevel(direction); float rightLevel = rightInputProcessor.GetLevel(direction); ControllerInput input = new ControllerInput(leftLevel, rightLevel, stickR.x, stickR.y); PanzerCommandSender.RemoteControlThrottle(input); if (this.EnableVibration) { Vibrate(leftLevel, rightLevel); } EventBus.Instance.NotifyController(input); }
static public void RemoteControlThrottle(ControllerInput input) { var instance = GetInstance(); // sending consecutive zeros is meaningless. if (instance.prevSendInput.IsZero() && input.IsZero()) { return; } instance.sendCommandThrottle.Run(() => { try { PanzerCommandSender.RemoteControl(input); } catch (RpcException e) { // Debug.LogException(e); } }); }
// Start is called before the first frame update void Start() { this.panzerCommandSender = PanzerCommandSender.withConnection(Host, Port, ThrottleInterval); }