// Pattern : Pion posé - Ennemi - Ennemi - Case vide public static void CheckThirdCapturePattern(Intersection enemy, int direction) { Intersection secondEnemy = null, empty = null; Coordinates coords; int oppositeDirection; coords = Coordinates.GetDirection (direction, enemy.X, enemy.Y); secondEnemy = BoardManager.INSTANCE.GetIntersection (coords); if (secondEnemy != null && secondEnemy.GetPawnType () == enemy.GetPawnType ()) { coords = Coordinates.GetDirection(direction, secondEnemy.X, secondEnemy.Y); empty = BoardManager.INSTANCE.GetIntersection(coords); if (empty != null && empty.GetPawnType() == PawnType.NONE) { oppositeDirection = Coordinates.GetOppositeDirection(direction); empty.GetCaptures()[oppositeDirection] = BoardManager.INSTANCE.GetOppositePawnType (enemy.GetPawnType()); enemy.Catchable += 1; secondEnemy.Catchable += 1; } } }
private void RetrieveCaptures (Intersection intersection) { GameObject obj; for (int index = 0; index < intersection.GetDirections().Length; ++index) { obj = this.captures[index].transform.GetChild(0).gameObject; obj.GetComponent<Text> ().text = this.GetLetter(intersection.GetCaptures()[index]).ToString (); } obj = this.captures [8].transform.GetChild (0).gameObject; obj.GetComponent<Text> ().text = this.GetLetter(intersection.GetPawnType()).ToString (); }
// Pattern : Ennemi - Allié - Pion posé - Case vide public static bool CheckFirstCapturePattern(Intersection current, Intersection ally, int direction) { Intersection enemy = null, empty = null; Coordinates coords; int oppositeDirection; coords = Coordinates.GetDirection (direction, ally.X, ally.Y); enemy = BoardManager.INSTANCE.GetIntersection(coords); if (enemy != null && BoardManager.INSTANCE.AreOpposite (ally, enemy)) { oppositeDirection = Coordinates.GetOppositeDirection(direction); coords = Coordinates.GetDirection(oppositeDirection, current.X, current.Y); empty = BoardManager.INSTANCE.GetIntersection(coords); if (empty != null && empty.GetPawnType() == PawnType.NONE) { empty.GetCaptures()[direction] = BoardManager.INSTANCE.GetOppositePawnType (ally.GetPawnType()); current.Catchable += 1; ally.Catchable += 1; return (true); } } return (false); }
private void RetrieveOwnedBy (Intersection intersection) { this.ownedByText.GetComponent<Text> ().text += intersection.GetPawnType ().ToString (); }
public Freeline(Intersection A, Intersection B) { segment = new Segment (new Point (A.X, A.Y), new Point (B.X, B.Y)); type = A.GetPawnType (); }
public bool AreOpposite(Intersection first, Intersection second) { bool notNone = first.GetPawnType () != PawnType.NONE && second.GetPawnType () != PawnType.NONE; bool opposite = first.GetPawnType () != second.GetPawnType (); return (notNone && opposite); }
public static bool CheckSixthFreelinePattern(Intersection current, int direction) { Intersection inter = null, opposite = null; Coordinates coords; int oppositeDirection; coords = Coordinates.GetDirection (direction, current.X, current.Y); coords = Coordinates.GetDirection (direction, coords.X, coords.Y); inter = BoardManager.INSTANCE.GetIntersection (coords); if (inter != null && inter.GetPawnType() == current.GetPawnType ()) { coords = Coordinates.GetDirection (direction, inter.X, inter.Y); inter = BoardManager.INSTANCE.GetIntersection (coords); if (inter != null && inter.GetPawnType() == current.GetPawnType ()) { coords = Coordinates.GetDirection (direction, inter.X, inter.Y); inter = BoardManager.INSTANCE.GetIntersection (coords); if (inter != null && inter.GetPawnType () == PawnType.NONE) { oppositeDirection = Coordinates.GetOppositeDirection (direction); coords = Coordinates.GetDirection (oppositeDirection, current.X, current.Y); opposite = BoardManager.INSTANCE.GetIntersection (coords); if (opposite != null && opposite.GetPawnType () == PawnType.NONE) { Debug.Log ("Pattern found : °x°oo°"); return (BoardManager.INSTANCE.CreateNewFreeline(inter, opposite)); } } } } return false; }
public static bool CheckSecondFreelinePattern (Intersection current, int direction) { Intersection inter = null; Coordinates coords; coords = Coordinates.GetDirection (direction, current.X, current.Y); coords = Coordinates.GetDirection (direction, coords.X, coords.Y); inter = BoardManager.INSTANCE.GetIntersection (coords); if (inter != null) { if (inter.GetPawnType() == current.GetPawnType()) return (Patterns.CheckFourthFreelinePattern(current, direction)); else if (inter.GetPawnType() == PawnType.NONE) return (Patterns.CheckFifthFreelinePattern(current, direction)); } return false; }