 _LOADED["level/core/pool/common_elements.lua"] = nil;
require("level/core/pool/common_elements.lua");

-- Style overrides
--------------------------------------

PoolSideStyle.navgraph = "level/core/pool/nav_2.xml",

SetDefaultStyle(PoolSideStyle);

MakeState{
	type="StateCoreLevel",
	levelId = 2,

	-- Customer Factory
	-----------------------------------
	customerFactory = {

		locations = {
			{ x = 1084, y = 336 },
		},

		customers = {
		
			-- list all customers to be spawned in the current wave
			-- nextWave defines the time to wait until the next wave
			-- use as many waves as necessary for the level
			
			{
				name = {"PoolOldTimerFemaleTutorialDrag"},
				nextWave = 6,
			},
			{
				name = {"PoolLocalLovebirdTutorialDrag"},
				nextWave = 6,
			},
			{
				name = {"PoolSpringBreakGirlTutorialDrag", "PoolSpringBreakGirlTutorialDrag"},
				nextWave = 6,
			},
			{
				name = {"PoolFemale1TutorialDrag"},
				nextWave = 6,
			},
			{
				name = {"PoolLocalLovebirdTutorialDrag"},
				nextWave = 6,
			},
			
			-- Spawnable customers
			--[[
				-- Basic customers
				-----------------------------------
				PoolOldTimerFemale						-- Orange Juice, Boat
				PoolSpringBreakGirl						-- Suntan, Volley
				PoolLocalLovebird						-- Ice Cream, Swim
				PoolFemale1								-- Wildcard, Wildcard
				
				-- Advanced customers
				-----------------------------------
				PoolConventionGeek						-- Wildcard, Suntan
				
				PoolNewlywedMale						-- Ice Cream or Cooking, Volley/Boat
				PoolNewlywedFemale						-- OJ or Suntan, Volley/Boat
				
				PoolJapaneseExecutive					-- Combination, Cooking, Boat
				PoolTexasTycoon							-- Cooking, Combination, Swim
				
				PoolAmericasFormerTopModel				-- Suntan, Cooking or Combination, Swim
				PoolShark								-- Suntan, Cooking or Combination, Volley
			]]
		},
	},
	
	targetMoney = 90,
	parTime = 180000,
	targetStars = 20,
	goals = {
		
		-- Level quota. Must match targetMoney above
		--------------------------------------------------------		
		{
			type = kClosingTimeWin,
			description = GetString("Goal_ClosingTime", "90"),
			quantity = 1,
			icon = goalIconsTable[kClosingTimeWin],
		},
		
		-- Par Time. Must match parTime above
		--------------------------------------------------------
		{
			type = kEndLevelInLessThan,
			description = GetString("Goal_CompleteBefore", "3:00"),
			quantity = 1,
			condition = 180000,
			optional = true,
			group = kGoalLessThan,
			icon = goalIconsTable[kEndLevelInLessThan],
		},
		
		-- Quality Stars. Must match targetStars above
		--------------------------------------------------------
		{
			type = kHaveStars,
			description = GetString("Goal_Stars", "20"),
			quantity = 1,
			condition = 20,
			optional = true,
			icon = goalIconsTable[kHaveStars],
		},
		
		-- Losing condition. Must match targetMoney above
		--------------------------------------------------------
		{
			type = kClosingTimeLose,
			description = GetString("Goal_ClosingTime", "90"),
			quantity = 1,
			loosingCondition = true,
			icon = goalIconsTable[kClosingTimeLose],
		},
		
	},

	tutorialManager = {
		firstStep = 0,
		lastStep = 28,
		boxImage = "level/core/common/textures/tutorial_back",
		boxBorder = 40,
		arrowAnim = TutorialArrowAnim,
		arrowImage = "level/core/common/textures/arrow",

		steps = {
			[0] = {
				message = "Tut_Pool_2_1",
				messagePosition = {x = 200, y = 125},
				waitTime = 3000,
				triggers = {
					[kWaitTimeFinished] = 1,
					[kSkippedStep] = 1,
				},
			},
			[1] = {
				customerList = {"PoolOldTimerFemaleTutorialDrag"},
				triggers = {
					[kCustomerArrived] = 2,
				},
			},
			[2] = {
				message = "Tut_Pool_2_2",
				messagePosition = {x = 200, y = 125},
				arrowPos = {
					{x = 895, y = 320},
				},
				triggers = {
					[kDragCustomer] = 3,
				},
			},
			[3] = {
				message = "Tut_Pool_2_3",
				messagePosition = {x = 200, y = 125},
				arrowPos = {
					{x = 650, y = 550},
				},
				triggers = {
					[kMoveCustomerInside] = 4,
					[kDropCustomerOutside] = 2,
				},
			},
			[4] = {
				message = "Tut_Pool_2_4",
				messagePosition = {x = 200, y = 125},
				arrowPos = {
					{x = 650, y = 550},
				},
				triggers = {
					[kMoveCustomerOutside] = 3,
					[kDropCustomerRight] = 5,
					[kDropCustomerWrong] = 5,
					[kDropCustomerOutside] = 5,
				},
			},
			[5] = {
				message = "Tut_Pool_2_5",
				waitTime = 5000,
				messagePosition = {x = 200, y = 125},
				triggers = {
					[kWaitTimeFinished] = 6,
					[kSkippedStep] = 6,
				},
			},
			[6] = {
				customerList = {"PoolOldTimerFemaleTutorialDrag"},
				triggers = {
					[kCustomerArrived] = 7,
				},
			},
			-- second boater
			[7] = {
				message = "Tut_Pool_2_6",
				messagePosition = {x = 200, y = 125},
				arrowPos = {
					{x = 895, y = 320},
				},
				triggers = {
					[kDragCustomer] = 8,
				},
			},
			-- try moving over the other customer
			[8] = {
				message = "Tut_Pool_2_7",
				messagePosition = {x = 200, y = 125},
				arrowPos = {
					{x = 550, y = 550},
				},
				triggers = {
					[kMoveCustomerWrong] = 9,
					[kDropCustomerRight] = 11,
					[kDropCustomerWrong] = 10,
					[kDropCustomerOutside] = 7,
				},
			},
			-- notice the marker changed colors
			[9] = {
				message = "Tut_Pool_2_8",
				waitTime = 5000,
				messagePosition = {x = 200, y = 125},
				arrowPos = {
					{x = 550, y = 550},
				},
				triggers = {
					[kDropCustomerRight] = 11,
					[kDropCustomerWrong] = 10,
					[kDropCustomerOutside] = 7,
				},
			},
			-- oops
			[10] = {
				message = "Tut_Pool_2_9",
				waitTime = 5000,
				messagePosition = {x = 200, y = 125},
				triggers = {
					[kWaitTimeFinished] = 29,
					[kSkippedStep] = 29,
				},
			},
			-- well done!
			[11] = {
				message = "Tut_Pool_2_10",
				waitTime = 5000,
				messagePosition = {x = 200, y = 125},
				triggers = {
					[kWaitTimeFinished] = 29,
					[kSkippedStep] = 29,
				},
			},
			
			[29] = {
				message = "Tut_Pool_2_11",
				stopDance = true,
				waitTime = 1000,
				messagePosition = {x = 200, y = 125},
				triggers = {
					[kWaitTimeFinished] = 12,
					[kSkippedStep] = 12,
				},
			},
			
			-- spawn swimmers
			[12] = {
				customerList = {"PoolLocalLovebirdTutorialDrag", "PoolLocalLovebirdTutorialDrag"},
				messagePosition = {x = 200, y = 125},
				triggers = {
					[kCustomerArrived] = 13,
				},
			},
			-- swimmers reach the pool
			[13] = {
				message = "Tut_Pool_2_11",
				messagePosition = {x = 200, y = 125},
				arrowPos = {
					{x = 895, y = 320},
				},
				triggers = {
					[kDragCustomer] = 14,
				},
			},
			-- player drags the first
			[14] = {
				message = "Tut_Pool_2_12",
				messagePosition = {x = 200, y = 125},
				arrowPos = {
					{x = 550, y = 550},
				},
				triggers = {
					[kDropCustomerRight] = 16,
					[kDropCustomerWrong] = 15,
					[kDropCustomerOutside] = 13,
				},
			},
			-- incorrect place
			[15] = {
				message = "Tut_Pool_2_13",
				waitTime = 5000,
				messagePosition = {x = 200, y = 125},
				triggers = {
					[kWaitTimeFinished] = 17,
					[kSkippedStep] = 17,
					[kDragCustomer] = 18,
				},
			},
			-- incorrect place
			[16] = {
				message = "Tut_Pool_2_14",
				waitTime = 5000,
				messagePosition = {x = 200, y = 125},
				triggers = {
					[kWaitTimeFinished] = 17,
					[kSkippedStep] = 17,
					[kDragCustomer] = 18,
				},
			},
			-- second customer
			[17] = {
				message = "Tut_Pool_2_15",
				messagePosition = {x = 200, y = 125},
				arrowPos = {
					{x = 895, y = 320},
				},
				triggers = {
					[kDragCustomer] = 18,
				},
			},
			-- player drags the second
			[18] = {
				message = "Tut_Pool_2_12",
				messagePosition = {x = 200, y = 125},
				arrowPos = {
					{x = 550, y = 600},
				},
				triggers = {
					[kDropCustomerRight] = 20,
					[kDropCustomerWrong] = 19,
					[kDropCustomerOutside] = 17,
				},
			},
			-- incorrect place
			[19] = {
				message = "Tut_Pool_2_13",
				waitTime = 5000,
				messagePosition = {x = 200, y = 125},
				triggers = {
					[kWaitTimeFinished] = 21,
					[kSkippedStep] = 21,
				},
			},
			-- correct place
			[20] = {
				message = "Tut_Pool_2_14",
				waitTime = 5000,
				messagePosition = {x = 200, y = 125},
				triggers = {
					[kWaitTimeFinished] = 21,
					[kSkippedStep] = 21,
				},
			},
			-- swimmers leave
			[21] = {
				message = "Tut_Pool_2_16",
				stopDance = true,
				waitTime = 5000,
				messagePosition = {x = 200, y = 125},
				triggers = {
					[kWaitTimeFinished] = 22,
					[kSkippedStep] = 22,
				},
			},
			-- spawn ball players
			[22] = {
				customerList = {"PoolSpringBreakGirlTutorialDrag", "PoolSpringBreakGirlTutorialDrag"},
				triggers = {
					[kCustomerArrived] = 23,
				},
			},
			-- dragging the first customer
			[23] = {
				message = "Tut_Pool_2_17",
				messagePosition = {x = 200, y = 125},
				arrowPos = {
					{x = 895, y = 320},
				},
				triggers = {
					[kDragCustomer] = 24,
				},
			},
			-- dragging the second customer
			[24] = {
				message = "Tut_Pool_2_18",
				messagePosition = {x = 200, y = 125},
				arrowPos = {
					{x = 550, y = 550},
				},
				triggers = {
					[kDropCustomerRight] = 25,
					[kDropCustomerWrong] = 25,
					[kDropCustomerOutside] = 23,
				},
			},
			-- correct/incorrect place
			[25] = {
				message = "Tut_Pool_2_19",
				messagePosition = {x = 200, y = 125},
				arrowPos = {
					{x = 895, y = 320},
					{x = 600, y = 600},
				},
				triggers = {
					[kDropCustomerRight] = 26,
					[kDropCustomerWrong] = 26,
				},
			},
			-- explanation msg
			[26] = {
				message = "Tut_Pool_2_20",
				waitTime = 5000,
				messagePosition = {x = 200, y = 125},
				triggers = {
					[kWaitTimeFinished] = 27,
					[kSkippedStep] = 27,
				},
			},
			-- players leave the pool
			[27] = {
				stopDance = true,
				message = "Tut_Pool_2_21",
				waitTime = 5000,
				messagePosition = {x = 200, y = 125},
				triggers = {
					[kWaitTimeFinished] = 28,
					[kSkippedStep] = 28,
				},
			},
			-- tutorial ends
			[28] = {
				stopDance = true,
				enableStations = {"icecream", "suntan", "orangejuice", "chair1", "chair2", "chair3", "garbage"},
				enableEmployees = true,
				activeMoney = 900000,
				resumeGame = true,
				endTutorial = true,
			},
		},
	},
		
	-- Level Content
	--------------------------------------------------------	
	CreateBackground();

	BlgContainer {
		name = "gameLayer",
		enableZSorting = true,

		-- Create level 0 stations
		CreateStations(0);
		
		-- Create the level decorations
		CreateDecos();
		CreateTimedDecos(1);

	},

	CreateBaseLevelControls(),
};

SetDefaultStyle(nil);