/// <summary> /// Generate background above our walkable layer and add them to our LevelScreen /// </summary> private void GenerateBackgroundAboveWalkableLayer() { int backgroundHeight = 4; int minY = walkingLayerPoints[0].Key.Y; string background = "Level\\Tiles\\BGTile (3)"; while (walkingLayerPoints.Exists(x => x.Key.Y < minY)) { minY = walkingLayerPoints.Find(x => x.Key.Y < minY).Key.Y; } for (int index = 0; index < walkingLayerPoints.Count; index++) { KeyValuePair <Point, Type> info = walkingLayerPoints[index]; // Want to create a background image behind our hazard so need to increment the currentPoint y by 1 so we start underneath our hazard Point currentPoint = info.Key; if (info.Value == Type.kHazard) { currentPoint.Y++; } for (int y = currentPoint.Y - 1; y > minY - 1 - backgroundHeight; y--) { Image addedObject = LevelScreen.AddEnvironmentObject(new Image(new Vector2(currentPoint.X, y) * TileDimensions, background)); addedObject.UsesCollider = false; } if (index % 3 == 0) { LevelScreen.AddLight(new PointLight(new Vector2(750, 750), new Vector2(currentPoint.X * TileDimensions.X, (minY - 1) * TileDimensions.Y), Color.White)); } } }
public NosamGame() { graphics = new GraphicsDeviceManager(this); graphics.PreferredBackBufferWidth = screenWidth; graphics.PreferredBackBufferHeight = screenHeight; graphics.SynchronizeWithVerticalRetrace = true; device = graphics.GraphicsDevice; Mouse.WindowHandle = Window.Handle; this.IsMouseVisible = true; Content.RootDirectory = "Content"; ScreenRectangle = new Rectangle(0, 0, screenWidth, screenHeight); Components.Add(new InputHandler(this)); stateManager = new GameStateManager(this); Components.Add(stateManager); StartMenuScreen = new StartMenuScreen(this, stateManager); NewGameScreen = new NewGameScreen(this, stateManager); LevelScreen = new LevelScreen(this, stateManager); stateManager.ChangeState(StartMenuScreen); this.IsFixedTimeStep = false; graphics.SynchronizeWithVerticalRetrace = false; }
public void Initialize(LevelScreen levelScreen, IntoTheBlaze game) { this.levelScreen = levelScreen; this.game = game; Position = Vector2.Zero; rotation = 90; Reset(); }
public void endDialogue(string levelUid) { ScreenSystem screenSystem = _systemManager.getSystem(SystemType.Screen) as ScreenSystem; LevelScreen levelScreen = screenSystem.getScreen(ScreenType.Level) as LevelScreen; _entityManager.removeComponent(levelUid, _currentEntityA, ComponentType.InDialogue); _entityManager.removeComponent(levelUid, _currentEntityB, ComponentType.InDialogue); levelScreen.removeDialoguePane(_currentDialogueComponent); }
public override void Initialize(GameScreen parentScreen) { base.Initialize(parentScreen); LevelScreen screen = (LevelScreen)parentScreen; Behaviour = screen.BehaviourFactory.Create <AIControlledEntity>( Settings.BehaviourName); }
// Checks if the collision is a new screen and moves appropriately public void UpdateCameraScreen(Collider2D collision) { LevelScreen newScreen = collision.gameObject.GetComponentInParent <LevelScreen>(); if (newScreen != currentScreen) { currentScreen = newScreen; } }
private void Awake() { levelScreen = FindObjectOfType <LevelScreen>(); controller = new Controller(1.85f); wFront = wheelFront.transform.GetComponent <Wheel>(); wBack = wheelBack.transform.GetComponent <Wheel>(); carpet = FindObjectOfType <Carpet>(); }
public void beginDialogue(string levelUid, int entityA, int entityB, CharacterDialogueComponent dialogueComponent) { ScreenSystem screenSystem = _systemManager.getSystem(SystemType.Screen) as ScreenSystem; LevelScreen levelScreen = screenSystem.getScreen(ScreenType.Level) as LevelScreen; _currentEntityA = entityA; _currentEntityB = entityB; _currentDialogueComponent = dialogueComponent; _entityManager.addComponent(levelUid, entityA, new InDialogueComponent()); _entityManager.addComponent(levelUid, entityB, new InDialogueComponent()); levelScreen.addDialoguePane(dialogueComponent); }
/// <summary> /// Adds the hazards and walkable layers to our LevelScreen Environment manager - this should happen after we add our background objects so the draw order is correct /// </summary> private void AddObjectsInFrontOfBackground() { for (int y = 0; y < GenerationData.Height; y++) { for (int x = 0; x < GenerationData.Width; x++) { if (LevelObjects[y, x] != null) { // Do we want to add environment objects for these guys? // Or should it be game objects? LevelScreen.AddEnvironmentObject(LevelObjects[y, x]); } } } }
public override void Initialize(GameScreen parentScreen) { base.Initialize(parentScreen); if (Settings.Physics != null) { var body = BodyFactory.CreateRectangle( parentScreen.Physics.World, Settings.Physics.Width * Settings.Scale.X, Settings.Physics.Height * Settings.Scale.Y, Settings.Physics.Density, ConvertUnits.ToSimUnits(Settings.Position), Settings.Physics.Offset); body.Enabled = false; body.FixtureList[0].CollidesWith = (Category)Settings.Physics.CollidesWith; body.FixtureList[0].CollisionCategories = (Category)Settings.Physics.Category; body.FixtureList[0].CollisionGroup = Settings.Physics.CollisionGroup; if (Settings.PhysicsFixture2 != null) { Fixture fix2 = FixtureFactory.AttachRectangle( Settings.PhysicsFixture2.Width, Settings.PhysicsFixture2.Height, Settings.PhysicsFixture2.Density, Settings.PhysicsFixture2.Offset, body); fix2.CollidesWith = (Category)Settings.PhysicsFixture2.CollidesWith; fix2.CollisionCategories = (Category)Settings.PhysicsFixture2.Category; fix2.CollisionGroup = Settings.PhysicsFixture2.CollisionGroup; } body.BodyType = BodyType.Dynamic; body.Inertia = Settings.Physics.RotationalInertia; physics = new PhysicsStructure { Bodies = { body } }; physics.Enabled = Settings.ActivateByDefault; } this.LevelScreen = (LevelScreen)parentScreen; }
/// <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() { graphics.ApplyChanges(); titleScreen = new TitleScreen(); levelScreen = new LevelScreen(); endScreen = new EndScreen(); if (LEVEL_DESIGN_MODE) { currentScreen = levelScreen; } else { currentScreen = titleScreen; // Choose starting screen; } titleScreen.Initialize(); levelScreen.Initialize(); endScreen.Initialize(); base.Initialize(); }
public IntoTheBlaze() { graphics = new GraphicsDeviceManager(this) { PreferredBackBufferWidth = 1024, PreferredBackBufferHeight = 640 }; Window.Title = "Into The Blaze"; graphics.ApplyChanges(); Content.RootDirectory = "Content"; MenuScreen = new MenuScreen(); LevelSelectScreen = new LevelSelectScreen(); CreditsScreen = new CreditsScreen(); LevelScreen = new LevelScreen(); LevelEndScreen = new LevelEndScreen(); screen = null; updateFps = new Queue <float>(); updateFps.Enqueue(0); drawFps = new Queue <float>(); drawFps.Enqueue(0); }
public Game1() { _graphics = new GraphicsDeviceManager(this); ScreenRectangle = new Rectangle( 0, 0, ScreenWidth, ScreenHeight); IsMouseVisible = true; Content.RootDirectory = "Content"; Components.Add(new InputHandler(this)); _gameStateManager = new GameStateManager(this); Components.Add(_gameStateManager); _ = new TextureManager(); TitleScreen = new TitleScreen(this, _gameStateManager); StartMenuScreen = new StartMenuScreen(this, _gameStateManager); GamePlayScreen = new GamePlayScreen(this, _gameStateManager); CharacterGeneratorScreen = new CharacterGeneratorScreen(this, _gameStateManager); SkillScreen = new SkillScreen(this, _gameStateManager); LoadGameScreen = new LoadGameScreen(this, _gameStateManager); ConversationScreen = new ConversationScreen(this, _gameStateManager); ShopScreen = new ShopState(this, _gameStateManager); InventoryScreen = new InventoryScreen(this, _gameStateManager); CombatScreen = new CombatScreen(this, _gameStateManager); GameOverScreen = new GameOverScreen(this, _gameStateManager); LootScreen = new LootScreen(this, _gameStateManager); StatsScreen = new StatsScreen(this, _gameStateManager); LevelScreen = new LevelScreen(this, _gameStateManager); QuestCompleteState = new QuestCompleteState(this, _gameStateManager); _gameStateManager.ChangeState(TitleScreen); IsFixedTimeStep = false; _graphics.SynchronizeWithVerticalRetrace = false; }
/// <summary> /// Generate background below our walkable layer and add them to our LevelScreen /// </summary> private void GenerateBackgroundBelowWalkableLayer() { Dictionary <Position, string> belowWalkableLayer = new Dictionary <Position, string>() { //{ Position.kLeft, "Level\\Tiles\\Tile (4)" }, { Position.kLeft, GenerationData.AboveWalkableLayerTextureAsset }, { Position.kMiddle, GenerationData.AboveWalkableLayerTextureAsset }, { Position.kRight, GenerationData.AboveWalkableLayerTextureAsset }, //{ Position.kRight, "Level\\Tiles\\Tile (6)" }, }; for (int index = 0; index < walkingLayerPoints.Count; index++) { Point point = walkingLayerPoints[index].Key; Position positionType = (Position)LevelObjects[point.Y, point.X].StoredObject; for (int y = point.Y + 1; y < GenerationData.Height; y++) { Image addedObject = LevelScreen.AddEnvironmentObject(new Image(new Vector2(point.X * TileDimensions.X, y * TileDimensions.Y), belowWalkableLayer[positionType])); addedObject.UsesCollider = false; } } }
protected override void Update(GameTime gameTime) { switch (_gameState) { case GameState.Initializing: Logger.log("Initializing in LoderGame.Update"); _gameState = GameState.Intro; handleArgs(); break; case GameState.Intro: Logger.log("In Intro game state in LoderGame.Update"); // TODO: Do some sort of intro, and then open the main menu Logger.log("Creating background object."); Background background = new Background(ResourceManager.getResource("main_menu_background")); Logger.log("Creating main menu screen."); _mainMenuScreen = new MainMenuScreen(this); Logger.log("Loading background textures."); background.loadTextures(); _menuBackgroundRenderer.background = background; Logger.log("Changing game state to MainMenu."); openMainMenu(true); _gameState = GameState.MainMenu; break; case GameState.MainMenu: _menuBackgroundScreenOffset += new Vector2(0.005f, 0f); _menuBackgroundRenderer.update(35f, _menuBackgroundScreenOffset); _systemManager.process(gameTime); break; case GameState.WorldMap: _systemManager.process(gameTime); break; case GameState.LoadingLevel: _systemManager.process(gameTime); if (!_levelSystem.isFinishedLoading) { _levelSystem.load(); } else if (_levelSystem.isFinishedLoading && !_levelSystem.finalized) { _levelSystem.relax(); _levelSystem.clean(); _levelSystem.callScripts(); _levelSystem.finalized = true; _levelSystem.switchToLevel(_levelSystem.lastLevelUidLoaded, _levelSystem.getPlayerSpawn(_levelSystem.lastLevelUidLoaded)); _loadingScreen.message = "Starting level!"; _screenSystem.addTransition(new ScreenFadeOutTransition(_loadingScreen, Color.Black, true, 0.05f, null, () => { _screenSystem.removeScreen(_loadingScreen); _gameState = GameState.Level; IsFixedTimeStep = true; _levelSystem.paused = false; _levelScreen = new LevelScreen(this, _systemManager, _entityManager); _screenSystem.addScreen(_levelScreen); _screenSystem.addTransition(new ScreenFadeInTransition(_levelScreen, Color.Black, true, 0.025f)); })); } break; case GameState.Level: _systemManager.process(gameTime); break; } base.Update(gameTime); }
static void Main() { Logger.Log(Logger.LogLevel.DEBUG, "Beginning of the graphic application"); using (var game = new LevelScreen()) game.Run(); }