Gunner = {}

jAttack = false

function Gunner.LoadAssets(me)
	LoadModel(me,"Gunner","Animated")
end

function Gunner.Create(me)
	--LoadModel(me,"Gunner","Animated")
	--SetHealth(me,5)
	SetHealth(me,math.random(2,6)) --Add in some spice
	SetPalette(me,14)
	SetPower(me,3)
	StopAnimation(me)
end

function Gunner.Collide(me, you)
	power = GetPower(you)
	TakeDamage(me, power)
end

function Gunner.Death(me)
	child = CreateObject(me,"Death","EnemyFX", 0,11,1,false)
	SetSFX(child,true)
	MoveObject(child,32,0)
end

function Gunner.Update(me)
	if IsPlaying(me,"Stand")
	then
		if PlayerDistanceX(me) < 128 and jAttack == false
		then
			ChangeAnimation(me,"Shoot")
			jAttack = true
		end
	elseif IsPlaying(me,"Shoot")
	then
		if PlayerDistanceX(me) > 128 and jAttack == false
		then
			SetVelocity(me,0,0)
			ChangeAnimation(me,"Stand")
		elseif PlayerDistanceX(me) < 128 and jAttack == true
		then
			JumpAttack(me)
			jAttack = false
		end
	end
end