public bool CanAdd(IGridObject o, int x, int y) { var space = o.Space(); bool result = ResourceState.instance.CanSpend(o.Price()); for (int i = x; i != x + space.Item2.Item1 && result; i++) { for (int j = y; j != y + space.Item2.Item2 && result; j++) { result = !(space.Item1[i - x, j - y] && this.matrix[i, j].Item1); } } return(result); }
public void Put(IGridObject o, int x, int y) { ResourceState.instance.Spend(o.Price()); var space = o.Space(); for (int i = x; i != x + space.Item2.Item1; i++) { for (int j = y; j != y + space.Item2.Item2; j++) { if (space.Item1[i - x, j - y]) { if (this.matrix[i, j].Item2 != null) { this.Remove(this.matrix[i, j].Item2); } this.matrix[i, j] = new Tuple <bool, IGridObject>(true, o); } } } }