public ButtonCollection(Game game, EditorState editor) : base(game) { _editor = editor; ButtonCells = new Cell[] { new Cell(game, "a0"), new Cell(game, "b0"), new Cell(game, "b1"), new Cell(game, "c0"), new Cell(game, "c2"), new Cell(game, "d0"), new Cell(game, "z0") }; _activeCell = new ActiveCell(game); _components = new GameComponentCollection(); foreach (var button in ButtonCells) { _components.Add(new ButtonClick(button, SelectCell, button)); } _components.Add(_activeCell); _editor.SelectedType = ButtonCells[0].CellType; _activeCell.Current = ButtonCells[0]; }
private void ObjectTests() { // Items AddObject(new Item(game, "Health_Medium")); // static test /*Static static1 = new Static(game, "Rock"); * static1.LocalPosition = new Vector3(50, -100, -1000); * AddObject(static1); * * Vector3[] positions = new Vector3[2]; * Quaternion[] rotations = new Quaternion[2]; * float[] scales = new float[2]; * positions[0] = new Vector3(50, -100, -900); * positions[1] = new Vector3(50, -100, -1100); * rotations[0] = Quaternion.CreateFromAxisAngle(new Vector3(0, 1, 0), (float)Math.PI / 4); * rotations[1] = Quaternion.CreateFromAxisAngle(new Vector3(0, 1, 0), -(float)Math.PI / 4); * scales[0] = 0.5f; * scales[1] = 0.5f; * Statics statics1 = new Statics(game, 0, "Rocks", positions, rotations, scales, true); * AddObject(statics1);*/ // debris test /*debris2 = new DebrisEmitter(game, "debrisTest", 50, 0.5f, 1.0f); * debris2.LocalPosition = new Vector3(50, 200, -1000); * debris2.Type = new DebrisEmitterTypeVolumeOOBB(game, new Vector3(100, 100, 200)); * AddObject(debris2); * if (!Helper.Lock("Debris Test 2", TimeSpan.FromSeconds(15))) * debris2.Emit(50); * * debris3 = new DebrisEmitter(game, "debrisTest", 20, 0.5f, 1.0f); * debris3.LocalPosition = new Vector3(-230, 0, -1000); * debris3.Type = new DebrisEmitterTypeCone(game, new Vector3(1, 0, 0), 10, 10, 50); * AddObject(debris3); * if (!Helper.Lock("Debris Test 3", TimeSpan.FromSeconds(15))) * debris3.Emit(20);*/ MovingPointLight light1 = new MovingPointLight(game, Color.Green, new Vector3(-100, 50, -400), new Vector3(150, 0, 0), Vector3.UnitY, 0.02f); AddPointLight(light1); components.Add(light1); MovingPointLight light2 = new MovingPointLight(game, new Color(150, 0, 0), new Vector3(100, 50, -400), new Vector3(-150, 0, 0), Vector3.UnitY, 0.02f); AddPointLight(light2); components.Add(light2); // physics test // EnablePlayerPhysics(); GraphicalConsole.GetSingleton(game).RegisterObjectFunction(this, "World", "EnablePlayerPhysics"); if (game.Graphics.ShadowMappingSupported) { sky.Sunlight.ShadowMapLow.Scene.AddDrawable(canyon); sky.Sunlight.ShadowMapHigh.Scene.AddDrawable(player); sky.Sunlight.ShadowMapHigh.Scene.AddDrawable(canyon); } }
public TestBench() : base(GameWindowSettings.Default, new NativeWindowSettings { Size = new Vector2i(800, 600), APIVersion = new Version(4, 5), API = OpenTK.Windowing.Common.ContextAPI.OpenGL, Profile = ContextProfile.Compatability, Flags = ContextFlags.Default }) //base( // 800, 600, // GraphicsMode.Default, "OpenTKExtensions TestBench", // GameWindowFlags.Default, DisplayDevice.Default, // 4, 5, GraphicsContextFlags.ForwardCompatible // ) { VSync = VSyncMode.Off; // set static loader ShaderProgram.DefaultLoader = new OpenTKExtensions.Loaders.MultiPathFileSystemLoader(SHADERPATH); Load += TestBench_Load; Unload += TestBench_Unload; UpdateFrame += TestBench_UpdateFrame; RenderFrame += TestBench_RenderFrame; Resize += TestBench_Resize; components.Add(font = new Font("Resources/Fonts/consolab.ttf_sdf_512.png", "Resources/Fonts/consolab.ttf_sdf_512.txt")); components.Add(renderTarget = new RenderTargetBase(false, false, 512, 512) { DrawOrder = 1 }); renderTarget.Loading += (s, e) => { renderTarget.SetOutput(0, new TextureSlotParam(TextureTarget.Texture2D, PixelInternalFormat.Rgba32f, PixelFormat.Rgba, PixelType.Float, false, Texture.Params().FilterNearest().Repeat().ToArray() )); }; renderTarget.Add(testcomp2 = new TestComponent2()); components.Add(testcomp1 = new TestComponent() { DrawOrder = 2 }); testcomp1.PreRender += (s, e) => { testcomp1.tex2 = renderTarget.GetTexture(0); }; //components.Add(new OperatorComponentTest()); components.Add(new FrameCounter(font) { LoadOrder = 2, DrawOrder = 3 }); timer.Start(); }
public void Item() { MyComponent c = new MyComponent(game); components.Add(c); Assert.AreSame(c, components[0]); }
public World(ICanyonShooterGame Game, string LevelName, GameComponentCollection Components) : base(Game as Game) { game = Game; components = Components; levelName = LevelName; game.World = this; // Erste Komponenten benötigen dies bereits jetzt // wenn world sich selbst zerstört, soll kein objekt mehr in der update-warteschleife sein, weil dieses objekt world benötigen könnte. UpdateOrder = int.MaxValue - 1; // Sky sky = new Sky(game, "Skybox"); if (game.Graphics.ShadowMappingSupported) { sky.Sunlight.Shadows = true; } components.Add(sky); if (levelName != "") { LoadLevel(); // Canyon canyon = new Canyon.Canyon(game); components.Add(canyon); freeCamera = new FreePerspectiveCamera(game); components.Add(freeCamera); // Player 1 //player = new Player(game, 1); player = new Player2(game); //ghost = new Ghost(game); AddObject(player); if (levelName.Equals("The Hell of Tunnels") || levelName.Equals("The Corkscrew") || levelName.Equals("The Way goes Up and Down")) { ((Player2)player).RemainingTime = 90; } //AddObject(ghost); ObjectTests(); StreamLoader(); } }
public static void Register(WpfGame game, GameComponentCollection components) { _keyboardListener = new WpfKeyboardListener(game); _mouseListener = new WpfMouseListener(game); components.Add(new WpfInputListenerComponent(game, _keyboardListener, _mouseListener)); }
public void createPlayer(Game game, Vector3 pos) { GameObject body = createGameObject(game, Vector3.Zero, "sphere", "player"); //Player body GameObject fist = createGameObject(game, Vector3.Zero, "sphere", "tex_fist"); //Player fist gameobjs.Add(body); gameobjs.Add(fist); //Add the body and fist of player to gameobjs player = new Player(game, body, fist, pos, camera); player.body.setPosition(pos); //Add to Game.Components components.Add(player); physworld.addCollisionEvent(player.body.physobj, player.fist.physobj); }
public PickupManager(Game game, SosEngine.Level level, GameComponentCollection gameComponents) : base(game) { spriteFrameCache = new SosEngine.SpriteFrameCache(); for (int y = 0; y < level.Height; y++) { for (int x = 0; x < level.Width; x++) { int block = level.GetBlock("Pickups", x, y); if (block > 0) { string spriteFrameName = GetSpriteFrameNameForBlock(block); Pickup pickup = new Pickup(game, spriteFrameName, block, x * 16, y * 16, animationDelay, 100, spriteFrameCache); if (IsHiddenItem(block)) { pickup.Visible = false; } if (IsAnimatedItem(block)) { string spriteFrameName2 = GetSpriteFrameNameForBlock(block + 1); pickup.AddFrame(spriteFrameName2, animationDelay); pickup.AddFrame(GetSpriteFrameNameForBlock(block + 2), animationDelay); pickup.AddFrame(GetSpriteFrameNameForBlock(block + 3), animationDelay); } pickup.DrawOffsetX = 0; gameComponents.Add(pickup); AddSprite(pickup); } } } }
/// <summary> /// Add the components to the main collection here, /// so that code in the GameState constructor can run. /// </summary> protected void RegisterComponents() { foreach (IGameComponent subComponent in _subComponents) { _mainComponents.Add(subComponent); } }
internal static void ReplaceComponent <T>( this GameComponentCollection components, T toBeReplaced, T replacement ) where T : IGameComponent { components.Remove(toBeReplaced); components.Add(replacement); }
public static T Add <T>(this GameComponentCollection collection) where T : IGameComponent, new() { var gameComponent = new T(); collection.Add(gameComponent); return(gameComponent); }
public static T Add <T>(this GameComponentCollection collection, Func <T> createGameComponent) where T : IGameComponent { var gameComponent = createGameComponent(); collection.Add(gameComponent); return(gameComponent); }
public static void Add( this GameComponentCollection self, params IGameComponent [] components) { foreach (var component in components) { self.Add(component); } }
/// <summary> /// Will add components to the main GameComponentCollection and the game state GameComponentCollection. /// </summary> /// <param name="mainComponents">The main GameComponentCollection.</param> /// <param name="subComponents">A list of the GameComponents which you want to be added and removed with the CustomGameState.</param> protected GameState(GameComponentCollection mainComponents, params IGameComponent[] subComponents) { _mainComponents = mainComponents; foreach (IGameComponent subComponent in subComponents) { _subComponents.Add(subComponent); } }
protected void SortComponentsByStackOrder() { IEnumerable <IGameComponent> query = components.OrderBy(comp => ((IStackable)comp).StackOrder); sortedComponents.Clear(); for (int i = 0; i < query.Count(); i++) { sortedComponents.Add(query.ElementAt(i)); } }
public CellMap(Game game, EditorState editor) : base(game) { _editor = editor; _components = new GameComponentCollection(); MapCell = new Cell[Map.GetLength(0), Map.GetLength(1)]; for (int y = 0; y < Map.GetLength(0); y++) { for (int x = 0; x < Map.GetLength(1); x++) { Cell cell = new Cell(Game, Map[y, x]); _components.Add(cell); MapCell[y, x] = cell; } } //_components.Add(new CellMapHover(this)); _components.Add(new CellMapClick(this, SetMapCell)); }
public GameWorld(Game game, ContentManager cm, Camera cam) : base(game) { content = cm; camera = cam; components = game.Components; physworld = new PhysicsWorld(game); modelmgr = new ModelManager(game, cam); level = new Level(); components.Add(physworld); components.Add(modelmgr); sfx = game.Content.Load <SoundEffect>(@"Audio/punch"); punch = sfx.CreateInstance(); punch.IsLooped = false; sfx = game.Content.Load <SoundEffect>(@"Audio/bgm"); bgm = sfx.CreateInstance(); bgm.IsLooped = true; bgm.Play(); }
public static void Add(this GameComponentCollection components, object component) { if (component == null) { throw new ArgumentNullException("component"); } components.Add(new GameComponentAdapter() { InnerComponent = component }); }
/// <summary> /// Add component to the screen and game. /// </summary> /// <param name="i_GameComponents">Game components.</param> public void AddComponents(params IGameComponent[] i_GameComponents) { foreach (GameComponent component in i_GameComponents) { m_gameComponentCollection.Add(component); component.Initialize(); if (component is DrawableGameComponent) { m_gameDrawableComponentCollection.Add(component); } if (!Game.Components.Contains(component)) { Game.Components.Add(component); } } if (ComponentAdded != null) { ComponentAdded.Invoke(i_GameComponents); } }
public DebugAudioData(Font font, List <string> outputNames) : base(@"DebugAudioData.glsl|vert", @"DebugAudioData.glsl|frag") { TextureBinds = () => { if (frameData != null) { frameData.GlobalTextures.AudioDataTex.Bind(TextureUnit.Texture0); } }; SetShaderUniforms = (sp) => { if (frameData != null && sp != null) { sp .SetUniform("audioDataTex", 0) .SetUniform("projectionMatrix", ProjectionMatrix) .SetUniform("modelMatrix", ModelMatrix) .SetUniform("viewMatrix", ViewMatrix) .SetUniform("currentPosition", frameData.GlobalTextures.SamplePositionRelative) .SetUniform("currentPositionEst", frameData.GlobalTextures.EstimatedSamplePositionRelative); } }; Loading += DebugAudioData_Loading; Unloading += DebugAudioData_Unloading; if (outputNames != null) { filterOutputNames.AddRange(outputNames); } components.Add(textManager = new TextManager("tm", font) { DrawOrder = 2 }); }
public void SetStateProfil() { Reset(); if (profil == null) { profil = new Profil(game); components.Add(profil); } else if (!components.Contains(profil)) { profil = null; profil = new Profil(game); components.Add(profil); profil.Menü = true; profil.Opt = true; profil.Esc = true; } inputFocus = profil; }
public T AddCompnent <T>(T comp) where T : IGameComponent { Components.Add(comp); return(comp); }
internal void addToComponents(GameComponentCollection gameComponents) { gameComponents.Add(bloom); gameComponents.Add(blur); }
public void AddChild(GameComponent component) { components.Add(component); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> public override void LoadContent() { if (content == null) { content = new ContentManager(ScreenManager.Game.Services, "Content"); } if (components == null) { components = ScreenManager.Game.Components; } if (graphics == null) { graphics = ScreenManager.GraphicsDevice; } // create the particle systems and add them to the components list. // we should never see more than one explosion at once explosion = new ExplosionParticleSystem(this, 1); components.Add(explosion); // but the smoke from the explosion lingers a while. smoke = new ExplosionSmokeParticleSystem(this, 2); components.Add(smoke); bloodSprayUp = new RetroBloodSprayWide(this, 100); bloodSprayRight = new RetroBloodSprayParticleSystem(this, 10); bloodSprayLeft = new RetroBloodSprayParticleSystem(this, 10); bloodSprayLeft.Dir = -1.0f; components.Add(bloodSprayUp); components.Add(bloodSprayRight); components.Add(bloodSprayLeft); // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(ScreenManager.Game.GraphicsDevice); // Load fonts hudFont = content.Load <SpriteFont>("Fonts/Hud"); // Load overlay textures winOverlay = content.Load <Texture2D>("Overlays/you_win"); loseOverlay = content.Load <Texture2D>("Overlays/you_lose"); diedOverlay = content.Load <Texture2D>("Overlays/you_died"); arrow = content.Load <Texture2D>("Sprites/arrow"); // Load sounds firstBloodSound = content.Load <SoundEffect>("Sounds/UT/firstblood"); dominatingSound = content.Load <SoundEffect>("Sounds/UT/dominating"); doublekillSound = content.Load <SoundEffect>("Sounds/UT/doublekill"); godlikeSound = content.Load <SoundEffect>("Sounds/UT/godlike"); holyshitSound = content.Load <SoundEffect>("Sounds/UT/holyshit"); killingspreeSound = content.Load <SoundEffect>("Sounds/UT/killingspree"); megakillSound = content.Load <SoundEffect>("Sounds/UT/megakill"); monsterKillSound = content.Load <SoundEffect>("Sounds/UT/monsterkill"); multikillSound = content.Load <SoundEffect>("Sounds/UT/multikill"); ultrakillSound = content.Load <SoundEffect>("Sounds/UT/ultrakill"); unstoppableSound = content.Load <SoundEffect>("Sounds/UT/unstoppable"); wickedsickSound = content.Load <SoundEffect>("Sounds/UT/wickedsick"); failSound = content.Load <SoundEffect>("Sounds/smb_gameover"); //Known issue that you get exceptions if you use Media PLayer while connected to your PC //See http://social.msdn.microsoft.com/Forums/en/windowsphone7series/thread/c8a243d2-d360-46b1-96bd-62b1ef268c66 //Which means its impossible to test this from VS. //So we have to catch the exception and throw it away try { MediaPlayer.IsRepeating = true; MediaPlayer.Play(content.Load <Song>("Sounds/Music/bgmusic1")); } catch { } //Create the players //Player 1 players.Add(new Player(this, Vector2.Zero, 0)); players.Add(new Player(this, Vector2.Zero, 1)); // Set player 2's colors players[1].LoadContent("Sprites/Player/cop_yellow_idle", "Sprites/Player/cop_yellow_running", "Sprites/Player/cop_yellow_jump", "Sprites/Player/cop_yellow_die", "Sprites/Player/cop_yellow_roll", "Sprites/Player/cop_yellow_grenade"); players[1].Flip = SpriteEffects.FlipHorizontally; LoadNextLevel(); }
/// <summary> /// Add const componenet (won't be removed from screen if it will be removed from the game) /// </summary> /// <param name="i_GameComponent"></param> protected void addConstComponents(IGameComponent i_GameComponent) { m_constGameComponentCollection.Add(i_GameComponent); AddComponents(i_GameComponent); }
public void Submit(SceneEntity obj) { collection.Add(obj); }
public void AddGameComponent(GameComponent gameComponent) { gameComponents.Add(gameComponent); }
public static void Add(this GameComponentCollection collection, IUpdatablePart component, Game game) { collection.Add(new UpdatableComponentWrapper(component, game)); }
public ParticleTestBench() : base(800, 600, GraphicsMode.Default, "Particles or summin or nuttin") { VSync = VSyncMode.Off; Load += ParticleTestBench_Load; Unload += ParticleTestBench_Unload; UpdateFrame += ParticleTestBench_UpdateFrame; RenderFrame += ParticleTestBench_RenderFrame; Resize += ParticleTestBench_Resize; // set default shader loader ShaderProgram.DefaultLoader = new OpenTKExtensions.Loaders.MultiPathFileSystemLoader(SHADERPATH); //OpenTK.Input.Keyboard.GetState() components.Add(camera = new WalkCamera() { FOV = 75.0f, ZFar = 10.0f, ZNear = 0.001f, MovementSpeed = 0.0001f, LookMode = WalkCamera.LookModeEnum.Mouse1, Position = new Vector3(0f, 0f, 0f), EyeHeight = 0f }, 1); components.Add(resources = new CommonResources()); // Particle model components.Add(model = new MotionParticleModel(particleArrayWidth, particleArrayHeight)); // Particle render target components.Add(particleRenderTarget = new PosVelColRenderTarget(particleArrayWidth, particleArrayHeight) { DrawOrder = 1, SetBuffers = (rt) => { rt.SetOutput(0, model.ParticlePositionWrite); rt.SetOutput(1, model.ParticleVelocityWrite); rt.SetOutput(2, model.ParticleColourWrite); } }); // particle operator particleRenderTarget.Add(new OperatorTest()); /* * particleRenderTarget.Add(particleOperator = new RaymarchOperator() * { * TextureBinds = () => * { * model.ParticlePositionRead.Bind(TextureUnit.Texture0); * model.ParticleVelocityRead.Bind(TextureUnit.Texture1); * model.ParticleColourRead.Bind(TextureUnit.Texture2); * }, * SetShaderUniforms = (sp) => * { * sp.SetUniform("time", (float)timer.Elapsed.TotalSeconds); * sp.SetUniform("particlePositionTexture", 0); * sp.SetUniform("particleVelocityTexture", 1); * sp.SetUniform("particleColourTexture", 2); * } * });*/ // Render particles components.Add(particleRenderer = new ColourParticleRenderer(particleArrayWidth, particleArrayHeight) { DrawOrder = 2, ParticlePositionTextureFunc = () => model.ParticlePositionWrite, ParticleColourTextureFunc = () => model.ParticleColourWrite }); }