示例#1
0
        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);
        }
示例#2
0
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
                Exit();

            EntityManager.Update(gameTime, currentGameState);

            switch (currentGameState)
            {
                case GameState.Ingame:

                    break;
                case GameState.LevelEditing:

                    Vector2 mousePosition = new Vector2(Mouse.GetState().X, Mouse.GetState().Y);

                    if (InputState.mouseLeftClick.Evaluate())
                    {
                        if (tileButtonClickable.isWithinRectangle(mousePosition))
                        {
                            foreach (DrawableComponent drawable in sceneryToolSprites)
                                drawable.Visible = false;
                            foreach (DrawableComponent drawable in tileToolSprites)
                                drawable.Visible = true;
                            foreach (DrawableComponent drawable in objectiveToolSprites)
                                drawable.Visible = false;

                            currentToolState = ToolState.Tile;
                            tileButtonSprite.Color = Color.White;
                            objectiveButtonSprite.Color = new Color(100, 100, 100);
                            sceneryButtonSprite.Color = new Color(100, 100, 100);
                        }
                        if (sceneryButtonClickable.isWithinRectangle(mousePosition))
                        {
                            foreach (DrawableComponent drawable in sceneryToolSprites)
                                drawable.Visible = true;
                            foreach (DrawableComponent drawable in tileToolSprites)
                                drawable.Visible = false;
                            foreach (DrawableComponent drawable in objectiveToolSprites)
                                drawable.Visible = false;

                            currentToolState = ToolState.Scenery;
                            tileButtonSprite.Color = new Color(100, 100, 100);
                            objectiveButtonSprite.Color = new Color(100, 100, 100);
                            sceneryButtonSprite.Color = Color.White;
                        }
                        if (objectiveButtonClickable.isWithinRectangle(mousePosition))
                        {
                            foreach (DrawableComponent drawable in sceneryToolSprites)
                                drawable.Visible = false;
                            foreach (DrawableComponent drawable in tileToolSprites)
                                drawable.Visible = false;
                            foreach (DrawableComponent drawable in objectiveToolSprites)
                                drawable.Visible = true;

                            currentToolState = ToolState.Objectives;
                            tileButtonSprite.Color = new Color(100, 100, 100);
                            objectiveButtonSprite.Color = Color.White;
                            sceneryButtonSprite.Color = new Color(100, 100, 100);
                        }
                        switch (currentToolState)
                        {
                            case ToolState.Tile:
                                if (floorRadioClickable.isWithinRectangle(mousePosition))
                                {
                                    currentTileType = TileType.Floor;

                                    floorRadioSprite.Color = Color.Yellow;
                                    windowRadioSprite.Color = Color.White;
                                    wallRadioSprite.Color = Color.White;
                                    wallPaperRadioSprite.Color = Color.White;

                                    placingTileSprite.setCurrentFrameX(2);
                                }
                                if (wallRadioClickable.isWithinRectangle(mousePosition))
                                {
                                    currentTileType = TileType.Wall;

                                    floorRadioSprite.Color = Color.White;
                                    windowRadioSprite.Color = Color.White;
                                    wallRadioSprite.Color = Color.Yellow;
                                    wallPaperRadioSprite.Color = Color.White;

                                    placingTileSprite.setCurrentFrameX(1);
                                }
                                if (wallPaperRadioClickable.isWithinRectangle(mousePosition))
                                {
                                    currentTileType = TileType.Wallpaper;

                                    floorRadioSprite.Color = Color.White;
                                    windowRadioSprite.Color = Color.White;
                                    wallRadioSprite.Color = Color.White;
                                    wallPaperRadioSprite.Color = Color.Yellow;

                                    placingTileSprite.setCurrentFrameX(4);
                                }
                                if (windowRadioClickable.isWithinRectangle(mousePosition))
                                {
                                    currentTileType = TileType.Glass;

                                    floorRadioSprite.Color = Color.White;
                                    windowRadioSprite.Color = Color.Yellow;
                                    wallRadioSprite.Color = Color.White;
                                    wallPaperRadioSprite.Color = Color.White;

                                    placingTileSprite.setCurrentFrameX(3);
                                }
                                if (!toolbarClickable.isWithinRectangle(mousePosition))
                                {
                                    Entity tile = new Entity(tileLayer, GameState.LevelEditing);
                                    SpriteSheetComponent tileSprite = new SpriteSheetComponent(new Rectangle((int)placingTileSprite.Destination.X,
                                                                                                        (int)placingTileSprite.Destination.Y,
                                                                                                        50, 50),
                                                                                                        tileSpriteSheet);
                                    tile.AddComponent(tileSprite);
                                    switch (currentTileType)
                                    {
                                        case TileType.Floor:
                                            tileSprite.setCurrentFrameX(2);
                                            break;
                                        case TileType.Wall:
                                            tileSprite.setCurrentFrameX(1);
                                            break;
                                        case TileType.Grass:
                                            tileSprite.setCurrentFrameX(0);
                                            break;
                                        case TileType.Wallpaper:
                                            tileSprite.setCurrentFrameX(4);
                                            break;
                                        case TileType.Glass:
                                            tileSprite.setCurrentFrameX(3);
                                            break;

                                    }
                                    TileComponent tileTile = new TileComponent(currentTileType);
                                    tile.AddComponent(tileTile);
                                    tiles.Add(tile);
                                    EntityManager.AddEntity(tile);

                                }
                                break;

                            case ToolState.Scenery:

                                if (upLayerClickable.isWithinRectangle(mousePosition))
                                {
                                    if (currentLayer < maxEditableLayer - 1)
                                    {
                                        currentLayer++;
                                        layerNumberText.Text = "Layer: " + currentLayer.ToString();

                                        UpdateLayerColor();
                                    }
                                }
                                else if (downLayerClickable.isWithinRectangle(mousePosition))
                                {
                                    if (currentLayer > 0)
                                    {
                                        currentLayer--;
                                        layerNumberText.Text = "Layer: " + currentLayer.ToString();

                                        UpdateLayerColor();
                                    }
                                }
                                else if (upSceneryClickable.isWithinRectangle(mousePosition))
                                {
                                    if (currentSceneryOption < sceneryOptions.Count - 1)
                                    {
                                        currentSceneryOption++;
                                        sceneryPreviewSprite.Texture = sceneryOptions[currentSceneryOption];
                                        placingScenerySprite.Texture = sceneryOptions[currentSceneryOption];
                                        placingScenerySprite.SpriteWidth = sceneryOptions[currentSceneryOption].Width;
                                        placingScenerySprite.SpriteHeight = sceneryOptions[currentSceneryOption].Height;
                                    }
                                }
                                else if (downSceneryClickable.isWithinRectangle(mousePosition))
                                {
                                    if (currentSceneryOption > 0)
                                    {
                                        currentSceneryOption--;
                                        sceneryPreviewSprite.Texture = sceneryOptions[currentSceneryOption];
                                        placingScenerySprite.Texture = sceneryOptions[currentSceneryOption];
                                        placingScenerySprite.SpriteWidth = sceneryOptions[currentSceneryOption].Width;
                                        placingScenerySprite.SpriteHeight = sceneryOptions[currentSceneryOption].Height;
                                    }
                                }
                                else if (!toolbarClickable.isWithinRectangle(mousePosition))
                                {
                                    //We arent clicking wihtin the toolbar
                                    Entity scenery = new Entity(currentLayer, GameState.LevelEditing);
                                    SpriteComponent scenerySprite = new SpriteComponent(new Rectangle(
                                        (int)mousePosition.X + (int)Camera.Pos.X,
                                        (int)mousePosition.Y + (int)Camera.Pos.Y,
                                        sceneryOptions[currentSceneryOption].Width, sceneryOptions[currentSceneryOption].Height),
                                        sceneryOptions[currentSceneryOption]);
                                    scenery.AddComponent(scenerySprite);
                                    layersOfScenery[currentLayer].Add(scenerySprite);
                                    EntityManager.AddEntity(scenery);

                                    UpdateLayerColor();
                                }
                                break;
                            case ToolState.Objectives:
                                if (playerSpawnRadioClickable.isWithinRectangle(mousePosition))
                                {
                                    visitorSpawnRadioSprite.Color = Color.White;
                                    playerSpawnRadioSprite.Color = Color.Yellow;
                                    objectiveToolState = ObjectiveToolState.PlayerSpawn;
                                }
                                else if (visitorSpawnRadioClickable.isWithinRectangle(mousePosition))
                                {
                                    objectiveToolState = ObjectiveToolState.VisitorSpawn;
                                    visitorSpawnRadioSprite.Color = Color.Yellow;
                                    playerSpawnRadioSprite.Color = Color.White;
                                }
                                else if (!toolbarClickable.isWithinRectangle(mousePosition))
                                {
                                    //If you are not pressing the toolbar
                                    if (objectiveToolState == ObjectiveToolState.PlayerSpawn)
                                    {
                                        playerSpawnText.Destination = new Vector2(mousePosition.X + Camera.Pos.X, mousePosition.Y + Camera.Pos.Y);
                                    }
                                    else if (objectiveToolState == ObjectiveToolState.VisitorSpawn)
                                    {
                                        visitorSpawnText.Destination = new Vector2(mousePosition.X + Camera.Pos.X, mousePosition.Y + Camera.Pos.Y);
                                    }

                                }

                                break;
                            default:
                                break;
                        }

                    }

                    if (InputState.upHold.Evaluate() && InputState.downHold.Evaluate())
                    {

                    }
                    if (InputState.leftHold.Evaluate() && InputState.rightHold.Evaluate())
                    {

                    }
                    if (InputState.upClick.Evaluate())
                    {
                        Camera.Move(new Vector2(0, -10));
                    }
                    if (InputState.rightClick.Evaluate())
                    {
                        Camera.Move(new Vector2(10, 0));
                    }
                    if (InputState.downClick.Evaluate())
                    {
                        Camera.Move(new Vector2(0, 10));
                    }
                    if (InputState.leftClick.Evaluate())
                    {
                        Camera.Move(new Vector2(-10, 0));
                    }

                    //Moving the current selection
                    switch (currentToolState)
                    {
                        case ToolState.Tile:
                            placingTileSprite.Destination = new Vector2((mousePosition.X + Camera.Pos.X) - ((mousePosition.X + Camera.Pos.X) % 50f), (mousePosition.Y + Camera.Pos.Y) - ((mousePosition.Y + Camera.Pos.Y) % 50));
                            break;
                        case ToolState.Scenery:
                            placingScenerySprite.Destination = new Vector2(mousePosition.X + Camera.Pos.X, mousePosition.Y + Camera.Pos.Y);
                            break;
                        case ToolState.Objectives:
                            break;
                    }
                    break;
            }

            base.Update(gameTime);
        }
示例#3
0
        static Entity PopulateTile(uint color, int x, int y, int width, int height, int layer)
        {
            Entity tileEntity = new Entity(layer + 2, GameState.Ingame);

            SpriteComponent sprite;
            TileComponent tile;
            switch (color)
            {
                case LevelKey.Grass:
                    sprite = new SpriteComponent(new Rectangle(x * width, y * height, width, height), Game1.grassTexture);
                    tile = new TileComponent(TileType.Grass);
                    break;
                case LevelKey.Floor:
                    sprite = new SpriteComponent(new Rectangle(x * width, y * height, width, height), Game1.floorTexture);
                    tile = new TileComponent(TileType.Floor);
                    break;
                case LevelKey.Wall:
                    sprite = new SpriteComponent(new Rectangle(x * width, y * height, width, height), Game1.wallTexture);
                    tile = new TileComponent(TileType.Wall);
                    break;
                case LevelKey.Wallpaper:
                    sprite = new SpriteComponent(new Rectangle(x * width, y * height, width, height), Game1.wallpaperTexture);
                    tile = new TileComponent(TileType.Wallpaper);
                    break;
                case LevelKey.Glass:
                    sprite = new SpriteComponent(new Rectangle(x * width, y * height, width, height), Game1.glassTexture);
                    tile = new TileComponent(TileType.Glass);
                    break;
                default:
                    sprite = new SpriteComponent(new Rectangle(x * width, y * height, width, height), Game1.grassTexture);
                    tile = new TileComponent(TileType.Glass);
                    break;
            }
            tileEntity.AddComponent(sprite);
            tileEntity.AddComponent(tile);

            return tileEntity;
        }