public LilyPadXF(LilyPadCP lily) { _lily = lily; this.SetName(nameof(FroggiesMainViewModel.MakeMoveAsync)); CommandParameter = lily; //has to be this way now. ThisDraw.PaintSurface += PaintSurface; }
public async Task MakeMoveAsync(LilyPadCP lily) { if (lily == null) { throw new BasicBlankException("Lily cannot be null. Rethink"); } await _mainGame.ProcessLilyClickAsync(lily, this); }
private async Task LeapFrogAsync(LilyPadCP obj_Target, FroggiesMainViewModel model) { LilyPadCP obj_Leap; string str_Index = ""; // Stop if (obj_Target.Row < _obj_SelectedPad !.Row) { str_Index = $"{_obj_SelectedPad.Column}, {_obj_SelectedPad.Row - 1}"; }
public LilyPadWPF(LilyPadCP lily) { _thisDraw = new SKElement(); _thisDraw.PaintSurface += PaintSurface; CommandParameter = lily; //has to be this way now. //MouseUp += LilyPadWPF_MouseUp; Name = nameof(FroggiesMainViewModel.MakeMoveAsync); Content = _thisDraw; _lily = lily; }
private void CreateLilyPads(FroggiesMainViewModel model) { LilyPadCP?obj_TempPad1 = null; LilyPadCP?obj_TempPad2 = null; LilyPadCP obj_CurrentPad; int int_RowCount; int int_ColCount; int int_FrogCount; int int_TryCount = 0; int int_RandomNumber; int int_RandomIndex; int int_NewX = 0; int int_NewY = 0; int int_NewX2 = 0; int int_NewY2 = 0; bool bln_Pad1OK; bool bln_Pad2OK; _col_Pads = new Dictionary <string, LilyPadCP>(); _col_TargetPads = new Dictionary <string, LilyPadCP>(); _obj_SelectedPad = null; int_ColCount = 4; int_RowCount = 4; // *** This will be the final pad in the puzzle obj_CurrentPad = new LilyPadCP(int_ColCount, int_RowCount, true); _col_Pads.Add($"{int_ColCount}, {int_RowCount}", obj_CurrentPad); int_FrogCount = 1; while (int_FrogCount < model.NumberOfFrogs) { // *** Get a random occupied pad int_RandomIndex = GetRandomInteger(_col_Pads.Count - 1); obj_CurrentPad = _col_Pads.ElementAt(int_RandomIndex).Value; // *** Only find a new path if the pad has a frog on it if (obj_CurrentPad.HasFrog) { int_RandomNumber = GetRandomInteger(4); // *** Pick a random direction in which to move switch (int_RandomNumber) { case 0: // move up { int_NewX = obj_CurrentPad.Column; int_NewY = obj_CurrentPad.Row - 1; int_NewX2 = obj_CurrentPad.Column; int_NewY2 = obj_CurrentPad.Row - 2; break; } case 1: // move down { int_NewX = obj_CurrentPad.Column; int_NewY = obj_CurrentPad.Row + 1; int_NewX2 = obj_CurrentPad.Column; int_NewY2 = obj_CurrentPad.Row + 2; break; } case 2: // move left { int_NewX = obj_CurrentPad.Column - 1; int_NewY = obj_CurrentPad.Row; int_NewX2 = obj_CurrentPad.Column - 2; int_NewY2 = obj_CurrentPad.Row; break; } case 3: // move right { int_NewX = obj_CurrentPad.Column + 1; int_NewY = obj_CurrentPad.Row; int_NewX2 = obj_CurrentPad.Column + 2; int_NewY2 = obj_CurrentPad.Row; break; } } bln_Pad1OK = false; bln_Pad2OK = false; if ((int_NewX != int_NewX2) | (int_NewY != int_NewY2)) { // *** If the target pad already exists, make sure it is blank if (_col_Pads.ContainsKey(int_NewX + ", " + int_NewY)) { obj_TempPad1 = _col_Pads[int_NewX + ", " + int_NewY]; if (!obj_TempPad1.HasFrog) { bln_Pad1OK = true; } } else { bln_Pad1OK = true; } // *** If the target pad already exists, make sure it is blank if (_col_Pads.ContainsKey(int_NewX2 + ", " + int_NewY2)) { obj_TempPad2 = _col_Pads[int_NewX2 + ", " + int_NewY2]; if (!obj_TempPad2.HasFrog) { bln_Pad2OK = true; } } else { bln_Pad2OK = true; } if (bln_Pad1OK & bln_Pad2OK & (int_NewX2 >= 0) & (int_NewX2 <= 9) & (int_NewX >= 0) & (int_NewX <= 9) & (int_NewY2 >= 0) & (int_NewY2 <= 9) & (int_NewY >= 0) & (int_NewY <= 9)) { if (_col_Pads.ContainsKey(int_NewX + ", " + int_NewY)) { obj_TempPad1 !.HasFrog = true; } else { obj_TempPad1 = new LilyPadCP(int_NewX, int_NewY, true); _col_Pads.Add(int_NewX + ", " + int_NewY, obj_TempPad1); } if (_col_Pads.ContainsKey(int_NewX2 + ", " + int_NewY2)) { obj_TempPad2 !.HasFrog = true; } else { obj_TempPad2 = new LilyPadCP(int_NewX2, int_NewY2, true); _col_Pads.Add(int_NewX2 + ", " + int_NewY2, obj_TempPad2); } int_TryCount = 0; obj_CurrentPad.HasFrog = false; int_FrogCount = GetNumberOfFrogs; } } } int_TryCount += 1; // *** Make sure we didn't get stuck - if we did, start over if (int_TryCount >= 1000) { _col_Pads.Clear(); _col_Pads = new Dictionary <string, LilyPadCP>(); obj_CurrentPad = new LilyPadCP(4, 4, true); _col_Pads.Add(int_ColCount + ", " + int_RowCount, obj_CurrentPad); int_FrogCount = 1; } } }