示例#1
0
        public Player(IContentManager contentManager, IViewport viewport, IAnimationFactory animationFactory, ISpriteBatch spriteBatch,
                      IPlayerConfiguration configuration)
            : base(spriteBatch)
        {
            _configuration = configuration;
            _viewport      = viewport.Viewport;
            _animation     = animationFactory.Build(
                contentManager.Load(@"Graphics\shipAnimation"),
                115, 30, 8);

            Position = new Vector2(_viewport.TitleSafeArea.X + 100, _viewport.TitleSafeArea.Y + _viewport.TitleSafeArea.Height / 2);

            BeforeDraw   += time => _animation.Update(time);
            BeforeUpdate += state =>
            {
                if (_health <= 0)
                {
                    _active = false;
                }
                UpdateVelocity(state);
            };

            _boundaries = new[]
            {
                new Rectangle(-100, 0, 100 + _configuration.LeftBoundary, _viewport.Height),
                new Rectangle(_viewport.Width - _configuration.RightBoundary, 0, 100, _viewport.Height),
                new Rectangle(0, -100, _viewport.Width, 100 + _configuration.TopBoundary),
                new Rectangle(0, _viewport.Height - _configuration.BottomBoundary, _viewport.Width, 100),
            };
        }
示例#2
0
        private void Construct(SignalBus signalBus, IPlayerConfiguration playerConfiguration)
        {
            this.signalBus           = signalBus;
            this.playerConfiguration = playerConfiguration;

            livesRemaining = playerConfiguration.LivesTotal;

            AddShootingComponent();

            signalBus.Subscribe <ShotAttemptSignal>(OnShotAttempt);
            signalBus.Subscribe <PlayerMovedSignal>(OnPlayerMoved);
        }
示例#3
0
        private void Construct(SignalBus signalBus,
                               IPlayerConfiguration playerConfiguration,
                               IHighScoresKeeper highScoresKeeper,
                               IWavesCounter wavesCounter)
        {
            this.signalBus   = signalBus;
            playerLives.text = playerConfiguration.LivesTotal.ToString();
            highScore.text   = highScoresKeeper.GetCurrenHighScore().ToString();
            waveNumber.text  = wavesCounter.GetCurrentWaveNumber().ToString();

            signalBus.Subscribe <PlayerLivesAmountChangedSignal>(OnPlayerLivesChanged);
            signalBus.Subscribe <PlayerScoreChangedSignal>(OnPlayerScoreChanged);
            signalBus.Subscribe <WaveSpawnedSignal>(OnWaveSpawned);
        }
 public PlayerBuilder WithPlayerConfiguration(IPlayerConfiguration playerConfiguration)
 {
     _playerConfiguration = playerConfiguration;
     return(this);
 }
示例#5
0
 public bool InitializeFromPlayer(IPlayerConfiguration configuration)
 {
     _configuration = configuration;
     _showNotifier = new ShowNotifier(_configuration);
     _showNotifier.OnPreparationFinished += _showNotifier_OnPreparationFinished;
     _showNotifier.OnProgressChanged += _showNotifier_OnProgressChanged;
     _showNotifier.OnReceiveAgentResourcesList += _showNotifier_OnReceiveAgentResourcesList;
     _showNotifier.OnUploadSpeed +=new Action<double,string, string>(_showNotifier_OnUploadSpeed);
     _showNotifier.OnPreparationForDisplayEnded += new Action<string, bool>(_showNotifier_OnPreparationForDisplayEnded);
     _showNotifier.OnEquipmentStateChanged += _showNotifier_OnEquipmentStateChanged;
     _showNotifier.OnNotEnoughSpace += _showNotifier_OnNotEnoughSpace;
     _showNotifier.OnLogMessage += new Action<string>(_showNotifier_OnLogMessage);
     _showNotifier.OnExternalSystemCommand += _showNotifier_OnExternalSystemCommand;
     _svc = new DuplexClient<IShowCommon>(new InstanceContext(_showNotifier), configuration.PingInterval);
     try
     {
         _svc.Open();
     }
     catch (Exception /*ex*/)
     {
         _svc.Dispose();
         _svc = null;
         return false;
     }
     return true;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="PlayerConfigurationViewModel"/> class.
        /// </summary>
        public PlayerConfigurationViewModel(IPlayerConfiguration playerConfiguration)
        {
            Argument.IsNotNull(() => playerConfiguration);

            Configuration = playerConfiguration;
        }