public override bool InitOne(ContentManager content, int id)
        {
            XmlDocument _doc = new XmlDocument();
            _doc.Load(_xmlInfo);
            XmlNode _MapObstacle = _doc.SelectSingleNode(@"//MapObstacle[@id = '" + id.ToString() + "']");
            _prototype[id] = new MapObstacle();
            _prototype[id]._nsprite = 1;
            _prototype[id]._sprite = new GameSprite[_prototype[id]._nsprite];

            string contentName = _MapObstacle.SelectSingleNode(@"ContentName").InnerText;
            int nFrame = int.Parse(_MapObstacle.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(_MapObstacle.SelectSingleNode(@"XOffset").InnerText);
            _prototype[id]._sprite[0].Yoffset = int.Parse(_MapObstacle.SelectSingleNode(@"YOffset").InnerText);
            _prototype[id]._sprite[0].NDelay = 3;

            ((MapObstacle)_prototype[id]).StartObstacleX = int.Parse(_MapObstacle.SelectSingleNode(@"StartObstacleX").InnerText);
            ((MapObstacle)_prototype[id]).StartObstacleY = int.Parse(_MapObstacle.SelectSingleNode(@"StartObstacleY").InnerText);
            ((MapObstacle)_prototype[id]).ObstacleWidth = int.Parse(_MapObstacle.SelectSingleNode(@"ObstacleWidth").InnerText);
            ((MapObstacle)_prototype[id]).ObstacleHeight = int.Parse(_MapObstacle.SelectSingleNode(@"ObstacleHeight").InnerText);

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

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

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

            string contentName = _MapObstacle.SelectSingleNode(@"ContentName").InnerText;
            int    nFrame      = int.Parse(_MapObstacle.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(_MapObstacle.SelectSingleNode(@"XOffset").InnerText);
            _prototype[id]._sprite[0].Yoffset = int.Parse(_MapObstacle.SelectSingleNode(@"YOffset").InnerText);
            _prototype[id]._sprite[0].NDelay  = 3;

            ((MapObstacle)_prototype[id]).StartObstacleX = int.Parse(_MapObstacle.SelectSingleNode(@"StartObstacleX").InnerText);
            ((MapObstacle)_prototype[id]).StartObstacleY = int.Parse(_MapObstacle.SelectSingleNode(@"StartObstacleY").InnerText);
            ((MapObstacle)_prototype[id]).ObstacleWidth  = int.Parse(_MapObstacle.SelectSingleNode(@"ObstacleWidth").InnerText);
            ((MapObstacle)_prototype[id]).ObstacleHeight = int.Parse(_MapObstacle.SelectSingleNode(@"ObstacleHeight").InnerText);

            return(true);
        }
Esempio n. 3
0
        internal List <MapObstacle> InitObstacle(MapObstacleManager mapObstacleManager, string xmlMapObstacleFile)
        {
            List <MapObstacle> ret = new List <MapObstacle>();
            XmlDocument        doc = new XmlDocument();

            doc.Load(xmlMapObstacleFile);
            XmlNodeList MapObstacles = doc.SelectNodes(@"//MapObstacle");

            for (int i = 0; i < MapObstacles.Count; ++i)
            {
                MapObstacle pt = (MapObstacle)mapObstacleManager.CreateObject(int.Parse(MapObstacles[i].SelectSingleNode(@"Type").InnerText));
                ret.Add(pt);
                int XLogic = int.Parse(MapObstacles[i].SelectSingleNode(@"X").InnerText);
                int YLogic = int.Parse(MapObstacles[i].SelectSingleNode(@"Y").InnerText);
                ret[i].X = XLogic * GlobalVariables.MapCollisionDim;
                ret[i].Y = YLogic * GlobalVariables.MapCollisionDim;
                for (int j = YLogic + ret[i].StartObstacleY; j < ret[i].ObstacleHeight + YLogic + ret[i].StartObstacleY; ++j)
                {
                    for (int k = XLogic + ret[i].StartObstacleX; k < ret[i].ObstacleWidth + XLogic + ret[i].StartObstacleX; ++k)
                    {
                        Matrix[j][k] = false;
                    }
                }
            }
            return(ret);
        }