Литмир - Электронная Библиотека
Содержание  
A
A

Or pos = 73 Or pos = 74 Or pos = 75 Then

Return 0

End If

Dim type As Integer = MPBoxes(pos).MPIndex

Dim i As Integer = pos Mod 10

i = IIf(i = 8, 18, IIf(i = 7, 27, IIf(i = 6, 36, i)))

Dim count As Integer

Dim startpos As Integer = i

Dim endpos As Integer = i

Dim tempi As Integer = i + 1

Dim temp As Integer

If i < 9 Then

temp = 9 – i

Else

temp = 9 – (i \ 9)

End If

While i < tempi + (temp – 1) * 10

If MPBoxes(i).MPIndex = type Then

endpos += 10

count = (endpos – startpos) \ 10

Else

If count > 4 Then

While MPBoxes(pos).MPState = _

BallState.ZOOMING_BALL

Application.DoEvents()

End While

For j As Integer = 0 To count – 1

MPBoxes(startpos + j * 10).Destroy()

Next

Return count

End If

If i >= pos + 40 Then

Return count

End If

startpos = i + 10

endpos = i + 10

End If

i += 10

End While

If count > 4 Then

While MPBoxes(pos).MPState = BallState.ZOOMING_BALL

Application.DoEvents()

End While

For j As Integer = 0 To count – 1

MPBoxes(startpos + j * 10).Destroy()

Next

Return count

End If

End Function

Private Function CheckRL(ByVal pos As Integer) As Integer

If pos = 0 Or pos = 1 Or pos = 2 Or pos = 3 Or pos = 9 _

Or pos = 10 Or pos = 11 _

Or pos = 18 Or pos = 19 Or pos = 27 Or pos = 53 _

Or pos = 61 Or pos = 62 _

Or pos = 69 Or pos = 70 Or pos = 71 Or pos = 77 _

Or pos = 78 Or pos = 79 Or pos = 80 Then

Return 0

End If

Dim type As Integer = MPBoxes(pos).MPIndex

Dim i As Integer = pos Mod 8

If i = 0 Then

i = 8

ElseIf i < 4 Then

i = (i + 1) * 8 + i

ElseIf pos \ 8 >= 5 Then

i = 45

End If

Dim count As Integer

Dim startpos As Integer = i

Dim endpos As Integer = i

Dim tempi As Integer = i + 1

Dim temp As Integer

If i < 9 Then

temp = i + 1

Else

temp = 9 – (i \ 8)

End If

While i < tempi + temp * 8

If MPBoxes(i).MPIndex = type Then

endpos += 8

count = (endpos – startpos) \ 8

Else

If count > 4 Then

While MPBoxes(pos).MPState = _

BallState.ZOOMING_BALL

Application.DoEvents()

End While

For j As Integer = 0 To count – 1

MPBoxes(startpos + j * 8).Destroy()

Next

Return count

End If

If i >= pos + 32 Then

Return count

End If

startpos = i + 8

endpos = i + 8

End If

i += 8

End While

If count > 4 Then

While MPBoxes(pos).MPState = BallState.ZOOMING_BALL

Application.DoEvents()

End While

For j As Integer = 0 To count – 1

MPBoxes(startpos + j * 8).Destroy()

Next

Return count

End If

End Function

Private Function CalWin(ByVal pos As Integer) As Integer

Dim point As Integer = CheckHor(pos)

If point < 4 Then

point = CheckVer(pos)

End If

If point < 4 Then

point = CheckLR(pos)

End If

If point < 4 Then

point = CheckRL(pos)

End If

If point > 4 Then

Dim dpoint As Double = point * 100 + (dpoint \ 6) * 100

Dim n As Double = DDScore.number + dpoint

For i As Double = DDScore.number To n Step 10

DDScore.number = i

lblScore.Refresh()

Next

DDScore.number = n

Return point

Else

Return 0

End If

End Function

'#Region "Ball Event And Paint Board"

Private Sub Ball_Click(ByVal sender As System.Object, _

ByVal e As System.EventArgs)

CType(sender, MotionPic).Jump()

If CType(sender, MotionPic).MPState <> _

BallState.NO_BALL Then

If intFlag <> -1 Then

MPBoxes(intFlag).Jump()

End If

'intFlag = MPBoxes.IndexOf(MPBoxes, sender)

'Исправляем предупреждение:

intFlag = Array.IndexOf(MPBoxes, sender)

ElseIf intFlag <> -1 Then

Dim tempS As String = MPBoxes(intFlag).Tag

MPBoxes(intFlag).Tag = ""

FindSol(intFlag)

If sender.tag = "Here" Then

'posMoveTo = MPBoxes.IndexOf(MPBoxes, sender)

'Исправляем предупреждение:

posMoveTo = Array.IndexOf(MPBoxes, sender)

If posMoveTo = ThreeBP(0) Then

prePic(0).SendToBack()

ElseIf posMoveTo = ThreeBP(1) Then

prePic(1).SendToBack()

ElseIf posMoveTo = ThreeBP(2) Then

prePic(2).SendToBack()

End If

CType(sender, MotionPic).Init(MPBoxes(intFlag). _

MPIndex)

MPBoxes(intFlag).Destroy()

While MPBoxes(intFlag).MPState = _

BallState.DESTROYING_BALL

Application.DoEvents()

End While

If CalWin(posMoveTo) = 0 Then

If GiveThreeBalls() = False Then

playerScore = DDScore.number

Dim frm As Form2 = New Form2

frm.AddPlayer() = _

New Player(playerName, playerScore)

frm.Show()

frm.PlashScreen()

frm.drawTable()

ResetBoard()

End If

End If

PreShow()

intFlag = -1

Else

MPBoxes(intFlag).Tag = tempS

End If

ResetAllTag()

End If

End Sub

Private Sub ResetBoard()

ThreeBI(0) = -1

tmr1.Enabled = False

tmr2.Enabled = False

playerScore = 0

playerTime = 0

DDScore.number = 0

DDTime.number = 0

Me.Refresh()

PreShow()

lblNameShow.Text = ""

picBallPre1.Image = Nothing

For i As Integer = 0 To 80

MPBoxes(i).Reset()

Next

End Sub

Private Sub DrawBoard(ByVal sender As Object, _

ByVal e As System.Windows.Forms.PaintEventArgs) _

Handles MyBase.Paint

Dim g As Graphics = e.Graphics

'Рисуем сетку линиями красного (Red) цвета:

Dim p1 As New Pen(Color.Red)

Dim p2 As New Pen(Color.Black)

For i As Integer = 0 To 9

g.DrawLine(p1, intBaseX + 45 * i – 4, intBaseY – 5, _

intBaseX + 45 * i – 4, intBaseY + 45 * 9 – 5)

g.DrawLine(p2, intBaseX + 45 * i – 3, intBaseY – 4, _

intBaseX + 45 * i – 3, intBaseY + 45 * 9 – 4)

g.DrawLine(p1, intBaseX – 4, intBaseY + 45 * i – 5, _

intBaseX + 45 * 9 – 4, intBaseY + 45 * i – 5)

g.DrawLine(p2, intBaseX – 3, intBaseY + 45 * i – 4, _

intBaseX + 45 * 9 – 3, intBaseY + 45 * i – 4)

Next

End Sub

Private Sub LabelScore_Paint(ByVal sender As System.Object, _

ByVal e As System.Windows.Forms.PaintEventArgs)

DDScore.showNumber(e.Graphics)

End Sub

Private Sub LabelTime_Paint(ByVal sender As System.Object, _

ByVal e As System.Windows.Forms.PaintEventArgs)

DDTime.showTime(e.Graphics)

End Sub

Private Sub tmr1_Tick(ByVal sender As System.Object, _

ByVal e As System.EventArgs) Handles tmr1.Tick

Dim s As String = lblNameShow.Text

lblNameShow.Text = s.Substring(1) + s.Substring(0, 1)

End Sub

'Счётчик секунд, который обнуляем в начале каждой игры

'в методе NewGame:

Dim secondCounter As Integer

'Время, через которое звучит мелодия

'возможного окончания игры:

Dim EndGameTime As Integer = 60

Private Sub tmr2_Tick(ByVal sender As System.Object, _

ByVal e As System.EventArgs) Handles tmr2.Tick

DDTime.number += 1

lblTime.Refresh()

'Счётчик секунд:

secondCounter = secondCounter + 1

'Мелодия окончания игры:

If secondCounter = EndGameTime Then

My.Computer.Audio.Play("..\..\Sounds\win.wav", _

AudioPlayMode.Background)

End If

End Sub

'#Region "Preview Balls"

Private Sub PreShow()

Dim col, row As Integer

For i As Integer = 0 To 2

If ThreeBI(i) = -1 Then

prePic(i).Visible = False

Else

prePic(i).Visible = True

13
{"b":"813074","o":1}