Advertisement
Guest User

Untitled

a guest
Apr 8th, 2016
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.70 KB | None | 0 0
  1. // HEX - Hex.cs
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Drawing;
  6. using System.Data;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Windows.Forms;
  10.  
  11. namespace Middle_Ages_Country
  12. {
  13.     public partial class Hex : UserControl
  14.     {
  15.         public Country Holder;
  16.         protected bool _selected;
  17.         int r;
  18.         protected int _ticks;
  19.  
  20.         public Hex(Country holder)
  21.         {
  22.             InitializeComponent();
  23.             Holder = holder;
  24.             setup();
  25.         }
  26.  
  27.         public Hex()
  28.         {
  29.             InitializeComponent();
  30.             Holder = null;
  31.             setup();
  32.         }
  33.  
  34.         protected void setup()
  35.         {
  36.             this.Paint += new PaintEventHandler(Hex_Paint);
  37.         }
  38.  
  39.         private void Hex_Load(object sender, EventArgs e)
  40.         {
  41.             this.Refresh();
  42.         }
  43.  
  44.         private void Hex_MouseClick(object sender, MouseEventArgs e)
  45.         {
  46.             _selected = true;
  47.         }
  48.  
  49.         private void timer1_Tick(object sender, EventArgs e)
  50.         {
  51.             this.Refresh();
  52.         }
  53.  
  54.         protected override void OnPaint(PaintEventArgs e)
  55.         {
  56.             base.OnPaint(e);
  57.         }
  58.  
  59.         private void Hex_VisibleChanged(object sender, EventArgs e)
  60.         {
  61.             this.Refresh();
  62.         }
  63.  
  64.         private void Hex_Paint(object sender, PaintEventArgs e)
  65.         {
  66.             Parent.CreateGraphics().DrawImage(Middle_Ages_Country.Properties.Resources.h,
  67.                 ClientRectangle);
  68.         }
  69.     }
  70. }
  71.  
  72. // MAP - Map.cs
  73. using System;
  74. using System.Collections.Generic;
  75. using System.Linq;
  76. using System.Text;
  77.  
  78. namespace Middle_Ages_Country
  79. {
  80.     public class Map
  81.     {
  82.         public List<List<Hex>> Grid = new List<List<Hex>>();
  83.         public List<Country> Countries = new List<Country>();
  84.  
  85.         public Map(int rows, int columns, Form1 owner)
  86.         {
  87.             int x = 40, y = 40;
  88.             // Create map
  89.             for (int row = 0; row < rows; row++)
  90.             {
  91.                 List<Hex> r = new List<Hex>();
  92.                 for (int column = 0; column < columns; column++)
  93.                 {
  94.                     Hex h = new Hex(null)
  95.                     {
  96.                         Location = new System.Drawing.Point(x, y),
  97.                         Parent = owner
  98.                     };
  99.                     r.Add(h);
  100.                     h.Show();
  101.                     h.Invalidate();
  102.                     x += 40;
  103.                 }
  104.                 Grid.Add(r);
  105.                 x -= columns * 40;
  106.                 x = (row % 2) * 20 + 20;
  107.                 y += 30;
  108.             }
  109.         }
  110.     }
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement