Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // HEX - Hex.cs
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Drawing;
- using System.Data;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace Middle_Ages_Country
- {
- public partial class Hex : UserControl
- {
- public Country Holder;
- protected bool _selected;
- int r;
- protected int _ticks;
- public Hex(Country holder)
- {
- InitializeComponent();
- Holder = holder;
- setup();
- }
- public Hex()
- {
- InitializeComponent();
- Holder = null;
- setup();
- }
- protected void setup()
- {
- this.Paint += new PaintEventHandler(Hex_Paint);
- }
- private void Hex_Load(object sender, EventArgs e)
- {
- this.Refresh();
- }
- private void Hex_MouseClick(object sender, MouseEventArgs e)
- {
- _selected = true;
- }
- private void timer1_Tick(object sender, EventArgs e)
- {
- this.Refresh();
- }
- protected override void OnPaint(PaintEventArgs e)
- {
- base.OnPaint(e);
- }
- private void Hex_VisibleChanged(object sender, EventArgs e)
- {
- this.Refresh();
- }
- private void Hex_Paint(object sender, PaintEventArgs e)
- {
- Parent.CreateGraphics().DrawImage(Middle_Ages_Country.Properties.Resources.h,
- ClientRectangle);
- }
- }
- }
- // MAP - Map.cs
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace Middle_Ages_Country
- {
- public class Map
- {
- public List<List<Hex>> Grid = new List<List<Hex>>();
- public List<Country> Countries = new List<Country>();
- public Map(int rows, int columns, Form1 owner)
- {
- int x = 40, y = 40;
- // Create map
- for (int row = 0; row < rows; row++)
- {
- List<Hex> r = new List<Hex>();
- for (int column = 0; column < columns; column++)
- {
- Hex h = new Hex(null)
- {
- Location = new System.Drawing.Point(x, y),
- Parent = owner
- };
- r.Add(h);
- h.Show();
- h.Invalidate();
- x += 40;
- }
- Grid.Add(r);
- x -= columns * 40;
- x = (row % 2) * 20 + 20;
- y += 30;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement