public override bool InitOne(ContentManager content, int id)
        {
            XmlDocument _doc = new XmlDocument();

            _doc.Load(_xmlInfo);
            XmlNode _portral = _doc.SelectSingleNode(@"//Portral[@id = '" + id.ToString() + "']");

            _prototype[id]          = new Portral();
            _prototype[id]._nsprite = 1;
            _prototype[id]._sprite  = new GameSprite[_prototype[id]._nsprite];

            string contentName = _portral.SelectSingleNode(@"ContentName").InnerText;
            int    nFrame      = int.Parse(_portral.SelectSingleNode(@"NumOfFrame").InnerText);

            Texture2D[] _texture = new Texture2D[nFrame];
            for (int i = 0; i < nFrame; ++i)
            {
                _texture[i] = content.Load <Texture2D>(contentName + i.ToString("00"));
            }
            _prototype[id]._sprite[0]         = new GameSprite(_texture, 0, 0);
            _prototype[id]._sprite[0].Xoffset = int.Parse(_portral.SelectSingleNode(@"XOffset").InnerText);
            _prototype[id]._sprite[0].Yoffset = int.Parse(_portral.SelectSingleNode(@"YOffset").InnerText);
            _prototype[id]._sprite[0].NDelay  = 3;

            return(true);
        }
Esempio n. 2
0
        public List <Portral> InitPortralList(PortralManager portralManager, string xmlPortralFile)
        {
            List <Portral> ret = new List <Portral>();
            XmlDocument    doc = new XmlDocument();

            doc.Load(xmlPortralFile);
            XmlNodeList Portrals = doc.SelectNodes(@"//Portral");

            for (int i = 0; i < Portrals.Count; ++i)
            {
                Portral pt = (Portral)portralManager.CreateObject(int.Parse(Portrals[i].SelectSingleNode(@"Type").InnerText));
                ret.Add(pt);
                ret[i].X           = int.Parse(Portrals[i].SelectSingleNode(@"X").InnerText) * GlobalVariables.MapCollisionDim;
                ret[i].Y           = int.Parse(Portrals[i].SelectSingleNode(@"Y").InnerText) * GlobalVariables.MapCollisionDim;
                ret[i].Destination = Portrals[i].SelectSingleNode(@"Destination").InnerText;
                ret[i].DestX       = int.Parse(Portrals[i].SelectSingleNode(@"DestinationX").InnerText);
                ret[i].DestY       = int.Parse(Portrals[i].SelectSingleNode(@"DestinationY").InnerText);
                ret[i].Owner       = this.Owner;
            }
            return(ret);
        }