some changes
This commit is contained in:
@@ -16,6 +16,8 @@ namespace CoopSweeper.GameTypes
|
||||
|
||||
public FieldState State { get; set; }
|
||||
|
||||
public int SurroundingBombs { get; set; }
|
||||
|
||||
public char ToChar()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
|
||||
namespace CoopSweeper.GameTypes
|
||||
@@ -30,6 +31,39 @@ namespace CoopSweeper.GameTypes
|
||||
Map[i, j] = field;
|
||||
}
|
||||
}
|
||||
|
||||
UpdateSorroundingBombs();
|
||||
}
|
||||
|
||||
private void UpdateSorroundingBombs()
|
||||
{
|
||||
for (int i = 0; i < Map.GetLength(0); i++)
|
||||
{
|
||||
for (int j = 0; j < Map.GetLength(1); j++)
|
||||
{
|
||||
var field = Map[i, j];
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<Point> GetSorroundedFields(int x, int y)
|
||||
{
|
||||
var points = new List<Point>();
|
||||
points.Add(new Point(x - 1, y - 1));
|
||||
points.Add(new Point(x, y - 1));
|
||||
points.Add(new Point(x + 1, y - 1));
|
||||
|
||||
points.Add(new Point(x + 1, y));
|
||||
points.Add(new Point(x - 1, y));
|
||||
|
||||
points.Add(new Point(x - 1, y + 1));
|
||||
points.Add(new Point(x, y + 1));
|
||||
points.Add(new Point(x + 1, y + 1));
|
||||
|
||||
|
||||
return points;
|
||||
}
|
||||
|
||||
public void GenerateGame(int x, int y)
|
||||
@@ -65,6 +99,7 @@ namespace CoopSweeper.GameTypes
|
||||
|
||||
public void Reveal(int x, int y)
|
||||
{
|
||||
CheckMap();
|
||||
var field = Map[x, y];
|
||||
if (field.State != FieldState.REVEALED)
|
||||
{
|
||||
@@ -77,24 +112,23 @@ namespace CoopSweeper.GameTypes
|
||||
GameFinished?.Invoke(true);
|
||||
}
|
||||
|
||||
public void SetQuestionMark(int x, int y)
|
||||
{
|
||||
Map[x, y].State = FieldState.QUESTIONMARK;
|
||||
}
|
||||
|
||||
public void SetFlag(int x, int y)
|
||||
{
|
||||
Map[x, y].State = FieldState.FLAG;
|
||||
}
|
||||
|
||||
public void ResetField(int x, int y)
|
||||
public void ToggleMark(int x, int y)
|
||||
{
|
||||
CheckMap();
|
||||
var field = Map[x, y];
|
||||
if (field.State == FieldState.REVEALED)
|
||||
throw new Exception("A Revealed Field can't be resetet!");
|
||||
|
||||
switch (field.State)
|
||||
{
|
||||
case FieldState.NONE:
|
||||
field.State = FieldState.FLAG;
|
||||
|
||||
return;
|
||||
case FieldState.FLAG:
|
||||
field.State = FieldState.QUESTIONMARK;
|
||||
return;
|
||||
case FieldState.QUESTIONMARK:
|
||||
field.State = FieldState.NONE;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@ namespace CoopSweeper.GameTypes
|
||||
|
||||
bool ContainsBomb { get; set; }
|
||||
|
||||
int SurroundingBombs { get; set; }
|
||||
|
||||
FieldState State { get; set; }
|
||||
|
||||
char ToChar();
|
||||
|
||||
@@ -10,10 +10,6 @@ namespace CoopSweeper.GameTypes
|
||||
|
||||
void Reveal(int x, int y);
|
||||
|
||||
void SetQuestionMark(int x, int y);
|
||||
|
||||
void SetFlag(int x, int y);
|
||||
|
||||
void ResetField(int x, int y);
|
||||
void ToggleMark(int x, int y);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user