示例#1
0
        public Explosion(Texture2D texture,
            
            int X, int Y, int W, int H, int Frames)
        {
            asSprite = new SpriteAnimation(texture);

            //asSprite.FrameLength = 0.05f;
        }
示例#2
0
 public Bullet(Texture2D t2dTexture)
 {
     asSprite = new SpriteAnimation(t2dTexture);
     iSpeed = 1;
     asSprite.AutoRotate = true;
     bActive = false;
     bVisible = false;
     m_CurrDirection = BattleShip.Core.Utils.Common.Direction.Up;
 }
示例#3
0
        public void LoadFromXml(XmlNode node, ContentManager contentManager)
        {
            int iTileWidth = 0;
            int iTileHeight = 0;
            int iFrameCount = 0;
            string strSound = string.Empty;

            foreach (XmlAttribute att in node.Attributes)
            {
                switch (att.Name)
                {
                    case "Name":
                        m_strName = att.Value;
                        break;
                    case "TileWidth":
                        iTileWidth = int.Parse(att.Value);
                        break;
                    case "TileHeight":
                        iTileHeight = int.Parse(att.Value);
                        break;
                    case "FrameCount":
                        iFrameCount = int.Parse(att.Value);
                        break;
                    case "Speed":
                        iSpeed = int.Parse(att.Value);
                        break;
                    case "NumBullet":
                        m_iMaxNumBullet = m_iNumBullet = int.Parse(att.Value);
                        break;
                    case "CollisionBufferX":
                        iCollisionBufferX = int.Parse(att.Value);
                        break;
                    case "CollisionBufferY":
                        iCollisionBufferY = int.Parse(att.Value);
                        break;
                    case "SoundEffect":
                        strSound = att.Value;
                        break;
                    case "Attack":
                        m_iAttack = int.Parse(att.Value);
                        break;
                }
            }

            Texture2D t2d = contentManager.Load<Texture2D>(@"Resource/Sprite/Bullet/" + m_strName);
            asSprite = new SpriteAnimation(t2d);
            asSprite.AddAnimation("bullet", 0, 0, iTileWidth, iTileHeight, iFrameCount, 0.1f, true);

            m_SoundGun = contentManager.Load<SoundEffect>(@"Resource/Sound/" + strSound);
        }
示例#4
0
 public AnimateEffect(Texture2D t2dTexture)
 {
     asSprite = new SpriteAnimation(t2dTexture);
     bActive = false;
     bVisible = false;
 }
        public SpriteAnimation Clone()
        {
            SpriteAnimation tmp = new SpriteAnimation(this.t2dTexture);

            tmp.sCurrentAnimation = this.sCurrentAnimation;
            tmp.t2dTexture = this.t2dTexture;
            tmp.v2Center = this.v2Center;
            tmp.v2LastPosition = this.v2LastPosition;
            tmp.v2Position = this.v2Position;
            tmp.iWidth = this.iWidth;
            tmp.iHeight = this.iHeight;
            tmp.fRotation = this.fRotation;
            tmp.faCurrAnimation = this.faCurrAnimation;
            tmp.faAnimations = this.faAnimations;
            tmp.colorTint = this.colorTint;
            tmp.bRotateByPosition = this.bRotateByPosition;
            tmp.bAnimating = this.bAnimating;

            return tmp;
        }
示例#6
0
 public Sprite(Texture2D texture)
 {
     asSprite = new SpriteAnimation(texture);
     m_CurrDirection = BattleShip.Core.Utils.Common.Direction.None;
     m_ColorOnMap = Color.Red;
 }
示例#7
0
        public virtual void LoadFromXml(XmlNode node, ContentManager contentManager)
        {
            Point initPosition = new Point();    //tile hien thi up

            Texture2D textureImage = null; //texture cua sprite
            Point frameSize = new Point();  //kich thuot 1 tile

            int frameCount;

            XmlNodeList nodeList = node.ChildNodes;
            foreach (XmlNode tmp in nodeList)
            {
                switch (tmp.Name)
                {
                    case "TileSet":
                        textureImage = contentManager.Load<Texture2D>(@"Resource/Sprite/Computer/" + tmp.Attributes["FileName"].Value);
                        asSprite = new SpriteAnimation(textureImage);
                        break;
                    case "Position":
                        XmlNodeList childs = tmp.ChildNodes;
                        foreach (XmlNode child in childs)
                        {
                            switch (child.Name)
                            {
                                case "Up":
                                    initPosition.X = int.Parse(child.Attributes["X"].Value);
                                    initPosition.Y = int.Parse(child.Attributes["Y"].Value);
                                    frameSize.X = int.Parse(child.Attributes["TileWidth"].Value);
                                    frameSize.Y = int.Parse(child.Attributes["TileHeight"].Value);
                                    frameCount = int.Parse(child.Attributes["FrameCount"].Value);
                                    asSprite.AddAnimation("up", initPosition.X, initPosition.Y, frameSize.X, frameSize.Y, frameCount, 0.1f, true);
                                    break;
                                case "Down":
                                    initPosition.X = int.Parse(child.Attributes["X"].Value);
                                    initPosition.Y = int.Parse(child.Attributes["Y"].Value);
                                    frameSize.X = int.Parse(child.Attributes["TileWidth"].Value);
                                    frameSize.Y = int.Parse(child.Attributes["TileHeight"].Value);
                                    frameCount = int.Parse(child.Attributes["FrameCount"].Value);
                                    asSprite.AddAnimation("down", initPosition.X, initPosition.Y, frameSize.X, frameSize.Y, frameCount, 0.1f, true);
                                    break;
                                case "Left":
                                    initPosition.X = int.Parse(child.Attributes["X"].Value);
                                    initPosition.Y = int.Parse(child.Attributes["Y"].Value);
                                    frameSize.X = int.Parse(child.Attributes["TileWidth"].Value);
                                    frameSize.Y = int.Parse(child.Attributes["TileHeight"].Value);
                                    frameCount = int.Parse(child.Attributes["FrameCount"].Value);
                                    asSprite.AddAnimation("left", initPosition.X, initPosition.Y, frameSize.X, frameSize.Y, frameCount, 0.1f, true);
                                    break;
                                case "Right":
                                    initPosition.X = int.Parse(child.Attributes["X"].Value);
                                    initPosition.Y = int.Parse(child.Attributes["Y"].Value);
                                    frameSize.X = int.Parse(child.Attributes["TileWidth"].Value);
                                    frameSize.Y = int.Parse(child.Attributes["TileHeight"].Value);
                                    frameCount = int.Parse(child.Attributes["FrameCount"].Value);
                                    asSprite.AddAnimation("right", initPosition.X, initPosition.Y, frameSize.X, frameSize.Y, frameCount, 0.1f, true);
                                    break;
                            }
                        }
                        break;
                    case "Sink":
                        childs = tmp.ChildNodes;
                        foreach (XmlNode child in childs)
                        {
                            switch (child.Name)
                            {
                                case "Up":
                                    initPosition.X = int.Parse(child.Attributes["X"].Value);
                                    initPosition.Y = int.Parse(child.Attributes["Y"].Value);
                                    frameSize.X = int.Parse(child.Attributes["TileWidth"].Value);
                                    frameSize.Y = int.Parse(child.Attributes["TileHeight"].Value);
                                    frameCount = int.Parse(child.Attributes["FrameCount"].Value);
                                    asSprite.AddAnimation("sink_up", initPosition.X, initPosition.Y, frameSize.X, frameSize.Y, frameCount, 0.1f, false);
                                    break;
                                case "Down":
                                    initPosition.X = int.Parse(child.Attributes["X"].Value);
                                    initPosition.Y = int.Parse(child.Attributes["Y"].Value);
                                    frameSize.X = int.Parse(child.Attributes["TileWidth"].Value);
                                    frameSize.Y = int.Parse(child.Attributes["TileHeight"].Value);
                                    frameCount = int.Parse(child.Attributes["FrameCount"].Value);
                                    asSprite.AddAnimation("sink_down", initPosition.X, initPosition.Y, frameSize.X, frameSize.Y, frameCount, 0.1f, false);
                                    break;
                                case "Left":
                                    initPosition.X = int.Parse(child.Attributes["X"].Value);
                                    initPosition.Y = int.Parse(child.Attributes["Y"].Value);
                                    frameSize.X = int.Parse(child.Attributes["TileWidth"].Value);
                                    frameSize.Y = int.Parse(child.Attributes["TileHeight"].Value);
                                    frameCount = int.Parse(child.Attributes["FrameCount"].Value);
                                    asSprite.AddAnimation("sink_left", initPosition.X, initPosition.Y, frameSize.X, frameSize.Y, frameCount, 0.1f, false);
                                    break;
                                case "Right":
                                    initPosition.X = int.Parse(child.Attributes["X"].Value);
                                    initPosition.Y = int.Parse(child.Attributes["Y"].Value);
                                    frameSize.X = int.Parse(child.Attributes["TileWidth"].Value);
                                    frameSize.Y = int.Parse(child.Attributes["TileHeight"].Value);
                                    frameCount = int.Parse(child.Attributes["FrameCount"].Value);
                                    asSprite.AddAnimation("sink_right", initPosition.X, initPosition.Y, frameSize.X, frameSize.Y, frameCount, 0.1f, false);
                                    break;
                            }
                        }
                        break;
                    case "Properties":
                        m_iAttack = int.Parse(tmp.Attributes["Attack"].Value);
                        m_iDefence = int.Parse(tmp.Attributes["Defence"].Value);
                        m_iMaxHP = m_iCurrHP = int.Parse(tmp.Attributes["HP"].Value);
                        fSpeed = int.Parse(tmp.Attributes["Speed"].Value);
                        m_iPoint = int.Parse(tmp.Attributes["Point"].Value);
                        m_fTimerAttack = float.Parse(tmp.Attributes["TimeDelayAttack"].Value);
                        break;
                }
            }

            asSprite.CurrentAnimation = "down";

            /*
            asSprite = new SpriteAnimation(textureImage);

            asSprite.AddAnimation("sink_left", leftShink.X * frameSize.X, leftShink.Y * frameSize.Y, frameSize.X, frameSize.Y, sheetSize.X / 2, 0.1f, false);
            asSprite.AddAnimation("sink_right", rightShink.X * frameSize.X, rightShink.Y * frameSize.Y, frameSize.X, frameSize.Y, sheetSize.X / 2, 0.1f, false);
            asSprite.AddAnimation("sink_up", upShink.X * frameSize.X, upShink.Y * frameSize.Y, frameSize.X, frameSize.Y, sheetSize.X / 2, 0.1f, false);
            asSprite.AddAnimation("sink_down", downShink.X * frameSize.X, downShink.Y * frameSize.Y, frameSize.X, frameSize.Y, sheetSize.X / 2, 0.1f, false);

            asSprite.AddAnimation("left", leftFrame.X * frameSize.X, leftFrame.Y * frameSize.Y, frameSize.X, frameSize.Y, 1, 0.1f, true);
            asSprite.AddAnimation("right", rightFrame.X * frameSize.X, rightFrame.Y * frameSize.Y, frameSize.X, frameSize.Y, 1, 0.1f, true);

            asSprite.AddAnimation("down", downFrame.X * frameSize.X, downFrame.Y * frameSize.Y, frameSize.X, frameSize.Y, 1, 0.1f, true);
             */
        }