PlayAnimation() public method

Begins or continues playback of an animation.
public PlayAnimation ( List lsequence, StateElement stateElement ) : void
lsequence List
stateElement StateElement
return void
Ejemplo n.º 1
0
        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
            }
        }
Ejemplo n.º 2
0
        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();
            }
        }