Example #1
0
        public void ReloadAllPlayers()
        {
            _playerDrawables.Clear();

            foreach (var playerDataKeyVal in GameData.GetPlayers())
            {
                var playerId       = playerDataKeyVal.Key;
                var playerData     = playerDataKeyVal.Value;
                var playerDrawable = new PlayerDrawable(playerData.Color);
                _playerDrawables.Add(playerId, playerDrawable);

                var playerAnimator = new PlayerAnimator(playerDrawable);
                _playerAnimators.Add(playerDrawable, playerAnimator);

                var concretePlace = (ConcretePlace)playerData.Place.GetPlaceId();
                _playerConcretePlaces[playerId] = concretePlace;
            }

            var distinctConcretePlaces = _playerConcretePlaces.Values.Distinct().ToList();

            foreach (var concretePlace in distinctConcretePlaces)
            {
                var playerIds       = _playerConcretePlaces.Where(x => x.Value == concretePlace).Select(x => x.Key).ToList();
                var playerDrawables = _playerDrawables.Where(x => playerIds.Contains(x.Key)).Select(x => x.Value).ToList();
                var playerAnimators = _playerAnimators.Where(x => playerDrawables.Contains(x.Key)).Select(x => x.Value).ToList();

                var leftCornerPoint = PlacesPositions.GetPlayerPosition(concretePlace);
                PlayerPositionSetterHelper.SetPlayersPositions(playerAnimators, leftCornerPoint);
            }

            _debugInfoDrawable.UpdateCurrentPlayerId(GameData.GetCurrentPlayerId());

            _view.AddDrawables(_playerDrawables.Values);
        }
Example #2
0
        public void PlayerPassedPlace(int playerId, int placeId)
        {
            var player        = GameData.GetPlayerById(playerId);
            var concretePlace = (ConcretePlace)placeId;

            _playerConcretePlaces[playerId] = concretePlace;


            /*var playerDrawable = _playerDrawables[playerId];
             * var playerAnimator = _playerAnimators[playerDrawable];
             * var placePosition = PlacesPositions.GetPlayerPosition(concretePlace);
             *
             * playerAnimator.MoveTo(placePosition.X + 25, placePosition.Y + 25);*/

            // TODO: animace skakani figurky



            var playerIds       = _playerConcretePlaces.Where(x => x.Value == concretePlace).Select(x => x.Key).ToList();
            var playerDrawables = _playerDrawables.Where(x => playerIds.Contains(x.Key)).Select(x => x.Value).ToList();
            var playerAnimators = _playerAnimators.Where(x => playerDrawables.Contains(x.Key)).Select(x => x.Value).ToList();

            var leftCornerPoint = PlacesPositions.GetPlayerPosition(concretePlace);

            PlayerPositionSetterHelper.SetPlayersPositions(playerAnimators, leftCornerPoint);

            //_playerConcretePlaces[playerId] = concretePlace;

            /*var playerIds = _playerConcretePlaces.Where(x => x.Value == concretePlace).Select(x => x.Key).ToList();
             * var playerDrawables = _playerDrawables.Where(x => playerIds.Contains(x.Key)).Select(x => x.Value).ToList();
             *
             * PlayerPositionSetterHelper.SetPlayersPositions(playerDrawables, leftCornerPoint);*/
        }