Exemplo n.º 1
0
        public void Initialize(Game1 myGame, Vector2 coords, CameraController c, SoundManager soundManager)
        {
            //200 milliseconds
            Time      = new TimeSpan(0, 0, 0, 0, 150);
            ClickTime = new TimeSpan(0, 0, 0, 0, 400);
            game      = myGame;

            camera   = c;
            location = coords;
            sm       = soundManager;

            path = string.Concat(Environment.CurrentDirectory, @"\Levels\");

            extremes = new Vector4(Game1.graphics.PreferredBackBufferWidth, 0, Game1.graphics.PreferredBackBufferHeight, Game1.graphics.PreferredBackBufferHeight);

            blocks  = new List <IBlock>();
            pipes   = new List <IPipe>();
            enemies = new List <IEnemy>();
            items   = new List <IItem>();
            players = new List <IPlayer>();

            displayBlocks  = new List <IBlock>();
            displayPipes   = new List <IPipe>();
            displayEnemies = new List <IEnemy>();
            displayItems   = new List <IItem>();
            displayPlayers = new List <IPlayer>();

            EditUtility.InitTypeDicts(blockDict, pipeDict, enemyDict, itemDict, playerDict);
            InitBlocks();
            InitPipes();
            InitEnemies();
            InitItems();
            InitPlayers();

            optionsIndex = 0;

            options = new List <ActionText>();
            options.Add(new ActionText("Blocks", zeroVector, new Vector2(80, 16)));
            options.Add(new ActionText("Pipes", zeroVector, new Vector2(80, 16)));
            options.Add(new ActionText("Enemies", zeroVector, new Vector2(80, 16)));
            options.Add(new ActionText("Items", zeroVector, new Vector2(80, 16)));
            options.Add(new ActionText("Players", zeroVector, new Vector2(80, 16)));
            saveAction = new ActionText("Save Level", new Vector2(150, 0), new Vector2(100, 16));
            loadAction = new ActionText("Load Level", new Vector2(320, 0), new Vector2(100, 16));

            string[] files = System.IO.Directory.GetFiles(path);

            saveTextBox = new TextBox(new Vector2(125, 75), fileExt, "Type desired level name \n      then press ENTER", new Vector2(165, 85), new Vector2(125, 150));

            loadTextBox = new TextBox(new Vector2(125, 75), files, "Left Click a level to load", new Vector2(140, 85), new Vector2(125, 150));

            players.Add(new Mario(new Vector2(Game1.graphics.PreferredBackBufferWidth / 2, Game1.graphics.PreferredBackBufferHeight / 2), sm));
        }
Exemplo n.º 2
0
        public void CheckMouseDisplayCollisions(ActionText option, Rectangle mouseRect, Rectangle previousMouseRect, List <IBlock> displayBlocks, List <IPipe> displayPipes, List <IEnemy> displayEnemies, List <IItem> displayItems, List <IPlayer> displayPlayers, List <IBlock> blocks, List <IPipe> pipes, List <IEnemy> enemies, List <IItem> items, List <IPlayer> players)
        {
            int x = mouseRect.X;
            int y = mouseRect.Y;

            Rectangle r = new Rectangle(x, y, 1, 1);

            if (option.GetOption().Equals("Blocks"))
            {
                foreach (IBlock displayBlock in displayBlocks)
                {
                    if (mouseRect.Intersects(displayBlock.GetRectangle()))
                    {
                        EditUtility.blockCreator(displayBlock, blockDict, blocks, x, y);
                    }
                }
            }
            else if (option.GetOption().Equals("Pipes"))
            {
                foreach (IPipe displayPipe in displayPipes)
                {
                    if (mouseRect.Intersects(displayPipe.GetRectangle()))
                    {
                        EditUtility.pipeCreator(displayPipe, pipeDict, pipes, x, y);
                    }
                }
            }
            else if (option.GetOption().Equals("Enemies"))
            {
                foreach (IEnemy displayEnemy in displayEnemies)
                {
                    if (mouseRect.Intersects(displayEnemy.GetRectangle()))
                    {
                        EditUtility.enemyCreator(displayEnemy, enemyDict, enemies, x, y);
                    }
                }
            }
            else if (option.GetOption().Equals("Items"))
            {
                foreach (IItem displayItem in displayItems)
                {
                    if (mouseRect.Intersects(displayItem.GetRectangle()))
                    {
                        EditUtility.itemCreator(displayItem, itemDict, items, x, y);
                    }
                }
            }
            else if (option.GetOption().Equals("Players"))
            {
                foreach (IPlayer displayPlayer in displayPlayers)
                {
                    if (mouseRect.Intersects(displayPlayer.GetRectangle()))
                    {
                        EditUtility.playerCreator(displayPlayer, playerDict, players, displayPlayer.GetState());
                    }
                }
            }

            if (mouseRect.Intersects(option.GetRectangle()))
            {
                EditLevelDisplay.optionsIndex = (EditLevelDisplay.optionsIndex + 1) % EditLevelDisplay.options.Count();
            }
        }