Button 1 Label TestPosAndColor

Button 3 Label CollectEcoCredits

Button 5 Label AssignAllPets
Button 6 Label UnassignAllPets

Button 8 Label PaintSeedLaunch
Button 9 Label PaintSeedLaunchFast

PaintSeedLauncherInit
Stop


Variable Numeric MX = 0 'Monitor 1/2/3 = -1920 / 0 / 1920


' ===================================================================
'  TEST POS AND COLOR
' ===================================================================
Label TestPosAndColor
	For v1 = 1 To Infinity
		s1 = MouseXP  + " " + MouseYP + " "
		s1 = s1 + GetPixelColor(MouseXP, MouseYP) + " "
		s1 = s1 + GetColorIndex(GetPixelColor(MouseXP, MouseYP))
		Print s1
	Next
Return


' ===================================================================
'  ASSIGN / UNASSIGN  PETS
' ===================================================================
Label CollectEcoCredits
	' -------------------------------- Save the old position
	v1 = MouseXP
	v2 = MouseYP
	' --------------------------------
	CollectEcoCredits2
	' --------------------------------
	Controls SetCursorPos v1 v2
Return

Label CollectEcoCredits2
	' ---------------------------------- double click the Ajam icon
	Controls SetCursorPos 1025 70
	DoubleClickLeftButton
	' ---------------------------------- test and click the DEN button
	Wait GetColorIndex(GetPixelColor(MX+3607, 51)) = 2
	Wait GetColorIndex(GetPixelColor(MX+3618, 86)) = 4
	Wait Seconds 0.5
	Wait GetColorIndex(GetPixelColor(MX+3607, 51)) = 2
	Wait GetColorIndex(GetPixelColor(MX+3618, 86)) = 4
	Controls SetCursorPos MX+3618 80
	DoubleClickLeftButton
	Wait Seconds 2
	' ---------------------------------- test the DEN yellow area
	Wait GetColorIndex(GetPixelColor(MX+3660, 58)) = 2
	' ---------------------------------- click Paintseeds
	ClickPaintSeeds
    ' ---------------------------------- click the solar panel
	Controls SetCursorPos MX+3431 872
	DoubleClickLeftButton
    ' ---------------------------------- test and click the eco credits button
	Wait GetColorIndex(GetPixelColor(MX+2783, 515)) = 5
	Controls SetCursorPos MX+3003 360
	DoubleClickLeftButton
	Wait Seconds 2
	' ---------------------------------- click the red X button
	Controls SetCursorPos MX+3110 840
	DoubleClickLeftButton
	Wait Seconds 0.5
	' ---------------------------------- click the fox button
	Controls SetCursorPos MX+2879 85
	DoubleClickLeftButton
	Wait Seconds 0.5
	' ---------------------------------- click the ZZZ button
	Controls SetCursorPos MX+3122 218
	DoubleClickLeftButton
	Wait Seconds 0.5
	' ---------------------------------- click the GEAR button
	Controls SetCursorPos MX+3756 1000
	DoubleClickLeftButton
	Wait Seconds 0.5
	' ---------------------------------- click the ZZZ button
	Controls SetCursorPos MX+3369 160
	DoubleClickLeftButton
	Wait Seconds 0.5
	' ---------------------------------- click the YES button
	Controls SetCursorPos MX+3055 417
	DoubleClickLeftButton
	Wait Seconds 0.5
Return

Label ClickLeftButton
	Wait Seconds 0.05
	PressKeys LButtonDOWN
	Wait Seconds 0.05
	PressKeys LButtonUP
Return

Label DoubleClickLeftButton
	ClickLeftButton
	ClickLeftButton
	Wait Seconds 0.1
Return

Label ClickPaintSeeds
	
	'Controls SetCursorPos MX+2785 573
	'Controls SetCursorPos MX+2841 611
	'ClickLeftButton
	'Wait Seconds 0.5
	
	
	Variable Numeric nn
	Variable Numeric x1
	Variable Numeric y1
	For x1 = MX+2680 To MX+2899 Step 20
		For y1 = 560 To 620 Step 20
			If GetColorIndex(GetPixelColor(x1, y1)) = 6
				For nn = 1 To 6
					Controls SetCursorPos x1 y1
					ClickLeftButton
					Wait Seconds 0.5
				Next
				Exit 2
			EndIf
		Next
	Next
Return



' ===================================================================
'  ASSIGN / UNASSIGN
' ===================================================================
Label AssignAllPets
	Controls SetCursorPos MX+2540 614
	PressLeftButton
	PressAssign
	Controls SetCursorPos MX+2713 614
	PressLeftButton
	PressAssign
	Controls SetCursorPos MX+2870 614
	PressLeftButton
	PressAssign
	Controls SetCursorPos MX+3060 614
	PressLeftButton
	PressAssign
	Controls SetCursorPos MX+3220 614
	PressLeftButton
	PressAssign
	Controls SetCursorPos MX+3274 761
	PressLeftButton
Return

Label UnassignAllPets
	Controls SetCursorPos MX+2540 614
	PressLeftButton
	PressOK
	Controls SetCursorPos MX+2713 614
	PressLeftButton
	PressOK
	Controls SetCursorPos MX+2870 614
	PressLeftButton
	PressOK
	Controls SetCursorPos MX+3060 614
	PressLeftButton
	PressOK
	Controls SetCursorPos MX+3220 614
	PressLeftButton
	PressOK
	Controls SetCursorPos MX+3274 761
	PressLeftButton
Return

Label PressAssign
	Wait Seconds 0.3
	Controls SetCursorPos MX+2836 559
	PressLeftButton
Return

Label PressOK
	Controls SetCursorPos MX+3033 413
	PressLeftButton
Return

Label PressLeftButton
	PressKeys LButtonDOWN
	Wait Seconds 0.1
	PressKeys LButtonUP
	Wait Seconds 0.2
Return


' ===================================================================
'  PAINTSEED LAUNCHER
' ===================================================================

Label PaintSeedLauncherInit
	Variable Numeric ActiveTime
	Variable Numeric PauseTime
	Variable Numeric TotalSeeds
	Option GlobalKeys Enabled
	Key Up   Gosub ExecKeys
	Key Down Gosub ExecKeys
	Key Left   Gosub ExecKeys
	Key Right Gosub ExecKeys
Return

Label PaintSeedLaunch
	ActiveTime = 0.46
	PauseTime =  1.1
	TotalSeeds = 380
	Gosub Launcher
Return

Label PaintSeedLaunchFast
	ActiveTime = 0.46
	PauseTime =  0
	TotalSeeds = 760
	Gosub Launcher
Return

Label Launcher
	' -------------------------------- Save the old position
	v1 = MouseXP
	v2 = MouseYP
	' ------------------------------------ Set the Cursor position
	Controls SetCursorPos MX+2875 230
	' ------------------------------------ Wait a little
	Wait Seconds 1
	' ------------------------------------ Start launcher
	For v91 = 1 To TotalSeeds
		' -------------------------------- Test the color
		v9 = GetCursorPixelColor()
		v9 = GetColorIndex(v9)
		If v9 <> 6
			Exit
		EndIf
		' -------------------------------- Launch
		Wait Not Key("Space")
		PressKeys LButtonDOWN
		Wait Seconds ActiveTime
		PressKeys LButtonUP
		Wait Seconds PauseTime
		Print v91 + " " + ActiveTime + " " + PauseTime
	Next
	Controls SetCursorPos v1 v2
Return

Label ExecKeys
	Select True
		Case Key("Up")
			ActiveTime = ActiveTime + 0.01
		Case Key("Down")
			ActiveTime = ActiveTime - 0.01
		Case Key("Right")
			PauseTime = PauseTime + 0.1
		Case Key("Left")
			PauseTime = PauseTime - 0.1
	EndSelect
	Print v91 + " " + ActiveTime + " " + PauseTime
Return


'WATCH SewTo_Speed
'EXEC Button 5 Text Button5
