Type=Activity
Version=4.3
ModulesStructureVersion=1
B4A=true
@EndOfDesignText@
#Region  Activity Attributes 
	#FullScreen: False
	#IncludeTitle: False
#End Region
'در این قسمت صدای عددی پخش خواهد شد و کودک باید تشخیص دهد
Sub Process_Globals
	'These global variables will be declared once when the application starts.
	'These variables can be accessed from all modules.
	Dim tmr2,tmr1 As Timer
End Sub

Sub Globals
	'These global variables will be redeclared each time the activity is created.
	'These variables can only be accessed from this module.
	Dim btn1 As Button
	Dim btn2 As Button
	Dim btn3 As Button
	Dim btn4 As Button
	Dim btn5 As Button
	Dim lblscore As Label
	Dim lblstage As Label
	Dim lblseconds As Label
	Dim lblsecond As Label
	Dim sTimeout As Int
	Dim res As String
	Dim sT As Int
	Dim imgbg1 As ImageView
	Dim imgbackground As ImageView
End Sub

Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("game6")
common.changeTheme(imgbackground)
btn1.Typeface = Typeface.LoadFromAssets("BNazanin.ttf")
btn2.Typeface = Typeface.LoadFromAssets("BNazanin.ttf")
btn3.Typeface = Typeface.LoadFromAssets("BNazanin.ttf")
btn4.Typeface = Typeface.LoadFromAssets("BNazanin.ttf")
btn5.Typeface = Typeface.LoadFromAssets("BNazanin.ttf")
lblscore.Typeface = Typeface.LoadFromAssets("BNazanin.ttf")
lblsecond.Typeface = Typeface.LoadFromAssets("BNazanin.ttf")
lblseconds.Typeface = Typeface.LoadFromAssets("BNazanin.ttf")
lblscore.Typeface = Typeface.LoadFromAssets("BNazanin.ttf")
lblstage.Typeface = Typeface.LoadFromAssets("BNazanin.ttf")
settings.loadDefaultSetting("5")
sTimeout = settings.getData("settingGame5.app","timeout")
lblstage.Text = settings.getData("settingGame5.app","stage")

Select Case lblstage.Text
 Case 1
    sT = Rnd(0,6)
	common.playAudioNumber(sT)
 Case 2
    sT = Rnd(0,8)
	common.playAudioNumber(sT)
 Case 3
    sT = Rnd(0,13)
	common.playAudioNumber(sT)
 Case 4
    sT = Rnd(0,18)
	common.playAudioNumber(sT)
 Case 5
    sT = Rnd(0,26)
	common.playAudioNumber(sT)
 Case 6
    sT = Rnd(0,40)
	common.playAudioNumber(sT)
 Case 7
    sT = Rnd(0,50)
	common.playAudioNumber(sT)
 Case 8
    sT = Rnd(0,70)
	common.playAudioNumber(sT)	
 Case 9
    sT = Rnd(0,80)
	common.playAudioNumber(sT)	
 Case 10
    sT = Rnd(0,90)
	common.playAudioNumber(sT)
 Case 11
    sT = Rnd(0,99)
	common.playAudioNumber(sT)	
 Case 12
    sT = Rnd(0,99)
	common.playAudioNumber(sT)	
End Select
res = sT
loadResultAction
'common.playAnimation(btn1,"scale1",1200)
'common.playAnimation(btn2,"scale1",1200)
'common.playAnimation(btn3,"scale1",1200)
'common.playAnimation(btn4,"scale1",1200)
'common.playAnimation(btn5,"scale1",1200)

tmr2.Initialize("tmr2",1)
tmr2.Enabled = True
tmr1.Initialize("tmr1",1400)
tmr1.Enabled = True
loadMenu
End Sub
Sub loadMenu
Activity.AddMenuItem2("تنظیمات","btnsetting",LoadBitmap(File.DirAssets,"setting.png"))
Activity.AddMenuItem2("درباره ما","btnabout",LoadBitmap(File.DirAssets,"about.png"))
Activity.AddMenuItem2("خروج","exit1",LoadBitmap(File.DirAssets,"exit.png"))
End Sub
Sub btnsetting_Click
Activity.Finish
StartActivity(setting)
End Sub
Sub btnabout_Click
Activity.Finish
StartActivity(frmabout)
End Sub
Sub exit1_Click
Dim i As Int
i = Msgbox2("آیا مایل به خروج هستید؟","خروج","آری","خیر","",Null)
If i = DialogResponse.POSITIVE Then
 ExitApplication
End If
End Sub
Sub loadResultAction
Dim k1(5) As String
k1(0) = Rnd(0,20)
k1(1) = Rnd(21,50)
k1(2) = Rnd(51,70)
k1(3) = Rnd(71,99)
k1(4) = sT
common.ShuffleArray(k1)
btn1.Text = k1(0)
btn2.Text = k1(1)
btn3.Text = k1(2)
btn4.Text = k1(3)
btn5.Text = k1(4)
End Sub
Sub tmr1_Tick
common.playAnimation(imgbg1,"alpha",200)
End Sub

Sub tmr2_Tick
Dim k1 As Int
If lblsecond.Text > sTimeout Then
   tmr2.Enabled = False
   frmGame1_result.sTime = "زمان سپری شده "  & lblsecond.Text & " : " & lblseconds.Text & " ثانیه"
   frmGame1_result.sState = "unwin"
   frmGame1_result.sGameNumber = "5"
   frmGame1_result.sScore = lblscore.Text
   common.stopAudio
   Activity.Finish
   StartActivity(frmGame1_result)
End If
'Create Timer
k1 = lblseconds.Text + 1
lblseconds.Text = k1
If lblseconds.Text > 60 Then
 lblseconds.Text = 0
 k1 = lblsecond.Text + 1
 lblsecond.Text = k1
End If
'----------------------------------------------------------------------
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
Sub btn5_Click
 If res <> btn5.Text Then
  wrongItem(btn5)
 Else
  stateGame("win")
 End If	
End Sub
Sub btn4_Click
 If res <> btn4.Text Then
  wrongItem(btn4)
 Else
  stateGame("win")
 End If	
End Sub
Sub btn3_Click
 If res <> btn3.Text Then
  wrongItem(btn3)
 Else
  stateGame("win")
 End If	
End Sub
Sub btn2_Click
 If res <> btn2.Text Then
  wrongItem(btn2)
 Else
  stateGame("win")
 End If	
End Sub
Sub btn1_Click
 If res <> btn1.Text Then
  wrongItem(btn1)
 Else
  stateGame("win")
 End If
End Sub
Sub wrongItem(c1 As Button)
Dim t1 As Int
common.playAudio("wrong.wav")
common.playAnimation(c1,"scale",1000)
c1.Visible = False
t1 = lblscore.Text
lblscore.Text = t1 - 10
common.vibrePhone
End Sub
Sub stateGame(sState1 As String)
   tmr2.Enabled = False
   frmGame1_result.sStage = lblstage.Text
   frmGame1_result.sTime = "زمان سپری شده "  & lblsecond.Text & " : " & lblseconds.Text & " ثانیه"
   frmGame1_result.sState = sState1
   frmGame1_result.sScore = lblscore.Text
   frmGame1_result.sGameNumber = "5"
   Activity.Finish
   StartActivity(frmGame1_result)
End Sub
Sub Activity_KeyPress (KeyCode As Int) As Boolean 'Return True to consume the event
  If KeyCode = KeyCodes.KEYCODE_BACK Then
   Activity.Finish
   common.stopAudio   
   StartActivity(Main)
  End If
End Sub