require("scripts/styles/style.lua");
require("scripts/styles/deco_animations.lua");

FixMinigameData();

MakeState{
	type = "StateMGRavingBalls",

	BlgBitmap{
		image = "common/backgrounds/bg_mainmenu",
		name = "mainmenuBG",
		center = {x = 0, y = 0},
		transformMatrix = {x =  -112, y = -84},
	},
	
	gameTime = 45000,
	initScore = 0,
	
	miniMessageFont  = {
		secondaryFont,
		30,
		Color(138, 237, 58),
	},
	miniMessageWrongColor = Color (255, 90, 70),
	miniMessageBorder = 0,
	miniMessageBorderColor = Color(0,0,0),
	
	tutorialText = "Tutorial_RavingBalls",

	-- Notes
	notes = {	1, 0, 0, 0,	0, 0, 0, 0,
				1, 0, 0, 0,	1, 0, 0, 0,
				1, 0, 0, 0,	1, 0, 0, 0,
				1, 0, 0, 0,	1, 0, 0, 0, --[[ first variant ]]
				1, 0, 0, 0,	0, 0, 0, 0,
				1, 0, 0, 0,	1, 0, 0, 0,
				1, 0, 0, 0,	1, 0, 0, 0,
				1, 0, 1, 0, 1, 0, 1, 0, --[[ second variant ]]
				1, 0, 0, 0,	0, 0, 0, 0,
				1, 0, 0, 0,	1, 0, 0, 0,
				1, 0, 1, 0,	1, 0, 1, 0,
				1, 0, 1, 0, 1, 0, 1, 0, --[[ third variant ]]
				1, 0, 0, 0,	0, 0, 0, 0,
				1, 0, 0, 0,	1, 0, 0, 0,
				1, 0, 0, 0,	1, 0, 0, 0,
				1, 0, 1, 1, 1, 0, 0, 0, --[[ fourth variant ]]
				1, 0, 0, 0,	0, 0, 0, 0,
				1, 0, 0, 0,	1, 0, 0, 0,
				1, 0, 0, 0,	1, 0, 0, 0,
				1, 1, 0, 0, 0, 0, 0, 1, --[[ fourth variant ]]
	},

	-- Generators
	generators = {
		-- Generators common variables
		distance = 350,
		time = 1.435, -- 0.205 * 7

		{
			pos = {x = 296, y = 184},
			direction = {x = 1, y = 1},
			color = "red",

		},
		{
			pos = {x = 512, y = 183},
			direction = {x = -1, y = 1},
			color = "blue",
		},
		{
			pos = {x = 296, y = 373},
			direction = {x = 1, y = -1},
			color = "yellow",
		},
		{
			pos = {x = 512, y = 374},
			direction = {x = -1, y = -1},
			color = "green",
		}
	},
	
	BlgContainer {
		name = "gameContainer",
		transformMatrix = {x =  112, y = 84},

		BlgContainer{
			name = "mainContainer",
			BlgBitmap{
				image="level/ravingballs/textures/background",
				center = {x = 0, y = 0},
			},
			
			BlgContainer{
				name = "rbInputContainer",
			},	

			BlgBitmap{
				image="level/ravingballs/textures/white",
				center = {x = 0, y = 0},
				blendMode = kBlendSubtractive,
			},
			
			BlgMovieClip{
				zLayer = 1990,
				repeatCount = 0,
				SetStyle(DrumDancerStyle),
				BlgBitmap{
					image="level/ravingballs/textures/conga_minigame",
					transformMatrix = {x = 100, y = 550, scaleX = 1.5, scaleY = 1.5},
					alpha = 0.15,
					playAnim = "Mconga",
				},
			},
			
			BlgMovieClip{
				zLayer = 1990,
				repeatCount = 0,
				SetStyle(DrumDancerStyle),
				BlgBitmap{
					image="level/ravingballs/textures/conga_minigame",
					transformMatrix = {x = 300, y = 550, scaleX = 1.5, scaleY = 1.5},
					alpha = 0.15,
					playAnim = "Mconga",
				},
			},
			
			BlgMovieClip{
				zLayer = 1990,
				repeatCount = 0,
				SetStyle(DrumDancerStyle),
				BlgBitmap{
					image="level/ravingballs/textures/conga_minigame",
					transformMatrix = {x = 500, y = 550, scaleX = 1.5, scaleY = 1.5},
					alpha = 0.15,
					playAnim = "Mconga",
				},
			},
			
			BlgMovieClip{
				zLayer = 1990,
				repeatCount = 0,
				SetStyle(DrumDancerStyle),
				BlgBitmap{
					image="level/ravingballs/textures/conga_minigame",
					transformMatrix = {x = 700, y = 550, scaleX = 1.5, scaleY = 1.5},
					alpha = 0.15,
					playAnim = "Mconga",
				},
			},
			
			BlgMovieClip{
				zLayer = 1990,
				repeatCount = 0,
				SetStyle(DrumDancerStyle),
				BlgBitmap{
					image="level/ravingballs/textures/conga_minigame",
					transformMatrix = {x = 900, y = 550, scaleX = 1.5, scaleY = 1.5},
					alpha = 0.15,
					playAnim = "Mconga",
				},
			},
			
			BlgMovieClip{
				zLayer = 2000,
				repeatCount = 0,
				SetStyle(DiscoLight1Style),				
				BlgBitmap {
					image="level/core/club/textures/deco_discolights",
					center = {x = 128, y = 128},
					transformMatrix = {x = 0, y = 300, scaleX = 4.0, scaleY = 4.0},
					alpha = 0.75,
					blendMode = kBlendAdditiveAlpha,
				},
			},
			
			BlgMovieClip{
				zLayer = 2000,
				repeatCount = 0,
				SetStyle(DiscoLight2Style),				
				BlgBitmap {
					image="level/core/club/textures/deco_discolights",
					center = {x = 128, y = 128},
					transformMatrix = {x = 800, y = 300, rotation = 180, scaleX = 4.0, scaleY = 4.0},
					alpha = 0.75,
					blendMode = kBlendAdditiveAlpha,
				},
			},
		},
		
		CreateMinigameControls();

	},
	
	-- Drum animations
	drumCorrectAnim = {
		keyframes = {
			{
				index = 0,
				tweens = {
					{
						type = "SimpleEase",
						target = TWEEN_ALL,
						ease = 1,
					},
				},
			},
			{
				index = 4,
				scaleX = 0.75,
				scaleY = 0.75,
				tweens = {
					{
						type = "SimpleEase",
						target = TWEEN_ALL,
						ease = 0,
					},
				},
			},
			{
				index = 7,
				scaleX = 1.25,
				scaleY = 1.25,
				tweens = {
					{
						type = "SimpleEase",
						target = TWEEN_ALL,
						ease = -1,
					},
				},
			},
			{
				index = 9,
				scaleX = 1,
				scaleY = 1,
			},
		},
	};

	drumIncorrectAnim = 
	{
		keyframes = {
			{
				index = 0,
				tweens = {
					{
						type = "SimpleEase",
						target = TWEEN_ALL,
						ease = 0,
					},
				},
			},
			{
				index = 3,
				x = -10,
				y = 10,
				scaleX = 0.90,
				scaleY = 0.90,
				tweens = {
					{
						type = "SimpleEase",
						target = TWEEN_ALL,
						ease = 0,
					},
				},
			},
			{
				index = 6,
				x = 10,
				y = 0,
				tweens = {
					{
						type = "SimpleEase",
						target = TWEEN_ALL,
						ease = 0,
					},
				},
			},
			{
				index = 9,
				x = -10,
				y = -10,
				tweens = {
					{
						type = "SimpleEase",
						target = TWEEN_ALL,
						ease = 0,
					},
				},
			},
			{
				index = 12,
				x = 10,
				y = 10,
				tweens = {
					{
						type = "SimpleEase",
						target = TWEEN_ALL,
						ease = 0,
					},
				},
			},
			{
				index = 15,
				x = -10,
				y = -10,
				tweens = {
					{
						type = "SimpleEase",
						target = TWEEN_ALL,
						ease = 0,
					},
				},
			},
			{
				index = 19,
				x = 0,
				y = 0,
				scaleX = 1,
				scaleY = 1,
			},
		},
	};
	
	blurCorrectAnim = {
		keyframes = {
			{
				index = 0,
				blendMode = kBlendAdditiveAlpha,
				color = {red = 1.0, green = 1.0, blue = 1.0},
				tweens = {
					{
						type = "SimpleEase",
						target = TWEEN_ALL,
						ease = 0,
					},
				},
			},
			{
				index = 7,
				scaleX = 1.5,
				scaleY = 1.5,
				alpha = 1.0,
				blendMode = kBlendAdditiveAlpha,
				color = {red = 1.0, green = 1.0, blue = 1.0},
				tweens = {
					{
						type = "SimpleEase",
						target = TWEEN_ALL,
						ease = 1,
					},
				},
			},
			{
				index = 15,
				scaleX = 2.0,
				scaleY = 2.0,
				alpha = 0.0,
				blendMode = kBlendAdditiveAlpha,
				color = {red = 1.0, green = 1.0, blue = 1.0},
			},
		},
	};
	
	blurIncorrectAnim = 
	{
		keyframes = {
			{
				index = 0,
				blendMode = kBlendNormal,
				alpha = 0.5,
				color = {red = 0.5, green = 0.5, blue = 0.5},
				tweens = {
					{
						type = "SimpleEase",
						target = TWEEN_ALL,
						ease = 0,
					},
				},
			},
			{
				index = 8,
				scaleX = 1.5,
				scaleY = 1.5,
				alpha = 0.5,
				color = {red = 0.5, green = 0.5, blue = 0.5},
				blendMode = kBlendNormal,
				tweens = {
					{
						type = "SimpleEase",
						target = TWEEN_ALL,
						ease = 1,
					},
				},
			},
			{
				index = 20,
				scaleX = 2.0,
				scaleY = 2.0,
				alpha = 0.0,
				color = {red = 0.5, green = 0.5, blue = 0.5},
				blendMode = kBlendNormal,
			},
		},
	};
};
