/// <summary> /// Initializes a new instance of the <see cref="Bridge" /> class. /// </summary> /// <param name="entityService">The entity service.</param> /// <param name="resourceService">The resource service.</param> /// <param name="variableService">The variable service.</param> /// <param name="collisionService">The collision service.</param> public Bridge(IEntityService entityService, IResourceService resourceService, IVariableService variableService, ICollisionService collisionService) { if (entityService == null) { throw new ArgumentNullException(nameof(entityService)); } if (resourceService == null) { throw new ArgumentNullException(nameof(resourceService)); } if (variableService == null) { throw new ArgumentNullException(nameof(variableService)); } if (collisionService == null) { throw new ArgumentNullException(nameof(collisionService)); } _collisionService = collisionService; _variableService = variableService; _entityService = entityService; _resourceService = resourceService; _resourceService.PreloadResource <Sprite>("bridgelog"); _depressionFactor = 0.0; _standIndex = 4; }
public Actor(Vector2 initialPosition, Vector2?initialVelocity = null, ICollisionService collisionService = null) : base(initialPosition, initialVelocity, collisionService) { TintColor = Color.White; // FIXES: bug where entities were invisible in fragEd. Alpha = 255f; // entities are visible by default }
public Actor( Vector2 initialPosition, Vector2? initialVelocity = null, ICollisionService collisionService = null ) : base( initialPosition, initialVelocity, collisionService ) { TintColor = Color.White; // FIXES: bug where entities were invisible in fragEd. Alpha = 255f; // entities are visible by default }
public CoreServices(IViewService view, IInputService input, IInputController inputController, ICollisionService collision, ISelectionService selection, ITimeService time, ITickService tick) { View = view; Input = input; InputController = inputController; Collision = collision; Selection = selection; Time = time; Tick = tick; }
public Services(IViewService view, IInputActionService inputAction, ISelectionService selection, ITimeService time, ITickService tick, ICollisionService collision, IInputService input) { View = view; InputAction = inputAction; Selection = selection; Time = time; Tick = tick; Collision = collision; Input = input; }
public void Update(ICollisionService collisionManager) { for (int i = 1; i < _levelObjects.Count; i++) { if (collisionManager.IsCollision(_player, _levelObjects[i])) { _player.Position = _player.PrevPosition; _player.Velocity = Vector2.Zero; } } }
public TickProcessingService( ICollisionHandlerResolver collisionHandlerResolver, IVectorCalculatorService vectorCalculatorService, IWorldStateService worldStateService, ICollisionService collisionService) { this.collisionHandlerResolver = collisionHandlerResolver; this.vectorCalculatorService = vectorCalculatorService; this.worldStateService = worldStateService; this.collisionService = collisionService; }
public new void Setup() { base.Setup(); collisionService = new CollisionService(EngineConfigFake, WorldStateService, VectorCalculatorService); collisionHandlers = new List <ICollisionHandler> { new FoodCollisionHandler(WorldStateService, EngineConfigFake), new PlayerCollisionHandler(WorldStateService, collisionService, EngineConfigFake, VectorCalculatorService) }; collisionHandlerResolver = new CollisionHandlerResolver(collisionHandlers); }
public PlayerCollisionHandler( IWorldStateService worldStateService, ICollisionService collisionService, IConfigurationService engineConfigOptions, IVectorCalculatorService vectorCalculatorService) { engineConfig = engineConfigOptions.Value; this.worldStateService = worldStateService; this.collisionService = collisionService; this.vectorCalculatorService = vectorCalculatorService; }
public new void Setup() { base.Setup(); collisionService = new CollisionService(EngineConfigFake, WorldStateService, VectorCalculatorService); collisionHandlers = new List <ICollisionHandler> { new FoodCollisionHandler(WorldStateService, EngineConfigFake), new WormholeCollisionHandler(WorldStateService, VectorCalculatorService, EngineConfigFake), new PlayerCollisionHandler(WorldStateService, collisionService, EngineConfigFake, new VectorCalculatorService()), new GasCloudCollisionHandler(WorldStateService, EngineConfigFake), new AsteroidFieldCollisionHandler(WorldStateService), new SuperfoodCollisionHandler(WorldStateService, EngineConfigFake) }; collisionHandlerResolver = new CollisionHandlerResolver(collisionHandlers); }
/// <summary> /// Initializes a new instance of the <see cref="Monitor" /> class. /// </summary> /// <param name="collisionService">The collision service.</param> /// <param name="resourceService">The resource service.</param> /// <param name="variableService">The variable service.</param> /// <param name="entityService">The entity service.</param> /// <param name="audioService">The audio service.</param> /// <exception cref="System.ArgumentNullException"> /// </exception> public Monitor(ICollisionService collisionService, IResourceService resourceService, IVariableService variableService, IEntityService entityService, IAudioService audioService) : base(variableService, resourceService) { if (collisionService == null) { throw new ArgumentNullException(nameof(collisionService)); } if (resourceService == null) { throw new ArgumentNullException(nameof(resourceService)); } if (variableService == null) { throw new ArgumentNullException(nameof(variableService)); } if (entityService == null) { throw new ArgumentNullException(nameof(entityService)); } if (audioService == null) { throw new ArgumentNullException(nameof(audioService)); } _audioService = audioService; _entityService = entityService; _resourceService = resourceService; _collisionService = collisionService; _resourceService.PreloadResource <Sprite>("monitor"); _resourceService.PreloadResource <Sprite>("mpowerup"); _resourceService.PreloadResource <Sprite>("explosion1"); _resourceService.PreloadResource <Sound>("small_explosion"); PowerupType = PowerupType.None; RenderPriority = RenderPriority.Low; MoveController = new FallMoveController(this, _collisionService, variableService) { FallOnce = true, TerrainOnly = true }; }
protected GameObject( Vector2 initialLocation, Vector2? initialVelocity = null, ICollisionService collisionService = null ) { Position = initialLocation; IsAlive = true; Offset = Vector2.Zero; Velocity = initialVelocity ?? Vector2.Zero; // by default, gravity will affect entities GravityFactor = 1f; // entities are moved by changing the acceleration vector... Acceleration = Vector2.Zero; CollisionService = collisionService ?? ServiceLocator.Get<ICollisionService>(); }
protected GameObject(Vector2 initialLocation, Vector2?initialVelocity = null, ICollisionService collisionService = null) { Position = initialLocation; IsAlive = true; Offset = Vector2.Zero; Velocity = initialVelocity ?? Vector2.Zero; // by default, gravity will affect entities GravityFactor = 1f; // entities are moved by changing the acceleration vector... Acceleration = Vector2.Zero; CollisionService = collisionService ?? ServiceLocator.Get <ICollisionService>(); }
/// <summary> /// Initializes a new instance of the <see cref="PlayerMoveController" /> class. /// </summary> /// <param name="player">The player entity to control.</param> /// <param name="collisionService">The collision service.</param> /// <param name="varService">The variable service.</param> /// <param name="inputService">The input service.</param> /// <param name="audioService">The audio service.</param> public PlayerMoveController(Player player, ICollisionService collisionService, IVariableService varService, IInputService inputService, IAudioService audioService) : base(player) { if (collisionService == null) { throw new ArgumentNullException(nameof(collisionService)); } if (varService == null) { throw new ArgumentNullException(nameof(varService)); } if (inputService == null) { throw new ArgumentNullException(nameof(inputService)); } if (audioService == null) { throw new ArgumentNullException(nameof(audioService)); } _player = player; _audioService = audioService; _inputService = inputService; _varService = varService; _collisionService = collisionService; _falling = true; _rolling = false; _jumping = false; _pushing = false; _turning = false; _lookingUp = false; _allowJump = true; _controlsEnabled = true; _gravity = DefaultGravity; _controlLockTime = 0.0; _gsp = 0.0; }
/// <summary> /// Initializes a new instance of the <see cref="BasicMoveController" /> class. /// </summary> /// <param name="parent">The parent.</param> public BounceMoveController(GameEntity parent, ICollisionService collisionService, IVariableService varService) : base(parent) { if (collisionService == null) { throw new ArgumentNullException(nameof(collisionService)); } if (varService == null) { throw new ArgumentNullException(nameof(varService)); } _varService = varService; _collisionService = collisionService; MaxSpeed = DefaultMaxSpeed; Gravity = DefaultGravity; VerticalBounceFactor = HorizontalBounceFactor = 0.5; TerrainOnly = false; }
/// <summary> /// Initializes a new instance of the <see cref="BasicMoveController" /> class. /// </summary> /// <param name="parent">The parent.</param> public FallMoveController(GameEntity parent, ICollisionService collisionService, IVariableService varService) : base(parent) { if (collisionService == null) { throw new ArgumentNullException(nameof(collisionService)); } if (varService == null) { throw new ArgumentNullException(nameof(varService)); } _varService = varService; _collisionService = collisionService; _falling = true; Gravity = DefaultGravity; MaxFallSpeed = DefaultMaxFallSpeed; FallOnce = true; TerrainOnly = true; }
public void Initialize(Contexts contexts, IEntity entity) { _collisionService = contexts.meta.collisionService.service; _entity = (GameEntity)entity; }
public RegisterCollisionServiceSystem(Contexts contexts, ICollisionService collision) { _contexts = contexts; _collision = collision; }
public CollisionController(ICollisionService service, IAutoMappingService mapper) { _service = service; _mapper = mapper; }
/// <summary> /// Initializes a new instance of the <see cref="Player" /> class. /// </summary> /// <param name="resourceService">The resource service.</param> /// <param name="renderService">The render service.</param> /// <param name="varService">The variable service.</param> /// <param name="inputService">The input service.</param> /// <param name="entityService">The entity service.</param> /// <param name="audioService">The audio service.</param> /// <param name="collisionService">The collision service.</param> public Player( IResourceService resourceService, IRenderService renderService, IVariableService varService, IInputService inputService, IEntityService entityService, IAudioService audioService, ICollisionService collisionService) : base(varService, resourceService) { if (resourceService == null) { throw new ArgumentNullException(nameof(resourceService)); } if (renderService == null) { throw new ArgumentNullException(nameof(renderService)); } if (varService == null) { throw new ArgumentNullException(nameof(varService)); } if (inputService == null) { throw new ArgumentNullException(nameof(inputService)); } if (entityService == null) { throw new ArgumentNullException(nameof(entityService)); } if (audioService == null) { throw new ArgumentNullException(nameof(audioService)); } if (collisionService == null) { throw new ArgumentNullException(nameof(collisionService)); } _entityService = entityService; _varService = varService; _renderService = renderService; _inputService = inputService; _audioService = audioService; _collisionService = collisionService; _resourceService = resourceService; _resourceService.PreloadResource <Sprite>("brakesmoke"); _resourceService.PreloadResource <Sprite>("spindashsmoke"); _resourceService.PreloadResource <Sound>("brake"); _resourceService.PreloadResource <Sound>("jump"); _resourceService.PreloadResource <Sound>("roll"); _resourceService.PreloadResource <Sound>("spindash"); _resourceService.PreloadResource <Sound>("spindash_release"); _resourceService.PreloadResource <Sound>("ring_loss"); MoveController = _moveController = new PlayerMoveController(this, _collisionService, _varService, _inputService, _audioService); Options |= EntityOptions.Collidable; SolidType = SolidType.None; CollisionPath = 0; RenderPriority = RenderPriority.High; _lookup = false; _crouching = false; _takingDamage = false; _invulnerabilityTime = 0.0; _nextFlashTime = 0.0; _invulnerable = false; _springing = false; SetBoundingBox(StandingBox); }
/// <summary> /// Initializes a new instance of the <see cref="Renderer" /> class. /// </summary> /// <param name="gameEngine">The game engine.</param> /// <param name="form">The form.</param> /// <param name="width">The primary width of the view in pixels.</param> /// <param name="height">The primary height of the view in pixels.</param> public Renderer(IGameEngine gameEngine, GameForm form, int width, int height) { if (gameEngine == null) { throw new ArgumentNullException(nameof(gameEngine)); } if (form == null) { throw new ArgumentNullException(nameof(form)); } _form = form; _resize = false; _scale = 1.0f; _width = width; _height = height; _dwFactory = new SharpDX.DirectWrite.Factory(); InitFonts(); // DeviceCreationFlags.BgraSupport must be enabled to allow Direct2D interop. SharpDX.Direct3D11.Device defaultDevice = new SharpDX.Direct3D11.Device(DriverType.Hardware, DeviceCreationFlags.Debug | DeviceCreationFlags.BgraSupport); // Query the default device for the supported device and context interfaces. _device = defaultDevice.QueryInterface <SharpDX.Direct3D11.Device1>(); _d3dContext = _device.ImmediateContext.QueryInterface <SharpDX.Direct3D11.DeviceContext1>(); // Query for the adapter and more advanced DXGI objects. using (var dxgiDevice2 = _device.QueryInterface <SharpDX.DXGI.Device2>()) { _d2dFactory = new SharpDX.Direct2D1.Factory2(SharpDX.Direct2D1.FactoryType.SingleThreaded); // Get the default Direct2D device and create a context. using (var d2dDevice = new SharpDX.Direct2D1.Device1(_d2dFactory, dxgiDevice2)) { _d2dContext = new SharpDX.Direct2D1.DeviceContext1(d2dDevice, SharpDX.Direct2D1.DeviceContextOptions.None); } } CreateSizeDependentResources(); _d2dContext.TextAntialiasMode = SharpDX.Direct2D1.TextAntialiasMode.Aliased; _d2dContext.AntialiasMode = AntialiasMode.Aliased; _d2dContext.UnitMode = UnitMode.Pixels; _hudYellow = new SolidColorBrush(_d2dContext, new Color4(1.0f, 1.0f, 0.0f, 1.0f)); _hudWhite = new SolidColorBrush(_d2dContext, new Color4(1.0f, 1.0f, 1.0f, 1.0f)); _hudTextFormat = new TextFormat(_dwFactory, "Sonic Genesis/Mega Drive Font", _fontCollection, FontWeight.Normal, FontStyle.Normal, FontStretch.Normal, 14); // init game stuff _game = gameEngine; _texResMan = new TextureResourceManager(gameEngine, _d2dContext); _spriteResMan = new SpriteResourceManager(gameEngine, _d2dContext); // get the services _mapService = _game.GetService <IMapService>(); _varService = _game.GetService <IVariableService>(); _entityService = _game.GetService <IEntityService>(); _renderService = _game.GetService <IRenderService>(); _collisionService = _game.GetService <ICollisionService>(); _varShowCollisionMaps = _varService.GetVar <bool>("r_showcollisionmaps"); _varShowTileFrames = _varService.GetVar <bool>("r_showtileframes"); _varShowEntityOrigins = _varService.GetVar <bool>("r_showentityorigins"); _varShowTraceLines = _varService.GetVar <bool>("r_showtracelines"); _varShowCollisionBoxes = _varService.GetVar <bool>("r_showcollisionboxes"); _rc = new RenderContext(); _spriteRenderList = new List <Animatable>(25); }
/// <summary> /// Initializes a new instance of the <see cref="Player" /> class. /// </summary> /// <param name="resourceService">The resource service.</param> /// <param name="renderService">The render service.</param> /// <param name="varService">The variable service.</param> /// <param name="inputService">The input service.</param> /// <param name="entityService">The entity service.</param> /// <param name="audioService"></param> /// <param name="collisionService"></param> public Sonic( IResourceService resourceService, IRenderService renderService, IVariableService varService, IInputService inputService, IEntityService entityService, IAudioService audioService, ICollisionService collisionService) : base( resourceService, renderService, varService, inputService, entityService, audioService, collisionService) { if (resourceService == null) { throw new ArgumentNullException(nameof(resourceService)); } if (renderService == null) { throw new ArgumentNullException(nameof(renderService)); } if (varService == null) { throw new ArgumentNullException(nameof(varService)); } if (inputService == null) { throw new ArgumentNullException(nameof(inputService)); } if (entityService == null) { throw new ArgumentNullException(nameof(entityService)); } if (audioService == null) { throw new ArgumentNullException(nameof(audioService)); } if (collisionService == null) { throw new ArgumentNullException(nameof(collisionService)); } _entityService = entityService; _varService = varService; _renderService = renderService; _inputService = inputService; _audioService = audioService; _collisionService = collisionService; _resourceService = resourceService; _resourceService.PreloadResource <Sprite>("sonic"); }
/// <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() { // TODO: Add your initialization logic here IsMouseVisible = true; _gameState = GameState.StartMenu; _gameStateCheck = 0; input = (IInputService)Services.GetService(typeof(IInputService)); renderer = (IDrawSprites)Services.GetService(typeof(IDrawSprites)); collisionManager = (ICollisionService)Services.GetService(typeof(ICollisionService)); _screenWidth = GraphicsDevice.Viewport.Width; _screenHeight = GraphicsDevice.Viewport.Height; _camera = new Camera(GraphicsDevice.Viewport); Services.AddService(typeof(Camera), _camera); base.Initialize(); }