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

var GO_Necklace = function(){
	this.sprite = new Sprite(GO_Necklace.spriteSheet,"Necklace");
	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.frame_timer=4;
};
GO_Necklace.spriteImg = SDS_Load_Image("art/sheets/sprite/necklace.png");
GO_Necklace.spriteSheet = new TileSheet(4, 4, 4, 0, GO_Necklace.spriteImg);

GO_Necklace.prototype = new GameObject(
	new Sprite(
		GO_Necklace.spriteSheet,
		"Necklace"
	),
	"Necklace"
	);

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

	GO_Necklace.prototype.checkEvent = function(sourceGO){
		var grace = this.manager.getNamedObject("Grace");
		if (grace){
			grace.target=null;
			grace.target_name="Passage_Out";
		}

		this.sprite.map_room.removeSprite(this.sprite);
		this.manager.remove(this);
		GLOBAL_DIARY.note(2,"TREASURE");
		GLOBAL_DIARY.hasCollar=true;
		return "Get_Necklace";
	};

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

	GO_Necklace.prototype.Update = function(){
		this.frame_timer--;
		if (this.frame_timer<=0){
			this.sprite.frame = (this.sprite.frame+1)%9;
			this.frame_timer=4;
		}
	};
