Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
No results found
Show changes
Showing
with 185 additions and 0 deletions
namespace Wanderer.model
{
public class Map
{
private Tile[,] _tiles;
public Map(int x, int y)
{
_tiles = new Tile[x, y];
for (int i = 0; i < x; ++i)
for (int j = 0; j < y; ++j)
_tiles[i, j] = new Tile();
}
public Tile[,] Tiles
{
get => _tiles;
set => _tiles = value;
}
}
}
\ No newline at end of file
using System.Drawing;
namespace Wanderer.model
{
public class Player
{
public Color Color { get; set; }
public int bonusCh = 0;//bonus Chemin
public int bonusCl = 0; //bonus Club
public int marks = 50;
public int randonneurs = 0;
public int tailleTerritoire;
public int gain = 0;
public Player(Color color)
{
Color = color;
}
}
}
\ No newline at end of file
namespace Wanderer.model
{
public enum Terrain
{
Plains,
Hills,
Mountains,
Forest,
Lake,
River,
Urban
}
}
\ No newline at end of file
namespace Wanderer.model
{
public class Tile
{
private Improvement _improvement;
public Terrain Terrain { get; set; }
public Player Owner { get; set; }
public bool HasChanged { get; set; }
public Improvement Improvement
{
get => _improvement;
set
{
_improvement = _improvement == 0 ? value : _improvement;
HasChanged = true;
}
}
}
}
\ No newline at end of file
src/ressources/34258_large.jpg

1.01 MiB

src/ressources/Reliefkarte_Massif_des_Vosges.JPG

3.81 MiB

src/ressources/Reliefkarte_Massif_des_Vosgess.JPG

2.79 MiB

src/ressources/cabin.png

2.75 KiB

src/ressources/coins.png

1.12 KiB

src/ressources/factory-4.png

2.82 KiB

src/ressources/group.png

1.64 KiB

src/ressources/mountaineer.png

1.82 KiB

src/ressources/mountains.ico

66.1 KiB

src/ressources/path-forest-trees-bushes-grass-cc.jpg

7.94 MiB

src/ressources/path-forest-trees-bushes-grass-min.jpg

839 KiB

src/ressources/path.png

3.63 KiB

src/ressources/pointdinterrogation.png

22.3 KiB

src/ressources/train.png

2.71 KiB

using System.ComponentModel;
using System.Drawing.Design;
using System.Windows.Forms;
using System.Windows.Forms.Design;
using Wanderer.model;
namespace Wanderer.view.Controls
{
public class MapView : TableLayoutPanel
{
public static TileView SelectedTile;
private TileView[,] tileViews;
private IContainer components = null;
[Category("Model")]
[Browsable(true)]
[Description("La map correspondante.")]
[Editor(typeof(WindowsFormsComponentEditor), typeof(UITypeEditor))]
public Map Model {
set {
ColumnCount = value.Tiles.GetLength(0);
RowCount = value.Tiles.GetLength(1);
tileViews = new TileView[ColumnCount, RowCount];
for(int i = 0; i < ColumnCount; i++)
{
this.ColumnStyles.Add(new ColumnStyle());
}
for (int i = 0; i < RowCount; i++)
{
this.RowStyles.Add(new RowStyle());
}
for (int i = 0; i < ColumnCount; ++i)
{
for (int j = 0; j < RowCount; ++j)
{
tileViews[i, j] = new TileView(value.Tiles[i, j]);
Controls.Add(tileViews[i, j], i, j);
this.RowStyles[j].Height = 14;
}
this.ColumnStyles[i].Width = 14;
}
}
}
public MapView()
{
InitializeComponent();
}
protected override void Dispose(bool disposing)
{
if (disposing && (components != null)) {
components.Dispose();
}
base.Dispose(disposing);
}
private void InitializeComponent()
{
this.SuspendLayout();
this.ResumeLayout(false);
}
}
}
\ No newline at end of file
using System;
using System.Drawing;
using System.Windows.Forms;
using Wanderer.model;
namespace Wanderer.view.Controls
{
public class TileView : Button
{
public Tile model { get; }
public TileView(Tile tile)
{
model = tile;
Height = Width;
FlatStyle = FlatStyle.Flat;
FlatAppearance.MouseOverBackColor = Color.Transparent;
BackColor = Color.Transparent;
MouseEnter += OnMouseEnterButton1;
MouseLeave += OnMouseLeaveButton1;
Click += OnClick;
//Image = imageFromTerrain();
}
private void OnMouseEnterButton1(object sender, EventArgs e)
{
this.FlatAppearance.BorderColor = Color.Yellow; // or Color.Red or whatever you want
//this.BackColor = Color.Transparent;
}
private void OnMouseLeaveButton1(object sender, EventArgs e)
{
this.FlatAppearance.BorderColor = Color.Black;
}
private void OnClick(object sender, EventArgs e)
{
MapView.SelectedTile = this;
}
}
}
\ No newline at end of file