コード例 #1
0
ファイル: Board.cs プロジェクト: hakanaku2009/svn-dump
        public Board(int sizeX, int sizeY, bool twoSided)
        {
            this.twoSided = twoSided;
            this.width    = sizeX;
            this.height   = sizeY;

            camera = new Camera((float)Math.Max(sizeX, sizeY) * 400.0f / 5.0f);

            nextPictureSet = PictureDatabase.GetNextPictureSet(twoSided ? 2 : 1);

            this.layout = new Chip[Width, Height];
            this.boardPositionMatrices = new Matrix[Width, Height];

            for (int y = 0; y < Height; y++)
            {
                for (int x = 0; x < Width; x++)
                {
                    Chip chip = new Chip();
                    chips.Add(chip);

                    chip.XPosition = x;
                    chip.YPosition = y;
                    layout[x, y]   = chip;

                    Vector2 chipTexCoordFactor = new Vector2(1.0f / Width, 1.0f / Height);

                    chip.TexCoordScale            = chipTexCoordFactor;
                    chip.TexCoordTranslationFront = new Vector2((x * chipTexCoordFactor.X), ((Height - 1) - y) * chipTexCoordFactor.Y);
                    chip.TexCoordTranslationBack  = new Vector2(((Width - 1) - x) * chipTexCoordFactor.X, ((Height - 1) - y) * chipTexCoordFactor.Y);
                }
            }

            emptyX = RandomHelper.Random.Next(0, Width);
            emptyY = RandomHelper.Random.Next(0, Height);
            Chip removed = layout[emptyX, emptyY];

            chips.Remove(removed);
            layout[emptyX, emptyY] = null;
        }
コード例 #2
0
ファイル: Core.cs プロジェクト: hakanaku2009/svn-dump
        public Puzzle3D()
        {
            if (mInstance != null)
            {
                throw new InvalidOperationException("Only one instance of Puzzle3D may be created.");
            }

            mInstance = this;

            graphics = new GraphicsDeviceManager(this);
            graphics.MinimumVertexShaderProfile = ShaderProfile.VS_2_0;
            graphics.MinimumPixelShaderProfile  = ShaderProfile.PS_2_0;

            graphics.PreferredBackBufferWidth  = 800;
            graphics.PreferredBackBufferHeight = 600;
            Window.AllowUserResizing           = true;
            graphics.IsFullScreen = false;

            Content.RootDirectory = "Content";

            ScreenManager screenManager = new ScreenManager(this);

            Components.Add(screenManager);

            PictureDatabase.Initialize();
            if (PictureDatabase.Count >= 2)
            {
                screenManager.AddScreen(new MainMenuScreen());
            }
            else
            {
                MessageBoxScreen messageBox = new MessageBoxScreen("Unable to find enough pictures to play.", false);
                messageBox.Accepted += new EventHandler <EventArgs>(messageBox_Accepted);
                screenManager.AddScreen(messageBox);
            }
        }