コード例 #1
0
ファイル: Tile.cs プロジェクト: ARLM-Attic/prince-of-persia
        public Tile(Room room, Enumeration.TileType tileType, Enumeration.StateTile state, Enumeration.Items eitem, Enumeration.TileType NextTileType)
        {
            tileAnimation = new AnimationSequence(this);
            this.room     = room;
            nextTileType  = NextTileType;

            System.Xml.Serialization.XmlSerializer ax = new System.Xml.Serialization.XmlSerializer(tileSequence.GetType());

            Stream txtReader = Microsoft.Xna.Framework.TitleContainer.OpenStream(PoP.CONFIG_PATH_CONTENT + PoP.CONFIG_PATH_SEQUENCES + tileType.ToString() + "_sequence.xml");

            //TextReader txtReader = File.OpenText(PrinceOfPersiaGame.CONFIG_PATH_CONTENT + PrinceOfPersiaGame.CONFIG_PATH_SEQUENCES + tileType.ToString() + "_sequence.xml");


            tileSequence = (List <Sequence>)ax.Deserialize(txtReader);

            foreach (Sequence s in tileSequence)
            {
                s.Initialize();
            }

            //Search in the sequence the right type
            Sequence result = tileSequence.Find(delegate(Sequence s)
            {
                return(s.name.ToUpper() == state.ToString().ToUpper());
            });

            if (result != null)
            {
                //AMF to be adjust....
                result.frames[0].SetTexture((Texture2D)Maze.Content[PoP.CONFIG_TILES + result.frames[0].value]);
                //result.frames[0].SetTexture(Content.Load<Texture2D>(PrinceOfPersiaGame.CONFIG_TILES + 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(tileSequence, tileState);

            //load item
            switch (eitem)
            {
            case Enumeration.Items.flask:
                item = new Flask();
                break;

            case Enumeration.Items.sword:
                item = new Sword();
                break;
            }
        }
コード例 #2
0
        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());
        }
コード例 #3
0
ファイル: PoP.cs プロジェクト: ARLM-Attic/prince-of-persia
        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);
                }
            }
        }
コード例 #4
0
        public Chomper(Room room, Enumeration.TileType tileType, Enumeration.StateTile state, Enumeration.TileType NextTileType)
        {
            base.room = room;

            nextTileType = NextTileType;
            System.Xml.Serialization.XmlSerializer ax = new System.Xml.Serialization.XmlSerializer(tileSequence.GetType());

            Stream txtReader = Microsoft.Xna.Framework.TitleContainer.OpenStream(PoP.CONFIG_PATH_CONTENT + PoP.CONFIG_PATH_SEQUENCES + tileType.ToString() + "_sequence.xml");

            tileSequence = (List <Sequence>)ax.Deserialize(txtReader);

            foreach (Sequence s in tileSequence)
            {
                s.Initialize();
            }

            //Search in the sequence the right type
            Sequence result = tileSequence.Find(delegate(Sequence s)
            {
                return(s.name.ToUpper() == state.ToString().ToUpper());
            });

            if (result != null)
            {
                result.frames[0].SetTexture((Texture2D)Maze.Content[PoP.CONFIG_TILES + 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);
        }
コード例 #5
0
ファイル: Tile.cs プロジェクト: salvadorc17/Prince-Monogame
        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
            }
        }
コード例 #6
0
ファイル: Gate.cs プロジェクト: ARLM-Attic/prince-of-persia
        public Gate(Room room, Enumeration.TileType tileType, Enumeration.StateTile state, int switchButton, Enumeration.TileType NextTileType)
        {
            collision    = Enumeration.TileCollision.Platform;
            base.room    = room;
            nextTileType = NextTileType;


            switchButtons.Add(switchButton);
            System.Xml.Serialization.XmlSerializer ax = new System.Xml.Serialization.XmlSerializer(tileSequence.GetType());
            Stream txtReader = Microsoft.Xna.Framework.TitleContainer.OpenStream(PoP.CONFIG_PATH_CONTENT + PoP.CONFIG_PATH_SEQUENCES + tileType.ToString() + "_sequence.xml");

            //TextReader txtReader = File.OpenText(PrinceOfPersiaGame.CONFIG_PATH_CONTENT + PrinceOfPersiaGame.CONFIG_PATH_SEQUENCES + tileType.ToString() + "_sequence.xml");

            tileSequence = (List <Sequence>)ax.Deserialize(txtReader);

            foreach (Sequence s in tileSequence)
            {
                s.Initialize();
            }

            if (state == Enumeration.StateTile.normal)
            {
                state = Enumeration.StateTile.closed;
            }

            //Search in the sequence the right type
            Sequence result = tileSequence.Find(delegate(Sequence s)
            {
                return(s.name.ToUpper() == state.ToString().ToUpper());
            });

            if (result != null)
            {
                //AMF to be adjust....
                result.frames[0].SetTexture((Texture2D)Maze.Content[PoP.CONFIG_TILES + result.frames[0].value]);
                //result.frames[0].SetTexture(Content.Load<Texture2D>(PrinceOfPersiaGame.CONFIG_TILES + 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);
        }
コード例 #7
0
        public Mirror(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());
        }