public void Place(VectorInt location) { var turnables = GetTurnableStones(location); if (turnables.Count == 0) { throw new ArgumentException(null, nameof(location)); } Board[location.X, location.Y] = CurrentStone; turnables.ForEach(l => Board[l.X, l.Y] = CurrentStone); CurrentStone = CurrentStone.Invert(); Update(); if (PlaceableLocations.Length == 0) { // パス CurrentStone = CurrentStone.Invert(); Update(); if (PlaceableLocations.Length == 0) { // ゲームセット IsGameSet = true; } } }
public override void SetStone(Stone s, bool gameStart = false) { if (reserveStone == null) { reserveStone = new List <Stone>(); } if (reserveStone.Count > 0) { if (gameStart) { reserveStone[reserveStone.Count - 1].gameObject.SetActive(false); } else { reserveStone[reserveStone.Count - 1].Appear(false); } } reserveStone.Add(s); CurrentStone = reserveStone[reserveStone.Count - 1]; CurrentStone.SetInteractable(true); if (gameStart) { if (!countText.gameObject.activeSelf && reserveStone.Count > 0) { countText.gameObject.SetActive(true); } countText.text = reserveStone.Count.ToString(); countText.transform.SetAsLastSibling(); } }
private IEnumerable <VectorInt> GetTurnableStones(VectorInt location, VectorInt way) { var t = new List <VectorInt>(); var cur = location; cur += way; var yourStone = CurrentStone.Invert(); var endsWithMyStone = false; while (0 <= cur.X && 0 <= cur.Y && cur.X <= 7 && cur.Y <= 7) { var s = Board[cur.X, cur.Y]; endsWithMyStone = s == CurrentStone; if (s == yourStone) { t.Add(cur); } else { break; } cur += way; } return(endsWithMyStone ? t : Array.Empty <VectorInt>()); }
public override void TakeStone() { Stone s = CurrentStone; reserveStone.Remove(CurrentStone); if (reserveStone.Count > 0) { CurrentStone = reserveStone[reserveStone.Count - 1]; CurrentStone.Appear(true); } else { CurrentStone = null; } if (reserveStone.Count <= 0) { countText.gameObject.SetActive(false); } else { countText.text = reserveStone.Count.ToString(); } countText.transform.SetAsLastSibling(); }