public DrawableScreen() { this.drawables = new List<Drawable>(); this.drawablesToUpdate = new List<Drawable>(); this.drawablesToDraw = new List<Drawable>(); this.gameCollection = new GameComponentCollection(); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); tc = new TestComponent(); GameComponentCollection gcc = Components; Stream stream = new FileStream("sdfsdf", System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.None); // TODO: use this.Content to load your game content here }
public static SceneHandler CreateSceneHandler(GameComponentCollection gameComponents, GraphicsDevice graphicsDevice, ContentManager contentManager) { var scene = new MenuScene(); var sceneHandler = new SceneHandler(scene, gameComponents, graphicsDevice, contentManager); scene.SetSceneHandler(sceneHandler); sceneHandler.LoadScene(); return(sceneHandler); }
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 BaseScene(MainGame game) : base(game) { Components = new GameComponentCollection(); Components.ComponentAdded += Components_ComponentAdded; Components.ComponentRemoved += Components_ComponentRemoved; _drawables = new List <IDrawable>(); _updateables = new List <IUpdateable>(); }
public GameScene(Game game) : base(game) { renderTarget2D = new RenderTarget2D(game.GraphicsDevice, SosEngine.Core.RenderWidth, SosEngine.Core.RenderHeight); backgroundColor = Color.Black; gameComponents = new GameComponentCollection(); gameComponentsToRemove = new List <IGameComponent>(); tasks = new List <Tasks.Task>(); highlighedSprites = new List <Sprite>(); }
/// <summary> /// Constructor of class. /// </summary> /// <param name="game">The instance of game that is running.</param> /// <param name="priority">Drawing priority of screen. Higher indicates that the screen will be at the top of the others.</param> public IScreen(Game game, int priority) : base(game) { this.ComponentsField = new GameComponentCollection(); this.Enabled = false; this.Visible = false; this.Initialized = false; this.Priority = priority; }
private SyncedGameCollection(Game game) : base(game) { if (componentCollection != null) { componentCollection.Clear(); } else { componentCollection = new GameComponentCollection(); } }
public static void Insert(this GameComponentCollection components, int index, object component) { if (component == null) { throw new ArgumentNullException("component"); } components.Insert(index, new GameComponentAdapter() { InnerComponent = component }); }
public static void Add(this GameComponentCollection components, object component) { if (component == null) { throw new ArgumentNullException("component"); } components.Add(new GameComponentAdapter() { InnerComponent = component }); }
public VisualComponent(Game game) : base(game) { Game.Components.Add(this); components = new GameComponentCollection(); sortedComponents = new GameComponentCollection(); components.ComponentAdded += new EventHandler <GameComponentCollectionEventArgs>(components_ComponentAdded); components.ComponentRemoved += new EventHandler <GameComponentCollectionEventArgs>(components_ComponentRemoved); StackOrder = 0; neededDrawOrders = 0; Visible = true; isVisible = true; }
public static GameComponent GetCompByName(String name, GameComponentCollection compList) { foreach (GameComponent comp in compList) { foreach (GameComponent c in comp.Children) { Identifier idComp = c as Identifier; if (idComp != null && idComp.Name == name) return comp; } } return NullGameComponent.Instance; }
/// <summary> /// Creates a new instance of a game host panel. /// </summary> protected WpfGame(string contentDir = "ContentOutput") { if (string.IsNullOrEmpty(contentDir)) { throw new ArgumentNullException(nameof(contentDir)); } _contentDir = contentDir; Focusable = true; Components = new GameComponentCollection(); _sortedDrawables = new List <IDrawable>(); _sortedUpdateables = new List <IUpdateable>(); }
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 Remove(this GameComponentCollection components, object component) { if (component == null) { throw new ArgumentNullException("component"); } var item = components.FirstOrDefault(c => (c is GameComponentAdapter) && ((GameComponentAdapter)c).InnerComponent == component); if (item != null) { components.Remove(item); } }
/// <summary> /// Releases unmanaged and - optionally - managed resources /// </summary> /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param> protected override void Dispose(bool disposing) { if (_children != null) { foreach (IGameComponent child in Children) { child.Dispose(); } _children.Clear(); } if (disposing) { _children = null; ActionProcessor = null; } }
public GameStateWorld(GameComponentCollection mainCollection, InputManager input, WorldManager world, DebugManager debug, Player player, GuiManager gui, Game game, AlttpConsole console) : base(mainCollection, world, debug, console) { _input = input; _world = world; _debug = debug; _player = player; _gui = gui; _game = game; _console = console; RegisterComponents(); Initialize(); }
public static BaseObject FindObject(GameComponentCollection components, string name) { foreach (GameComponent component in components) { if (component is BaseObject) { BaseObject obj = component as BaseObject; if (obj.Name == name) { return(obj); } } } return(null); }
/// <summary> /// Creates a new instance of a game host panel. /// </summary> protected WpfGame(GraphicsDevice graphics, string contentDir = "Content") : base(graphics) { if (string.IsNullOrEmpty(contentDir)) { throw new ArgumentNullException(nameof(contentDir)); } Content = new ContentManager(Services, contentDir); Focusable = true; Components = new GameComponentCollection(); _sortedDrawables = new List <IDrawable>(); _sortedUpdateables = new List <IUpdateable>(); }
public GameUpdateClassComponents(MouseState curMouseState, ContentManager Content, Model.StaticTextureImages staticTextureImages, Model.StaticFonts staticFonts, Game1 _This, GameComponentCollection Components, GraphicsDevice graphicsDevice, int screenWidth, int screenHeight) { _curMouseState = curMouseState; _Content = Content; _staticTextureImages = staticTextureImages; _staticFonts = staticFonts; _this = _This; _Components = Components; _graphicsDevice = graphicsDevice; _screenWidth = screenWidth; _screenHeight = screenHeight; _isNull = false; }
/// <summary> /// GameScreen abstract constructor. /// </summary> /// <param name="i_ScreensManager">Screen Manager.</param> /// <param name="i_BackgroundTexture">Background texture name.</param> public GameScreen(ScreensManager i_ScreensManager, string i_BackgroundTexture) : base(i_ScreensManager.Game) { Enabled = false; Visible = false; m_gameComponentCollection = new GameComponentCollection(); m_gameDrawableComponentCollection = new GameComponentCollection(); m_constGameComponentCollection = new GameComponentCollection(); Game.Components.ComponentRemoved += components_ComponentRemoved; ScreensManager = i_ScreensManager; Vector2 backgroundProportion = Vector2.One; m_background = new Sprite(this, i_BackgroundTexture, Color.White, backgroundProportion); m_background.DrawOrder = -2; addConstComponents(m_background); }
public Placeable GetCollidingPlaceable(Rectangle bouncer) { GameComponentCollection components = game.Components; foreach (GameComponent component in components) { if (!component.Equals(this)) { if (bouncer.Intersects(((Placeable)component).bouncingBox)) { return((Placeable)component); } } } return(null); }
// Look for a game component marked with a SampleAttribute. private static bool FindSample(GameComponentCollection gameComponents, out string sampleName, out SampleAttribute sampleAttribute) { foreach (var gameComponent in gameComponents) { var type = gameComponent.GetType(); sampleAttribute = SampleAttribute.GetSampleAttribute(type); if (sampleAttribute != null) { // Sample found. sampleName = type.Name; return(true); } } // No sample found. sampleName = null; sampleAttribute = null; return(false); }
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 void ApplyMovementVelocity(Vector2 positionShift) { GameComponentCollection components = game.Components; foreach (GameComponent component in components) { if (!component.Equals(this)) { if (component.GetType().Equals(typeof(Placeable))) { // See if the item is not penetrable if (!((Placeable)component).Incollidable) { //See if it is moveable if (((Placeable)component).Moveable) { // Pushing objects Rectangle bouncer = CreateCollisionRectangle(positionShift); if (bouncer.Intersects(((Placeable)component).BoundingBox)) { if (this.position.Y > ((Placeable)component).Position.Y - bouncer.Height / 2 && this.position.Y < ((Placeable)component).Position.Y + bouncer.Height / 2) { ((Placeable)component).Velocity += new Vector2(this.velocity.X, 0); } } // Moving objects by rolling on them bouncer = CreateCollisionRectangle(new Vector2(0, 1)); if (bouncer.Intersects(((Placeable)component).BoundingBox)) { if (this.position.Y <= ((Placeable)component).Position.Y) { ((Placeable)component).Velocity -= new Vector2(this.velocity.X, 0); } } } } } } } }
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 Placeable GetCollidingPlaceable(Vector2 positionShift) { GameComponentCollection components = game.Components; foreach (GameComponent component in components) { if (!component.Equals(this)) { if (component.GetType().Equals(typeof(Placeable))) { Placeable placeable = (Placeable)component; Rectangle bouncer = CreateCollisionRectangle(positionShift); if (bouncer.Intersects(placeable.bouncingBox)) { return(placeable); } } } } return(null); }
public bool GetWillCollideWithOtherGameComponents(Vector2 positionShift) { GameComponentCollection components = game.Components; Rectangle bouncer; // See if we are going to go outside the game area's borders, not intersecting with the area borders bouncer = CreateCollisionRectangle(positionShift); bouncer.Inflate(-this.animation.Width + 1, -this.animation.Height + 1); if (!bouncer.Intersects(this.areaBorders)) { return(true); } // Collisions with game components bouncer = CreateCollisionRectangle(positionShift); foreach (GameComponent component in components) { if (!component.Equals(this)) { if (component.GetType().Equals(typeof(Placeable))) { Placeable placeable = (Placeable)component; // if the object we are colliding with is not incollidable // or the object colliding is incollidable if (!placeable.Incollidable || this.Incollidable) { if (bouncer.Intersects(placeable.bouncingBox)) { return(true); } } } } } return(false); }
public void DumpDebugInfo(GameComponentCollection collection) { if (m_streamWriter != null) { StringBuilder stringBuilder = new StringBuilder(); // timestamp stringBuilder.AppendLine("Timestamp : " + DateTime.Now.ToString()); foreach (GameComponent gc in collection) { IDebuggable i = gc as IDebuggable; if (i != null) { i.DumpDebugInfo(stringBuilder); stringBuilder.AppendLine(); stringBuilder.AppendLine("--------------------------------------------------------------------------"); stringBuilder.AppendLine(); } } m_streamWriter.Write(stringBuilder.ToString()); m_streamWriter.Flush(); } }
public Screen(Game game) : base(game) { GameComponents = new GameComponentCollection(); }
/// <summary> /// Runs the demo. /// </summary> public void Run(GameConfiguration demoConfiguration) { _demoConfiguration = demoConfiguration ?? new GameConfiguration(); _form = CreateForm(_demoConfiguration); Components = new GameComponentCollection(); Initialize(_demoConfiguration); bool isFormClosed = false; bool formIsResizing = false; _form.MouseClick += HandleMouseClick; _form.KeyDown += HandleKeyDown; _form.KeyUp += HandleKeyUp; _form.Resize += (o, args) => { if (_form.WindowState != _currentFormWindowState) { HandleResize(o, args); } _currentFormWindowState = _form.WindowState; }; _form.ResizeBegin += (o, args) => { formIsResizing = true; }; _form.ResizeEnd += (o, args) => { formIsResizing = false; HandleResize(o, args); }; _form.Closed += (o, args) => { isFormClosed = true; }; LoadContent(); clock.Start(); BeginRun(); RenderLoop.Run(_form, () => { if (isFormClosed) { return; } OnUpdate(); if (!formIsResizing) Render(); }); UnloadContent(); EndRun(); // Dispose explicity Dispose(); }
public override void Initialize() { Components = new GameComponentCollection(); DrawableComponents = new DrawableComponentCollection(); base.Initialize(); }
public GameComponent() { Children = new GameComponentCollection(); Triggers = new List<Trigger>(); }
/// <summary> /// Initializes a new instance of the <see cref="GameState"/> class. /// </summary> /// <param name="name">The name.</param> protected GameState(string name) { Name = name; Components = new GameComponentCollection(); StateVariables = new ExpandoObject(); }
/// <summary> /// Initializes a new instance of the <see cref="GameComponent"/> class. /// </summary> protected GameComponent() { _children = new GameComponentCollection(); }
public Renderer(ICanyonShooterGame game, GameComponentCollection gameComponents) { this.game = game; this.gameComponents = gameComponents; camera = new PerspectiveCamera(game); }
public void Init() { game = new TestGame(true); components = game.Components; }
internal static T FirstOfType <T>(this GameComponentCollection components) where T : IGameComponent { return((T)components.First(c => c.GetType() == typeof(T))); }
private NullGameComponent() { Children = new GameComponentCollection(); }