MegaMobGunner = {againstWall = 0}
MegaMobGunner.__index = MegaMobGunner

function MegaMobGunner.LoadAssets(me)
	LoadModel(me,"DeathWheel","Animated")
end

function MegaMobGunner:Create(me)
	SetHealth(me,2)
	--SetHealth(me,20)	
	SetPower(me,32)
	--ChangeAnimation(me,"Stand")
	--self.Update = Instance.CustomUpdate
	SetState(me,0)
	--playerDirection = GetPlayerDirection(me)
	
end

function MegaMobGunner:Update(me)
	if ( GetLifetime(me) == 0)
	then
		TargetPlayer(me)
		SetVelocity(me,8*GetDirection(me),0)
	end
	
	--Returning from against the wall
	if(self.againstWall == 1)
	then
		TargetPlayer(me)
		SetDirection(me, GetDirection(me)*-1)
		SetVelocity(me,8*GetDirection(me),0)
	end
	if(self.againstWall > 0 )
	then
		self.againstWall = self.againstWall - 1
	
	--else if(math.abs(x) < 10 )
	--then
		--x,y = GetVelocity(me)
		--SetVelocity(me, x + .25*GetDirection(me),0)
	end
end

function MegaMobGunner:Collide(me, you)
	TakeDamage(me,GetPower(you))
	if( CheckCombo("AirGroundPound") == false)
	then
		Smash(you,16*GetDirection(me),-8)
	end
end


function MegaMobGunner:CollideWorld(me)
	ShakeScreen(8)
	SetVelocity(me,0,0)
	PlaySoundEffect(1)
end

function MegaMobGunner:CollideWall(me)
	ShakeScreen(8)
	--TakeDamage(me, 2);
	--SetVelocity(me,0,0)
	PlaySoundEffect(1)
	self.againstWall = 20
	SetState(me,0)
end

function MegaMobGunner:Death(me)
	x,y = GetPosition(me)
	y = y - 32
	CreateEmitter("Explosion", x,y)
end