/// <summary> /// Initializes a new instance of the <see cref="T:MyGame.CollisionCheckSystem"/> class. /// </summary> /// <param name="world">The World the System belongs to.</param> public CollisionCheckSystem(World world) : base(new List <Type> { }, new List <Type> { typeof(CExcludeAll) }, world) { /// <summary> /// Initialise Entity Holder Systems and add them to the World. /// </summary> _playerEnts = new EntityHolderSystem(new List <Type> { typeof(CPlayerTeam), typeof(CCollidable) }, new List <Type> { }, world); _enemyEnts = new EntityHolderSystem(new List <Type> { typeof(CEnemyTeam), typeof(CCollidable) }, new List <Type> { }, world); world.AddSystem(_playerEnts); world.AddSystem(_enemyEnts); /// <summary> /// Generate Spatial Hash cell details and initialise cells. /// </summary> /// <value>The player cells.</value> _cols = (int)Math.Floor((double)SwinGame.ScreenWidth() / _cellSize); _rows = (int)Math.Floor((double)SwinGame.ScreenHeight() / _cellSize); _numCells = _cols * _rows; for (int i = 0; i < _numCells; i++) { _playerCells.Add(i, new List <ulong>()); _enemyCells.Add(i, new List <ulong>()); } }
/// <summary> /// Initializes a new instance of the <see cref="T:MyGame.PlayerAISystem"/> class. /// </summary> /// <param name="world">The World the System belongs to.</param> public PlayerAISystem(World world) : base(world) { /// <summary> /// The Player AI System's Component Masks are: /// Include - CAI, CPlayerTeam /// Exclude - CENemyTeam /// </summary> /// <param name="entID">Ent identifier.</param> Include.Remove(typeof(CEnemyTeam)); Include.Add(typeof(CPlayerTeam)); _enemies = new EntityHolderSystem(new List <Type> { typeof(CEnemyTeam), typeof(CHealth) }, new List <Type> { }, world); World.AddSystem(_enemies); }
public static void Main() { //Open the game window SwinGame.OpenGraphicsWindow("GameMain", 1200, 600); SwinGame.LoadResourceBundleNamed("GameResources", "GameResources.txt", false); World world = new World(); #region MISC SYSTEMS world.AddSystem(new InputSystem(world)); world.AddSystem(new PlayerSystem(world)); world.AddSystem(new SpawningSystem(world)); world.AddSystem(new LootSystem(world)); world.AddSystem(new MovementSystem(world)); world.AddSystem(new LifetimeSystem(world)); #endregion MISC SYSTEMS #region AI SYSTEMS world.AddSystem(new PlayerAISystem(world)); world.AddSystem(new EnemyAISystem(world)); #endregion AI SYSTEMS #region PROJECTILE SYSTEMS world.AddSystem(new ProjectileSystem(world)); world.AddSystem(new FreezingBulletSystem(world)); #endregion PROJECTILE SYSTEMS #region COLLISION SYSTEMS world.AddSystem(new CollisionCheckSystem(world)); world.AddSystem(new FreezeZoneCollisionHandlerSystem(world)); world.AddSystem(new PoisonZoneCollisionHandlerSystem(world)); world.AddSystem(new DamageCollisionHandlerSystem(world)); #endregion COLLISION SYSTEMS #region STATUS EFFECT SYSTEMS world.AddSystem(new FrozenSystem(world)); world.AddSystem(new PoisonedSystem(world)); world.AddSystem(new GotStatusEffectSystem(world)); #endregion STATUS EFFECT SYSTEMS world.AddSystem(new DamageSystem(world)); world.AddSystem(new ExplosionManSystem(world)); #region RENDERING SYSTEMS world.AddSystem(new HealthRenderingSystem(world)); world.AddSystem(new AnimationRenderingSystem(world)); world.AddSystem(new RenderingSystem(world)); world.AddSystem(new PlayerRenderingSystem(world)); world.AddSystem(new StatusAnimationRenderingSystem(world)); #endregion RENDERING SYSTEMS world.AddSystem(new CollisionCleanupSystem(world)); EntityFactory.World = world; EntityFactory.CreatePlayer(); //Run the game loop while (false == SwinGame.WindowCloseRequested() && SwinGame.KeyTyped(KeyCode.EscapeKey) == false) { //Fetch the next batch of UI interaction SwinGame.ProcessEvents(); //Clear the screen and draw the framerate SwinGame.ClearScreen(Color.SandyBrown); SwinGame.DrawFramerate(200, 570); world.Process(); SwinGame.RefreshScreen(60); } }