private void SetDynamicEntities() { DynamicShapes = new List <RigidShape> { Capacity = 50 }; SceneShapes = new ShapesIterator(StaticShapes, DynamicShapes); WavesAmount = levelInfo.WavesAmount; Player = LevelDynamicEntitiesFactory.CreatePlayer(levelInfo.PlayerInfo); Bots = LevelDynamicEntitiesFactory.CreateBots(levelInfo.BotsInfo, levelInfo.BotPatrolPoints); Collectables = LevelDynamicEntitiesFactory.CreateCollectables(levelInfo.CollectableWeaponsInfo); Bullets = new List <Bullet> { Capacity = 700 }; Particles = new List <AbstractParticleUnit> { Capacity = 700 }; Sprites = new List <SpriteContainer> { Capacity = 50 }; VisibilityRegions = new List <Raytracing.VisibilityRegion> { Capacity = 2 }; HookUpSprites(); HookUpCollisions(); }
private void UpdateBots(bool calculateLight) { if (livingBotsAmount == 0 && currentLevel.WavesAmount != 0) { currentLevel.TryOptimize(); LevelDynamicEntitiesFactory.SpawnBots( currentLevel.BotSpawnPoints, player.Position, currentLevel.Bots, currentLevel.Sprites, currentLevel.DynamicShapes, currentLevel.BotPatrolPoints); livingBotsAmount += currentLevel.BotSpawnPoints.Count; currentLevel.WavesAmount--; } var regions = new List <Raytracing.VisibilityRegion>(); if (calculateLight) { regions.Add(new Raytracing.VisibilityRegion(player.Position, currentLevel.RaytracingEdges, 1000)); // TODO find use for it } var paths = new List <List <Vector> > { Capacity = 10 }; var bots = currentLevel.Bots; var particles = currentLevel.Particles; livingBotsAmount = 0; foreach (var bot in bots) { if (bot.IsDead) { continue; } if (player.WasMeleeWeaponRaised && player.MeleeWeapon.IsInRange(bot)) { HandleMeleeHit(bot, particles); } bot.Update( player.Position, player.Velocity, currentLevel.Bullets, currentLevel.Particles, currentLevel.SceneShapes, paths, currentLevel.RaytracingEdges); if (!bot.IsDead) { livingBotsAmount++; } } currentLevel.VisibilityRegions = regions; currentLevel.Paths = paths; }