/// <summary> /// Moves the destination x and y of the creature to the stairs' link's x&y destination /// </summary> public int UseStairs(DrawableComponent myCreatureDrawable, Direction myDirection) { // // //THIS MAY POP YOU IN A WEIRD POSITION// // // if (outputs[myDirection]!=null) { SpriteComponent stairsSprite = (SpriteComponent)outputs[myDirection].GetDrawable("Sprite"); if (myCreatureDrawable is SpriteComponent) { SpriteComponent sprite = myCreatureDrawable as SpriteComponent; sprite.Position = new Rectangle(stairsSprite.Position.X, stairsSprite.Position.Y, sprite.Position.Width, sprite.Position.Height); } if (myCreatureDrawable is AnimatedComponent) { AnimatedComponent sprite = myCreatureDrawable as AnimatedComponent; sprite.Position = new Rectangle(stairsSprite.Position.X, stairsSprite.Position.Y, sprite.Position.Width, sprite.Position.Height); } return 0; } else { return 1; } }
public void InitializeLevelEditor() { for (int l = 0; l < layersOfScenery.Length; l++) { layersOfScenery[l] = new List<DrawableComponent>(); } Entity originMarker = new Entity(22, GameState.LevelEditing); originMarker.AddComponent(new SpriteComponent(new Rectangle(-5, -5, 10, 10), grassTexture)); EntityManager.AddEntity(originMarker); // // //Main GUI// // // Entity toolbarBackdrop = new Entity(23, GameState.LevelEditing); SpriteComponent toolbarBackdropSprite = new SpriteComponent(new Rectangle(0, 0, 150, 600), grassTexture); toolbarBackdropSprite.IsGUI = true; toolbarBackdropSprite.OffsetRatio = new Vector2(0, 0); toolbarBackdrop.AddComponent(toolbarBackdropSprite); toolbarClickable = new ClickableComponent(new Vector2(75, 300), 150, 600); toolbarBackdrop.AddComponent(toolbarClickable); EntityManager.AddEntity(toolbarBackdrop); Entity tileButton = new Entity(24, GameState.LevelEditing); tileButtonSprite = new SpriteComponent(new Rectangle(25, 25, 50, 50), tileButtonTexture); tileButtonSprite.IsGUI = true; tileButton.AddComponent(tileButtonSprite); tileButtonClickable = new ClickableComponent(new Vector2(25, 25), 50, 50); tileButton.AddComponent(tileButtonClickable); EntityManager.AddEntity(tileButton); Entity sceneryButton = new Entity(24, GameState.LevelEditing); sceneryButtonSprite = new SpriteComponent(new Rectangle(75, 25, 50, 50), sceneryButtonTexture); sceneryButtonSprite.IsGUI = true; sceneryButtonSprite.Color = new Color(100, 100, 100); sceneryButton.AddComponent(sceneryButtonSprite); sceneryButtonClickable = new ClickableComponent(new Vector2(75, 25), 50, 50); sceneryButton.AddComponent(sceneryButtonClickable); EntityManager.AddEntity(sceneryButton); Entity objectiveButton = new Entity(24, GameState.LevelEditing); objectiveButtonSprite = new SpriteComponent(new Rectangle(125, 25, 50, 50), objectiveButtonTexture); objectiveButtonSprite.IsGUI = true; objectiveButtonSprite.Color = new Color(100, 100, 100); objectiveButton.AddComponent(objectiveButtonSprite); objectiveButtonClickable = new ClickableComponent(new Vector2(125, 25), 50, 50); objectiveButton.AddComponent(objectiveButtonClickable); EntityManager.AddEntity(objectiveButton); // // //Tile Tools// // // Entity tileHeader = new Entity(24, GameState.LevelEditing); TextComponent tileHeaderSprite = new TextComponent("Tile Type:", TextAlignment.left, new Vector2(10, 50), menuFont); tileHeader.AddComponent(tileHeaderSprite); tileHeaderSprite.IsGUI = true; EntityManager.AddEntity(tileHeader); tileToolSprites.Add(tileHeaderSprite); //The currently placed thing for tiles placingTile = new Entity(currentLayer, GameState.LevelEditing); placingTileSprite = new SpriteSheetComponent(new Rectangle(300, 300, 50, 50), tileSpriteSheet); placingTileSprite.setCurrentFrameX(2); placingTile.AddComponent(placingTileSprite); tileToolSprites.Add(placingTileSprite); placingTileSprite.Transparency = .5f; EntityManager.AddEntity(placingTile); Entity floorRadioButton = new Entity(24, GameState.LevelEditing); TextComponent floorRadioText = new TextComponent("Floor", TextAlignment.left, new Vector2(10, 100), menuFont); floorRadioText.IsGUI = true; floorRadioButton.AddComponent(floorRadioText); tileToolSprites.Add(floorRadioText); floorRadioSprite = new SpriteComponent(new Rectangle(120, 100, 25, 25), radioButtonTexture); floorRadioButton.AddComponent(floorRadioSprite); tileToolSprites.Add(floorRadioSprite); floorRadioSprite.Color = Color.Yellow; floorRadioSprite.IsGUI = true; floorRadioClickable = new ClickableComponent(new Vector2(120, 100), 25, 25); floorRadioButton.AddComponent(floorRadioClickable); EntityManager.AddEntity(floorRadioButton); Entity wallRadioButton = new Entity(24, GameState.LevelEditing); TextComponent wallRadioText = new TextComponent("Wall", TextAlignment.left, new Vector2(10, 125), menuFont); wallRadioButton.AddComponent(wallRadioText); tileToolSprites.Add(wallRadioText); wallRadioText.IsGUI = true; wallRadioSprite = new SpriteComponent(new Rectangle(120, 125, 25, 25), radioButtonTexture); wallRadioButton.AddComponent(wallRadioSprite); tileToolSprites.Add(wallRadioSprite); wallRadioSprite.IsGUI = true; wallRadioClickable = new ClickableComponent(new Vector2(120, 125), 25, 25); wallRadioButton.AddComponent(wallRadioClickable); EntityManager.AddEntity(wallRadioButton); Entity wallPaperRadioButton = new Entity(24, GameState.LevelEditing); TextComponent wallPaperRadioText = new TextComponent("WallPaper", TextAlignment.left, new Vector2(10, 150), menuFont); wallPaperRadioButton.AddComponent(wallPaperRadioText); tileToolSprites.Add(wallPaperRadioText); wallPaperRadioText.IsGUI = true; wallPaperRadioSprite = new SpriteComponent(new Rectangle(120, 150, 25, 25), radioButtonTexture); wallPaperRadioButton.AddComponent(wallPaperRadioSprite); tileToolSprites.Add(wallPaperRadioSprite); wallPaperRadioSprite.IsGUI = true; wallPaperRadioClickable = new ClickableComponent(new Vector2(120, 150), 25, 25); wallPaperRadioButton.AddComponent(wallPaperRadioClickable); EntityManager.AddEntity(wallPaperRadioButton); Entity windowRadioButton = new Entity(24, GameState.LevelEditing); TextComponent windowRadioText = new TextComponent("Window", TextAlignment.left, new Vector2(10, 175), menuFont); windowRadioButton.AddComponent(windowRadioText); tileToolSprites.Add(windowRadioText); windowRadioText.IsGUI = true; windowRadioSprite = new SpriteComponent(new Rectangle(120, 175, 25, 25), radioButtonTexture); windowRadioButton.AddComponent(windowRadioSprite); tileToolSprites.Add(windowRadioSprite); windowRadioSprite.IsGUI = true; windowRadioClickable = new ClickableComponent(new Vector2(120, 175), 25, 25); windowRadioButton.AddComponent(windowRadioClickable); EntityManager.AddEntity(windowRadioButton); // // //Scenery tools// // // placingScenery = new Entity(currentLayer, GameState.LevelEditing); placingScenerySprite = new SpriteComponent(new Rectangle(300, 300, 50, 50), sceneryOptions[0]); placingScenerySprite.SpriteWidth = sceneryOptions[currentSceneryOption].Width; placingScenerySprite.SpriteHeight = sceneryOptions[currentSceneryOption].Height; placingScenery.AddComponent(placingScenerySprite); sceneryToolSprites.Add(placingScenerySprite); placingScenerySprite.Visible = false; placingScenerySprite.Transparency = .5f; EntityManager.AddEntity(placingScenery); Entity layerNumberGUI = new Entity(24, GameState.LevelEditing); layerNumberText = new TextComponent("Layer: " + currentLayer.ToString(), TextAlignment.left, new Vector2(30, 75), menuFont); layerNumberText.IsGUI = true; layerNumberText.Visible = false; sceneryToolSprites.Add(layerNumberText); layerNumberGUI.AddComponent(layerNumberText); EntityManager.AddEntity(layerNumberGUI); Entity upLayerButton = new Entity(24, GameState.LevelEditing); SpriteComponent upLayerButtonSprite = new SpriteComponent(new Rectangle(75, 60, 50, 20), arrowTexture); upLayerButtonSprite.IsGUI = true; upLayerButtonSprite.Visible = false; upLayerButtonSprite.OffsetRatio = new Vector2(.5f, .5f); upLayerButton.AddComponent(upLayerButtonSprite); sceneryToolSprites.Add(upLayerButtonSprite); upLayerClickable = new ClickableComponent(new Vector2(75, 60), 50, 30); upLayerButton.AddComponent(upLayerClickable); EntityManager.AddEntity(upLayerButton); Entity downLayerButton = new Entity(24, GameState.LevelEditing); SpriteComponent downLayerButtonSprite = new SpriteComponent(new Rectangle(75, 125, 50, 20), arrowTexture); downLayerButtonSprite.Rotation = 3.14f; downLayerButtonSprite.IsGUI = true; downLayerButtonSprite.Visible = false; downLayerButtonSprite.OffsetRatio = new Vector2(.5f, .5f); downLayerButton.AddComponent(downLayerButtonSprite); sceneryToolSprites.Add(downLayerButtonSprite); downLayerClickable = new ClickableComponent(new Vector2(75, 125), 50, 30); downLayerButton.AddComponent(downLayerClickable); EntityManager.AddEntity(downLayerButton); Entity sceneryPreviewTitle = new Entity(24, GameState.LevelEditing); TextComponent sceneryPreviewText = new TextComponent("Preview:", TextAlignment.left, new Vector2(10, 260), menuFont); sceneryPreviewText.IsGUI = true; sceneryPreviewText.Visible = false; sceneryPreviewTitle.AddComponent(sceneryPreviewText); sceneryToolSprites.Add(sceneryPreviewText); EntityManager.AddEntity(sceneryPreviewTitle); Entity sceneryPreview = new Entity(24, GameState.LevelEditing); sceneryPreviewSprite = new SpriteComponent(new Rectangle(10, 325, 125, 100), sceneryOptions[0]); sceneryPreviewSprite.OffsetRatio = Vector2.Zero; sceneryPreviewSprite.Visible = false; sceneryPreviewSprite.IsGUI = true; sceneryToolSprites.Add(sceneryPreviewSprite); sceneryPreview.AddComponent(sceneryPreviewSprite); EntityManager.AddEntity(sceneryPreview); Entity upSceneryButton = new Entity(24, GameState.LevelEditing); SpriteComponent upSceneryButtonSprite = new SpriteComponent(new Rectangle(75, 300, 50, 20), arrowTexture); upSceneryButtonSprite.IsGUI = true; upSceneryButtonSprite.Visible = false; upSceneryButtonSprite.OffsetRatio = new Vector2(.5f, .5f); upSceneryButton.AddComponent(upSceneryButtonSprite); sceneryToolSprites.Add(upSceneryButtonSprite); upSceneryClickable = new ClickableComponent(new Vector2(75, 300), 50, 30); upSceneryButton.AddComponent(upSceneryClickable); EntityManager.AddEntity(upSceneryButton); Entity downSceneryButton = new Entity(24, GameState.LevelEditing); SpriteComponent downSceneryButtonSprite = new SpriteComponent(new Rectangle(75, 450, 50, 20), arrowTexture); downSceneryButtonSprite.Rotation = 3.14f; downSceneryButtonSprite.IsGUI = true; downSceneryButtonSprite.Visible = false; downSceneryButtonSprite.OffsetRatio = new Vector2(.5f, .5f); downSceneryButton.AddComponent(downSceneryButtonSprite); sceneryToolSprites.Add(downSceneryButtonSprite); downSceneryClickable = new ClickableComponent(new Vector2(75, 450), 50, 30); downSceneryButton.AddComponent(downSceneryClickable); EntityManager.AddEntity(downSceneryButton); // // //Objective// // // Entity objectiveHeader = new Entity(24, GameState.LevelEditing); TextComponent objectiveHeaderSprite = new TextComponent("Spawn:", TextAlignment.left, new Vector2(10, 50), menuFont); objectiveHeader.AddComponent(objectiveHeaderSprite); objectiveHeaderSprite.Visible = false; objectiveHeaderSprite.IsGUI = true; EntityManager.AddEntity(objectiveHeader); objectiveToolSprites.Add(objectiveHeaderSprite); Entity visitorSpawnRadioButton = new Entity(23, GameState.LevelEditing); TextComponent visitorSpawnRadioText = new TextComponent("Visitor", TextAlignment.left, new Vector2(10, 100), menuFont); visitorSpawnRadioButton.AddComponent(visitorSpawnRadioText); visitorSpawnRadioText.Visible = false; objectiveToolSprites.Add(visitorSpawnRadioText); playerSpawn = new Entity(22, GameState.LevelEditing); playerSpawnText = new TextComponent("P", TextAlignment.center, new Vector2(300, 300), menuFont); playerSpawn.AddComponent(playerSpawnText); EntityManager.AddEntity(playerSpawn); visitorSpawn = new Entity(currentLayer, GameState.LevelEditing); visitorSpawnText = new TextComponent("V", TextAlignment.center, new Vector2(400, 300), menuFont); visitorSpawnRadioText.IsGUI = true; visitorSpawn.AddComponent(visitorSpawnText); EntityManager.AddEntity(visitorSpawn); visitorSpawnRadioSprite = new SpriteComponent(new Rectangle(120, 100, 25, 25), radioButtonTexture); visitorSpawnRadioButton.AddComponent(visitorSpawnRadioSprite); visitorSpawnRadioSprite.Visible = false; visitorSpawnRadioSprite.IsGUI = true; visitorSpawnRadioSprite.Color = Color.Yellow; objectiveToolSprites.Add(visitorSpawnRadioSprite); visitorSpawnRadioClickable = new ClickableComponent(new Vector2(120, 100), 25, 25); visitorSpawnRadioButton.AddComponent(visitorSpawnRadioClickable); EntityManager.AddEntity(visitorSpawnRadioButton); Entity playerSpawnRadioButton = new Entity(23, GameState.LevelEditing); TextComponent playerSpawnRadioText = new TextComponent("Player", TextAlignment.left, new Vector2(10, 125), menuFont); playerSpawnRadioButton.AddComponent(playerSpawnRadioText); playerSpawnRadioText.Visible = false; playerSpawnRadioText.IsGUI = true; objectiveToolSprites.Add(playerSpawnRadioText); playerSpawnRadioSprite = new SpriteComponent(new Rectangle(120, 125, 25, 25), radioButtonTexture); playerSpawnRadioButton.AddComponent(playerSpawnRadioSprite); playerSpawnRadioSprite.Visible = false; playerSpawnRadioSprite.IsGUI = true; playerSpawnRadioSprite.Color = Color.White; objectiveToolSprites.Add(playerSpawnRadioSprite); playerSpawnRadioClickable = new ClickableComponent(new Vector2(120, 125), 25, 25); playerSpawnRadioButton.AddComponent(playerSpawnRadioClickable); EntityManager.AddEntity(playerSpawnRadioButton); }