Ejemplo n.º 1
0
        public void HandleCollision()
        {
            if (this.Type == Enumeration.TileType.loose)
            {
                if (this.tileState.Value().state != Enumeration.StateTile.loosefall)
                {
                    return;
                }

                Rectangle r      = new Rectangle((int)Position.X, (int)Position.Y, Tile.WIDTH, Tile.HEIGHT);
                Vector4   v      = room.getBoundTiles(r);
                Tile      myTile = room.GetTile((int)v.X, (int)v.W);
                //Rectangle tileBounds = room.GetBounds((int)v.X, (int)v.W);

                Vector2 depth = RectangleExtensions.GetIntersectionDepth(myTile.Position.Bounding, r);
                Enumeration.TileType      tileType      = room.GetType((int)v.X, (int)v.W);
                Enumeration.TileCollision tileCollision = room.GetCollision((int)v.X, (int)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);
                        }
                        //THE LOOSE FALL INTO FLOOR
                        if (tileType == Enumeration.TileType.loose)
                        {
                            Loose l = (Loose)room.GetTile((int)v.X, (int)v.W);
                            l.Fall(true);
                        }
                        else if (tileType == Enumeration.TileType.pressplate)
                        {
                            ((SoundEffect)Maze.Content[PoP.CONFIG_SOUNDS + "tile crashing into the floor"]).Play();
                            PressPlate pressPlate = (PressPlate)room.GetTile((int)v.X, (int)v.Y);
                            pressPlate.Press();
                        }
                        else
                        {
                            ((SoundEffect)Maze.Content[PoP.CONFIG_SOUNDS + "tile crashing into the floor"]).Play();
                            room.SubsTile(Coordinates, Enumeration.TileType.rubble);
                        }
                    }
                }


                //if (_position.Y >= RoomNew.BOTTOM_LIMIT - Tile.HEIGHT - Tile.PERSPECTIVE)
                if (_position.Y >= Room.BOTTOM_LIMIT - Tile.PERSPECTIVE)
                {
                    //remove tiles from tilesTemporaney
                    lock (room.tilesTemporaney)
                    {
                        room.tilesTemporaney.Remove(this);
                    }
                    //exit from DOWN room
                    room        = room.Down;
                    _position.Y = Room.TOP_LIMIT - 10;

                    lock (room.tilesTemporaney)
                    {
                        room.tilesTemporaney.Add(this);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void DrawDebug(Room room)
        {
            if (CONFIG_DEBUG == false)
            {
                return;
            }

            Rectangle titleSafeArea = GraphicsDevice.Viewport.TitleSafeArea;
            Vector2   hudLocation   = new Vector2(titleSafeArea.X, titleSafeArea.Y);

            DrawShadowedString(fontPrinceOfPersia_bigger, "LEVEL NAME=" + maze.player.MyLevel.levelName, hudLocation, Color.White);
            hudLocation.Y = hudLocation.Y + 10;

            DrawShadowedString(fontPrinceOfPersia_bigger, "ROOM NAME=" + maze.player.MyRoom.roomName, hudLocation, Color.White);
            hudLocation.Y = hudLocation.Y + 10;

            DrawShadowedString(fontPrinceOfPersia_bigger, "POSTION X=" + maze.player.Position.X.ToString() + " Y=" + maze.player.Position.Y.ToString(), hudLocation, Color.White);
            hudLocation.Y = hudLocation.Y + 10;
            DrawShadowedString(fontPrinceOfPersia_bigger, "FRAME RATE=" + AnimationSequence.frameRate.ToString(), hudLocation, Color.White);

            hudLocation.Y = hudLocation.Y + 10;
            DrawShadowedString(fontPrinceOfPersia_bigger, "PLAYER STATE=" + maze.player.spriteState.Value().state + " SEQUENCE CountOffset=" + maze.player.sprite.sequence.CountOffSet, hudLocation, Color.White);

            hudLocation.Y = hudLocation.Y + 10;
            DrawShadowedString(fontPrinceOfPersia_bigger, "PLAYER FRAME=" + maze.player.spriteState.Value().Frame + " NAME=" + maze.player.spriteState.Value().Name, hudLocation, Color.White);

            hudLocation.Y = hudLocation.Y + 10;
            DrawShadowedString(fontPrinceOfPersia_bigger, "PLAYER SWORD=" + maze.player.Sword.ToString(), hudLocation, Color.White);

            TouchCollection touchState = TouchPanel.GetState();

            for (int x = 0; x < touchState.Count; x++)
            {
                hudLocation.Y = hudLocation.Y + 10;
                DrawShadowedString(fontPrinceOfPersia_bigger, "TOUCH_STATE=" + touchState[x].State.ToString(), hudLocation, Color.White);
                hudLocation.Y = hudLocation.Y + 10;
                DrawShadowedString(fontPrinceOfPersia_bigger, "TOUCH_LOCATION=" + touchState[x].Position.ToString(), hudLocation, Color.White);
            }

            hudLocation.Y = hudLocation.Y + 10;
            DrawShadowedString(fontPrinceOfPersia_bigger, "-SHIFTZONE=" + CntShiftZone.ToString(), hudLocation, Color.White);



            // Get the player's bounding rectangle and find neighboring tiles.
            Rectangle playerBounds = maze.player.Position.Bounding;
            Vector4   v4           = room.getBoundTiles(playerBounds);

            // For each potentially colliding Tile, warning the for check only the player row ground..W
            for (int y = (int)v4.Z; y <= (int)v4.W; ++y)
            {
                for (int x = (int)v4.X; x <= (int)v4.Y; ++x)
                {
                    //Rectangle tileBounds = room.GetBounds(x, y);
                    Tile    myTile = room.GetTile(x, y);
                    Vector2 depth  = RectangleExtensions.GetIntersectionDepth(playerBounds, myTile.Position.Bounding);
                    Enumeration.TileCollision tileCollision = room.GetCollision(x, y);
                    Enumeration.TileType      tileType      = room.GetType(x, y);

                    hudLocation.Y = hudLocation.Y + 10;
                    DrawShadowedString(fontPrinceOfPersia_bigger, "GRID X=" + x + " Y=" + y + " TILETYPE=" + tileType.ToString() + " BOUND X=" + myTile.Position.Bounding.X + " Y=" + myTile.Position.Bounding.Y + " DEPTH X=" + depth.X + " Y=" + depth.Y, hudLocation, Color.White);
                }
            }
        }