Exemplo n.º 1
0
        private void onBulletHitEnemy(object sender, EnemyHitEventArgs e)
        {
            ICollidable someEnemy   = e.CollidedEnemy;
            int         pointsToAdd = 0;

            if (someEnemy is MotherShip)
            {
                pointsToAdd = 600;
            }
            else if (someEnemy is Enemy)
            {
                IPlayersManager playersManager = this.Game.Services.GetService(typeof(IPlayersManager)) as IPlayersManager;

                int relativeLevel = (playersManager.CurrentLevel - 1) % 6;

                Enemy enemy = someEnemy as Enemy;
                if (enemy.TintColor == Color.LightPink)
                {
                    pointsToAdd = 220 + (50 * relativeLevel);
                }
                else if (enemy.TintColor == Color.LightBlue)
                {
                    pointsToAdd = 160 + (50 * relativeLevel);
                }
                else
                {
                    pointsToAdd = 90 + (50 * relativeLevel);
                }
            }

            Player.ScoreOfTheGame.AddPoints(pointsToAdd);
        }
Exemplo n.º 2
0
        private void createEnemiesMatrix(GameScreen i_GameScreen, BaseGame i_Game)
        {
            IPlayersManager playersManager = this.Game.Services.GetService(typeof(IPlayersManager)) as IPlayersManager;

            int relativeLevel = (playersManager.CurrentLevel - 1) % 6;

            m_MatrixColSize += relativeLevel;

            this.m_EnemiesMatrix = new Enemy[m_MatrixRowSize, m_MatrixColSize];

            for (int i = 0; i < m_MatrixRowSize; i++)
            {
                for (int j = 0; j < m_MatrixColSize; j++)
                {
                    if (i == 0)
                    {
                        this.m_EnemiesMatrix[i, j] = new Enemy(i_Game, Color.LightPink, i_GameScreen);
                    }
                    else if (i == 1 || i == 2)
                    {
                        this.m_EnemiesMatrix[i, j] = new Enemy(i_Game, Color.LightBlue, i_GameScreen);
                    }
                    else
                    {
                        this.m_EnemiesMatrix[i, j] = new Enemy(i_Game, Color.LightYellow, i_GameScreen);
                    }

                    this.m_EnemiesMatrix[i, j].HitFloor  += this.enemiesHitBottom;
                    this.m_EnemiesMatrix[i, j].EnemyDied += this.enemyDied;
                }
            }
        }
Exemplo n.º 3
0
        private void enemiesHitBottom(object sender, EventArgs e)
        {
            this.m_ReachedBottom = true;
            IPlayersManager playerManager = Game.Services.GetService(typeof(IPlayersManager)) as IPlayersManager;

            playerManager.GameOver();
        }
        public MmApplication(
            IShamanLogger logger,
            IApplicationConfig config,
            ISerializer serializer,
            ISocketFactory socketFactory,
            IMatchMaker matchMaker,
            IRequestSender requestSender,
            ITaskSchedulerFactory taskSchedulerFactory,
            IPacketSender packetSender,
            IShamanMessageSenderFactory messageSenderFactory,
            IMatchMakerServerInfoProvider serverProvider,
            IRoomManager roomManager, IMatchMakingGroupsManager matchMakingGroupManager, IPlayersManager playersManager, IMmMetrics mmMetrics, IProtectionManager protectionManager) : base(logger, config, serializer,
                                                                                                                                                                                            socketFactory, taskSchedulerFactory, requestSender, mmMetrics, protectionManager)
        {
            _packetSender            = packetSender;
            _messageSenderFactory    = messageSenderFactory;
            _serverProvider          = serverProvider;
            _roomManager             = roomManager;
            _matchMakingGroupManager = matchMakingGroupManager;
            _playersManager          = playersManager;
            _matchMaker = matchMaker;
            _id         = Guid.NewGuid();

            Logger?.Debug($"MmApplication constructor called. Id = {_id}");
        }
        public override void Initialize()
        {
            base.Initialize();

            m_PlayerManager             = m_Game.Services.GetService(typeof(IPlayersManager)) as IPlayersManager;
            m_PlayerManager.RestartGame = true;
        }
        public PlayerManagerShould()
        {
            _betCards = new ReadOnlyCollection <IBetCard>(EnumerableGenerator.Generate(5, x => new Mock <IBetCard>().Object));

            _mockgGenericMixStrategy.Setup(x => x.Mix <IBetCard>(It.IsAny <List <IBetCard> >()))
            .Returns(EnumerableGenerator.Generate(10, x => new Mock <IBetCard>().Object));

            _sut = new PlayersManager(_mockPlayers.Object, _mockRacingCardManager.Object, _mockgGenericMixStrategy.Object);
        }
Exemplo n.º 7
0
 public override void Initialize()
 {
     base.Initialize();
     m_LevelCounterTextPosition = new Vector2(m_Game.GraphicsDevice.Viewport.Width / 2, m_Game.GraphicsDevice.Viewport.Height / 2);
     m_PlayersManager           = this.Game.Services.GetService(typeof(IPlayersManager)) as IPlayersManager;
     m_LevelGameText.Text       = "Level " + (m_PlayersManager.CurrentLevel + 1).ToString();
     m_LevelGameText.Position   = new Vector2(m_LevelCounterTextPosition.X - (m_LevelGameText.Width / 2), m_LevelGameText.Height);
     m_Level = m_PlayersManager.CurrentLevel + 1;
 }
Exemplo n.º 8
0
        public void AddToPlayerManager()
        {
            IPlayersManager livesManager = this.m_Game.Services.GetService(typeof(IPlayersManager)) as IPlayersManager;

            if (livesManager != null)
            {
                livesManager.AddObjectToMonitor(this as Player);
            }
        }
Exemplo n.º 9
0
 public override void Initialize()
 {
     base.Initialize();
     initSpaceshipBullets();
     this.m_InputManager = Game.Services.GetService(typeof(IInputManager)) as IInputManager;
     m_PlayerManager     = Game.Services.GetService(typeof(IPlayersManager)) as IPlayersManager;
     this.RotationOrigin = new Vector2(this.Width / 2, this.Height / 2);
     m_UsePremultAlpha   = false;
 }
Exemplo n.º 10
0
 private void enemyDied(object sender, EventArgs e)
 {
     if (this.checkIfWon())
     {
         IPlayersManager playerManager = Game.Services.GetService(typeof(IPlayersManager)) as IPlayersManager;
         playerManager.LevelWon();
     }
     else
     {
         this.m_JumpTimeInterval *= 0.94f;
     }
 }
Exemplo n.º 11
0
 public MatchMakingGroupManager(IShamanLogger logger, ITaskSchedulerFactory taskSchedulerFactory,
                                IPlayersManager playersManager, IShamanMessageSender messageSender, IMmMetrics mmMetrics, IRoomManager roomManager,
                                IRoomPropertiesProvider roomPropertiesProvider, IApplicationConfig config)
 {
     _logger = logger;
     _taskSchedulerFactory   = taskSchedulerFactory;
     _playersManager         = playersManager;
     _messageSender          = messageSender;
     _mmMetrics              = mmMetrics;
     _roomManager            = roomManager;
     _roomPropertiesProvider = roomPropertiesProvider;
     _config = config;
 }
Exemplo n.º 12
0
        public override void Initialize()
        {
            base.Initialize();
            IPlayersManager playersManager = this.Game.Services.GetService(typeof(IPlayersManager)) as IPlayersManager;

            if ((playersManager.CurrentLevel - 1) % 6 == 0)
            {
                this.Velocity = new Vector2(0, 0);
            }
            else
            {
                this.Velocity = new Vector2(40 * (float)Math.Pow(1.06, (playersManager.CurrentLevel - 1) % 6), 0);
            }
        }
Exemplo n.º 13
0
 public GameManagers(IGameManager gameManager, IActivateCardManager activateCardManager, IBarsPlayerManager barsPlayerManager,
                     IBarsEnemyManager barsEnemyManager, IEnemyManager enemyManager, IAlliesManager alliesManager, IPlayersManager playersManager, IDeckManager deckManager,
                     IInventoryManager inventoryManager, ITargetManager targetManager, ITokenRewardManager tokenRewardManager)
 {
     GameManager         = gameManager;
     ActivateCardManager = activateCardManager;
     BarsPlayerManager   = barsPlayerManager;
     BarsEnemyManager    = barsEnemyManager;
     EnemyManager        = enemyManager;
     AlliesManager       = alliesManager;
     PlayersManager      = playersManager;
     DeckManager         = deckManager;
     InventoryManager    = inventoryManager;
     TargetManager       = targetManager;
     TokenRewardManager  = tokenRewardManager;
 }
Exemplo n.º 14
0
        public SpaceshipPlayers(BaseGame i_Game, GameScreen i_BaseScreen) : base(i_Game)
        {
            m_SpaceshipPlayers   = new List <SpaceshipPlayer>();
            m_GameScreen         = i_BaseScreen;
            m_Game               = i_Game;
            this.m_PlayerManager = Game.Services.GetService(typeof(IPlayersManager)) as IPlayersManager;
            m_NumOfPlayers       = 1;
            this.createSpaceshipPlayers(i_BaseScreen, i_Game);
            if (m_Accelerometer == null)
            {
                m_Accelerometer = new Accelerometer();

                m_Accelerometer.CurrentValueChanged += accelSensor_CurrentValueChanged;

                m_Accelerometer.Start();
            }
        }
Exemplo n.º 15
0
        private void initLevelDetails()
        {
            Background       background = new Background(m_Game, this);
            SpaceshipPlayers players    = new SpaceshipPlayers(m_Game, this);

            this.Add(players);
            MotherShip motherShip = new MotherShip(m_Game, this);
            Enemies    enemies    = new Enemies(this, m_Game);

            this.Add(enemies);
            int      numOfBarriers = 4;
            Barriers barriers      = new Barriers(this, m_Game, numOfBarriers);

            this.Add(barriers);
            m_PlayersManager = Game.Services.GetService(typeof(IPlayersManager)) as IPlayersManager;
            m_PlayersManager.GameOverEvent += onGameOver;
            m_PlayersManager.LevelWonEvent += onLevelWon;
        }
Exemplo n.º 16
0
        private void randomShoot(GameTime i_GameTime)
        {
            int             randomEnemiesRowIndex;
            int             randomEnemiesColIndex;
            IPlayersManager playersManager = this.Game.Services.GetService(typeof(IPlayersManager)) as IPlayersManager;

            int relativeLevel = (playersManager.CurrentLevel - 1) % 6;

            do
            {
                randomEnemiesRowIndex = m_EnemiesRandomShoot.Next(0, this.m_EnemiesMatrix.GetLength(0));
                randomEnemiesColIndex = m_EnemiesRandomShoot.Next(0, this.m_EnemiesMatrix.GetLength(1));
            }while (!this.m_EnemiesMatrix[randomEnemiesRowIndex, randomEnemiesColIndex].Visible);
            this.m_ShootTime += (float)i_GameTime.ElapsedGameTime.TotalSeconds;
            if (this.m_ShootTime > (float)m_EnemiesRandomShoot.Next(1, 5) - (relativeLevel * 0.17))
            {
                this.m_ShootTime = 0;
                this.m_EnemiesMatrix[randomEnemiesRowIndex, randomEnemiesColIndex].Shoot();
            }
        }
        public MatchMakingGroup(Dictionary <byte, object> roomProperties,
                                IShamanLogger logger, ITaskSchedulerFactory taskSchedulerFactory, IPlayersManager playersManager,
                                IShamanMessageSender messageSender, IMmMetrics mmMetrics, IRoomManager roomManager)
        {
            Id = Guid.NewGuid();

            _logger             = logger;
            _playersManager     = playersManager;
            _taskScheduler      = taskSchedulerFactory.GetTaskScheduler();
            _matchmakingPlayers = new Queue <MatchMakingPlayer>();
            RoomProperties      = roomProperties;
            _messageSender      = messageSender;
            _mmMetrics          = mmMetrics;
            _roomManager        = roomManager;

            //get properties from dict
            if (!roomProperties.TryGetValue(PropertyCode.RoomProperties.MatchMakingTick, out var tickProperty))
            {
                throw new Exception($"MatchMakingGroup ctr error: there is no MatchMakingTick property");
            }
            if (!roomProperties.TryGetValue(PropertyCode.RoomProperties.TotalPlayersNeeded, out var totalPlayersProperty))
            {
                throw new Exception($"MatchMakingGroup ctr error: there is no TotalPlayersNeeded property");
            }
            if (!roomProperties.TryGetValue(PropertyCode.RoomProperties.MaximumMmTime, out var timeBeforeBotsProperty))
            {
                throw new Exception($"MatchMakingGroup ctr error: there is no MaximumMmTime property");
            }
            if (!roomProperties.TryGetValue(PropertyCode.RoomProperties.MaximumMatchMakingWeight, out var maxMmWeight))
            {
                throw new Exception($"MatchMakingGroup ctr error: there is no MaximumMatchMakingWeight property");
            }

            _matchMakingTickMs  = (int)tickProperty;
            _totalPlayersNeeded = (int)totalPlayersProperty;
            _maximumMmTime      = (int)timeBeforeBotsProperty;
            _maxMmWeight        = (int)maxMmWeight;
        }
        public void Setup()
        {
            _logger = new ConsoleLogger();
            _taskSchedulerFactory = new TaskSchedulerFactory(_logger);
            _playersManager       = new PlayersManager(Mock.Of <IMmMetrics>(), _logger);
            _packetSender         = Mock.Of <IShamanMessageSender>();
            _serverProvider       = new FakeServerProvider();
            _requestSender        = new FakeSender();
            _roomApiProvider      = new DefaultRoomApiProvider(_requestSender, _logger);
            _roomManager          = new RoomManager(_serverProvider, _logger, _taskSchedulerFactory, _roomApiProvider);

            _measures.Add(FakePropertyCodes.PlayerProperties.GameMode, 1);
            _roomProperties.Add(FakePropertyCodes.RoomProperties.MatchMakingTick, 250);
            _roomProperties.Add(FakePropertyCodes.RoomProperties.TotalPlayersNeeded, 3);
            _roomProperties.Add(FakePropertyCodes.RoomProperties.MaximumMmTime, 500);
            _roomProperties.Add(FakePropertyCodes.RoomProperties.MaximumMatchMakingWeight, 1);


            _group = new MatchMakingGroup(_roomProperties, _logger, _taskSchedulerFactory, _playersManager,
                                          _packetSender, Mock.Of <IMmMetrics>(), _roomManager);
            _roomManager.Start(10000);
            _group.Start();
        }
        public void Setup()
        {
            // var config = new MmApplicationConfig("", "127.0.0.1", new List<ushort> {0}, "", 120000, GameProject.DefaultGame,"", 7002, isAuthOn:false);
            var config = new ApplicationConfig
            {
                PublicDomainNameOrAddress = "127.0.0.1",
                ListenPorts = new List <ushort> {
                    0
                },
                IsAuthOn       = false,
                BindToPortHttp = 7002
            };

            _logger = new ConsoleLogger();
            _roomPropertiesProvider = new FakeRoomPropertiesProvider(3, 500, 250, 3);

            _taskSchedulerFactory = new TaskSchedulerFactory(_logger);
            _playersManager       = new PlayersManager(Mock.Of <IMmMetrics>(), _logger);
            _packetSender         = Mock.Of <IShamanMessageSender>();
            _serverProvider       = new FakeServerProvider();
            _requestSender        = new FakeSender();
            _roomApiProvider      = new DefaultRoomApiProvider(_requestSender, _logger);
            _roomManager          = new RoomManager(_serverProvider, _logger, _taskSchedulerFactory, _roomApiProvider);

            _measures.Add(FakePropertyCodes.PlayerProperties.GameMode, 1);

            _playerProperties = new Dictionary <byte, object>
            {
                { FakePropertyCodes.PlayerProperties.GameMode, 1 }
            };

            _matchMakingGroupManager = new MatchMakingGroupManager(_logger, _taskSchedulerFactory, _playersManager,
                                                                   _packetSender, Mock.Of <IMmMetrics>(), _roomManager, _roomPropertiesProvider, config);
            _matchMakingGroupManager.AddMatchMakingGroup(_measures);
            _matchMakingGroupManager.Start(10000);
        }
Exemplo n.º 20
0
 public TotalPlayersController(ILogger <LeageController> logger, IPlayersManager playersManager)
 {
     this.logger         = logger;
     this.playersManager = playersManager;
 }
Exemplo n.º 21
0
 public RequestResolver(IMessageConverter messageConverter, IPlayersManager playersManager, IGameManager gameManager)
 {
     _messageConverter = messageConverter;
     _playersManager   = playersManager;
     _gameManager      = gameManager;
 }
Exemplo n.º 22
0
 public GameManager(IPlayersManager playersManager, IGameProcessor gameProcessor)
 {
     _playersManager = playersManager;
     _gameProcessor  = gameProcessor;
 }
 private void initServices()
 {
     m_PlayersManager = new PlayersManager(this);
     m_PlayersManager.PlayerCollided += playersManager_PlayerCollided;
     m_InputManager = this.Game.Services.GetService(typeof(IInputManager)) as IInputManager;
 }
Exemplo n.º 24
0
    void Start()
   {
       _publisher = new Publisher();

       _saveManager = new SaveManager();
       _animaManager = new AnimaManager();
       _objectLoader = new ObjectLoader();
       _configurateManager = new ConfigurateManager();

       _objectStorage = new ObjectStorage(_objectLoader,_configurateManager);
       _tokenRewardManager = new TokenRewardManager(_publisher, _animaManager, _objectStorage,_configurateManager);
       _audioManager = new AudioManager(_objectStorage, _coroutiner);
       _barsPlayerManager = new BarsPlayerManager(_objectStorage);

       _inventoryManager = new InventoryManager(_objectStorage, _publisher, _coroutiner,_configurateManager);
       
       _gameStageManager = new GameStageManager(_publisher, _coroutiner);
       _gameManager = new GameManager(_publisher, _animaManager, _objectStorage, _coroutiner,_inventoryManager,_configurateManager);
       _enemyManager = new EnemyManager(_publisher, _coroutiner,_animaManager,_objectStorage, _configurateManager);
       _alliesManager = new AlliesManager(_coroutiner, _configurateManager);
       _playersManager = new PlayersManager(_publisher,_animaManager, _tokenRewardManager);
       _barsEnemyManager = new BarsEnemyManager(_enemyManager, _publisher);
       _activateCardManager = new ActivateCardManager(_publisher, _barsPlayerManager,_enemyManager);
       _targetManager = new TargetManager(_publisher, _animaManager, _activateCardManager, _enemyManager);
       _deckManager = new DeckManager(_objectStorage,_inventoryManager,_animaManager,_publisher,_coroutiner, _targetManager,_configurateManager);
       
       _popupEvent = new PopupEvent(_objectStorage,_publisher,_animaManager,_coroutiner, _configurateManager);
       _popupGameMenu = new PopupGameMenu(_objectStorage, _publisher, _animaManager,_coroutiner);
       _popupInventory = new PopupInventory(_inventoryManager, _animaManager);
       _popupPlaceInSlot = new PopupPlaceInSlot(_publisher);
       _popupPlayers = new PopupPlayers(_animaManager, _objectStorage, _publisher, _configurateManager);
       //_descriptionCardPopup = new PopupDescriptionCard(_popupDescriptionCard);
       _popupDescriptionCard = new PopupDescriptionCard(_coroutiner,_animaManager);
       _popupRewardEvent = new PopupRewardEvent(_publisher, _objectStorage, _configurateManager, _coroutiner);
       
       _publisher.AddSubscriber((ISubscriber) _gameManager);
       _publisher.AddSubscriber((ISubscriber) _inventoryManager);
       _publisher.AddSubscriber((ISubscriber) _gameStageManager);
       _publisher.AddSubscriber((ISubscriber) _activateCardManager);
       _publisher.AddSubscriber((ISubscriber) _barsPlayerManager);
       _publisher.AddSubscriber((ISubscriber) _barsEnemyManager);
       _publisher.AddSubscriber((ISubscriber) _enemyManager);
       _publisher.AddSubscriber((ISubscriber) _alliesManager);
       _publisher.AddSubscriber((ISubscriber) _playersManager);
       _publisher.AddSubscriber((ISubscriber) _deckManager);
       _publisher.AddSubscriber((ISubscriber) _targetManager);
       _publisher.AddSubscriber((ISubscriber) _audioManager);
       _publisher.AddSubscriber((ISubscriber) _tokenRewardManager);
       
       _publisher.AddSubscriber((ISubscriber) _popupGameMenu);
       _publisher.AddSubscriber((ISubscriber) _popupInventory);
       _publisher.AddSubscriber((ISubscriber) _popupEvent);
       _publisher.AddSubscriber((ISubscriber) _popupPlayers);
       _publisher.AddSubscriber((ISubscriber) _popupDescriptionCard);
       _publisher.AddSubscriber((ISubscriber) _popupRewardEvent);
       _publisher.AddSubscriber((ISubscriber) _popupPlaceInSlot);
       
       _baseManagers = new BaseManagers(_saveManager,_animaManager,_publisher,_objectStorage,_configurateManager,_coroutiner, _audioManager);
       _gameManagers = new GameManagers(_gameManager, _activateCardManager, _barsPlayerManager, _barsEnemyManager, 
           _enemyManager, _alliesManager,  _playersManager, _deckManager, _inventoryManager, _targetManager, _tokenRewardManager);
       _popupManagers = new PopupManagers(_popupGameMenu,_popupInventory, _popupEvent, _popupPlayers, _popupDescriptionCard,_popupPlaceInSlot, _popupRewardEvent);
       
       
       _logicManager = new LogicManager(_baseManagers,_gameManagers, _popupManagers);
       _loadManager = new LoadManager(_logicManager);
       //-------------------Делаем переход в сцену "Меню"
       _loadManager.Navigate(SceneTypeEnum.Bootstrapper, SceneTypeEnum.Menu, CustomObject.Empty);
   }
Exemplo n.º 25
0
 public GameManager(IGridManager gridManager, IPlayersManager playersManager)
 {
     _gridManager    = gridManager;
     _playersManager = playersManager;
 }
 public MemoryGameHub(IMemoryGameManager memoryGameManager, IPlayersManager playersManager)
 {
     _memoryGameManager = memoryGameManager;
     _playersManager    = playersManager;
 }
 public StatisticsProvider(IPlayersManager playersManager)
 {
     _playersManager = playersManager;
 }
 public void Setup()
 {
     _logger         = new ConsoleLogger();
     _playersManager = new PlayersManager(Mock.Of <IMmMetrics>(), _logger);
 }
Exemplo n.º 29
0
        //hashcodes lists
        //private Dictionary<Guid, int> _hashCodeSets = new Dictionary<Guid, int>();

        public MatchMaker(IPlayersManager playersManager, IMatchMakingGroupsManager groupManager)
        {
            _playersManager = playersManager;
            _groupManager   = groupManager;
            _requiredMatchMakingProperties = new List <byte>();
        }