コード例 #1
0
        public void CheckMouseDefaultCollisions(Rectangle mouseRect, Rectangle previousMouseRect, List <IBlock> blocks, List <IPipe> pipes, List <IEnemy> enemies, List <IItem> items, List <IPlayer> players)
        {
            int x = mouseRect.X - previousMouseRect.X;
            int y = mouseRect.Y - previousMouseRect.Y;


            foreach (IBlock block in blocks)
            {
                if (mouseRect.Intersects(block.GetRectangle()))
                {
                    block.AdjustLocation(new Vector2(x, y));
                    EditLevelDisplay.SetExtremes(x + previousMouseRect.X, y + previousMouseRect.Y);
                }
            }

            foreach (IPipe pipe in pipes)
            {
                if (mouseRect.Intersects(pipe.GetRectangle()))
                {
                    pipe.AdjustLocation(new Vector2(x, y));
                    EditLevelDisplay.SetExtremes(x + previousMouseRect.X, y + previousMouseRect.Y);
                }
            }

            foreach (IEnemy enemy in enemies)
            {
                if (mouseRect.Intersects(enemy.GetRectangle()))
                {
                    enemy.AdjustLocation(new Vector2(x, y));
                    EditLevelDisplay.SetExtremes(x + previousMouseRect.X, y + previousMouseRect.Y);
                }
            }

            foreach (IItem item in items)
            {
                if (mouseRect.Intersects(item.GetRectangle()))
                {
                    item.AdjustLocation(new Vector2(x, y));
                    EditLevelDisplay.SetExtremes(x + previousMouseRect.X, y + previousMouseRect.Y);
                }
            }

            foreach (IPlayer player in players)
            {
                if (mouseRect.Intersects(player.GetRectangle()))
                {
                    player.AdjustLocation(new Vector2(x, y));
                    EditLevelDisplay.SetExtremes(x + previousMouseRect.X, y + previousMouseRect.Y);
                }
            }
        }
コード例 #2
0
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            graphics.IsFullScreen              = false;
            graphics.PreferredBackBufferWidth  = 500;
            graphics.PreferredBackBufferHeight = 300;

            controllerList        = new ArrayList();
            defaultControllerList = new ArrayList();
            defaultControllerList.Add(new DefaultKeyboardController(this));
            defaultControllerList.Add(new GamepadController(this));

            levelControllerList = new ArrayList();
            levelEditingCamera  = new CameraController(this, new Vector2(0, 0), graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight);
            levelControllerList.Add(new EditingKeyboardController(this, levelEditingCamera));

            jumpOnlyControllerList = new ArrayList();
            jumpOnlyControllerList.Add(new JumpOnlyKeyboardController(this));
            //Add mouse controller

            filename = "";
            if (!this.isInReplayMode)
            {
                swWriteFile = File.CreateText(strWriteFilePath);
            }
            else
            {
                this.gR = new GamerReplayer(this);
            }

            sm = new SoundManager();
            su = new StarUtility();

            Content.RootDirectory = "Content";

            SoundManager.LoadSoundContent(this);

            mainBGMInstance = mainBGM.CreateInstance();
            mainBGMInstance.Play();

            MarioUtility.SetSpriteSheetWidths();
            EnemySpriteUtility.SetSpriteSheetWidths();

            EnSp = new EnemySpawner();

            eld = new EditLevelDisplay();
            eld.Initialize(this, new Vector2(0, 0), levelEditingCamera, sm);
        }