/*
The first treasure
*/
"use strict";

var GO_Sealkey = function(id){
	this.sprite = new Sprite(GO_Sealkey.spriteSheet,"Sealkey");
	this.sprite.collision_flags = 
		DEFINE_SPRITE_COLLISION_FLAGS.SPRITES_PASSIVE;
	this.sprite.setBoundingBox(0,0,15,15);
	this.sprite.game_object = this; // no longer a generic GO
	
	this.id = id;
	if (this.id) this.name += "_"+this.id;

	this.frame_timer=4;
};
GO_Sealkey.spriteImg = SDS_Load_Image("art/sheets/sprite/sealkey.png");
GO_Sealkey.spriteSheet = new TileSheet(4, 4, 2, 1, GO_Sealkey.spriteImg);

GO_Sealkey.prototype = new GameObject(
	new Sprite(
		GO_Sealkey.spriteSheet,
		"Sealkey"
	),
	"Sealkey"
	);

	GO_Sealkey.prototype.interactions = 
		DEFINE_GAMEOBJECT_INTERACTIONS.CHECK |
		DEFINE_GAMEOBJECT_INTERACTIONS.COLLECT;

	GO_Sealkey.prototype.checkEvent = function(sourceGO){
		this._heap.poof = new GO_Poof("FX_poof");
		this._heap.poof.spawnOnSprite(this.sprite,this.manager);
		this._heap.poof = null;

		this.sprite.map_room.removeSprite(this.sprite);
		this.manager.remove(this);
		GLOBAL_DIARY.note(5,"SEALKEY_"+this.id);
		return "Get_Sealkey";
	};

	GO_Sealkey.prototype.collect = function(sourceGO){
		return this.checkEvent(sourceGO);
	};

	GO_Sealkey.prototype.Update = function(){
		this.frame_timer--;
		if (this.frame_timer<=0){
			this.sprite.frame = (this.sprite.frame+1)&7;
			this.frame_timer=4;
		}
	};
