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.

End Sub

Sub Globals
	Dim img1,img2,img3,img4,img5,img6,img7,img8,img9,img10,img11,img12 As ImageView
	Dim sImg1,sImg2 As String
	Dim imgbackground As ImageView
	Dim imTemp As ImageView
	Dim cnt As Int
	Dim lblscore As Label
	Dim lblscore1 As Label
End Sub

Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("game7")
common.changeTheme(imgbackground)
'common.playAnimation(img1,"alpha",500)
'common.playAnimation(img2,"alpha",500)
'common.playAnimation(img3,"alpha",500)
'common.playAnimation(img4,"alpha",500)
'common.playAnimation(img5,"alpha",500)
'common.playAnimation(img6,"alpha",500)
'common.playAnimation(img7,"alpha",500)
'common.playAnimation(img8,"alpha",500)
'common.playAnimation(img9,"alpha",500)
'common.playAnimation(img10,"alpha",500)
'common.playAnimation(img11,"alpha",500)
'common.playAnimation(img12,"alpha",500)
MakePuzzle
cnt = 0
ToastMessageShow("شروع شد",False)
loadMenu
lblscore.Typeface = Typeface.LoadFromAssets("BNazanin.ttf")
lblscore1.Typeface = Typeface.LoadFromAssets("BNazanin.ttf")
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 MakePuzzle
Dim r1 As Int
r1 = Rnd(1,5)
Select Case r1
 Case 1
	img1.Tag="cat.jpg"
	img7.Tag="cat.jpg"
	'------------------
	img2.Tag="chicken.jpg"
	img8.Tag="chicken.jpg"
	'------------
	img3.Tag="cow.jpg"
	img9.Tag="cow.jpg"
	'------------
	img4.Tag="dog.jpg"
	img10.Tag="dog.jpg"
	'------------
	img5.Tag="duck.jpg"
	img11.Tag="duck.jpg"
	'-----------
	img6.Tag="elephant.jpg"
	img12.Tag="elephant.jpg"
 Case 2
	img1.Tag="cat.jpg"
	img3.Tag="cat.jpg"
	'------------------
	img2.Tag="chicken.jpg"
	img4.Tag="chicken.jpg"
	'------------
	img5.Tag="cow.jpg"
	img7.Tag="cow.jpg"
	'------------
	img8.Tag="dog.jpg"
	img9.Tag="dog.jpg"
	'------------
	img10.Tag="duck.jpg"
	img12.Tag="duck.jpg"
	'-----------
	img11.Tag="elephant.jpg"
	img6.Tag="elephant.jpg"
 Case 3
	img1.Tag="cat.jpg"
	img5.Tag="cat.jpg"
	'------------------
	img2.Tag="chicken.jpg"
	img12.Tag="chicken.jpg"
	'------------
	img3.Tag="cow.jpg"
	img11.Tag="cow.jpg"
	'------------
	img4.Tag="dog.jpg"
	img8.Tag="dog.jpg"
	'------------
	img6.Tag="duck.jpg"
	img9.Tag="duck.jpg"
	'-----------
	img7.Tag="elephant.jpg"
	img10.Tag="elephant.jpg"
 Case 4
	img10.Tag="cat.jpg"
	img11.Tag="cat.jpg"
	'------------------
	img1.Tag="chicken.jpg"
	img12.Tag="chicken.jpg"
	'------------
	img2.Tag="cow.jpg"
	img9.Tag="cow.jpg"
	'------------
	img8.Tag="dog.jpg"
	img3.Tag="dog.jpg"
	'------------
	img7.Tag="duck.jpg"
	img4.Tag="duck.jpg"
	'-----------
	img5.Tag="elephant.jpg"
	img6.Tag="elephant.jpg"
 Case 5
	img7.Tag="cat.jpg"
	img8.Tag="cat.jpg"
	'------------------
	img2.Tag="chicken.jpg"
	img12.Tag="chicken.jpg"
	'------------
	img1.Tag="cow.jpg"
	img9.Tag="cow.jpg"
	'------------
	img3.Tag="dog.jpg"
	img4.Tag="dog.jpg"
	'------------
	img10.Tag="duck.jpg"
	img5.Tag="duck.jpg"
	'-----------
	img6.Tag="elephant.jpg"
	img11.Tag="elephant.jpg"
 End Select
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub CheckItem(c1 As ImageView)
Dim i1 As Int
Dim t2,t3 As String
Dim t1 As Thread
If sImg1 <> "" Then
 sImg2 = c1.Tag
 c1.Bitmap = LoadBitmap(File.DirAssets,c1.Tag)
Else
 sImg1 = c1.Tag
 imTemp = c1
 c1.Bitmap = LoadBitmap(File.DirAssets,c1.Tag)
End If
If sImg1 <> "" AND sImg2 <> "" AND sImg1 <> sImg2 Then
  common.playAudio("wrong.wav")
  c1.Bitmap = LoadBitmap(File.DirAssets,c1.Tag)
  DoEvents
  t1.Sleep(1700)
  DoEvents
  c1.Bitmap = LoadBitmap(File.DirAssets,"none.gif")
  imTemp.Bitmap = LoadBitmap(File.DirAssets,"none.gif")
  common.vibrePhone
  sImg1 = ""
  sImg2 = ""
  t2 = lblscore1.Text
  lblscore1.Text = t2 - 10  
  ToastMessageShow("اشتباه بود",False)
Else If sImg1 <> "" AND sImg2 <> "" AND sImg1 = sImg2 Then
  sImg1 = ""
  sImg2 = ""
  common.playAnimation(c1,"scale",500)
  cnt = cnt + 1
  common.playAnimation(imTemp,"scale",500)
  t2 = lblscore1.Text
  lblscore1.Text = t2 + 10    
  c1.Visible = False
  imTemp.Visible = False
  If cnt = 6 Then
	If lblscore1.Text < -10 Then
	 t3 = "حافظه شما خیلی ضعیف است"
	Else If lblscore1.Text < 0 Then
	 t3 = "حافظه شما بد نیست"
	Else If lblscore1.Text < 40 Then
	 t3 = "حافظه شما واقعی عالیست"
	Else If lblscore1.Text < 20 Then
	 t3 = "حافظه شما وضعیت متوسط دارد"
	End If
	common.playAudio("win.mp3")
     i1 = Msgbox2("حافظه شما خوب است","آفرین","دوباره","خروج","",Null)
      If i1 = DialogResponse.POSITIVE Then
       Activity_Create(False)
      Else
	   common.stopAudio
       Activity.Finish
	   StartActivity(Main)
      End If
  End If
End If
End Sub

Sub img9_Click
 CheckItem(img9)
End Sub
Sub img8_Click
 CheckItem(img8)	
End Sub
Sub img7_Click
 CheckItem(img7)
End Sub
Sub img6_Click
 CheckItem(img6)
End Sub
Sub img5_Click
 CheckItem(img5)
End Sub
Sub img4_Click
 CheckItem(img4)
End Sub
Sub img3_Click
 CheckItem(img3)
End Sub
Sub img2_Click
 CheckItem(img2)
End Sub
Sub img12_Click
 CheckItem(img12)
End Sub
Sub img11_Click
 CheckItem(img11)
End Sub
Sub img10_Click
 CheckItem(img10)
End Sub
Sub img1_Click
CheckItem(img1)
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
  If KeyCode = KeyCodes.KEYCODE_MENU Then
   Activity.OpenMenu
  End If
End Sub