Пример #1
0
        public override void Enter(params object[] args)
        {
            _roomId = (int)args[0];
            var loadMapFile = (bool)args[1];

            var lives = DEFAULT_LIVES;

            if (args.Length > 2)
            {
                _score   = (int)args[2];
                _hiScore = (int)args[3];
                lives    = (int)args[4];
            }

            if (loadMapFile)
            {
                _mapFile          = StateManager.Game.ContentManager.LoadJson <MMMapFile>("manicminer.json");
                _font.Text        = _mapFile.rooms[_roomId].name;
                _lives.Lives      = lives;
                _airMeter.AirLeft = _mapFile.rooms[_roomId].airCount;
                _currentRoom      = _mapFile.rooms[_roomId].Copy();

                _roomRenderer.SetRoom(_currentRoom, _roomId);
                _baddieRenderer.SetRoom(_currentRoom);
                _willy.SetRoom(_currentRoom, _roomId, ChangeState);
                _exit.SetRoom(_currentRoom, _roomId);
                _scoreRenderer.UpdateScore(_score, _hiScore);
            }

            _livesAnimationTween = StateManager.Game.Tweens.AddClamp(0.2f, 0, 3, frame => _lives.Frame = frame);
            _keyAnimationTween   = StateManager.Game.Tweens.AddClamp(0.2f, 0, 3, frame => _roomRenderer.KeyAnimFrame = frame);
            _airMeterTween       = StateManager.Game.Tweens.Add(1, () => _airMeter.AirLeft--);

            _pauseables.Add(_livesAnimationTween);
            _pauseables.Add(_keyAnimationTween);
            _pauseables.Add(_airMeterTween);

            // Force all paused items to become unpaused. This is for when
            // the level changes
            _pauseables.ForEach(p => p.Paused = false);

            AddImage(_roomRenderer, Layer.Background);
            AddImage(_air, Layer.UI, 0, 16 * 8);

            AddImage(_airMeter, Layer.UI, 28, 10 + (16 * 8));
            AddImage(_font, Layer.UI, 0, 16 * 8);
            AddImage(_lives, Layer.UI, 0, 168);

            AddImage(_scoreRenderer, Layer.UI, 0, 19 * 8);
            AddImage(_baddieRenderer, Layer.Sprite);
            AddImage(_willy, Layer.Sprite);
            AddImage(_exit, Layer.Sprite);
            AddImage(_quitGameRenderer, Layer.UI);
        }
Пример #2
0
        private async Task PlayBackReactionAsync()
        {
            while (true)
            {
                SimulationStep step = simulator.SimulateNextStep();

                sessionMetrics.RegisterSimulationStep(step);

                scoreKeeper.ScoreStep(step, simulator.DifficultyLevel);
                // We might need to tie this into the board renderer
                // to sync the update with the match animation.
                scoreRenderer.UpdateScore();

                if (step is MatchStep matchStep)
                {
                    await boardManipulator.RewardMatches(matchStep);

                    if (gameEnded)
                    {
                        break;
                    }
                }
                else if (step is CleanUpStep cleanUpStep)
                {
                    if (cleanUpStep.InertTiles.Count(tile => tile.Marked) > 0)
                    {
                        await ShowIncorrectPredictionsTutorialAsync(cleanUpStep.InertTiles);

                        if (gameEnded)
                        {
                            break;
                        }
                    }

                    if (cleanUpStep.CrackedTiles.Count > 0)
                    {
                        await ShowCrackedVialsTutorialAsync(cleanUpStep.CrackedTiles);

                        if (gameEnded)
                        {
                            break;
                        }
                    }
                }

                await boardRenderer.AnimateSimulationStepAsync(step);

                if (step.FinalStep || gameEnded)
                {
                    break;
                }
            }
        }