/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { GameEntityFactory.GraphicsDevice = GraphicsDevice; frameCounterSystem = new FrameCounterSystem(true, this.Window); modelRenderSystem = new ModelRenderSystem(); modelRenderSystem.graphicsDevice = GraphicsDevice; playerInputSystem = new PlayerInputSystem(); cameraSystem = new CameraSystem(); uiSystem = new UIRenderSystem(); collisionHandlingSystem = new CollisionHandlingSystem(); aiSystem = new AiSystem(); collisionDetectionSystem = new CollisionDetectionSystem(false); frictionSystem = new FrictionSystem(); gravitySystem = new GravitySystem(); transformSystem = new TransformSystem(); SystemManager.Instance.AddToUpdateables( cameraSystem, collisionDetectionSystem, transformSystem, gravitySystem, frictionSystem, playerInputSystem, collisionHandlingSystem, aiSystem, frameCounterSystem ); SystemManager.Instance.AddToDrawables(modelRenderSystem, frameCounterSystem, uiSystem); base.Initialize(); }
//When a collision occurs, this becomes whatever it collided with //public List<Entity> collidedWith { get; set; } public PositionComponent(float x, float y, float w, float h, Entity myEntity) { componentName = GlobalVars.POSITION_COMPONENT_NAME; this.prevX = x; this.prevY = y; this.x = x; this.y = y; startingX = x; startingY = y; this.prevW = w; this.prevH = h; this.width = w; this.height = h; this.startingWidth = w; this.startingHeight = h; this.myEntity = myEntity; if (this.myEntity.level.sysManager != null && this.myEntity.level.sysManager.colSystem != null) { colSys = this.myEntity.level.sysManager.colSystem; } else { colSys = null; } //collidedWith = new List<Entity>(); positionHasChanged = false; }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { CollisionDetectionSystem det = new CollisionDetectionSystem(); CollisionSystem col = new CollisionSystem(); det.Subscribe(col); SystemManager.Instance.AddSystem(new ScrollingBackgroundSystem(instance.GraphicsDevice, instance.GetContent <Texture2D>("Pic/gamebackground"))); SystemManager.Instance.AddSystem(new ChangeCubesSystem()); SystemManager.Instance.AddSystem(col); SystemManager.Instance.AddSystem(new HUDSystem()); HealthSystem healtSystem = new HealthSystem(); healtSystem.initialize(); SystemManager.Instance.AddSystem(healtSystem); SystemManager.Instance.AddSystem(det); SystemManager.Instance.AddSystem(new MovementSystem()); SystemManager.Instance.AddSystem(new BallOfSpikesSystem()); SystemManager.Instance.AddSystem(new SpawnPowerUpSystem(10)); SystemManager.Instance.AddSystem(new AISystem()); SystemManager.Instance.AddSystem(new DrawTTLSystem("Fonts/TestFont")); FPSCounterComponent fps = new FPSCounterComponent(); int ids = ComponentManager.Instance.CreateID(); ComponentManager.Instance.AddComponentToEntity(ids, fps); StartUpScreenScene stateOne = new StartUpScreenScene(10000); SceneSystem.Instance.setCurrentScene(stateOne); base.Initialize(); }
// Create all systems public void initializeSystems() { gravSystem = new GravitySystem(level); systems.Add(gravSystem); moveSystem = new MovementSystem(level); systems.Add(moveSystem); playerSystem = new PlayerMovementSystem(level); systems.Add(playerSystem); visSystem = new VisionOrbSystem(level); systems.Add(visSystem); colSystem = new CollisionDetectionSystem(level); systems.Add(colSystem); drawSystem = new DrawSystem(level.g, level); systems.Add(drawSystem); healthSystem = new HealthSystem(level); systems.Add(healthSystem); animSystem = new AnimationSystem(level); systems.Add(animSystem); timerSystem = new TimerSystem(level); systems.Add(timerSystem); timedShooterSystem = new TimedShooterSystem(level); systems.Add(timedShooterSystem); squishSystem = new SquishSystem(level); systems.Add(squishSystem); inputSystem = new InputSystem(level); systems.Add(inputSystem); scrEdgeSystem = new ScreenEdgeSystem(level); systems.Add(scrEdgeSystem); slSystem = new SwitchListenerSystem(level); systems.Add(slSystem); switchSystem = new SwitchSystem(level); systems.Add(switchSystem); spSystem = new SimplePowerUpSystem(level); systems.Add(spSystem); simpEnemySystem = new SimpleEnemyAISystem(level); systems.Add(simpEnemySystem); weapSystem = new PlayerWeaponSystem(level); systems.Add(weapSystem); bkgPosSystem = new BackgroundPositionSystem(level); systems.Add(bkgPosSystem); debugSystem = new DebugSystem(level); systems.Add(debugSystem); movPlatSystem = new MovingPlatformSystem(level); systems.Add(movPlatSystem); grapSystem = new GrappleSystem(level); systems.Add(grapSystem); pushSystem = new PushableSystem(level); systems.Add(pushSystem); velZeroSystem = new VelToZeroSystem(level); systems.Add(velZeroSystem); smushSystem = new SmushSystem(level); systems.Add(smushSystem); signSystem = new SignSystem(level); systems.Add(signSystem); }
// Create all systems public void initializeSystems() { moveSystem = new MovementSystem(level); colSystem = new CollisionDetectionSystem(level); drawSystem = new DrawSystem(level.g, level); inputSystem = new InputSystem(level); inputManSystem = new CreationInputManagerSystem(level); protEntSystem = new ProtoEntitySystem(level); }
private void ResetGame() { ComponentManager.Get().ClearComponents(); renderingSystem = new RenderingSystem(); physicsSystem = new PhysicsSystem(); collisionDetectionSystem = new CollisionDetectionSystem(); inputSystem = new InputSystem(); spawnSystem = new SpawnSystem(); textSystem = new TextSystem(); CreateEntities(); }
public Game1() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; renderingSystem = new RenderingSystem(); physicsSystem = new PhysicsSystem(); collisionDetectionSystem = new CollisionDetectionSystem(); inputSystem = new InputSystem(); spawnSystem = new SpawnSystem(); textSystem = new TextSystem(); scoreSystem = new ScoreSystem(); }
public Game1() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; ComponentManager cm = ComponentManager.Instance; inputSystem = new InputSystem(); renderSystem = new RenderSystem(); physicsSystem = new PhysicsSystem(); collisionDetectionSystem = new CollisionDetectionSystem(); Viewport viewport = new Viewport(); }
void Update() { if (Input.GetMouseButton(0)) { Ray r = cam.ScreenPointToRay(Input.mousePosition); Vector3 p = r.GetPoint(10); ShapeSystem.SpawnShape(new Circle(p, Random.Range(1f, 4f))); } ShapeSystem.Update(); CollisionDetectionSystem.DetectCollisions(); if (Input.GetKeyDown(KeyCode.F1)) { long quadtreeResult = BenchmarkHelper.Benchmark(() => { CollisionDetectionSystem.QuadtreeTest(); }, 10); long quadtreeNonAllocResult = BenchmarkHelper.Benchmark(() => { CollisionDetectionSystem.QuadtreeNonAllocTest(); }, 10); long conventionalResult = BenchmarkHelper.Benchmark(() => { CollisionDetectionSystem.ConventionalTest(); }, 10); print("Quadtree Benchmark Time: " + quadtreeResult); print("Quadtree(Non Alloc) Benchmark Time: " + quadtreeNonAllocResult); print("Conventional Benchmark Time: " + conventionalResult); } if (Input.GetKeyDown(KeyCode.F2)) { Settings.mode = Settings.CollisionDetectionMode.Conventional; } if (Input.GetKeyDown(KeyCode.F3)) { Settings.mode = Settings.CollisionDetectionMode.QuadtreeAllocated; } if (Input.GetKeyDown(KeyCode.F4)) { Settings.mode = Settings.CollisionDetectionMode.QuadtreeNonAllocated; } if (Input.GetKeyDown(KeyCode.F5)) { Settings.debugDrawShapes = !Settings.debugDrawShapes; } if (Input.GetKeyDown(KeyCode.F6)) { Settings.debugDrawTree = !Settings.debugDrawTree; } }
public Game1() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; graphics.IsFullScreen = true; graphics.PreferredBackBufferWidth = 800; graphics.PreferredBackBufferHeight = 480; graphics.SupportedOrientations = DisplayOrientation.LandscapeLeft | DisplayOrientation.LandscapeRight; renderingSystem = new RenderingSystem(); physicsSystem = new PhysicsSystem(); collisionDetectionSystem = new CollisionDetectionSystem(); inputSystem = new InputSystem(); spawnSystem = new SpawnSystem(); textSystem = new TextSystem(); scoreSystem = new ScoreSystem(); }
void Update() { ShapeSystem.Update(); CollisionDetectionSystem.QuadtreeTest(); }