public PlayersFactory(RenderTarget RenderTarget2D, GameInterface GameInterface, Character mainPlayer) : base(RenderTarget2D, GameInterface) { _mainPlayer = mainPlayer; _players = new List <Character>(); // Подпишем игрока на наведение мыши _mainPlayer.eventMouseOver += _playerEventMouseOver; }
protected override void Initialize(DemoConfiguration demoConfiguration) { base.Initialize(demoConfiguration); _infoGamePanel = Helpers.LoadFromFile(RenderTarget2D, "gameInfo.png"); GameInterface = new GameInterface(RenderTarget2D, RESOLUTION, FactoryDWrite); BuildingsFactory = new BuildingsFactory(RenderTarget2D, GameInterface); _myCharacter = new Character(RenderTarget2D, BuildingsFactory, "Серафим"); PlayersFactory = new PlayersFactory(RenderTarget2D, GameInterface, _myCharacter); MobsFactory = new MobsFactory(RenderTarget2D, GameInterface); GameStats = new GameStats(PlayersFactory, BuildingsFactory, null); GameStats.Money = 100; GameStats.Woods = 100; _myCharacter.eventCreateTower += (CommonTower tower) => { GameStats.Money -= (int)tower.Id; GameStats.Woods -= (int)tower.Id; }; GameInterface.SetGameStats(GameStats); _timeLastDraw = 0; _timeLastUpdate = 0; gameState = new GameState(); mainMenu = new MainMenu(RenderTarget2D, RESOLUTION); SoundsManager.init(); AudioPlayer sound = new AudioPlayer("goobye.mp3"); sound.Volume = 0.04f; sound.Play(); Connector.ConnectWithServer(); }
// Событие наведение мыши на игрока private void _playerEventMouseOver(Character player) { GameInterface.InfoHero(player); }