예제 #1
0
        /*
         * class TestHouseObject : HouseObjectDefinition
         * {
         *  public readonly Bitmap bitmap;
         *  public readonly String extra;
         *  public TestHouseObject(HouseObjectDefinition other, Bitmap bitmap, String extra)
         *      : base(other.id, other.pathName, other.states)
         *  {
         *      this.bitmap = bitmap;
         *      this.extra = extra;
         *  }
         *  public override Bitmap Bitmap
         *  {
         *      get
         *      {
         *          return bitmap;
         *      }
         *  }
         *  public override string Extra
         *  {
         *      get
         *      {
         *          return extra;
         *      }
         *  }
         * }
         */


        public void SetTileSize(Int32 tileSize)
        {
            this.tileSize        = tileSize;
            this.quarterTileSize = tileSize / 4;
            this.goalPen         = new Pen(Color.GreenYellow, quarterTileSize);


            for (int i = 0; i < tileBoxSets.Length; i++)
            {
                TileBoxSet tileBoxSet = tileBoxSets[i];
                tileBoxSet.Location = new Point(tileBoxSet.x * tileSize,
                                                tileBoxSet.y * tileSize);
                tileBoxSet.Size = new Size(tileBoxSet.size * tileSize,
                                           tileBoxSet.size * tileSize);
                tileBoxSet.Invalidate();
            }
            Invalidate();
        }
예제 #2
0
        public HouseViewerForm()
        {
            InitializeComponent();


            Text = "Castle Doctine Robber";
            //Width = 1024;
            //Height = 1024;
            AutoSize     = true;
            AutoSizeMode = AutoSizeMode.GrowAndShrink;
            Location     = new Point(Location.X, 10);


            label = new Label();
            Controls.Add(label);
            label.Location  = new Point(3, 3);
            label.BackColor = Color.FromArgb(0x88, 0xFF, 0xFF, 0xFF);

            Button zoomOutButton = new Button();

            zoomOutButton.Text        = "-";
            zoomOutButton.Width       = 25;
            zoomOutButton.Location    = new Point(150, 3);
            zoomOutButton.MouseClick += (s, e) =>
            {
                if (tileSize > 0)
                {
                    SetTileSize(tileSize - 1);
                }
            };
            Controls.Add(zoomOutButton);
            Button zoomInButton = new Button();

            zoomInButton.Text        = "+";
            zoomInButton.Width       = 25;
            zoomInButton.Location    = new Point(180, 3);
            zoomInButton.MouseClick += (s, e) =>
            {
                SetTileSize(tileSize + 1);
            };
            Controls.Add(zoomInButton);

            tileBoxSets[0]  = new TileBoxSet(this, 0, 0, 8);
            tileBoxSets[1]  = new TileBoxSet(this, 8, 0, 8);
            tileBoxSets[2]  = new TileBoxSet(this, 16, 0, 8);
            tileBoxSets[3]  = new TileBoxSet(this, 24, 0, 8);
            tileBoxSets[4]  = new TileBoxSet(this, 0, 8, 8);
            tileBoxSets[5]  = new TileBoxSet(this, 8, 8, 8);
            tileBoxSets[6]  = new TileBoxSet(this, 16, 8, 8);
            tileBoxSets[7]  = new TileBoxSet(this, 24, 8, 8);
            tileBoxSets[8]  = new TileBoxSet(this, 0, 16, 8);
            tileBoxSets[9]  = new TileBoxSet(this, 8, 16, 8);
            tileBoxSets[10] = new TileBoxSet(this, 16, 16, 8);
            tileBoxSets[11] = new TileBoxSet(this, 24, 16, 8);
            tileBoxSets[12] = new TileBoxSet(this, 0, 24, 8);
            tileBoxSets[13] = new TileBoxSet(this, 8, 24, 8);
            tileBoxSets[14] = new TileBoxSet(this, 16, 24, 8);
            tileBoxSets[15] = new TileBoxSet(this, 24, 24, 8);
            for (int i = 0; i < tileBoxSets.Length; i++)
            {
                TileBoxSet tileBoxSet = tileBoxSets[i];
                Controls.Add(tileBoxSet);
            }

            Rectangle screen     = Screen.FromControl(this).Bounds;
            Int32     screenSize = (screen.Width > screen.Height) ? screen.Height : screen.Width;

            SetTileSize(screenSize / 36);

            HouseObjectDefinition floor = CDLoader.HouseObjectDefinitionMap[0];

            for (int i = 0; i < houseObjects.Length; i++)
            {
                houseObjects[i] = floor;
            }

            //
            // Tests
            //

            /*
             * UInt32 index = (UInt32)houseObjects.Length - 33;
             * foreach (HouseObjectDefinition h in CDLoader.HouseObjectDefinitions)
             * {
             *  foreach(HouseObjectStateDefinition state in h.states.Values)
             *  {
             *      houseObjects[index--] = new TestHouseObject(h, state.bitmap, state.id.ToString());
             *  }
             *  houseObjects[index--] = floor;
             *  /*
             *  HouseObjectStateDefinition state0, state100;
             *  if(h.states.TryGetValue(100, out state100))
             *  {
             *      state0 = h.states[0];
             *      for (int i = 0; i < 32; i++)
             *      {
             *          for (int j = 0; j < 32; j++)
             *          {
             *              Color color1 = state0.bitmap.GetPixel(j, i);
             *              Color color2 = state100.bitmap.GetPixel(j, i);
             *              Int32 newRed = color1.R + color2.R;
             *              Int32 newGreen = color1.G + color2.G;
             *              Int32 newBlue = color1.B + color2.B;
             *              if (newRed > 255) newRed = 255;
             *              if (newGreen > 255) newGreen = 255;
             *              if (newBlue > 255) newBlue = 255;
             *              state0.bitmap.SetPixel(j, i, Color.FromArgb(0xFF,
             *                  newRed, newGreen, newBlue));
             *          }
             *      }
             *      houseObjects[index--] = new TestHouseObject(h, state0.bitmap);
             *  }
             *  //
             * }
             */
        }