|
分類:[.NET 全般]
Private Async Sub RectangleTapped(sender As Object, e As TappedRoutedEventArgs)
Dim r As Windows.UI.Xaml.Shapes.Rectangle = sender Dim x = r.GetValue(Grid.ColumnProperty) Dim y = r.GetValue(Grid.RowProperty) If CountGain(x, y Diskcolor.Red, True) > 0 Then SetDisk(x, y, DiskColor.Red) PlayerTurn = False If Await IsEnd() Then Await GameEnd() Else ComputerExecute()
End If Else Await ShowMessage("そこは打てません") End If End Sub
Private Function CountGain(x As Integer, y As Integer. diskColor As DiskColor, turn As Boolean) As Integer If Status(x, y) <> MainPage.DiskColor.Empty Then Return 0 Dim result = 0 result += Search(x, y, diskColor, New Point(1, 0), turn) result += Search(x, y, diskColor, New Point(-1, 0), turn) result += Search(x, y, diskColor, New Point(0, 1), turn) result += Search(x, y, diskColor, New Point(0, -1), turn) result += Search(x, y, diskColor, New Point(1, 1), turn) result += Search(x, y, diskColor, New Point(1, -1), turn) result += Search(x, y, diskColor, New Point(-1, 1), turn) result += Search(x, y, diskColor, New Point(-1, -1), turn) Return result End Function
Private Function Search(x As Integer, y As Integer, diskColor As DiskColor, point As Point, turn As Boolean) As Integer
Dim targetColor As DiskColor If diskColor = MainPage.DiskColor.Red Then targetColor = MainPage.DiskColor.White Else targetColor = MainPage.DiskColor.Red End If
Dim count = 0 Dim shouldTurn As New List(Of Point) Dim tempX, tempY As Integer
For i = 1 To Size - 1 tempX = x + point.X + i tempY = y + point.Y + i
If tempX >= 0 AndAlso tempX < Size AndAlso tempY >= 0 AndAlso tempY < Size Then
Select Case Status(tempX, tempY) Case diskColor If count = 0 Then Exit For Else If turn Then For Each p In shouldTurn SetDisk(p.X, p.Y, diskColor) Next End If Return count End If Case targetColor count += 1 If turn Then shouldTurn.Add(New Point(tempX, tempY)) Case MainPage.DiskColor.Empty Exit For End Select End If Next Return 0 End Function
書籍通りに記述したのですが、エラーが沢山出てきてしまいます。 DiskColorのエラーが多く出ます。 よろしくお願いします。
|