Esempio n. 1
0
        private void PlayLevel(LevelData levelData)
        {
            CellsField.Play(levelData);

            switch (levelData.LoseConditionType)
            {
            case LoseConditionType.LimitedTime:
                GameOverChecker = new LimitedTimeGameOverChecker(levelData.LoseConditionValue);
                break;

            case LoseConditionType.LimitedMoves:
                GameOverChecker = new LimitedMovesGameOverChecker(CellsField, levelData.LoseConditionValue);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            GameOverChecker.OnGameOver += OnGameOver;
            WinChecker        = new TargetsWinChecker(CellsField, levelData.Targets.ToList());
            WinChecker.OnWin += OnWin;

            App.Instance
            .WindowManager
            .Show <LevelInfoWindow>()
            .Initialize(GameOverChecker, WinChecker, Pause);
        }
Esempio n. 2
0
 public Game(ICollection <Player> players, IWinChecker winChecker, ILogger <Game> logger)
 {
     Players     = players;
     _logger     = logger;
     _winChecker = winChecker;
     GameState   = new GameState();
 }
Esempio n. 3
0
 public GameEngine(List <FieldButton> fields, Label status)
 {
     _status    = status;
     _fields    = fields;
     _playerOne = new Player('X', 1);
     _playerTwo = new Player('O', 2);
     _checker   = new WinChecker(fields, this);
     StartGame();
 }
Esempio n. 4
0
 public WinCombination(string description, IWinChecker winChecker, int oneCreditPayout,
                       int twoCreditPayout, int threeCreditPayout, int fourCreditPayout, int fiveCreditPayout)
 {
     Description       = description;
     WinChecker        = winChecker;
     OneCreditPayout   = oneCreditPayout;
     TwoCreditPayout   = twoCreditPayout;
     ThreeCreditPayout = threeCreditPayout;
     FourCreditPayout  = fourCreditPayout;
     FiveCreditPayout  = fiveCreditPayout;
 }
Esempio n. 5
0
        /// <summary>
        /// Constructor used for unit testing
        /// </summary>
        /// <param name="board">The board</param>
        /// <param name="renderer">The board renderer</param>
        /// <param name="winChecker">The win checker</param>
        /// <param name="inputprovider">The input provider</param>
        /// <param name="outputProvider">The output provider</param>
        public GameManager(IBoard board, IBoardRenderer renderer, IWinChecker winChecker, IInputProvider inputProvider, IOutputProvider outputProvider)
        {
            // validate the inputs

            this.board          = board;
            this.renderer       = renderer;
            this.winChecker     = winChecker;
            this.inputProvider  = inputProvider;
            this.outputProvider = outputProvider;

            // initialize the players list

            // set the game state to waiting to start
        }
Esempio n. 6
0
        private void Clear()
        {
            if (GameOverChecker != null)
            {
                GameOverChecker.Clear();
                GameOverChecker = null;
            }

            if (WinChecker != null)
            {
                WinChecker.Clear();
                WinChecker = null;
            }

            CellsField.Clear();
            App.Instance.WindowManager.CloseAll();
        }
Esempio n. 7
0
        public void Initialize(IGameOverChecker gameOverChecker, IWinChecker winChecker, Action onPauseButtonClick)
        {
            Clear();

            _pauseButton.onClick.AddListener(() => { onPauseButtonClick(); });

            _gameOverChecker = gameOverChecker;
            _gameOverChecker.OnRemainingValueChanged += OnLoseConditionCounterChange;
            OnLoseConditionCounterChange(_gameOverChecker.RemainingValue);

            _winChecker = winChecker;
            _winChecker.OnTargetsChange += OnTargetsChange;

            foreach (var targetItem in _winChecker.Targets)
            {
                var newTargetItem = Instantiate(_targetItemPrefab, _targetItemsContainer, false);
                newTargetItem.Initialize(targetItem);
                _targetItems.Add(newTargetItem);
            }
        }
Esempio n. 8
0
 public void SetWinner(IWinChecker winChecker)
 {
     _winChecker = winChecker;
 }
Esempio n. 9
0
 public Desk(int size)
 {
     Size = size;
     _deskFieldFactory = new ConsoleDeskFieldGenerator();
     _winChecker       = new SimpleWinChecker();
 }
Esempio n. 10
0
 //Constructor for tests
 public SlotMachine(uint coins, ISlotsRandomizer slotsRandomizer)
 {
     _winChecker      = new WinChecker(this);
     _slotsRandomizer = slotsRandomizer;
     Coins            = coins;
 }
Esempio n. 11
0
 public SlotMachine(uint coins)
 {
     _slotsRandomizer = new SlotsRandomizer();
     _winChecker      = new WinChecker(this);
     Coins            = coins;
 }
 public UltimateTicTacToeCreationService(IWinChecker winChecker)
 {
     this.winChecker = winChecker;
 }
Esempio n. 13
0
 public TicTacToe(IWinChecker winChecker)
 {
     this.winChecker = winChecker;
 }