Exemplo n.º 1
0
        // TODO: remove once the backend bug is fixed.
        /// <summary>
        /// Verifies that the current launch is in RunningGame state, otherwise aborts the attach
        /// process by throwing AttachException.
        /// </summary>
        void VerifyGameIsReady(IAction action)
        {
            // Either new launch api is disabled, or we didn't run the game and only have process
            // id to attach to. We don't match the game launch to the remote process id.
            if (_gameLaunch != null)
            {
                GgpGrpc.Models.GameLaunch state =
                    _taskContext.Factory.Run(async() =>
                                             await _gameLaunch.GetLaunchStateAsync(action));
                if (state.GameLaunchState != GameLaunchState.RunningGame)
                {
                    var devEvent = new DeveloperLogEvent
                    {
                        GameLaunchData = new GameLaunchData
                        {
                            LaunchId = _gameLaunch.LaunchId
                        }
                    };
                    string error = ErrorStrings.GameNotRunningDuringAttach;
                    if (state.GameLaunchEnded != null)
                    {
                        devEvent.GameLaunchData.EndReason = (int)state.GameLaunchEnded.EndReason;
                        error = LaunchUtils.GetEndReason(state.GameLaunchEnded, state.GameletName);
                    }

                    action.UpdateEvent(devEvent);

                    throw new GameLaunchAttachException(VSConstants.E_FAIL, error);
                }
            }
        }
Exemplo n.º 2
0
        public void CreatePages()
        {
            AddPage(new LaunchPage(
                        new PrintScreenAction()
                        ));
            AddPage(new LaunchPage(
                        new SpeedShiftAction()
                        ));

            LaunchUtils.SetPadFromPage(CurPage);
        }
Exemplo n.º 3
0
        public int PreviousPage()
        {
            if (CurPage.PageNumber - 1 > 0)
            {
                LaunchPage prevPage = GetPage(CurPage.PageNumber - 1);
                CurPage = prevPage;
                LaunchUtils.SetPadFromPage(prevPage);

                return(prevPage.PageNumber);
            }

            return(CurPage.PageNumber);
        }
Exemplo n.º 4
0
        public int NextPage()
        {
            if (CurPage.PageNumber + 1 <= TotalPages)
            {
                LaunchPage nextPage = GetPage(CurPage.PageNumber + 1);
                CurPage = nextPage;
                LaunchUtils.SetPadFromPage(nextPage);

                return(nextPage.PageNumber);
            }

            return(CurPage.PageNumber);
        }
Exemplo n.º 5
0
        public bool OnUpdate(ref byte outPos, ref byte outSpeed)
        {
            _dirChangeTimer -= Time.deltaTime;
            if (_dirChangeTimer <= 0.0f)
            {
                _moveUpwards = !_moveUpwards;

                float dist = _maxPosition.val - _minPosition.val;
                _dirChangeDuration = LaunchUtils.PredictMoveDuration(dist, _speed.val) + LAUNCH_DIR_CHANGE_DELAY;
                _dirChangeTimer    = _dirChangeDuration - Mathf.Min(_dirChangeDuration, -_dirChangeTimer);

                outPos   = _moveUpwards ? (byte)_maxPosition.val :  (byte)_minPosition.val;
                outSpeed = (byte)_speed.val;

                return(true);
            }

            return(false);
        }
Exemplo n.º 6
0
    public void Fire(SpriteRenderer sr)
    {
        //左向きの場合
        if (sr.flipX)
        {
            rotation    = 40;
            torquePower = 2;
        }
        else
        //右向きの場合
        {
            rotation    = -40;
            torquePower = -2;
        }

        Transform newItem = Object.Instantiate(item, transform.position, Quaternion.identity, transform).transform;

        LaunchUtils.LaunchItem(ref newItem, power, transform.up, rotation, torquePower);
    }
Exemplo n.º 7
0
        public bool OnUpdate(ref byte outPos, ref byte outSpeed)
        {
            if (_targetAnimationPattern == null)
            {
                if (!string.IsNullOrEmpty(_targetAnimationAtomChooser.val))
                {
                    _targetAnimationAtomChooser.SetVal("");
                }
                return(false);
            }

            if (_pluginFreeController.selected && SuperController.singleton.editModeToggle.isOn)
            {
                _lineDrawer0.SetLinePoints(_pluginFreeController.transform.position,
                                           _animationAtomController.transform.position);
                _lineDrawer0.Draw();
            }

            if (_targetAnimationPattern.steps.Length <= 1)
            {
                return(false);
            }

            float minPos, maxPos;

            GenerateMotionPointsFromPattern(_targetAnimationPattern, ref _motionPoints, out minPos, out maxPos);

            if (_includeMidPoints.val && _pluginFreeController.selected &&
                SuperController.singleton.editModeToggle.isOn)
            {
                for (int i = 0; i < _motionPoints.Count; i++)
                {
                    if (i % 2 == 0)
                    {
                        continue;
                    }

                    var boxMatrix = Matrix4x4.TRS(_motionPoints[i].Position, Quaternion.identity,
                                                  new Vector3(0.1f, 0.1f, 0.1f));

                    Graphics.DrawMesh(_animationAtomController.holdPositionMesh, boxMatrix,
                                      _animationAtomController.linkLineMaterial,
                                      _animationAtomController.gameObject.layer, null, 0, null, false, false);
                }
            }

            int p0, p1;

            if (GetMotionPointIndices(_patternTime.val, _motionPoints, out p0, out p1))
            {
                if (p0 != _lastPointIndex)
                {
                    float yFactor = Mathf.InverseLerp(minPos, maxPos, GetPositionForPlane(_motionPoints[p1].Position));

                    float timeToNextPoint;
                    if (p1 > p0)
                    {
                        timeToNextPoint = _motionPoints[p1].Time - _patternTime.val;
                    }
                    else
                    {
                        timeToNextPoint = _targetAnimationPattern.GetTotalTime() - _patternTime.val +
                                          _motionPoints[p1].Time;
                    }

                    timeToNextPoint /= Mathf.Max(_patternSpeed.val, 0.001f);

                    float launchFactor = _invertPosition.val ? 1.0f - yFactor : yFactor;

                    float launchPos   = Mathf.Lerp(_minPosition.val, _maxPosition.val, launchFactor);
                    float launchSpeed = LaunchUtils.PredictMoveSpeed(_lastLaunchPos, launchPos, timeToNextPoint);

                    outPos   = (byte)launchPos;
                    outSpeed = (byte)launchSpeed;

                    _lastPointIndex = p0;
                    _lastLaunchPos  = launchPos;

                    return(true);
                }
            }

            return(false);
        }
 public void Kill()
 {
     LaunchUtils.ResetPad();
     Process.GetCurrentProcess().Kill();
 }
Exemplo n.º 9
0
        private bool ProcessTarget(ref byte outPos, ref byte outSpeed)
        {
            bool shouldMoveLaunch = false;

            if (_targetAtom == null || _targetController == null)
            {
                return(false);
            }

            _positionSampleTimer -= Time.deltaTime;
            if (_positionSampleTimer > 0.0f)
            {
                return(false);
            }

            var sampleInterval = GetPositionSampleInterval();

            _positionSampleTimer = sampleInterval - Mathf.Min(sampleInterval, -_positionSampleTimer);

            // Convert target position into zone local space
            Vector3 localZonePos = _zoneInvMatrix.MultiplyPoint(_targetController.transform.position);

            if (localZonePos.x < -1.0f || localZonePos.x > 1.0f ||
                localZonePos.y < -1.0f || localZonePos.y > 1.0f ||
                localZonePos.z < -1.0f || localZonePos.z > 1.0f)
            {
                return(false);
            }

            // Convert Y range from -1.0, 1.0 to 0.0f, 99.0f
            float posFactor = Mathf.InverseLerp(-1.0f, 1.0f, localZonePos.y);

            _currentTargetPos.SetVal(Mathf.Lerp(0, LaunchUtils.LAUNCH_MAX_VAL, posFactor));

            // Calculate required launch move speed in order to reach new position
            float speed = LaunchUtils.PredictMoveSpeed(_lastLaunchPos, _currentTargetPos.val, Time.deltaTime);

            // We store this speed into our velocity buffer to help with generating a rolling average speed.
            if (_velocityHistory.Count == AVG_VELOCITY_BUFFER_CAPACITY)
            {
                _velocityHistory.RemoveAt(0);
            }
            _velocityHistory.Add(speed);

            float delta     = _currentTargetPos.val - _lastLaunchPos;
            int   deltaSign = delta > 0.0f ? 1 : -1;

            // We apply the users desired speed multiplier (After we store the original in for the rolling average to
            // prevent throwing off all the other parameters that tune the prediction logic)
            speed = Mathf.Clamp(speed * _launchSpeedMultiplier.val, 0.0f, LaunchUtils.LAUNCH_MAX_VAL);

            // Are we moving up?
            if (deltaSign == 1)
            {
                // Storing a rolling velocity for upwards motion
                if (_upwardsVelocityBuffer.Count == VELOCITY_BUFFER_CAPACITY)
                {
                    _upwardsVelocityBuffer.Dequeue();
                }
                _upwardsVelocityBuffer.Enqueue(speed);

                // If we continue moving in the same direction then we accumulate time, if that time goes over our
                // calculated threshold then we should consider telling the Launch about this movement
                var prevTime = _timeMovingUpwards;
                _timeMovingUpwards += Time.deltaTime;

                if (prevTime < _currentLaunchSignalTimeThreshold.val &&
                    _timeMovingUpwards >= _currentLaunchSignalTimeThreshold.val)
                {
                    // We take the highest speed during this upwards motion as it is most likely the highest speed that
                    // will be the closest representation of the motion.
                    float highestSpeed = RetrieveHighestSpeed(_upwardsVelocityBuffer);
                    highestSpeed = Mathf.Round(highestSpeed);

                    // Only if the speed is small do we tell the launch to go to exact locations
                    // (Not happy with this, need to think of a better way to deal with slower motions)
                    float launchPos   = highestSpeed > 1.0f ? LaunchUtils.LAUNCH_MAX_VAL : _currentTargetPos.val;
                    float launchSpeed = highestSpeed;

                    // Tell the Launch to do it's thing!
                    shouldMoveLaunch = true;
                    outPos           = (byte)launchPos;
                    outSpeed         = (byte)launchSpeed;

                    UpdateSignalThreshold();

                    if (highestSpeed < 1.0f)
                    {
                        _timeMovingUpwards = 0.0f;
                        _upwardsVelocityBuffer.Clear();
                    }
                }

                _timeMovingDownwards = 0.0f;
                _downwardsVelocityBuffer.Clear();
            }
            // This does the same as above except for downwards motion
            else if (deltaSign == -1)
            {
                if (_downwardsVelocityBuffer.Count == VELOCITY_BUFFER_CAPACITY)
                {
                    _downwardsVelocityBuffer.Dequeue();
                }
                _downwardsVelocityBuffer.Enqueue(speed);

                var prevTime = _timeMovingDownwards;
                _timeMovingDownwards += Time.deltaTime;

                if (prevTime < _currentLaunchSignalTimeThreshold.val &&
                    _timeMovingDownwards >= _currentLaunchSignalTimeThreshold.val)
                {
                    float highestSpeed = RetrieveHighestSpeed(_downwardsVelocityBuffer);

                    highestSpeed = Mathf.Round(highestSpeed);

                    float launchPos   = highestSpeed > 1.0f ? 0 : _currentTargetPos.val;
                    float launchSpeed = highestSpeed;

                    // Tell the Launch to do it's thing!
                    shouldMoveLaunch = true;
                    outPos           = (byte)launchPos;
                    outSpeed         = (byte)launchSpeed;

                    UpdateSignalThreshold();

                    if (highestSpeed < 1.0f)
                    {
                        _timeMovingDownwards = 0.0f;
                        _downwardsVelocityBuffer.Clear();
                    }
                }

                _timeMovingUpwards = 0.0f;
                _upwardsVelocityBuffer.Clear();
            }

            _lastLaunchPos = _currentTargetPos.val;

            return(shouldMoveLaunch);
        }