Switch to Vector2

This commit is contained in:
2021-02-26 17:11:08 -06:00
parent 640db4f4a2
commit 715b328ef5
9 changed files with 154 additions and 219 deletions

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Numerics;
namespace Gameboard.ShogiUI.BoardState
{
@@ -24,6 +25,11 @@ namespace Gameboard.ShogiUI.BoardState
get => array[y * width + x];
set => array[y * width + x] = value;
}
public T this[float x, float y]
{
get => array[(int)y * width + (int)x];
set => array[(int)y * width + (int)x] = value;
}
public void ForEach(ForEachDelegate callback)
{
@@ -48,15 +54,14 @@ namespace Gameboard.ShogiUI.BoardState
}
}
// TODO: Figure out a better return type, or make this class specific to ShogiBoard.
public BoardVector IndexOf(Predicate<T> predicate)
public Vector2? IndexOf(Predicate<T> predicate)
{
for (var x = 0; x < width; x++)
for (var y = 0; y < height; y++)
{
if (this[x, y] != null && predicate(this[x, y]))
{
return new BoardVector(x, y);
return new Vector2(x, y);
}
}
return null;