public clsNPC(string imagefolder, Point pos, clsSprite.dir defaultdirection, string dialogloc) { this.position = pos; this.folder = imagefolder; this.direction = defaultdirection; Load(imagefolder); }
public static void CheckEncounter(Point tilepos, clsSprite.dir dir) { string[] levelname = clsGame.level.levelname.ToString().Split('-'); //TODO: check if tilepos is next to NPC //check for house if (levelname[0] == "world") { if (clsGame.player.TilePosition.Y != clsGame.map.height - 1) { //check if tilepos is tall grass //if so, check for Edjimon //add 1 so the bottom tile of the sprite is used if (clsGame.map.Tiles[clsGame.player.TilePosition.X, clsGame.player.TilePosition.Y + 1] == 1) { //if you found one if (CheckEdjimon()) { clsGame.inbattle = true; clsEdjimon wildedjimon = DetermineEdjimon(); clsBattle b = new clsBattle(clsGame.player.edjimon[0], wildedjimon); } } if (clsGame.player.TilePosition.Y + 1 != 0 && dir == clsSprite.dir.Up && clsGame.map.Tiles[clsGame.player.TilePosition.X, clsGame.player.TilePosition.Y] == 16) { oldpos = tilepos; clsGame.level.LoadLevel("house-1"); clsGame.player.inmotion = false; } } } //try to leave house if (levelname[0] == "house" && clsGame.player.TilePosition.Y != clsGame.map.height) { //do individual house-X checks inside here switch(dir) { case clsSprite.dir.Up: if (clsGame.map.Tiles[clsGame.player.TilePosition.X, clsGame.player.TilePosition.Y] == 4) { clsGame.level.LoadLevel("world-1"); clsGame.player.position.X = oldpos.X * 30; clsGame.player.position.Y = (oldpos.Y) * 30; //clsGame.player.inmotion = false; } break; case clsSprite.dir.Down: if (clsGame.map.Tiles[clsGame.player.TilePosition.X, clsGame.player.TilePosition.Y + 2] == 4) { clsGame.level.LoadLevel("world-1"); clsGame.player.position.X = oldpos.X * 30; clsGame.player.position.Y = (oldpos.Y) * 30; //clsGame.player.inmotion = false; } break; } } }
public bool Allow(clsSprite.dir direction) { if (clsGame.inbattle == true) return false; else { //TODO: Figure out why I'm walking on some trees. Something about the +1/-1 math crap. switch (direction) { case clsSprite.dir.Up: //make sure tile above is on the map if (clsGame.player.TilePosition.Y + 1 == (int)0) return false; //now make sure that tile is passable if (clsGame.map.passable[clsGame.player.TilePosition.X, clsGame.player.TilePosition.Y]) return true; else return false; case clsSprite.dir.Down: //make sure tile below is on the map if (clsGame.player.TilePosition.Y == (clsGame.map.height - 1)) return false; //now make sure that tile is passable if (clsGame.map.passable[clsGame.player.TilePosition.X, clsGame.player.TilePosition.Y + 1]) return true; else return false; case clsSprite.dir.Left: //make sure tile left is on map if (clsGame.player.TilePosition.X == (int)0) return false; //now make sure tile is passable if (clsGame.map.passable[clsGame.player.TilePosition.X - 1, clsGame.player.TilePosition.Y + 1]) return true; else return false; case clsSprite.dir.Right: //make sure tile left is on map if (clsGame.player.TilePosition.X == (clsGame.map.width)) return false; //now make sure tile is passable if (clsGame.map.passable[clsGame.player.TilePosition.X + 1, clsGame.player.TilePosition.Y + 1]) return true; else return false; } } return false; }