
function LightningAnim04 (Begin, LiveTime, timeScene)
	local LocalTime = (timeScene - Begin)/LiveTime	
	local flash = 0.1
--	currentMult.Scene4_light.Lightning.scale = 0.8
	if Begin <= timeScene and  timeScene < Begin + LiveTime then
		currentMult.Scene4_light.layer.isVisible = true
		if LocalTime <= flash then
			local FlashTime = LocalTime/flash		
			currentMult.Scene4_light.Lightning.color = Color(240, 240, 255, lerp (0, 255, FlashTime))
			currentMult.Scene4.Light.color = Color(255, 255, 255, lerp (0, 150, FlashTime))
--			currentMult.Scene4_light.Lightning.color = Color(240, 240, 255, lerp (0, 255, FlashTime))			
currentMult.Scene4_light.Lightning.color = Color(240, 240, 255, 255)						
			currentMult.Scene4.CastleMaxDark.color = Color(255, 255, 255, lerp (0, 150, FlashTime))			
			currentMult.Scene4.StormCloudDark.color = Color(255, 255, 255, lerp (0, 100, FlashTime))
		else
			local SlowTime  = ease((LocalTime-flash)/(1 -flash), 0.1, 0) 		
			currentMult.Scene4_light.Lightning.color = Color(240, 240, 255, lerp (150, 0, SlowTime ))
			currentMult.Scene4.Light.color = Color(255, 255, 255, lerp (150, 0, SlowTime ))
			
			currentMult.Scene4.CastleMaxDark.color = Color(255, 255, 255, lerp (150, 0, SlowTime))
			currentMult.Scene4.StormCloudDark.color = Color(255, 255, 255, lerp (100, 0, SlowTime))
		end	
		currentMult.Scene4_light.Lightning.x     = lerp(350, 450, timeScene)
		currentMult.Scene4_light.Lightning.y     = 235
	else
		currentMult.Scene4.CastleMaxDark.color = Color(255, 255, 255, 0)
		currentMult.Scene4.StormCloudDark.color = Color(255, 255, 255, 0)
		currentMult.Scene4_light.Lightning.color = Color(255, 255, 255, 0)
		currentMult.Scene4_light.layer.isVisible = false
	end	
--
end

function FlameTree ( timeScene ) 

	currentMult.Effect04.TreeFlame1.x = lerp (220, 455, timeScene)
	currentMult.Effect04.TreeFlame1.y = lerp (250, 100, timeScene)
	                                             
	currentMult.Effect04.TreeFlame2.x = lerp (205, 425, timeScene)
	currentMult.Effect04.TreeFlame2.y = lerp (260, 115, timeScene)
	                                       
	currentMult.Effect04.TreeFlame3.x = lerp (220, 450, timeScene)
	currentMult.Effect04.TreeFlame3.y = lerp (265, 135, timeScene)	
	                                
end

local treeAnimDo = true

function Visual_4 (timeScene)

	currentMult.Scene4.Sky01.x     = 245
	currentMult.Scene4.Sky01.y     = 40 
	currentMult.Scene4.Sky01.scale = 1  
					   
	currentMult.Scene4.Sky02.x     = 250
	currentMult.Scene4.Sky02.y     = 200
	currentMult.Scene4.Sky02.scale = 1  
					   
	currentMult.Scene4.Sun.x     = lerp (300, 350, timeScene)
	currentMult.Scene4.Sun.y     = 250   
	currentMult.Scene4.Sun.scale = 1
					   
	currentMult.Scene4.StormCloud.x     = lerp (250, 280, timeScene)
	currentMult.Scene4.StormCloud.y     = 220
	currentMult.Scene4.StormCloud.scale = lerp (1, 1.2, timeScene)
	
	currentMult.Scene4.StormCloudDark.x     = lerp (250, 280, timeScene)
	currentMult.Scene4.StormCloudDark.y     = 220
	currentMult.Scene4.StormCloudDark.scale = lerp (1, 1.2, timeScene)
					   
	currentMult.Scene4.Plan2.x     = lerp (377, 550, timeScene)
	currentMult.Scene4.Plan2.y     = lerp (180, 30, timeScene)
	currentMult.Scene4.Plan2.scale = lerp (1.05, 1.1, timeScene)
					   
	currentMult.Scene4.Rain.x     = lerp (400, 500, timeScene)
	currentMult.Scene4.Rain.y     = 200
	currentMult.Scene4.Rain.scale = lerp (1.05, 1, timeScene)
	currentMult.Scene4.Rain.isVisible = false
					   
--	currentMult.Scene4.Lightning.x     = lerp (350, 450, timeScene)
--	currentMult.Scene4.Lightning.y     = 235
--	currentMult.Scene4.Lightning.scale = lerp (1, 1, timeScene)
--	
					   
	currentMult.Scene4.CastleMax.x     = lerp (150, 320, timeScene)
	currentMult.Scene4.CastleMax.y     = lerp (200, 0, timeScene)
	currentMult.Scene4.CastleMax.scale = lerp (0.5, 1, timeScene)
	
	currentMult.Scene4.CastleMaxDark.x     = lerp (150, 320, timeScene)
	currentMult.Scene4.CastleMaxDark.y     = lerp (200, 0, timeScene)
	currentMult.Scene4.CastleMaxDark.scale = lerp (0.5, 1, timeScene)
					   
	currentMult.Scene4.Rock.x     = lerp (122, -300, timeScene)
	currentMult.Scene4.Rock.y     = lerp (80, -80, timeScene)
	currentMult.Scene4.Rock.scale = lerp (1, 2.5, timeScene)                            
	
	if (timeScene >= 0.5) and (treeAnimDo) then 				
		treeAnimDo = false
		
		currentMult.Effect04.TreeFlame1:Do("Reset")			
		currentMult.Effect04.TreeFlame2:Do("Reset")			
		currentMult.Effect04.TreeFlame3:Do("Reset")			
		
	end		
	
	FlameTree ( timeScene )
end

function Effects04(timeScene)	
--	currentMult.Effect04.Lightning4.x = lerp (355, 450, timeScene)
--	currentMult.Effect04.Lightning4.y = 235
	
	local MegaX = lerp (400, 600, timeScene)
	local MegaY = 330
	
	currentMult.Effect04.RainRight.x = MegaX
	currentMult.Effect04.RainRight.y = MegaY
	
	currentMult.Effect04.BackgroundRain.x = 330 --MegaX
	currentMult.Effect04.BackgroundRain.y = MegaY
	
end


function Scene4Show()
	currentMult.Scene4.layer.isVisible = true
	currentMult.Effect04.RainRight:Do("Reset")
	currentMult.Effect04.BackgroundRain:Do("Reset")							
	treeAnimDo = true
end 

function Scene4Hide()
	currentMult.Scene4.layer.isVisible = false
	currentMult.Effect04.RainRight:Do("Finish")		
	currentMult.Effect04.BackgroundRain:Do("Finish")			
	currentMult.Effect04.TreeFlame1:Do("Finish")			
	currentMult.Effect04.TreeFlame2:Do("Finish")			
	currentMult.Effect04.TreeFlame3:Do("Finish")				
end 
				