void ProcessLevel(CanvasAnimatedUpdateEventArgs args) { if (_gameState == GameState.LevelUp) { _currentLevel++; if (_currentLevel > _gameSequence.Length - 1) _currentLevel = _gameSequence.Length - 1; _currentBeatTime = 0; _currentSequence = _gameSequence[_currentLevel]; _currentElapsedTime = TimeSpan.Zero; _gameState = GameState.ThreeTwoOneGo; } if (_gameState != GameState.ThreeTwoOneGo && _gameState2 != GameState.GotPoints) return; if (!_tribal.IsPlaying) { _tribal.Play(); } if (_tapType == SpheroTapType.DoubleTap) { _tapType = SpheroTapType.None; } _previousElapsedTime = _elapsedTime; _elapsedTime = args.Timing.ElapsedTime; _currentElapsedTime += _elapsedTime; _rewardElapsedTime += _elapsedTime; if ((_gameState2 == GameState.GotPoints || _gameState2 == GameState.Failed) && _currentElapsedTime.TotalMilliseconds > 2000) { _gameState2 = GameState.None; _rewardElapsedTime = TimeSpan.Zero; } if (_gameState2 == GameState.CheckMovement && _rewardElapsedTime.TotalMilliseconds > 1000) { int beat = _currentBeatTime - 1; if (beat < 0) beat = 0; if (_currentMovType == _currentSequence.Movements[beat]) { _gameState2 = GameState.GotPoints; _currentIdxReward = RAND.Next(0, _rewardMessage.Length - 1); _points += (_currentIdxReward + 1) * _currentLevel * beat; } else { _currentMovType = SpheroMovementType.None; _gameState2 = GameState.Failed; _numFails++; } } if (_currentBeatTime < _currentSequence.Times) { _posSpheroSeq.X -= 1; // TODO syncronize the movement with the song and active color if (_currentElapsedTime.TotalMilliseconds > _currentSequence.Tempo || _currentElapsedTime.TotalMilliseconds > _currentSequence.Tempo + _currentSequence.TempoColorSwitch) { _currentColor = _currentSequence.Colors[_currentBeatTime]; if (_currentElapsedTime.TotalMilliseconds > _currentSequence.Tempo + _currentSequence.TempoColorSwitch) _currentElapsedTime = TimeSpan.Zero; _robot.SetRGBLED(_currentColor.R, _currentColor.G, _currentColor.B); _prevBeatTime = _currentBeatTime; _currentBeatTime++; _gameState2 = GameState.CheckMovement; if (_currentBeatTime == _currentSequence.Times) _gameState = GameState.LevelUp; } } if (_currentBeatTime >= _currentSequence.Times && _movType == SpheroMovementType.ShakeIt) { _movType = SpheroMovementType.None; _currentMovType = SpheroMovementType.None; _tribal.Stop(); _currentBeatTime = 0; _currentLevel = 0; _currentElapsedTime = TimeSpan.Zero; } if (_numFails > 6) { _gameState = GameState.GameOver; _movType = SpheroMovementType.None; _tribal.Stop(); _currentColor = Colors.Red; _currentBeatTime = 0; _currentBeatTime = 0; _currentLevel = 0; _currentElapsedTime = TimeSpan.Zero; } }
private void OnCollisionDetected(object sender, CollisionData e) { _tapType = SpheroTapType.DoubleTap; }