internal void AddObjects(int num) { Random randgen = new Random(); for (int i = 0; i < num; i++) { MapTile t = GameEngine.GetRandomTileSpace(); int r = randgen.Next(0, 2); switch (r) { case 0: t.actionObject = new ObjectTeleport(); break; case 1: t.actionObject = new ObjectGold(); break; case 2: t.actionObject = new ObjectTrap(); break; default: t.actionObject = new ObjectGold(); break; } //make gold object and assign it to the tile and set the objects X,Y so the object can remove itself later. t.actionObject.X = t.X; t.actionObject.Y = t.Y; } }
public override void OnActionEnter() { //this should be a onetime teleport so delete the object after usage. var blank = GameEngine.GetRandomTileSpace(); GameEngine.Tiles[Y, X].Dirty = true; GameEngine.Tiles[Y, X].IsWalkable = true; GameEngine.Tiles[GameEngine.ThePlayer.LastY, GameEngine.ThePlayer.LastX].Dirty = true; GameEngine.Tiles[GameEngine.ThePlayer.LastY, GameEngine.ThePlayer.LastX].IsWalkable = true; //this is set false when a player lands on the tile GameEngine.ThePlayer.MoveTo(blank.X, blank.Y); GameEngine.Tiles[Y, X].ActionObject = null; //destroy the action object on the tile this object is on }