public Engine() { kbHandler = new KeyboardHandler(); //gpHandler = new PS4GamePadHandler(0); //TODO: Add support for PS4 controller reqHandler = new RequestHandler(); RenderState.activeGamepad = gpHandler; //Assign new palette to GLControl palette = Palettes.createPalettefromBasePalettes(); renderMgr = new renderManager(); //Init renderManager of the engine //Input Polling Timer inputPollTimer = new System.Timers.Timer(); inputPollTimer.Elapsed += new ElapsedEventHandler(input_poller); inputPollTimer.Interval = 1; //Camera Movement Timer cameraMovementTimer = new System.Timers.Timer(); cameraMovementTimer.Elapsed += new ElapsedEventHandler(camera_timer); cameraMovementTimer.Interval = 20; //cameraMovementTimer.Start(); Start in the main function //Systems Init actionSys = new ActionSystem(); animationSys = new AnimationSystem(); actionSys.SetEngine(this); animationSys.SetEngine(this); }
virtual protected void initialize() { stats = GetComponent <CharacterValues>(); characterAnimation = GetComponent <AnimationSystem>(); initialized = checkInitialization(); }
protected override void Initialise() { var renderSys = new RenderSystem(new Vector2u(800, 600)); renderSys.SetDebug(); var anim = new AnimationSystem(); var inputSys = new InputSystem(); _player = new Entity(); _player.AddComponent(new Position(0, 0)); _player.AddComponent(new Sprite()); _player.AddComponent(new Animation(@"player.png", 25, 25, 6, frameRate: 5f)); _player.AddComponent(new KeyboardInput()); var k = _player.GetComponent <KeyboardInput>(); k.InputEvents.Add(new KeyboardInput.Key(KeyboardInput.KeyState.Down, Keyboard.Key.Down), delegate { _player.GetComponent <Position>().Y += 1; }); k.InputEvents.Add(new KeyboardInput.Key(KeyboardInput.KeyState.Down, Keyboard.Key.Up), delegate { _player.GetComponent <Position>().Y -= 1; }); k.InputEvents.Add(new KeyboardInput.Key(KeyboardInput.KeyState.Down, Keyboard.Key.Left), delegate { _player.GetComponent <Position>().X -= 1; }); k.InputEvents.Add(new KeyboardInput.Key(KeyboardInput.KeyState.Down, Keyboard.Key.Right), delegate { _player.GetComponent <Position>().X += 1; }); }
void Start() { // Add systems here TouchSystem ts = new TouchSystem(); AddSystem(ts); AnimationSystem ans = new AnimationSystem(); AddSystem(ans); UISystem uis = new UISystem(); AddSystem(uis); PauseSystem ps = new PauseSystem(); AddSystem(ps); DestroySystem ds = new DestroySystem(); AddSystem(ds); AdSystem ads = new AdSystem(); AddSystem(ads); Enable(); ExtraSetup(); }
public RealtimeWorld(GameWindow window, IAudioAdapter audioAdapter, IGraphicsHost graphicsHost) { var graphics = graphicsHost.GetGraphicsAdapter(); var audioSystem = new AudioSystem(this, audioAdapter); var cameraSystem = new CameraSystem(this, graphicsHost); var actorSystem = new ActorSystem(this); var animationSystem = new AnimationSystem(this); // new up systems, order here will be order of update Systems.Add(new OpenTKInputSystem(this, window)); Systems.Add(new BspSystem(this)); Systems.Add(new PhysxPhysicsSystem(this)); Systems.Add(new MoverSystem(this)); Systems.Add(cameraSystem); Systems.Add(audioSystem); Systems.Add(actorSystem); Systems.Add(animationSystem); Systems.Add(new ScriptSystem(this, audioSystem, cameraSystem, actorSystem, animationSystem)); Systems.Add(new RenderCollectorSystem(this, graphics)); RenderSystems.Add(new RenderPipelineSystem(this, graphics)); globalResources.Add(new RenderListStore()); globalResources.Add(new InputStore()); }
void Start() { // Add systems here DialogSystem dls = new DialogSystem(); AddSystem(dls); PreMatchDialogSystem pmds = new PreMatchDialogSystem(); AddSystem(pmds); MatchSystem ms = new MatchSystem(); AddSystem(ms); AnimationSystem ans = new AnimationSystem(); AddSystem(ans); TouchSystem ts = new TouchSystem(); AddSystem(ts); UISystem uis = new UISystem(); AddSystem(uis); PauseSystem ps = new PauseSystem(); AddSystem(ps); DestroySystem ds = new DestroySystem(); AddSystem(ds); //AdSystem ads = new AdSystem(); //AddSystem(ads); Enable(); Setup(); }
public Animal(Wolf wolf, Model model, Dictionary <String, String> AnimationFolders, ContentManager contentManager, Matrix world, float colliderSize, int meat, string kindOfAnimal) : base(world, model) { this.kindOfAnimal = kindOfAnimal; this.wolf = wolf; this.meat = meat; animations = new Dictionary <string, Animation>(); foreach (String AnimationName in AnimationFolders.Keys) { animations.Add(AnimationName, new Animation(contentManager, AnimationFolders[AnimationName])); } if (animations.ContainsKey("Idle")) { animations["Idle"].frameSpeed = 0.05f; animationSystem = new AnimationSystem(animations["Idle"], this); } else { animationSystem = new AnimationSystem(animations["Move"], this); } ifColisionTerrain = false; position = world.Translation; position = position + new Vector3(0, -1f, 0); angle = 180; collider = new BoundingBox(new Vector3(world.Translation.X - colliderSize / 2, world.Translation.Y - colliderSize / 2, world.Translation.Z - colliderSize / 2), new Vector3(world.Translation.X + colliderSize / 2, world.Translation.Y + colliderSize / 2, world.Translation.Z + colliderSize / 2)); this.colliderSize = colliderSize; speedFactor = 100; animationOffset = (float)rand.NextDouble() * 10; animationFrequency = 1; turnFrequency = (float)rand.Next(5, 20); }
public void Awake() { var m = GetComponent <ICharacterSheet>().GetStat(StatType.MoveSpeed); this.moveSpeed = (m == null ? 0f : m.Value); animationSystem = GetComponent <AnimationSystem>(); }
// 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); }
protected Screen(IScreenContext game) { _layers = new List <ScreenLayer>(); Game = game; ClearColor = Color.CornflowerBlue; Animations = new AnimationSystem(); }
public void Awake() { var m = GetComponent <ICharacterSheet>().GetStat(StatType.MoveSpeed); this.moveSpeed = (m == null ? 0f : m.Value); characterController = GetComponent <CharacterController>(); animator = GetComponent <AnimationSystem>(); playerInput = GetComponent <IPlayerInput>(); }
public static void UnregisterAnimation(IAnimationParams ab) { AnimationSystem animator = GetAnimationSystemForAnimationBase(ab); if (animator != null) { animator.UnregisterAnimationParams(ab); } }
protected override void CreateSystems() { styleSystem = new StyleSystem(); layoutSystem = new MockLayoutSystem(this); inputSystem = new MockInputSystem(layoutSystem); renderSystem = new MockRenderSystem(Camera, this); routingSystem = new RoutingSystem(); animationSystem = new AnimationSystem(); linqBindingSystem = new LinqBindingSystem(); }
public void RequestAnimation(AnimationData animData) { if (anim == null) { anim = new AnimationSystem(animData.frames, animData.loop, animData.spf); } else { anim.SetFrames(animData.frames, animData.loop, animData.spf); } }
private void OnComponentRemoved(GameEvent e) { var data = (EntityComponentData)e.EventData; var form = data.Component as FormComponent; if (form != null) { AnimationSystem.RemoveAll(data.EntityId); form.DestroyForm(); } }
static Game() { // main UI elements _statLayer = new LayerInfo("Stats", 1, Constants.SIDEBAR_WIDTH + 2, 1, Constants.MAPVIEW_WIDTH, Constants.STATUS_HEIGHT); _mapLayer = new LayerInfo("Map", 1, Constants.SIDEBAR_WIDTH + 2, Constants.STATUS_HEIGHT + 1, Constants.MAPVIEW_WIDTH, Constants.MAPVIEW_HEIGHT); _messageLayer = new LayerInfo("Message", 1, Constants.SIDEBAR_WIDTH + 2, Constants.STATUS_HEIGHT + Constants.MAPVIEW_HEIGHT + 2, Constants.MAPVIEW_WIDTH, Constants.MESSAGE_HEIGHT); // left panel for look and info _leftLayer = new LayerInfo("Look", 1, 1, 1, Constants.SIDEBAR_WIDTH, Constants.SCREEN_HEIGHT); // right panel for inventory and equipment _rightLayer = new LayerInfo("Inventory", 1, Constants.SIDEBAR_WIDTH + Constants.MAPVIEW_WIDTH + 3, 1, Constants.SIDEBAR_WIDTH, Constants.SCREEN_HEIGHT); // overlay over map _highlightLayer = new LayerInfo("Highlight", 3, _mapLayer.X, _mapLayer.Y, _mapLayer.Width, _mapLayer.Height); _fullConsole = new LayerInfo("Full", 11, 0, 0, Constants.SCREEN_WIDTH + 2, Constants.SCREEN_HEIGHT + 2); StateHandler = new StateHandler(new Dictionary <Type, LayerInfo> { [typeof(ApplyState)] = _rightLayer, [typeof(AutoexploreState)] = _mapLayer, [typeof(DropState)] = _rightLayer, [typeof(EquipState)] = _rightLayer, [typeof(InventoryState)] = _rightLayer, [typeof(SubinvState)] = _rightLayer, [typeof(ItemMenuState)] = _rightLayer, [typeof(MenuState)] = _fullConsole, [typeof(NormalState)] = _mapLayer, [typeof(TargettingState)] = _mapLayer, [typeof(TextInputState)] = _mapLayer, [typeof(UnequipState)] = _rightLayer }); MessageHandler = new MessagePanel(Constants.MESSAGE_HISTORY_COUNT); EventScheduler = new EventScheduler(16); Overlay = new OverlayHandler(Constants.MAP_WIDTH, Constants.MAP_HEIGHT); Threatened = new OverlayHandler(Constants.MAP_WIDTH, Constants.MAP_HEIGHT); Animations = new AnimationSystem(); }
public void RequestAnimation(string id) { currentAnimID = id; AnimationData animData = unitData.GetAnimation(id); if (anim == null) { anim = new AnimationSystem(animData.frames, animData.loop, animData.spf); } else { anim.SetFrames(animData.frames, animData.loop, animData.spf); } }
public ParticleFXEntity(JSONNode data) { var sheet = ResourcesManager.GetSpritesSheet(data["source"]); JSONArray framesData = data["frames"].AsArray; sprites = new Sprite[framesData.Count]; for (int i = 0; i < framesData.Count; i++) { sprites[i] = sheet[framesData[i].AsInt]; } float spf = data["spf"].AsFloat; anim = new AnimationSystem(sprites, false, spf); }
public void SetUp() { _stopwatch = Substitute.For <IStopwatch>(); _stopwatch.ElapsedMilliseconds.ReturnsForAnyArgs(0); _random = Substitute.For <IRandom>(); _animationSystem = new AnimationSystem(_stopwatch, _random); _animationSystem.Initialise(); _testObject = CreateTestObject(); _animatedComponent = _testObject.Get <Animated>(); _animationSystem.AddEntity(_testObject); }
public ScriptEngine(Scene scene, IScriptExecutor executionOrchestrator, AudioSystem audioSystem, CameraSystem cameraSystem, ActorSystem actorSystem, AnimationSystem animationSystem) { this.scene = scene; this.executionOrchestrator = executionOrchestrator; this.audioSystem = audioSystem; this.cameraSystem = cameraSystem; this.actorSystem = actorSystem; this.animationSystem = animationSystem; this.rng = new Random(42); }
public override void Show() { _animationSystem = new AnimationSystem(); _spriteBatch = new SpriteBatch(GraphicsDevice); _texture = AssetManager.Load <Texture>("astrid-logo.png"); var x = Game.Viewport.Width / 2; var y = Game.Viewport.Height / 2; _position = new Vector2(x, y); _color = Color.White; CreateMoveToAnimation(new Vector2(x - 100, y), new Vector2(x + 100, y)); }
public override void Create() { _animationSystem = new AnimationSystem(); InputDevice.Processors.Add(new TouchInputProcessor(this)); _spriteBatch = new SpriteBatch(GraphicsDevice); _texture = AssetManager.Load <Texture>("AstridLogo.png"); var x = GraphicsDevice.Width / 2; var y = GraphicsDevice.Height / 2; _position = new Vector2(x, y); _color = Color.White; _bitmapFont = AssetManager.Load("CourierNew_32.fnt", new BitmapFontLoader()); }
void Start() { // Add systems here LivesSystem ls = new LivesSystem(); AddSystem(ls); StreakSystem ss = new StreakSystem(); AddSystem(ss); ScoreSystem scs = new ScoreSystem(); AddSystem(scs); ColoringSystem cs = new ColoringSystem(); AddSystem(cs); TouchSystem ts = new TouchSystem(); AddSystem(ts); GameSystem gs = new GameSystem(); AddSystem(gs); TutorialSystem tus = new TutorialSystem(); AddSystem(tus); AnimationSystem ans = new AnimationSystem(); AddSystem(ans); UISystem uis = new UISystem(); AddSystem(uis); PauseSystem ps = new PauseSystem(); AddSystem(ps); DestroySystem ds = new DestroySystem(); AddSystem(ds); AdSystem ads = new AdSystem(); AddSystem(ads); Enable(); this.initializeGame = true; ExtraSetup(); }
public void RequestAnimation(string animID, bool loop = false, bool resetIndex = true, float spf = 0.12f) { if (anim == null) { anim = new AnimationSystem(info.animationData[animID], loop, spf); } else { anim.SetFrames(info.animationData[animID]); anim.SetLoop(loop); anim.SetSpf(spf); } if (resetIndex) { anim.ResetIndex(); } }
/// <summary> /// Creates a new Director instance using the specified Game. /// </summary> /// <param name="game">Game instance for the Director to use.</param> /// <param name="preferredResolution">Preferred resolution for game graphics.</param> /// <remarks>Protected to prevent instantiating Director instances outside of the static SharedDirector property.</remarks> protected Director(Game game, Vector2 preferredResolution) : base(game) { if (preferredResolution == null) { throw new ArgumentNullException("defaultResolution"); } PreferredResolution = preferredResolution; DisplaySize = preferredResolution; DisplayCenter = new Vector2(DisplaySize.X / 2.0f, DisplaySize.Y / 2.0f); ResolutionIndependent = false; TransformationMatrix = new Matrix(); EntityWorld = new EntityWorld(game); RenderSystem renderSystem = EntityWorld.SystemManager.SetSystem <RenderSystem>(new RenderSystem(), SystemExecutionType.Draw); AnimationSystem animationSystem = EntityWorld.SystemManager.SetSystem <AnimationSystem>(new AnimationSystem(), SystemExecutionType.Update); MovementSystem movementSystem = EntityWorld.SystemManager.SetSystem <MovementSystem>(new MovementSystem(), SystemExecutionType.Update); ControlSystem controlSystem = EntityWorld.SystemManager.SetSystem <ControlSystem>(new ControlSystem(), SystemExecutionType.Update); MessageBoard = new MessageBoard(game); GameStateManager = new GameStateManager(game.Services); InputManager = new InputManager(game.Services); InputBindingManager = new InputBindingManager(game); TextureManager = new TextureManager(game.Content); FontManager = new FontManager(game.Content); GuiManager = new GuiManager(game.Services); game.Components.Add(EntityWorld); game.Components.Add(MessageBoard); game.Components.Add(InputManager); game.Components.Add(InputBindingManager); game.Services.AddService(typeof(IEntityWorld), EntityWorld); game.Services.AddService(typeof(IMessageBoard), MessageBoard); game.Services.AddService(typeof(IInputBindingManager), InputBindingManager); game.Services.AddService(typeof(ITextureManager), TextureManager); game.Services.AddService(typeof(IFontManager), FontManager); #if DEBUG DebugDisplay = new DebugDisplay(game); game.Components.Add(DebugDisplay); game.Services.AddService(typeof(IDebugDisplay), DebugDisplay); #endif }
protected override void Initialize() { this.IsMouseVisible = true; //Get Systems RenderSystem = SystemManager.Instance.GetSystem <RenderSystem>(); LoadContentSystem = SystemManager.Instance.GetSystem <LoadContentSystem>(); InputHandlerSystem = SystemManager.Instance.GetSystem <InputHandler>(); TankMovementSystem = SystemManager.Instance.GetSystem <TankMovementSystem>(); TitlesafeRenderSystem = SystemManager.Instance.GetSystem <TitlesafeRenderSystem>(); CollisionSystem = SystemManager.Instance.GetSystem <CollisionSystem>(); CameraFollowSystem = SystemManager.Instance.GetSystem <CameraSceneSystem>(); LightSystems = SystemManager.Instance.GetSystem <FlashlightSystem>(); MoveSystem = SystemManager.Instance.GetSystem <MoveSystem>(); CollisionResolveSystem = SystemManager.Instance.GetSystem <CollisionResolveSystem>(); WallCollisionSystem = SystemManager.Instance.GetSystem <WallCollisionSystem>(); AISystem = SystemManager.Instance.GetSystem <AISystem>(); EnemyCollisionSystem = SystemManager.Instance.GetSystem <EnemyCollisionSystem>(); AnimationSystem = SystemManager.Instance.GetSystem <AnimationSystem>(); SoundSystem = SystemManager.Instance.GetSystem <SoundSystem>(); WeaponSystem = SystemManager.Instance.GetSystem <WeaponSystem>(); BulletCollisionSystem = SystemManager.Instance.GetSystem <BulletCollisionSystem>(); HealthSystem = SystemManager.Instance.GetSystem <HealthSystem>(); TempGameEnder = new TempGameEnder(); //Init systems that require initialization TankMovementSystem.Start(); WallCollisionSystem.Start(); SoundSystem.Start(); WeaponSystem.Start(); EnemyCollisionSystem.Start(); BulletCollisionSystem.Start(); _gameDependencies.GameContent = this.Content; _gameDependencies.SpriteBatch = new SpriteBatch(GraphicsDevice); // just quickly done for FPS testing spriteBatch = _gameDependencies.SpriteBatch; _gameDependencies.Game = this; CreateTestEntities(); base.Initialize(); }
public void TestAnimationSystem() { var state = new GameState(); for (int i = 0; i < NUMBER_OF_ENTITIES; ++i) { state.GameData.AnimationData[i] = new AnimationData(AnimationSpecCreator.Create("Test", 64, 16, 16, 16, 160, true)); state.GameData.Tags[i] = 1; state.EntityCount++; } Console.WriteLine($"Number of entities: {state.EntityCount}"); for (int i = 1; i < 33; ++i) { var system = new AnimationSystem("Animation", state); RunSystem(system, i); } state.ClearState(); }
protected override void OnCreate() { var world = World.DefaultGameObjectInjectionWorld; animationSystem = world.GetOrCreateSystem <AnimationSystem>(); cameraFollowSystem = world.GetOrCreateSystem <CameraFollowSystem>(); retrieveInteractableCollisionsSystem = world.GetOrCreateSystem <RetrieveInteractableCollisionsSystem>(); playerCollisionSystem = world.GetOrCreateSystem <PlayerCollisionSystem>(); temporaryEnemySpawnerSystem = world.GetOrCreateSystem <TemporaryEnemySpawnerSystem>(); var lateSimulation = world.GetOrCreateSystem <LateSimulationManager>(); lateSimulation.AddSystemToUpdateList(animationSystem); lateSimulation.AddSystemToUpdateList(cameraFollowSystem); lateSimulation.AddSystemToUpdateList(retrieveInteractableCollisionsSystem); lateSimulation.AddSystemToUpdateList(playerCollisionSystem); lateSimulation.AddSystemToUpdateList(temporaryEnemySpawnerSystem); lateSimulation.SortSystemUpdateList(); }
public Wolf(Model model, Dictionary <String, String> AnimationFolders, ContentManager contentManager, Matrix world, float colliderSize, Camera cam, int strength, int resistance, int speed, string name) : base(world, model) { rand = new Random(strength); this.Name = name; this.strength = strength; this.resistance = resistance; this.speed = speed; animations = new Dictionary <string, Animation>(); foreach (String AnimationName in AnimationFolders.Keys) { animations.Add(AnimationName, new Animation(contentManager, AnimationFolders[AnimationName])); } if (animations.ContainsKey("Idle")) { animations["Idle"].frameSpeed = 0.05f; animationSystem = new AnimationSystem(animations["Idle"], this); } else { animationSystem = new AnimationSystem(animations["Move"], this); } this.cam = cam; ifColisionTerrain = false; position = world.Translation; position = position + new Vector3(0, -1f, 0); angle = 180; collider = new BoundingBox(new Vector3(world.Translation.X - colliderSize / 2, world.Translation.Y - colliderSize / 2, world.Translation.Z - colliderSize / 2), new Vector3(world.Translation.X + colliderSize / 2, world.Translation.Y + colliderSize / 2, world.Translation.Z + colliderSize / 2)); this.colliderSize = colliderSize; speedFactor = 100; animationOffset = (float)rand.NextDouble() * 10; }
void Start() { plasmaAnimation = GetComponent <AnimationSystem>(); }