Example #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()
        {
            AutomatedSprite tmp = new AutomatedSprite();

            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.m_fTimerAttack = this.m_fTimerAttack;
            tmp.m_iTimerChangeWay = this.m_iTimerChangeWay;
            tmp.m_iCurrTimeAttack = this.m_iCurrTimeAttack;
            tmp.m_iCurrTimeChangeWay = this.m_iCurrTimeChangeWay;
            tmp.m_Random = this.m_Random;
            tmp.bRandX = this.bRandX;
            tmp.Point = this.Point;
            tmp.m_fTimerAttack = this.m_fTimerAttack;

            return tmp;
        }