Example #1
0
        private void SendLaunchPosition(byte pos, byte speed)
        {
            SetSimulatorTarget(pos, speed);

            if (_network == null)
            {
                return;
            }

            if (!_pauseLaunchMessages.val)
            {
                _launchData[0] = pos;
                _launchData[1] = speed;

                float dist     = Mathf.Abs(pos - _lastSentLaunchPos);
                float duration = LaunchUtils.PredictMoveDuration(dist, speed);

                var durationData = BitConverter.GetBytes(duration);
                _launchData[2] = durationData[0];
                _launchData[3] = durationData[1];
                _launchData[4] = durationData[2];
                _launchData[5] = durationData[3];

                //SuperController.LogMessage(string.Format("Sending: P:{0}, S:{1}, D:{2}", pos, speed, duration));

                _network.Send(_launchData, _launchData.Length);

                _lastSentLaunchPos = pos;
            }
        }
Example #2
0
        private void UpdateSimulator()
        {
            var prevPos = _simulatorPosition.val;

            var newPos = Mathf.MoveTowards(prevPos, _simulatorTarget,
                                           LaunchUtils.PredictDistanceTraveled(_simulatorSpeed, Time.deltaTime));

            _simulatorPosition.SetVal(newPos);

            if (_currentMotionSource != null)
            {
                _currentMotionSource.OnSimulatorUpdate(prevPos, newPos, Time.deltaTime);
            }
        }