protected override void Process(UpdateContext updateContext, ReadOnlyBag<Entity> entities)
        {
            if (!_playerInfo.IsAlive)
            {
                return;
            }

            float range = _playerInfo.IsInvulnerable ? 12 : 6;
            IZombieSpatialMap zombieSpatialMap = this.EntityWorld.Services.Get<IZombieSpatialMap>();
            foreach (Entity zombie in zombieSpatialMap.GetAllIntersecting(_player.Transform, range))
            {
                CZombieInfo zombieInfo = zombie.Get<CZombieInfo>();
                if (!_playerInfo.IsInvulnerable)
                {
                    if (!ZombieAttackSystem.CanAttack(zombieInfo.Type))
                    {
                        continue;
                    }

                    _playerInfo.KillPlayer();
                    return;
                }

                // player is invulnerable
                ZombieHelper.Kill(zombie, Vector2.Zero);
            }
        }
示例#2
0
        public override bool OnBulletHitCallback(UpdateContext updateContext, CBullet bullet, Entity entityHit)
        {
            EntityWorld entityWorld = bullet.Entity.EntityWorld;
            IZombieSpatialMap zombieSpatialMap = entityWorld.Services.Get<IZombieSpatialMap>();

            // if the message has not listeners, then there's no point in doing in broadcasting it.
            RocketExplodedMessage explodedMessage = entityWorld.HasListeners<RocketExplodedMessage>() ? entityWorld.FetchMessage<RocketExplodedMessage>() : null; // AAWFFUUULL!!
            foreach (Entity zombie in zombieSpatialMap.GetAllIntersecting(bullet.Entity.Transform, RocketLauncher.ExplosionRange))
            {
                if (zombie.Get<CHealth>().IsAlive && ZombieHelper.TakeDamage(zombie, 25, Vector2.Zero))
                {
                    // if the message has not listeners, then there's no point in doing in broadcasting it.
                    if (explodedMessage != null)
                    {
                        explodedMessage.Add(zombie);
                    }
                }
            }

            // if the message has not listeners, then there's no point in doing in broadcasting it.
            if (explodedMessage != null)
            {
                entityWorld.BroadcastMessage(explodedMessage);
            }

            IParticleEngine particleEngine = entityWorld.Services.Get<IParticleEngine>();
            particleEngine[ParticleEffectID.RocketExplosion].Trigger(bullet.Entity.Transform);

            bullet.Entity.Delete();
            return true;
        }
示例#3
0
 protected override void ShootInner(UpdateContext updateContext, EntityWorld entityWorld, Entity playerEntity)
 {
     const float AngleOffset = 0.125f;
     entityWorld.CreateEntityFromPrefab<BouncerBulletPrefab>(playerEntity.Transform, this, -AngleOffset);
     entityWorld.CreateEntityFromPrefab<BouncerBulletPrefab>(playerEntity.Transform, this, AngleOffset);
     this.DecreaseBulletCount();
 }
示例#4
0
 protected override void Update(UpdateContext updateContext, bool otherScreenHasFocus, bool coveredByOtherScreen)
 {
     if (updateContext.InputState.IsNewKeyPress(Keys.Space))
     {
         this.ExitScreen();
     }
 }
示例#5
0
        public override void Shoot(UpdateContext updateContext, EntityWorld entityWorld, Entity playerEntity)
        {
            float boosterAttackSpeedMultiplier = BoosterHelper.GetPlayerAttackSpeedMultiplier(entityWorld.Services.Get<IBoosterState>());
            float passiveAttackSpeedMultiplier = entityWorld.Services.Get<IPlayerPassiveStats>().FireRateMultiplier;
            float attackSpeedMultiplier = boosterAttackSpeedMultiplier * passiveAttackSpeedMultiplier;

            if (this.CanShoot)
            {
                _ammoRemaining -= updateContext.DeltaSeconds * attackSpeedMultiplier * Laser.AmmoUsedPerSecond;
                if (_ammoRemaining < 0)
                {
                    _ammoRemaining = 0;
                }

                this.LaserSegment = this.GetLaserSegment(playerEntity.Transform, entityWorld);
                IZombieSpatialMap zombieSpatialMap = entityWorld.Services.Get<IZombieSpatialMap>();
                foreach (Entity zombie in zombieSpatialMap.GetAllIntersecting(this.LaserSegment, Laser.MaxHitDistance))
                {
                    if (zombie.Get<CHealth>().IsAlive && ZombieHelper.TakeDamage(zombie, Laser.DamagePerSecond * attackSpeedMultiplier * updateContext.DeltaSeconds, null))
                    {
                        ZombieHelper.TriggerBloodExplosion(zombie.Transform, this.LaserSegment.Direction * SkypieaConstants.PixelsPerMeter * 10f);
                    }
                }

                this.IsShooting = true;
            }
            else
            {
                this.IsShooting = false;
            }
        }
        public override void Control(UpdateContext updateContext)
        {
            // Check if the mouse is inside the world
            Vector2 mousePosition = _player.Camera.ScreenToWorld(FlaiGame.Current.GraphicsDevice, updateContext.InputState.MousePosition);
            if (mousePosition.X >= 0 && mousePosition.Y >= 0 &&
                mousePosition.X < _world.Map.Width * Tile.Size && mousePosition.Y < _world.Map.Height * Tile.Size)
            {
                _player.MouseIndex = Tile.WorldToTileCoordinate(mousePosition);
            }
            else
            {
                _player.MouseIndex = null;
            }
            
            this.HandleMovement(updateContext);
            this.HandleZooming(updateContext);

            if (_player.EditorMode == EditorMode.Normal)
            {
                // Lets put this here just to be safe, not sure if necessary
                _isResizing = false;

                this.HandleChangeTile(updateContext);
                this.HandleAddTile(updateContext);
            }
            else if (_player.EditorMode == EditorMode.Resizing)
            {
                this.HandleResizeMap(updateContext);
            }
        }
示例#7
0
 protected override void UpdateInner(UpdateContext updateContext)
 {
     _playerRenderer.Update(updateContext);
     _worldRenderer.Update(updateContext);
     _gameClockRenderer.Update(updateContext);
     _starFieldRenderer.Update(updateContext);
 }
示例#8
0
 public override sealed void Shoot(UpdateContext updateContext, EntityWorld entityWorld, Entity playerEntity)
 {
     if (this.CanShoot && !this.IsFinished)
     {
         this.ShootInner(updateContext, entityWorld, playerEntity);
         _bulletTimer.Restart();
     }
 }
 protected override void UpdateInner(UpdateContext updateContext)
 {
     _achievementShowTimer.Update(updateContext);
     if (_currentAchievement != null && _achievementShowTimer.HasFinished)
     {
         _currentAchievement = null;
     }
 }
 public override void Update(UpdateContext updateContext)
 {
     if (!_achievement.IsUnlocked)
     {
         _progression.Current = FlaiMath.Min(_progression.Max, _progression.Current + Vector2.Distance(_previousPosition, _playerTransform.Position) / SkypieaConstants.PixelsPerMeter * SkypieaConstants.MeterMultiplier);
         _previousPosition = _playerTransform.Position;
     }
 }
 protected override void Update(UpdateContext updateContext)
 {
     if (!_hasGameEnded)
     {
         _movementThumbstick.Update(updateContext);
         _rotationThumbstick.Update(updateContext);
     }
 }
示例#12
0
        public override sealed void Update(UpdateContext updateContext, EntityWorld entityWorld)
        {
            float boosterAttackSpeedMultiplier = BoosterHelper.GetPlayerAttackSpeedMultiplier(entityWorld.Services.Get<IBoosterState>());
            float passiveAttackSpeedMultiplier = entityWorld.Services.Get<IPlayerPassiveStats>().FireRateMultiplier;
            _bulletTimer.Update(updateContext.DeltaSeconds * boosterAttackSpeedMultiplier * passiveAttackSpeedMultiplier);

            this.UpdateInner(updateContext);
        }
示例#13
0
 private void HandleJumping(UpdateContext updateContext)
 {
     // TODO: Pre/Late jumping?
     if (updateContext.InputState.IsNewKeyPress(Keys.Space))
     {
         _player.Jump();
     }
 }
示例#14
0
 public override void Control(UpdateContext updateContext)
 {
     if (_player.IsAlive)
     {
         this.HandleMovement(updateContext);
         this.HandleJumping(updateContext);
     }
 }
示例#15
0
 public void Update(UpdateContext updateContext)
 {
     _timeRemaining -= updateContext.DeltaSeconds;
     if (_timeRemaining < 0)
     {
         _timeRemaining = 0;
     }
 }
示例#16
0
        public override bool OnBulletHitCallback(UpdateContext updateContext, CBullet bullet, Entity entityHit)
        {
            if (entityHit.Get<CHealth>().IsAlive && ZombieHelper.TakeDamage(entityHit, updateContext.DeltaSeconds * 10f, null))
            {
                ZombieHelper.TriggerBloodExplosion(entityHit.Transform, Vector2.Zero);
            }

            return false;
        }
示例#17
0
 protected override void UpdateInner(UpdateContext updateContext)
 {
     _mapRenderer.Update(updateContext);
     _timeBonusRenderer.Update(updateContext);
     _springRenderer.Update(updateContext);
     _keyRenderer.Update(updateContext);
     _cannonRenderer.Update(updateContext);
     _doorRenderer.Update(updateContext);
     _portalRenderer.Update(updateContext);
 }
示例#18
0
 protected override void Update(UpdateContext updateContext, bool otherScreenHasFocus, bool coveredByOtherScreen)
 {
     if (this.IsActive)
     {
         if (updateContext.InputState.IsNewKeyPress(Keys.Escape) || updateContext.InputState.IsNewKeyPress(Keys.Space))
         {
             LoadingScreen.Load(base.ScreenManager, false, new LevelSelectScreen(_levelPath));
         }
     }
 }
        protected override void Process(UpdateContext updateContext, Entity player)
        {
            if (!_playerInfo.IsAlive)
            {
                return;
            }

            this.Move(updateContext, player);
            this.Rotate(updateContext, player);
        }
示例#20
0
        public void Update(UpdateContext updateContext)
        {
            _world.Update(updateContext);
            _player.Update(updateContext);

            if (_player.IsAlive)
            {
                _gameClock.Update(updateContext);
            }
        }
        protected override void Process(UpdateContext updateContext, Entity player)
        {
            if (_weapon.Weapon.AmmoRemaining == 0)
            {
                WeaponChangedMessage message = this.EntityWorld.FetchMessage<WeaponChangedMessage>();
                message.Initialize(_weapon.Weapon, WeaponFactory.CreateDefaultWeapon());
                _weapon.Weapon = message.NewWeapon;

                this.EntityWorld.BroadcastMessage(message);
            }
        }
示例#22
0
        public override void Update(UpdateContext updateContext)
        {
            if (_achievement.IsUnlocked)
            {
                return;
            }

            if (_playerInfo.Score >= _scoreTarget)
            {
                _achievement.Progression.Cast<BooleanProgression>().Unlock();
            }
        }
示例#23
0
 public void Update(UpdateContext updateContext)
 {
     if (_remainingTime > 0)
     {
         _remainingTime -= updateContext.DeltaSeconds;
         if (_remainingTime < 0)
         {
             _remainingTime = 0;
             this.TimeOver.InvokeIfNotNull();
         }
     }
 }
示例#24
0
        protected override void Update(UpdateContext updateContext, bool otherScreenHasFocus, bool coveredByOtherScreen)
        {
            if (this.IsActive)
            {
                if (updateContext.InputState.IsBackButtonPressed)
                {
                    this.OnExitClicked();
                }

                _uiContainer.Update(updateContext);
            }
        }
示例#25
0
        protected override void ShootInner(UpdateContext updateContext, EntityWorld entityWorld, Entity playerEntity)
        {
            const int Bullets = 6;
            const float SpreadAngle = 0.3f;
            for (int i = 0; i < Bullets; i++)
            {
                float angle = -SpreadAngle / 2f + i / (float)Bullets * SpreadAngle;
                entityWorld.CreateEntityFromPrefab<NormalBulletPrefab>(playerEntity.Transform, this, angle);
            }

            this.DecreaseBulletCount();
        }
        protected override void Process(UpdateContext updateContext, ReadOnlyBag<Entity> entities)
        {
            float speedMultiplier = BoosterHelper.GetZombieSpeedMultiplier(_boosterState) * _zombieStatsProvider.SpeedMultiplier;

            for (int i = 0; i < entities.Count; i++)
            {
                Entity zombie = entities[i];
                CGoldenGoblinAI goldenGoblinAI = zombie.Get<CGoldenGoblinAI>();

                this.UpdateGoblin(updateContext, zombie, speedMultiplier);
            }
        }
        public override void Update(UpdateContext updateContext)
        {
            if (!_achievement.IsUnlocked)
            {
                return;
            }

            if (_currentKills > 0 && !_boosterState.IsActive<PlayerInvulnerabilityBooster>())
            {
                _currentKills = 0;
            }
        }
        protected override void Update(UpdateContext updateContext)
        {
            // for now, black boxes can drop only from goblins
            return;

            _spawnTimer.Update(updateContext);
            if (_spawnTimer.HasFinished)
            {
                _spawnTimer.Restart();
                this.SpawnBlackBox();
            }
        }
示例#29
0
        protected override void ShootInner(UpdateContext updateContext, EntityWorld entityWorld, Entity playerEntity)
        {
            entityWorld.CreateEntityFromPrefab<FlamethrowerBulletPrefab>(playerEntity.Transform, this);
            entityWorld.CreateEntityFromPrefab<FlamethrowerBulletPrefab>(playerEntity.Transform, this);

            _bulletCounter += 0.33333f;
            if (_bulletCounter > 1)
            {
                _bulletCounter -= 1;
                this.DecreaseBulletCount();
            }
        }
        public override void Update(UpdateContext updateContext)
        {
            if (_achievement.IsUnlocked)
            {
                return;
            }

            if (_playerInfo.LivesRemaining >= _lives)
            {
                _achievement.Progression.Cast<BooleanProgression>().Unlock();
            }
        }