public RoomNew PreviuosRoom(RoomNew room) { int c = room.roomIndex; if (c != 0) { c = System.Threading.Interlocked.Decrement(ref c); } else if (c == 0) { c = System.Threading.Interlocked.Increment(ref c); } foreach (RoomNew r in rooms) { if (r.roomIndex == c) { return(r); } } return(blockRoom); }
public Chomper(RoomNew room, ContentManager Content, Enumeration.TileType tileType, Enumeration.StateTile state, Enumeration.TileType NextTileType__1) { base.room = room; nextTileType = NextTileType__1; System.Xml.Serialization.XmlSerializer ax = new System.Xml.Serialization.XmlSerializer(tileSequence.GetType()); Stream txtReader = Microsoft.Xna.Framework.TitleContainer.OpenStream(PrinceOfPersiaGame.CONFIG_PATH_CONTENT + PrinceOfPersiaGame.CONFIG_PATH_SEQUENCES + tileType.ToString().ToUpper() + "_sequence.xml"); tileSequence = (List<Sequence>)ax.Deserialize(txtReader); foreach (Sequence s in tileSequence) { s.Initialize(Content); } //Search in the sequence the right type //Sequence result = tileSequence.Find((Sequence s) => s.name.ToUpper() == state.ToString().ToUpper()); Sequence result = tileSequence.Find((Sequence s) => s.name == state.ToString().ToUpper()); if (result != null) { result.frames[0].SetTexture(Content.Load<Texture2D>(PrinceOfPersiaGame.CONFIG_TILES[0] + result.frames[0].value)); collision = result.collision; Texture = result.frames[0].texture; } Type = tileType; //change statetile element tileState.Value().state = state; tileAnimation.PlayAnimation(tileSequence, tileState.Value()); }
public RoomNew UpRoom(RoomNew room) { int x = room.roomX; int y = room.roomY; int z = room.roomZ; if (y != levels[z].rows.Count() - 1) { y = System.Threading.Interlocked.Decrement(ref y); } else { return(blockRoom); } //return new RoomNew(this, PrinceOfPersiaGame.CONFIG_PATH_CONTENT + PrinceOfPersiaGame.CONFIG_PATH_ROOMS + "MAP_blockroom.xml"); foreach (RoomNew r in rooms) { if (r.roomX == x & r.roomY == y & r.roomZ == z) { return(r); } } return(blockRoom); //return new RoomNew(this, PrinceOfPersiaGame.CONFIG_PATH_CONTENT + PrinceOfPersiaGame.CONFIG_PATH_ROOMS + "MAP_blockroom.xml"); }
public Chomper(RoomNew room, ContentManager Content, Enumeration.TileType tileType, Enumeration.StateTile state, Enumeration.TileType NextTileType__1) { base.room = room; nextTileType = NextTileType__1; System.Xml.Serialization.XmlSerializer ax = new System.Xml.Serialization.XmlSerializer(tileSequence.GetType()); Stream txtReader = Microsoft.Xna.Framework.TitleContainer.OpenStream(PrinceOfPersiaGame.CONFIG_PATH_CONTENT + PrinceOfPersiaGame.CONFIG_PATH_SEQUENCES + tileType.ToString().ToUpper() + "_sequence.xml"); tileSequence = (List <Sequence>)ax.Deserialize(txtReader); foreach (Sequence s in tileSequence) { s.Initialize(Content); } //Search in the sequence the right type //Sequence result = tileSequence.Find((Sequence s) => s.name.ToUpper() == state.ToString().ToUpper()); Sequence result = tileSequence.Find((Sequence s) => s.name == state.ToString().ToUpper()); if (result != null) { result.frames[0].SetTexture(Content.Load <Texture2D>(PrinceOfPersiaGame.CONFIG_TILES[0] + result.frames[0].value)); collision = result.collision; Texture = result.frames[0].texture; } Type = tileType; //change statetile element tileState.Value().state = state; tileAnimation.PlayAnimation(tileSequence, tileState.Value()); }
/// <summary> /// Constructors a new player. /// </summary> public Guard(RoomNew room, Vector2 position, GraphicsDevice GraphicsDevice__1, SpriteEffects spriteEffect) { graphicsDevice = GraphicsDevice__1; m_spriteRoom = room; LoadContent(); //TAKE PLAYER Position Reset(position, spriteEffect); }
public Tile(RoomNew room, ContentManager Content, Enumeration.TileType tileType, Enumeration.StateTile state, Enumeration.Items eitem, Enumeration.TileType NextTileType__1) { this.room = room; nextTileType = NextTileType__1; System.Xml.Serialization.XmlSerializer ax = new System.Xml.Serialization.XmlSerializer(m_tileSequence.GetType()); Stream txtReader = Microsoft.Xna.Framework.TitleContainer.OpenStream(PrinceOfPersiaGame.CONFIG_PATH_CONTENT + PrinceOfPersiaGame.CONFIG_PATH_SEQUENCES + tileType.ToString().ToUpper() + "_sequence.xml"); //TextReader txtReader = File.OpenText(PrinceOfPersiaGame.CONFIG_PATH_CONTENT + PrinceOfPersiaGame.CONFIG_PATH_SEQUENCES + tileType.ToString().ToUpper() + "_sequence.xml"); m_tileSequence = (List <Sequence>)ax.Deserialize(txtReader); foreach (Sequence s in m_tileSequence) { s.Initialize(Content); } //Search in the sequence the right type Sequence result = m_tileSequence.Find((Sequence s) => s.name == state.ToString().ToUpper()); if (result != null) { //AMF to be adjust.... result.frames[0].SetTexture(Content.Load <Texture2D>(PrinceOfPersiaGame.CONFIG_TILES[0] + result.frames[0].value)); collision = result.collision; Texture = result.frames[0].texture; } Type = tileType; //change statetile element StateTileElement stateTileElement = new StateTileElement(); stateTileElement.state = state; tileState.Add(stateTileElement); tileAnimation.PlayAnimation(m_tileSequence, tileState.Value()); //load item switch (eitem) { case Enumeration.Items.flask: item = new Flask(Content); break; // TODO: might not be correct. Was : Exit Select case Enumeration.Items.flaskbig: item = new FlaskBig(Content); break; // TODO: might not be correct. Was : Exit Select case Enumeration.Items.sword: item = new Sword(Content); break; // TODO: might not be correct. Was : Exit Select } }
/// <summary> /// Constructors a new player. /// </summary> public Skeleton(RoomNew room, Vector2 position, GraphicsDevice GraphicsDevice__1, SpriteEffects spriteEffect) { graphicsDevice = GraphicsDevice__1; m_spriteRoom = room; LoadContent(); //TAKE PLAYER Position Reset(position, spriteEffect); }
/// <summary> /// Constructors a new player. /// </summary> public Player(RoomNew room, Vector2 position, Point roomcoords, GraphicsDevice GraphicsDevice__1, SpriteEffects spriteEffect) { graphicsDevice = GraphicsDevice__1; SpriteRoom = room; _roomcord = roomcoords; LoadContent(); //TAKE PLAYER Position Reset(position, spriteEffect); }
private void DrawDebug(RoomNew room) { //if (room.player.sprite.sequence == null) // return; Rectangle titleSafeArea = GraphicsDevice.Viewport.TitleSafeArea; Vector2 hudLocation = new Vector2(titleSafeArea.X, titleSafeArea.Y); hudLocation.X = hudLocation.X + 180; hudLocation.Y = hudLocation.Y + 380; if (CONFIG_DEBUG == true) { var CurrentLvl = maze.CurrentLevel(); if (CurrentLvl != null) { DrawShadowedString(hudFont, "LEVEL NAME=" + CurrentLvl.levelIndex + "-" + CurrentLvl.levelName + "-" + maze.levelindex, hudLocation, Color.White); } hudLocation.Y = hudLocation.Y + 10; //DrawShadowedString(hudFont, "FRAME RATE=" + AnimationSequence.frameRate.ToString(), hudLocation, Color.White); //hudLocation.Y = hudLocation.Y + 10; if (maze.player != null) { int CoordX = maze.player.RoomCoord.X; int CoordY = maze.player.RoomCoord.Y; DrawShadowedString(hudFont, "ROOM NAME=" + maze.player.SpriteRoom.roomName, hudLocation, Color.White); hudLocation.Y = hudLocation.Y + 10; DrawShadowedString(hudFont, "POSTION X=" + maze.player.Position.X + " Y=" + maze.player.Position.Y + " TILE= " + maze.player.SpriteRoom.GetTile(CoordX, CoordY).Type.ToString(), hudLocation, Color.White); hudLocation.Y = hudLocation.Y + 10; Rectangle playerBound = maze.player.Position.Bounding; Rectangle tileBounds = maze.player.SpriteRoom.GetBounds(maze.player.RealPosition.X, maze.player.RealPosition.Y); Vector2 depth = RectangleExtensions.GetIntersectionDepth(playerBound, tileBounds); DrawShadowedString(hudFont, "PLAYER BOUNDS =" + "X = " + depth.X.ToString() + " Y = " + depth.Y.ToString(), hudLocation, Color.White); } hudLocation.Y = hudLocation.Y + 10; if (maze.player.sprite.sequence != null) { DrawShadowedString(hudFont, "PLAYER STATE=" + Convert.ToString(maze.player.spriteState.Value().state) + " SEQUENCE CountOffset=" + Convert.ToString(maze.player.sprite.sequence.CountOffSet), hudLocation, Color.White); } } // Get the player's bounding rectangle and find neighboring tiles. Rectangle playerBounds = maze.player.Position.Bounding; Vector4 v4 = room.getBoundTiles(playerBounds); }
/// <summary> /// Constructors a new player. /// </summary> public Splash(RoomNew room, Vector2 position, GraphicsDevice GraphicsDevice__1, SpriteEffects spriteEffect, bool player) { _player = player; graphicsDevice = GraphicsDevice__1; m_spriteRoom = room; LoadContent(); //TAKE PLAYER Position Reset(position, spriteEffect); }
private void PopNet() { DirectoryInfo files = new DirectoryInfo(PrinceOfPersiaGame.CONFIG_PATH_CONTENT + PrinceOfPersiaGame.CONFIG_PATH_LEVELS); foreach (FileInfo f in files.GetFiles()) { //LOAD MXL CONTENT Stream txtReader = default(Stream); //#if ANDROID //txtReader = Game.Activity.Assets.Open(@PrinceOfPersiaGame.CONFIG_PATH_CONTENT + PrinceOfPersiaGame.CONFIG_PATH_LEVELS + "LEVEL_dungeon_prison.xml"); //#endif txtReader = Microsoft.Xna.Framework.TitleContainer.OpenStream(Path.Combine(PrinceOfPersiaGame.CONFIG_PATH_CONTENT, PrinceOfPersiaGame.CONFIG_PATH_LEVELS, f.Name)); System.Xml.Serialization.XmlSerializer ax = null; ax = new System.Xml.Serialization.XmlSerializer(typeof(Level)); levels.Add((Level)ax.Deserialize(txtReader)); } //Define and build a generic blockroom for usefull blockRoom = new RoomNew(this, Path.Combine(PrinceOfPersiaGame.CONFIG_PATH_CONTENT, PrinceOfPersiaGame.CONFIG_PATH_ROOMS, "MAP_blockroom.xml"), 1, 0); //load all room for (int z = 0; z <= levels.Count() - 1; z++) { //int newX = 1; for (int y = 0; y <= levels[z].rows.Count() - 1; y++) { for (int x = 0; x <= levels[z].rows[y].columns.Count() - 1; x++) { if (levels[z].rows[y].columns[x].FilePath == string.Empty) { levels[z].rows[y].columns[x].FilePath = "MAP_blockroom.xml"; } RoomNew room = new RoomNew(this, Path.Combine(PrinceOfPersiaGame.CONFIG_PATH_CONTENT, PrinceOfPersiaGame.CONFIG_PATH_ROOMS, levels[z].rows[y].columns[x].FilePath), levels[z].rows[y].columns[x].RoomIndex, levels[z].rows[y].columns[x].roomType); //RoomNew room = new RoomNew(this, "Maze/"+ levels[z].rows[y].columns[x].FilePath); room.roomStart = levels[z].rows[y].columns[x].RoomStart; room.roomName = levels[z].rows[y].columns[x].FilePath; room.roomZ = z; room.roomX = x; room.roomY = y; //newX++; rooms.Add(room); } } } }
public Gate(RoomNew room, ContentManager Content, Enumeration.TileType tileType, Enumeration.StateTile state, int switchButton, Enumeration.TileType NextTileType__1, float TimeOpen__2) { collision = Enumeration.TileCollision.Platform; base.room = room; nextTileType = NextTileType__1; timeOpen = TimeOpen__2; this.switchButton = switchButton; System.Xml.Serialization.XmlSerializer ax = new System.Xml.Serialization.XmlSerializer(tileSequence.GetType()); Stream txtReader = Microsoft.Xna.Framework.TitleContainer.OpenStream(PrinceOfPersiaGame.CONFIG_PATH_CONTENT + PrinceOfPersiaGame.CONFIG_PATH_SEQUENCES + tileType.ToString().ToUpper() + "_sequence.xml"); //TextReader txtReader = File.OpenText(PrinceOfPersiaGame.CONFIG_PATH_CONTENT + PrinceOfPersiaGame.CONFIG_PATH_SEQUENCES + tileType.ToString().ToUpper() + "_sequence.xml"); tileSequence = (List <Sequence>)ax.Deserialize(txtReader); foreach (Sequence s in tileSequence) { s.Initialize(Content); } if (state == Enumeration.StateTile.normal) { state = Enumeration.StateTile.closed; } //Search in the sequence the right type Sequence result = tileSequence.Find((Sequence s) => s.name == state.ToString().ToUpper()); if (result != null) { //AMF to be adjust.... result.frames[0].SetTexture(Content.Load <Texture2D>(PrinceOfPersiaGame.CONFIG_TILES[0] + result.frames[0].value)); collision = result.collision; Texture = result.frames[0].texture; } Type = tileType; //change statetile element tileState.Value().state = state; tileAnimation.PlayAnimation(tileSequence, tileState.Value()); }
public Gate(RoomNew room, ContentManager Content, Enumeration.TileType tileType, Enumeration.StateTile state, int switchButton, Enumeration.TileType NextTileType__1, float TimeOpen__2) { collision = Enumeration.TileCollision.Platform; base.room = room; nextTileType = NextTileType__1; timeOpen = TimeOpen__2; this.switchButton = switchButton; System.Xml.Serialization.XmlSerializer ax = new System.Xml.Serialization.XmlSerializer(tileSequence.GetType()); Stream txtReader = Microsoft.Xna.Framework.TitleContainer.OpenStream(PrinceOfPersiaGame.CONFIG_PATH_CONTENT + PrinceOfPersiaGame.CONFIG_PATH_SEQUENCES + tileType.ToString().ToUpper() + "_sequence.xml"); //TextReader txtReader = File.OpenText(PrinceOfPersiaGame.CONFIG_PATH_CONTENT + PrinceOfPersiaGame.CONFIG_PATH_SEQUENCES + tileType.ToString().ToUpper() + "_sequence.xml"); tileSequence = (List<Sequence>)ax.Deserialize(txtReader); foreach (Sequence s in tileSequence) { s.Initialize(Content); } if (state == Enumeration.StateTile.normal) { state = Enumeration.StateTile.closed; } //Search in the sequence the right type Sequence result = tileSequence.Find((Sequence s) => s.name == state.ToString().ToUpper()); if (result != null) { //AMF to be adjust.... result.frames[0].SetTexture(Content.Load<Texture2D>(PrinceOfPersiaGame.CONFIG_TILES[0] + result.frames[0].value)); collision = result.collision; Texture = result.frames[0].texture; } Type = tileType; //change statetile element tileState.Value().state = state; tileAnimation.PlayAnimation(tileSequence, tileState.Value()); }
public RoomNew RoomGet(RoomNew room) { int c = room.roomIndex; if (c == 0) { c = 1; } foreach (RoomNew r in rooms) { if (r.roomIndex == c) { return(r); } } return(blockRoom); }
public void HandleCollisionsNew() { isGround(); Rectangle playerBounds = _position.Bounding; //Find how many tiles are near on the left Vector4 v4 = SpriteRoom.getBoundTiles(playerBounds); // For each potentially colliding Tile, warning the for check only the player row ground..W for (int y = Convert.ToInt32(Math.Truncate(v4.Z)); y <= Convert.ToInt32(Math.Truncate(v4.W)); y++) { for (int x = Convert.ToInt32(Math.Truncate(v4.X)); x <= Convert.ToInt32(Math.Truncate(v4.Y)); x++) { Rectangle tileBounds = SpriteRoom.GetBounds(x, y); Vector2 depth = RectangleExtensions.GetIntersectionDepth(playerBounds, tileBounds); Enumeration.TileCollision tileCollision = SpriteRoom.GetCollision(x, y); Enumeration.TileType tileType = SpriteRoom.GetType(x, y); switch (tileType) { case Enumeration.TileType.spikes: if (IsAlive == false) { ((Spikes)SpriteRoom.GetTile(x, y)).Open(); return; } if (flip == SpriteEffects.FlipHorizontally) { if (depth.X < 10 & depth.Y >= Player.SPRITE_SIZE_Y) { ((Spikes)SpriteRoom.GetTile(x, y)).Open(); // if (depth.X <= -30 & depth.Y >= Player.SPRITE_SIZE_Y & ((Spikes)SpriteRoom.GetTile(x, y)).State == Enumeration.StateTile.open) // Impale(); } } else { if (depth.X > -10 & depth.Y >= Player.SPRITE_SIZE_Y) { ((Spikes)SpriteRoom.GetTile(x, y)).Open(); //if (depth.X >= 60 & depth.Y >= Player.SPRITE_SIZE_Y & ((Spikes)SpriteRoom.GetTile(x, y)).State == Enumeration.StateTile.open) // Impale(); } } break; // TODO: might not be correct. Was : Exit Select case Enumeration.TileType.lava: if (IsAlive == false) { ((Lava)SpriteRoom.GetTile(x, y)).Open(); return; } if (flip == SpriteEffects.FlipHorizontally) { if (depth.X < 10 & depth.Y >= Skeleton.SPRITE_SIZE_Y) { ((Lava)SpriteRoom.GetTile(x, y)).Open(); // if (depth.X <= -30 & depth.Y >= Player.SPRITE_SIZE_Y & ((Spikes)SpriteRoom.GetTile(x, y)).State == Enumeration.StateTile.open) // Impale(); } } else { if (depth.X > -10 & depth.Y >= Skeleton.SPRITE_SIZE_Y) { ((Lava)SpriteRoom.GetTile(x, y)).Open(); //if (depth.X >= 60 & depth.Y >= Player.SPRITE_SIZE_Y & ((Spikes)SpriteRoom.GetTile(x, y)).State == Enumeration.StateTile.open) // Impale(); } } break; // TODO: might not be correct. Was : Exit Select case Enumeration.TileType.loose: if (flip == SpriteEffects.FlipHorizontally) { if (depth.X < (-Tile.PERSPECTIVE - PLAYER_R_PENETRATION)) { ((Loose)SpriteRoom.GetTile(x, y)).Press(); //else //isLoosable(); } } else { if (depth.X > (Tile.PERSPECTIVE + PLAYER_L_PENETRATION)) { //45 ((Loose)SpriteRoom.GetTile(x, y)).Press(); //else //isLoosable(); } } break; // TODO: might not be correct. Was : Exit Select case Enumeration.TileType.pressplate: ((PressPlate)SpriteRoom.GetTile(x, y)).Press(); break; // TODO: might not be correct. Was : Exit Select case Enumeration.TileType.gate: case Enumeration.TileType.block: if (tileType == Enumeration.TileType.gate) { if (((Gate)SpriteRoom.GetTile(x, y)).State == Enumeration.StateTile.opened) { break; // TODO: might not be correct. Was : Exit Select } } //if player are raised then not collide.. //if sx wall i will penetrate..for perspective design if (flip == SpriteEffects.FlipHorizontally) { //only for x pixel if (depth.X < (-Tile.PERSPECTIVE - PLAYER_R_PENETRATION)) { if (spriteState.Value().state != Enumeration.State.freefall & spriteState.Value().state != Enumeration.State.highjump & spriteState.Value().state != Enumeration.State.hang & spriteState.Value().state != Enumeration.State.hangstraight & spriteState.Value().state != Enumeration.State.hangdrop & spriteState.Value().state != Enumeration.State.hangfall & spriteState.Value().state != Enumeration.State.jumphangMed & spriteState.Value().state != Enumeration.State.jumphangLong & spriteState.Value().state != Enumeration.State.climbup & spriteState.Value().state != Enumeration.State.climbdown) { //if (sprite.sequence.raised == false) // Bump(Enumeration.PriorityState.Force); //else // RJumpFall(Enumeration.PriorityState.Force); //return; _position.Value = new Vector2(_position.X + (depth.X - (-Tile.PERSPECTIVE - PLAYER_R_PENETRATION)), _position.Y); } } else { if (sprite.sequence.raised == true) { _position.Value = new Vector2(_position.X, _position.Y); } else { _position.Value = new Vector2(_position.X, _position.Y); } } } else { if (depth.X > (Tile.PERSPECTIVE + PLAYER_L_PENETRATION)) { //45 //if(sprite.sequence.raised == false) if (spriteState.Value().state != Enumeration.State.freefall & spriteState.Value().state != Enumeration.State.highjump & spriteState.Value().state != Enumeration.State.hang & spriteState.Value().state != Enumeration.State.hangstraight & spriteState.Value().state != Enumeration.State.hangdrop & spriteState.Value().state != Enumeration.State.hangfall & spriteState.Value().state != Enumeration.State.jumphangMed & spriteState.Value().state != Enumeration.State.jumphangLong & spriteState.Value().state != Enumeration.State.climbup & spriteState.Value().state != Enumeration.State.climbdown) { _position.Value = new Vector2(_position.X + (depth.X - (Tile.PERSPECTIVE + PLAYER_L_PENETRATION)), _position.Y); //Bump(Enumeration.PriorityState.Force); return; } } else if (sprite.sequence.raised == true) { _position.Value = new Vector2(_position.X, _position.Y); } else { _position.Value = new Vector2(_position.X, _position.Y); } } playerBounds = BoundingRectangle; break; // TODO: might not be correct. Was : Exit Select default: _position.Value = new Vector2(_position.X, tileBounds.Bottom); playerBounds = BoundingRectangle; break; } } } //??? //previousBottom = playerBounds.Bottom; //check if out room if (_position.Y > RoomNew.BOTTOM_LIMIT + 10) { RoomNew room = Maze.DownRoom(SpriteRoom); SpriteRoom = room; _position.Y = RoomNew.TOP_LIMIT + 27; // Y=77 //For calculate height fall from damage points calculations.. PositionFall = new Vector2(Position.X, (PrinceOfPersiaGame.CONFIG_SCREEN_HEIGHT - RoomNew.BOTTOM_LIMIT - PositionFall.Y)); } else if (_position.X >= RoomNew.RIGHT_LIMIT) { RoomNew room = Maze.RightRoom(SpriteRoom); SpriteRoom = room; _position.X = RoomNew.LEFT_LIMIT + 10; } else if (_position.X <= RoomNew.LEFT_LIMIT) { RoomNew room = Maze.LeftRoom(SpriteRoom); SpriteRoom = room; _position.X = RoomNew.RIGHT_LIMIT - 10; } else if (_position.Y < RoomNew.TOP_LIMIT - 10) { RoomNew room = Maze.UpRoom(SpriteRoom); SpriteRoom = room; //Y=270 _position.Y = RoomNew.BOTTOM_LIMIT - 24; } }
private void DrawDebug(RoomNew room) { //if (room.player.sprite.sequence == null) // return; Rectangle titleSafeArea = GraphicsDevice.Viewport.TitleSafeArea; Vector2 hudLocation = new Vector2(titleSafeArea.X, titleSafeArea.Y); hudLocation.X = hudLocation.X + 180; hudLocation.Y = hudLocation.Y + 380; if (CONFIG_DEBUG == false) { return; } DrawShadowedString(hudFont, "LEVEL NAME=" + maze.CurrentLevel().levelIndex + "-" + maze.CurrentLevel().levelName + "-" + maze.levelindex, hudLocation, Color.White); hudLocation.Y = hudLocation.Y + 10; //DrawShadowedString(hudFont, "FRAME RATE=" + AnimationSequence.frameRate.ToString(), hudLocation, Color.White); //hudLocation.Y = hudLocation.Y + 10; if (maze.player != null) { int CoordX = maze.player.RoomCoord.X; int CoordY = maze.player.RoomCoord.Y; DrawShadowedString(hudFont, "ROOM NAME=" + maze.player.SpriteRoom.roomName, hudLocation, Color.White); hudLocation.Y = hudLocation.Y + 10; DrawShadowedString(hudFont, "POSTION X=" + maze.player.Position.X + " Y=" + maze.player.Position.Y + " TILE= " + maze.player.SpriteRoom.GetTile(CoordX, CoordY).Type.ToString(), hudLocation, Color.White); hudLocation.Y = hudLocation.Y + 10; Rectangle playerBound = maze.player.Position.Bounding; Rectangle tileBounds = maze.player.SpriteRoom.GetBounds(maze.player.RealPosition.X, maze.player.RealPosition.Y); Vector2 depth = RectangleExtensions.GetIntersectionDepth(playerBound, tileBounds); DrawShadowedString(hudFont, "PLAYER BOUNDS =" + "X = " + depth.X.ToString() + " Y = " + depth.Y.ToString(), hudLocation, Color.White); } hudLocation.Y = hudLocation.Y + 10; if (maze.player.sprite.sequence != null) DrawShadowedString(hudFont, "PLAYER STATE=" + Convert.ToString(maze.player.spriteState.Value().state) + " SEQUENCE CountOffset=" + Convert.ToString(maze.player.sprite.sequence.CountOffSet), hudLocation, Color.White); // Get the player's bounding rectangle and find neighboring tiles. Rectangle playerBounds = maze.player.Position.Bounding; Vector4 v4 = room.getBoundTiles(playerBounds); }
public void HandleCollision() { if (this.Type == Enumeration.TileType.loose) { if (this.tileState.Value().state != Enumeration.StateTile.loosefall) { return; } Rectangle r = new Rectangle(Convert.ToInt32(Math.Truncate(Position.X)), Convert.ToInt32(Math.Truncate(Position.Y)), Tile.WIDTH, Tile.HEIGHT); Vector4 v = room.getBoundTiles(r); Rectangle tileBounds = room.GetBounds(Convert.ToInt32(Math.Truncate(v.X)), Convert.ToInt32(Math.Truncate(v.W))); Vector2 depth = RectangleExtensions.GetIntersectionDepth(tileBounds, r); Enumeration.TileType tileType = room.GetType(Convert.ToInt32(Math.Truncate(v.X)), Convert.ToInt32(Math.Truncate(v.W))); Enumeration.TileCollision tileCollision = room.GetCollision(Convert.ToInt32(Math.Truncate(v.X)), Convert.ToInt32(Math.Truncate(v.W))); //Tile tile = room.GetTile(new Vector2((int)v.X, (int)v.W)); if (tileCollision == Enumeration.TileCollision.Platform) { //if (tileType == Enumeration.TileType.floor) if (depth.Y >= Tile.HEIGHT - Tile.PERSPECTIVE) { lock (room.tilesTemporaney) { room.tilesTemporaney.Remove(this); } //Vector2 vs = new Vector2(this.Position.X, this.Position.Y); if (tileType == Enumeration.TileType.loose) { Loose l = (Loose)room.GetTile(Convert.ToInt32(Math.Truncate(v.X)), Convert.ToInt32(Math.Truncate(v.W))); l.Fall(true); } else { ((SoundEffect)Maze.dContentRes[PrinceOfPersiaGame.CONFIG_SOUNDS + "tile crashing into the floor".ToUpper()]).Play(); room.SubsTile(Coordinates, Enumeration.TileType.rubble); } } } //if (_position.Y >= RoomNew.BOTTOM_LIMIT - Tile.HEIGHT - Tile.PERSPECTIVE) if (_position.Y >= RoomNew.BOTTOM_LIMIT - Tile.PERSPECTIVE) { //remove tiles from tilesTemporaney lock (room.tilesTemporaney) { room.tilesTemporaney.Remove(this); } //exit from DOWN room RoomNew roomDown = room.maze.DownRoom(room); room = roomDown; _position.Y = RoomNew.TOP_LIMIT - 10; lock (room.tilesTemporaney) { room.tilesTemporaney.Add(this); } } } }
public Tile(RoomNew room, ContentManager Content, Enumeration.TileType tileType, Enumeration.StateTile state, Enumeration.Items eitem, Enumeration.TileType NextTileType__1) { this.room = room; nextTileType = NextTileType__1; System.Xml.Serialization.XmlSerializer ax = new System.Xml.Serialization.XmlSerializer(m_tileSequence.GetType()); Stream txtReader = Microsoft.Xna.Framework.TitleContainer.OpenStream(PrinceOfPersiaGame.CONFIG_PATH_CONTENT + PrinceOfPersiaGame.CONFIG_PATH_SEQUENCES + tileType.ToString().ToUpper() + "_sequence.xml"); //TextReader txtReader = File.OpenText(PrinceOfPersiaGame.CONFIG_PATH_CONTENT + PrinceOfPersiaGame.CONFIG_PATH_SEQUENCES + tileType.ToString().ToUpper() + "_sequence.xml"); m_tileSequence = (List<Sequence>)ax.Deserialize(txtReader); foreach (Sequence s in m_tileSequence) { s.Initialize(Content); } //Search in the sequence the right type Sequence result = m_tileSequence.Find((Sequence s) => s.name == state.ToString().ToUpper()); if (result != null) { //AMF to be adjust.... result.frames[0].SetTexture(Content.Load<Texture2D>(PrinceOfPersiaGame.CONFIG_TILES[0] + result.frames[0].value)); collision = result.collision; Texture = result.frames[0].texture; } Type = tileType; //change statetile element StateTileElement stateTileElement = new StateTileElement(); stateTileElement.state = state; tileState.Add(stateTileElement); tileAnimation.PlayAnimation(m_tileSequence, tileState.Value()); //load item switch (eitem) { case Enumeration.Items.flask: item = new Flask(Content); break; // TODO: might not be correct. Was : Exit Select case Enumeration.Items.flaskbig: item = new FlaskBig(Content); break; // TODO: might not be correct. Was : Exit Select case Enumeration.Items.sword: item = new Sword(Content); break; // TODO: might not be correct. Was : Exit Select } }
public void StartLevel(RoomNew room) { m_spriteRoom = room; LoadContent(); Reset(startPosition, startFlip); Sword = true; }
public void isGround() { if (IsAlive == false) { return; } m_isOnGround = false; RoomNew room = null; Rectangle playerBounds = _position.Bounding; Vector2 v2 = SpriteRoom.getCenterTile(playerBounds); Rectangle tileBounds = SpriteRoom.GetBounds(Convert.ToInt32(Math.Truncate(v2.X)), Convert.ToInt32(Math.Truncate(v2.Y))); //Check if kid outside Room if (v2.X < 0) { room = Maze.LeftRoom(SpriteRoom); } else { room = SpriteRoom; } if (v2.Y > 2) { m_isOnGround = false; } else if (v2.Y < 0) { m_isOnGround = false; } else { if (room.GetCollision(Convert.ToInt32(Math.Truncate(v2.X)), Convert.ToInt32(Math.Truncate(v2.Y))) != Enumeration.TileCollision.Passable) { if (playerBounds.Bottom >= tileBounds.Bottom) { m_isOnGround = true; } } } if (m_isOnGround == false) { if (sprite.sequence.raised == false) { if (spriteState.Value().state == Enumeration.State.runjump) { spriteState.Add(Enumeration.State.rjumpfall, Enumeration.PriorityState.Force); sprite.PlayAnimation(spriteSequence, spriteState.Value()); } else { if (spriteState.Previous().state == Enumeration.State.runjump) { spriteState.Add(Enumeration.State.stepfall, Enumeration.PriorityState.Force, new Vector2(20, 15)); } else if (spriteState.Value().state != Enumeration.State.freefall) { spriteState.Add(Enumeration.State.stepfall, Enumeration.PriorityState.Force); } } //SpriteRoom.LooseShake(); //and for upper room... SpriteRoom.maze.UpRoom(SpriteRoom).LooseShake(); } return; } //IS ON GROUND! if (spriteState.Value().state == Enumeration.State.freefall) { //Align to tile x _position.Y = tileBounds.Bottom - _position._spriteRealSize.Y; //CHECK IF LOOSE ENERGY... int Rem = 0; Rem = Convert.ToInt32(Math.Truncate(Math.Abs(Position.Y - PositionFall.Y))) / Tile.REALHEIGHT; if (Rem == 0) { ((SoundEffect)Maze.dContentRes["Sounds/dos/falling echo".ToUpper()]).Play(); } else if (Rem >= 1 & Rem < 3) { ((SoundEffect)Maze.dContentRes["Sounds/dos/loosing a life falling".ToUpper()]).Play(); } else { ((SoundEffect)Maze.dContentRes["Sounds/dos/falling".ToUpper()]).Play(); //you should dead!!! DeadFall(); } Energy = Energy - Rem; spriteState.Add(Enumeration.State.crouch, Enumeration.PriorityState.Force, false); SpriteRoom.LooseShake(); } }