public override void GetPossibleMoves(bool black, int roll1, int roll2, bool[] rollsUsed) { bool doubles = (roll1 == roll2); actualPossibleMoves.Clear(); SpotControl sc1 = (SpotControl)allSpots[possibleMoves[roll1 - 1]]; SpotControl sc2 = (SpotControl)allSpots[possibleMoves[roll2 - 1]]; if (sc1.isBlack == black && sc1.pieces.Count > 0) { if (!doubles) { if (!rollsUsed[0]) { actualPossibleMoves.Add(possibleMoves[roll1 - 1]); } } else { if (!rollsUsed[3]) { actualPossibleMoves.Add(possibleMoves[roll1 - 1]); } } } if (!doubles && sc2.isBlack == black && sc2.pieces.Count > 0 && !rollsUsed[1]) { actualPossibleMoves.Add(possibleMoves[roll2 - 1]); } if (actualPossibleMoves.Count == 0) { if (!doubles) { if (rollsUsed[0] && !rollsUsed[1]) { CheckAbove(roll2, black); } else if (!rollsUsed[0] && rollsUsed[1]) { CheckAbove(roll1, black); } else if (!rollsUsed[0] && !rollsUsed[1]) { if (roll1 < roll2) { CheckAbove(roll1, black); } else { CheckAbove(roll2, black); } } } else if (!rollsUsed[3]) { CheckAbove(roll1, black); } } }
void Spot() { var control = new SpotControl(); var vm = new SpotControlViewModel() { IsBusy = true }; control.DataContext = vm; OpenView("2 Matrix Analyse(" + ProcessMode.ToString() + "):" + GetHeader(), control); Task.Factory.StartNew(() => { try { Save(); Dictionary <string, List <Tuple <double, double> > > rl = TargetObject.Get2DCurve(); App.Current.Dispatcher.Invoke(() => { vm.LoadData(rl); }); } catch (Exception ex) { LogSupport.Error(ex); } }).ContinueWith((t) => { vm.IsBusy = false; }); }
public override void GetPossibleMoves(bool black, int roll1, int roll2, bool[] rollsUsed) { actualPossibleMoves.Clear(); SpotControl sc1 = (SpotControl)allSpots[possibleMoves[roll1 - 1]]; SpotControl sc2 = (SpotControl)allSpots[possibleMoves[roll2 - 1]]; //if not doubles if (!(roll1 == roll2)) { //if spot that roll would get you to is not controlled or is occuppied by this color //and roll has not been used -> Add spot to possible moves if ((!sc1.controlled || sc1.isBlack == black) && !rollsUsed[0]) { actualPossibleMoves.Add(possibleMoves[roll1 - 1]); } if ((!sc2.controlled || sc2.isBlack == black) && !rollsUsed[1]) { actualPossibleMoves.Add(possibleMoves[roll2 - 1]); } } else if ((!sc1.controlled || sc1.isBlack == black) && !rollsUsed[3]) { //if doubles and spot that roll would get you to is not controlled or is occuppied by this color //and theres atleast one move left -> Add the spot actualPossibleMoves.Add(possibleMoves[roll1 - 1]); } }
new void Awake() { base.Awake(); animator = GetComponent <Animator>(); myrBody = GetComponent <Rigidbody2D>(); sRenderer = GetComponent <SpriteRenderer>(); spotControl = GetComponent <SpotControl>(); }
public SpotControl(SpotControl pcc) { pieces = new List <GameObject>(); foreach (GameObject piece in pcc.pieces) { pieces.Add(piece); } position = pcc.position; possibleMovesWhite = pcc.possibleMovesWhite; possibleMovesBlack = pcc.possibleMovesBlack; actualPossibleMoves = pcc.actualPossibleMoves; }
public bool BearingOff() { //Check to see if Mover can start bearing off int sum = 0; foreach (int pos in possibleMoves) { SpotControl s = (SpotControl)allSpots[pos]; if (s.isBlack == isBlack) { sum += s.pieces.Count; } } sum += pieces.Count; return(sum == 15); }
public void InitializeAllSpotsOnControl() { SpotControl sc = (SpotControl)pcc; sc.InitializeOtherPieceContainerControls(gameMaster); }