Exemplo n.º 1
0
        public UnitManager(string strXMLFileSprites, string strXMLFileBullets, ContentManager contentManager)
        {
            try
            {
                XmlDocument doc = new XmlDocument();

                //load all sprites
                doc.Load(strXMLFileSprites);
                XmlNodeList nodeList = doc.GetElementsByTagName("Unit");
                m_nSampleUnit = nodeList.Count;

                m_SampleUnit = new Sprite[m_nSampleUnit];

                for (int i = 0; i < m_nSampleUnit; i++)
                {
                    if (nodeList[i].Attributes.Count > 0 && nodeList[i].Attributes["name"].Value.CompareTo("Player") == 0)
                    {
                        m_SampleUnit[i] = new UserControlledSprite();
                    }
                    else
                    {
                        m_SampleUnit[i] = new AutomatedSprite();
                    }
                    m_SampleUnit[i].LoadFromXml(nodeList[i], contentManager);
                }

                //load all bullets
                doc.Load(strXMLFileBullets);
                nodeList = doc.GetElementsByTagName("Bullet");
                m_nSampleBullet = nodeList.Count;
                m_SampleBullet = new Bullet[m_nSampleBullet];

                for (int i = 0; i < m_nSampleBullet; i++)
                {
                    m_SampleBullet[i] = new Bullet();
                    m_SampleBullet[i].LoadFromXml(nodeList[i], contentManager);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public override Sprite Clone()
        {
            UserControlledSprite tmp = new UserControlledSprite();

            tmp.asSprite = this.asSprite.Clone();
            tmp.bActive = this.bActive;
            tmp.bAutoCheckDirection = this.bAutoCheckDirection;
            tmp.bDeactivateAtEndOfPath = this.bDeactivateAtEndOfPath;
            tmp.bHideAtEndOfPath = this.bHideAtEndOfPath;
            tmp.bLoopPath = this.bLoopPath;
            tmp.bMovingTowardsTarget = this.bMovingTowardsTarget;
            tmp.bPathing = this.bPathing;
            tmp.bVisible = this.bVisible;
            tmp.collisionOffset = this.collisionOffset;
            tmp.fSpeed = this.fSpeed;
            tmp.iCollisionBufferX = this.iCollisionBufferX;
            tmp.iCollisionBufferY = this.iCollisionBufferY;
            tmp.bIsSail = this.bIsSail;
            tmp.m_CurrDirection = this.m_CurrDirection;
            tmp.queuePath = this.queuePath;
            tmp.sEndPathAnimation = this.sEndPathAnimation;
            tmp.v2Target = this.v2Target;
            tmp.m_strName = this.m_strName;
            tmp.m_iLevel = this.m_iLevel;
            tmp.m_iCurrHP = this.m_iCurrHP;
            tmp.m_iMaxHP = this.m_iMaxHP;
            tmp.m_iDefence = this.m_iDefence;
            tmp.m_iAttack = this.m_iAttack;
            tmp.m_iSelectedBullet = this.m_iSelectedBullet;
            tmp.m_ColorOnMap = this.m_ColorOnMap;
            tmp.bIsAttack = this.bIsAttack;
            tmp.Point = this.Point;
            tmp.m_fTimerAttack = this.m_fTimerAttack;
            tmp.m_iTotalGolds = this.m_iTotalGolds;
            tmp.m_iTotalLives = this.m_iTotalLives;
            tmp.m_iTotalStars = this.m_iTotalStars;

            return tmp;
        }
Exemplo n.º 3
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(Game.GraphicsDevice);
            player = new UserControlledSprite(Game.Content.Load<Texture2D>(@"Resource/Sprite/Computer/Tboot_Trans"), Vector2.Zero, new Point(64, 64), 10, new Point(0, 0), new Point(17, 6), new Vector2(6, 6));
            /*
            player = new UserControlledSprite(
                Game.Content.Load<Texture2D>(@"Images/threerings"),
                Vector2.Zero, new Point(75, 75), 10, new Point(0, 0),
                new Point(6, 8), new Vector2(6, 6));

            spriteList.Add(new AutomatedSprite(
                Game.Content.Load<Texture2D>(@"Images/skullball"),
                new Vector2(150, 150), new Point(75, 75), 10, new Point(0, 0),
                new Point(6, 8), Vector2.Zero, "skullcollision"));

            spriteList.Add(new AutomatedSprite(
                Game.Content.Load<Texture2D>(@"Images/skullball"),
                new Vector2(300, 150), new Point(75, 75), 10, new Point(0, 0),
                new Point(6, 8), Vector2.Zero, "skullcollision"));

            spriteList.Add(new AutomatedSprite(
                Game.Content.Load<Texture2D>(@"Images/skullball"),
                new Vector2(150, 300), new Point(75, 75), 10, new Point(0, 0),
                new Point(6, 8), Vector2.Zero, "skullcollision"));

            spriteList.Add(new AutomatedSprite(
                Game.Content.Load<Texture2D>(@"Images/skullball"),
                new Vector2(600, 400), new Point(75, 75), 10, new Point(0, 0),
                new Point(6, 8), Vector2.Zero, "skullcollision"));
            */

            base.LoadContent();
        }