"use strict";
/* nominally chief; more of a figurehead.  Overflowing with optimism... or not. */
var GO_Vince = function(){
	this.sprite = new Sprite(GO_Vince.spriteSheet,"Vince");
	this.sprite.collision_flags = 
		DEFINE_SPRITE_COLLISION_FLAGS.GROUND | 
		DEFINE_SPRITE_COLLISION_FLAGS.AIR |
		DEFINE_SPRITE_COLLISION_FLAGS.SPRITES_ACTIVE |
		DEFINE_SPRITE_COLLISION_FLAGS.SPRITES_PASSIVE;
	this.sprite.setBoundingBox(2,0,13,15);
	this.sprite.game_object = this; // no longer a generic GO

	this.controls = new Controls(); // just to init

	this.horizontal_move_index=0;
	this.vertical_move_index = 0;
	this.anim_state = this.ANIM_STATES.bob;
	this.frame_timer=0;

	this.direction = 1; // +/-1 for facing

};
GO_Vince.spriteImg = SDS_Load_Image("art/sheets/sprite/village_chief.png");
GO_Vince.spriteSheet = new TileSheet(4, 4, 2, 2, GO_Vince.spriteImg);

GO_Vince.prototype = new GameObject(
	new Sprite(
		GO_Vince.spriteSheet,
		"Vince"
	),
	"Vince"
	);

	GO_Vince.prototype.interactions = 
		DEFINE_GAMEOBJECT_INTERACTIONS.CONTROL |
		DEFINE_GAMEOBJECT_INTERACTIONS.CHECK;

	GO_Vince.prototype.leftward_move_water = [0,-1,-2];
	GO_Vince.prototype.rightward_move_water = [0,1,2];
	GO_Vince.prototype.upward_move_water = [0,-1,-2];
	GO_Vince.prototype.downward_move_water = [0,1,2];
	GO_Vince.prototype.ANIM_STATES = {
		"bob" : 0,
		"swim" : 1
	};
	GO_Vince.prototype.anim_frames = [
		[0,0,1,1], //"bob" : 
		[4,5,4,6] //"swim" : 
	];

	GO_Vince.prototype.checkEvent = function(sourceGO){
		if (sourceGO && sourceGO.sprite) this.direction = (sourceGO.sprite.x<this.sprite.x) ? -1 : 1;
		
		return Dialogue_getCurrentEvent["Vince"]();
	};

	GO_Vince.prototype.Update = function(){

		this._heap.oldAnimState = this.anim_state;

		this.NPCSwim();
		

		if (this._heap.oldAnimState != this.anim_state){
			this.frame_timer=0;
		}
		this.frame_timer++;
		this._heap.aniFrame = (this.frame_timer>>2) % this.anim_frames[this.anim_state].length;

		this.sprite.frame = this.anim_frames[this.anim_state][this._heap.aniFrame];

		this.sprite.frame = this.sprite.frame & 7;
		if (this.direction<0) this.sprite.frame+=8;
	};

