public ObjectLayerContent(XmlNode node, LevelContent level) 
     : base(node)
 {
     // Construct xpath query for all available objects.
     string[] objectNames = (from x in level.Project.Objects select x.Name).ToArray<string>();
     string xpath = string.Join("|", objectNames);
     foreach (XmlNode objectNode in node.SelectNodes(xpath))
     {
         ObjectTemplateContent objTemplate = level.Project.Objects.First<ObjectTemplateContent>((x) => { return x.Name.Equals(objectNode.Name); });
         if (objTemplate != null)
         {
             ObjectContent obj = new ObjectContent(objectNode, objTemplate);
             foreach (ValueTemplateContent valueContent in objTemplate.Values)
             {
                 XmlAttribute attribute = null;
                 if ((attribute = objectNode.Attributes[valueContent.Name]) != null)
                 {
                     if (valueContent is BooleanValueTemplateContent)
                         obj.Values.Add(new BooleanValueContent(valueContent.Name, bool.Parse(attribute.Value)));
                     else if (valueContent is IntegerValueTemplateContent)
                         obj.Values.Add(new IntegerValueContent(valueContent.Name,
                             int.Parse(attribute.Value, CultureInfo.InvariantCulture)));
                     else if (valueContent is NumberValueTemplateContent)
                         obj.Values.Add(new NumberValueContent(valueContent.Name,
                             float.Parse(attribute.Value, CultureInfo.InvariantCulture)));
                     else if (valueContent is StringValueTemplateContent)
                         obj.Values.Add(new StringValueContent(valueContent.Name, attribute.Value));
                 }
             }
             foreach (XmlNode nodeNode in objectNode.SelectNodes("node"))
                 obj.Nodes.Add(new NodeContent(nodeNode));
             this.Objects.Add(obj);
         }
     }
 }
 public GridLayerContent(XmlNode node, LevelContent level, GridLayerSettingsContent settings)
     : base(node)
 {
     if (settings.ExportAsObjects)
     {
         this.RectangleData = new List<Rectangle>();
         foreach (XmlNode rectNode in node.SelectNodes("rect"))
         {
             Rectangle rect = Rectangle.Empty;
             if (rectNode.Attributes["x"] != null)
                 rect.X = int.Parse(rectNode.Attributes["x"].Value, CultureInfo.InvariantCulture);
             if (rectNode.Attributes["y"] != null)
                 rect.Y = int.Parse(rectNode.Attributes["y"].Value, CultureInfo.InvariantCulture);
             if (rectNode.Attributes["w"] != null)
                 rect.Width = int.Parse(rectNode.Attributes["w"].Value, CultureInfo.InvariantCulture);
             if (rectNode.Attributes["h"] != null)
                 rect.Height = int.Parse(rectNode.Attributes["h"].Value, CultureInfo.InvariantCulture);
             if (rect != Rectangle.Empty)
                 this.RectangleData.Add(rect);
         }
     }
     else
     {
         // Read in XML as a single un-delimited string value.
         string rawData = string.Join(string.Empty, node.InnerText.Split(new string[] { settings.NewLine }, StringSplitOptions.None));
         // Convert this string to byte data.
         byte[] data = System.Text.Encoding.UTF8.GetBytes(rawData);
         // Convert byte data to base 64 string.
         this.RawData = Convert.ToBase64String(data);
     }
 }
Beispiel #3
0
        // Go to Level Editor Scene
        public static void ToLevelEditor(string worldId, string levelId, short myLevelNum = 0)
        {
            GameHandler handler = Systems.handler;

            // Load Level to Edit (unless it's already loaded)
            if (levelId != handler.levelContent.levelId)
            {
                // Get Level Path & Retrieve Level Data
                if (!handler.levelContent.LoadLevelData(levelId))
                {
                    // If this is a personal level, allow it to be created.
                    if (myLevelNum >= 0 && myLevelNum < GameValues.MaxLevelsAllowedPerUser)
                    {
                        handler.levelContent.data    = LevelContent.BuildEmptyLevel(levelId);
                        handler.levelContent.levelId = levelId;
                    }

                    else
                    {
                                                #if debug
                        throw new Exception("Unable to load level data.");
                                                #endif
                        return;
                    }
                }
            }

            // Update the Level State
            handler.levelState.FullReset();

            // Prepare Next Scene
            SceneTransition.nextScene = new EditorScene();
        }
Beispiel #4
0
        public MainWindowViewModel()
        {
            startWindow   = null;
            levelContent  = null;
            openLevelForm = null;

            dialogManager = new DialogManager();

            IsLevelOpen = false;

            model = new LevelEditor();

            UpdateTitle();

            Closing                    = new Command(OnClosingExecute);
            BindStartWindow            = new Command <StartWindow>(OnBindStartWindowExecute);
            BindLevelContent           = new Command <LevelContent>(OnBindLevelContentExecute);
            BindOpenLevelForm          = new Command <OpenLevelForm>(OnBindOpenLevelFormExecute);
            CreateNewLevel             = new Command(OnCreateNewLevelExecute);
            OpenExistsLevel            = new Command(OnOpenExistsLevelExecute);
            DeleteCurrentLevel         = new Command(OnDeleteCurrentLevelExecute);
            CopyMgElemsFromExistsLevel = new Command(OnCopyMgElemsFromExistsLevelExecute);
            ExportToXml                = new Command(OnExportToXmlExecute);
            ExportToXmlLL8Extras       = new Command(OnExportToXmlLL8ExtrasExecute);
            TryLoadLastLevel           = new Command(OnTryLoadLastLevelExecute);
        }
Beispiel #5
0
        public static async Task <bool> LevelRequest(string levelId)
        {
            levelId = levelId.ToUpper();

            // Make sure the level doesn't already exist locally. If it does, there's no need to call the online API.
            if (LevelContent.LevelExists(levelId))
            {
                Systems.handler.levelContent.LoadLevelData(levelId);
                return(true);
            }

            // All checks have passed. Request the Level.
            try {
                string json = await Systems.httpClient.GetStringAsync(GameValues.CreoAPI + "level/" + levelId);

                // If the retrieval fails:
                if (json.IndexOf("success:\"fail") > -1)
                {
                    return(false);
                }

                // Load Level Data
                LevelFormat levelData = JsonConvert.DeserializeObject <LevelFormat>(json);
                levelData.id = levelId;
                Systems.handler.levelContent.LoadLevelData(levelData);

                // Save Level
                Systems.handler.levelContent.SaveLevel();

                return(true);
            } catch (Exception ex) {
                return(false);
            }
        }
Beispiel #6
0
        public async Task <bool> DisplayLevelInfo()
        {
            // Reset Status Text
            this.worldUI.statusText.SetText(null, null);

            // Verify the Node is ready.
            if (!await RunNodeReadiness())
            {
                return(false);
            }

            // Identify Level Data at this node:
            int    coordId = Coords.MapToInt(this.character.curX, this.character.curY);
            string levelId = this.currentZone.nodes.ContainsKey(coordId.ToString()) ? this.currentZone.nodes[coordId.ToString()] : "";

            // Make sure the level exists.
            LevelFormat levelData = LevelContent.GetLevelData(levelId);

            if (levelData == null)
            {
                return(false);
            }

            // Set Level Title and Description
            this.worldUI.statusText.SetText(levelData.title, levelData.description);

            return(true);
        }
Beispiel #7
0
        public TileLayerContent(XmlNode node, LevelContent level, TileLayerSettingsContent settings)
            : base(node)
        {
            XmlNodeList tileNodes = node.SelectNodes("tile");

            if (!settings.MultipleTilesets)
            {
                // Just one tileset for this layer, so get it and save it.
                if (node.Attributes["set"] != null)
                {
                    this.Tilesets.Add(node.Attributes["set"].Value);
                }
                if (settings.ExportTileSize)
                {
                    if (node.Attributes["tileWidth"] != null)
                    {
                        this.TileWidth = int.Parse(node.Attributes["tileWidth"].Value, CultureInfo.InvariantCulture);
                    }
                    if (node.Attributes["tileHeight"] != null)
                    {
                        this.TileHeight = int.Parse(node.Attributes["tileHeight"].Value, CultureInfo.InvariantCulture);
                    }
                }
                else
                {
                    if (this.Tilesets.Count > 0)
                    {
                        // Extract the tileset so we can get the default tile width/height for the layer.
                        TilesetContent tileset = (from x in level.Project.Tilesets
                                                  where (x.Name == this.Tilesets[0])
                                                  select x).First <TilesetContent>();
                        if (tileset != null)
                        {
                            this.TileWidth  = tileset.TileWidth;
                            this.TileHeight = tileset.TileHeight;
                        }
                    }
                }
            }
            else
            {
                // Multiple tilesets for this layer, all saved to each tile.  We want to save these up front, so we
                // need to extract them all.
                List <XmlNode> nodes = new List <XmlNode>(tileNodes.Count);
                foreach (XmlNode tileNode in tileNodes)
                {
                    nodes.Add(tileNode);
                }
                string[] tilesetNames = (from x in nodes
                                         where (x.Attributes["set"] != null)
                                         select x.Attributes["set"].Value).Distinct <string>().ToArray <string>();
                this.Tilesets.AddRange(tilesetNames);
            }
            foreach (XmlNode tileNode in tileNodes)
            {
                this.Tiles.Add(new TileContent(tileNode, this, settings));
            }
        }
 public LevelPreview(string fileName)
 {
     FileName = fileName;
     Content  = LevelContent.Read(fileName, true);
     Preview  = new SoftwareBitmapSource();
     if (Content.previewData != null)
     {
         LoadPreview(Content.previewData);
     }
 }
Beispiel #9
0
        public void Initialize()
        {
            newState             = EState.none;
            currentKeyboardState = Keyboard.GetState();
            oldKeyboardState     = new KeyboardState();
            GameConstants.MainCam.ResetCamera();
            GameConstants.fMovingSpeed = 1.5f + (0.25f * GameConstants.iDifficulty);
            GameConstants.fSpeedTime   = 350 - (50 * GameConstants.iDifficulty);

            if (GameManager.Instance.Level < 2)
            {
                GameConstants.levelDictionary = LevelContent.LoadListContent <Model>(GameConstants.Content, "Models/Ebene0");
            }
            else if (GameManager.Instance.Level >= 2 && GameManager.Instance.Level < 4)
            {
                GameConstants.levelDictionary = LevelContent.LoadListContent <Model>(GameConstants.Content, "Models/Ebene1");
            }
            else if (GameManager.Instance.Level >= 4)
            {
                GameConstants.levelDictionary = LevelContent.LoadListContent <Model>(GameConstants.Content, "Models/Ebene2");
            }


            foreach (KeyValuePair <string, Model> SM in GameConstants.levelDictionary)
            {
                if (GameConstants.isDebugMode)
                {
                    Console.WriteLine("Key:" + SM.Key + ", Value: " + SM.Value);
                }
            }

            txVeil    = new Texture2D[3];
            txLine    = GameConstants.Content.Load <Texture2D>("GUI/line");
            txPlayer  = GameConstants.Content.Load <Texture2D>("GUI/playericon");
            txVeil[0] = GameConstants.Content.Load <Texture2D>("GUI/veil_1");
            txVeil[1] = GameConstants.Content.Load <Texture2D>("GUI/veil_2");
            txVeil[2] = GameConstants.Content.Load <Texture2D>("GUI/veil_3");

            CalculateGUIPositions();

            GameConstants.PointLightLayer = GameConstants.Content.Load <Effect>("FX/PointLightLayer");

            //shadeLayer = GameConstants.Content.Load<Texture2D>("Textures/shadeLayer");
            shadeLayer = GameConstants.Content.Load <Texture2D>("Textures/layer");

            GameConstants.renderTarget = new RenderTarget2D(
                GameConstants.Graphics.GraphicsDevice,
                GameConstants.Graphics.GraphicsDevice.PresentationParameters.BackBufferWidth,
                GameConstants.Graphics.GraphicsDevice.PresentationParameters.BackBufferHeight,
                false,
                GameConstants.Graphics.GraphicsDevice.PresentationParameters.BackBufferFormat,
                DepthFormat.Depth24);
        }
Beispiel #10
0
        // Moves the Tile JSON (per the currently indexed [static] grid coordinate trackers) with the new data:
        protected void MoveTileDataToLayer(LayerEnum newLayerEnum, byte tileId, byte subTypeId, Dictionary <string, short> paramList = null)
        {
            RoomFormat roomData = this.levelContent.data.rooms[curRoomId];
            Dictionary <string, Dictionary <string, ArrayList> > roomLayer = null;

            // Get the layer property with a switch.
            if (LevelConvert.curRoomLayerId == "main")
            {
                roomLayer = roomData.main;
            }
            else if (LevelConvert.curRoomLayerId == "obj")
            {
                roomLayer = roomData.obj;
            }
            else if (LevelConvert.curRoomLayerId == "bg")
            {
                roomLayer = roomData.bg;
            }
            else if (LevelConvert.curRoomLayerId == "fg")
            {
                roomLayer = roomData.fg;
            }

            // Remove the Layer
            if (roomLayer != null)
            {
                roomLayer[curGridY.ToString()].Remove(curGridX.ToString());
            }

            // Move to New Layer
            var newLayer = LevelContent.GetLayerData(roomData, newLayerEnum);

            if (paramList == null)
            {
                if (!newLayer.ContainsKey(curGridY.ToString()))
                {
                    newLayer.Add(curGridY.ToString(), new Dictionary <string, ArrayList>());
                }
                newLayer[curGridY.ToString()][curGridX.ToString()] = new ArrayList {
                    tileId, subTypeId
                };
            }
            else
            {
                if (!newLayer.ContainsKey(curGridY.ToString()))
                {
                    newLayer.Add(curGridY.ToString(), new Dictionary <string, ArrayList>());
                }
                newLayer[curGridY.ToString()][curGridX.ToString()] = new ArrayList {
                    tileId, subTypeId, paramList
                };
            }
        }
Beispiel #11
0
        protected override void ProcessLevel(string levelId)
        {
            System.Console.WriteLine("Processing Level ID: " + levelId);

            // Load the Level Content
            // Update the Level ID, or use existing Level ID if applicable.
            string fullLevelPath = LevelContent.GetFullLevelPath(levelId);

            // Make sure the level exists:
            if (!File.Exists(fullLevelPath))
            {
                return;
            }

            string json = File.ReadAllText(fullLevelPath);

            // If there is no JSON content, end the attempt to load level:
            if (json == "")
            {
                return;
            }

            // Load the Data
            LevelFormatOldV1 oldData = JsonConvert.DeserializeObject <LevelFormatOldV1>(json);

            // New Level Format
            LevelFormat newData = new LevelFormat();

            newData.account     = oldData.account;
            newData.description = oldData.description;
            newData.gameClass   = oldData.gameClass;
            newData.icon        = oldData.icon;
            newData.id          = oldData.id;
            newData.music       = oldData.music;
            newData.rooms       = new List <RoomFormat>();
            newData.timeLimit   = oldData.timeLimit;
            newData.title       = oldData.title;

            // Add the Rooms to New Format:
            foreach (KeyValuePair <string, RoomFormat> kvp in oldData.oldRooms)
            {
                RoomFormat room = kvp.Value;
                newData.rooms.Add(room);
            }

            // Assign the Level Content
            this.levelContent.data    = newData;
            this.levelContent.levelId = levelId;
            this.levelContent.data.id = levelId;

            // Save the level content.
            this.levelContent.SaveLevel(this.deliveryPath, levelId);
        }
    LevelContent[] DataOrganization(string[] data)
    {
        int sizeofData    = 2;
        int NumberOfLevel = data.Length / sizeofData;

        LevelContent[] OrganizedData = new LevelContent[NumberOfLevel];
        for (int i = 0; i < NumberOfLevel; i++)
        {
            OrganizedData[i] = new LevelContent();
            OrganizedData[i].SetLevelName(data[i * 2]);
            OrganizedData[i].SetHighestScore(data[i * 2 + 1]);
        }
        return(OrganizedData);
    }
 public TileLayerContent(XmlNode node, LevelContent level, TileLayerSettingsContent settings)
     : base(node)
 {
     XmlNodeList tileNodes = node.SelectNodes("tile");
     if (!settings.MultipleTilesets)
     {
         // Just one tileset for this layer, so get it and save it.
         if (node.Attributes["set"] != null)
             this.Tilesets.Add(node.Attributes["set"].Value);
         if (settings.ExportTileSize)
         {
             if (node.Attributes["tileWidth"] != null)
                 this.TileWidth = int.Parse(node.Attributes["tileWidth"].Value, CultureInfo.InvariantCulture);
             if (node.Attributes["tileHeight"] != null)
                 this.TileHeight = int.Parse(node.Attributes["tileHeight"].Value, CultureInfo.InvariantCulture);
         }
         else
         {
             if(this.Tilesets.Count > 0) 
             {
                 // Extract the tileset so we can get the default tile width/height for the layer.
                 TilesetContent tileset = (from x in level.Project.Tilesets
                                           where (x.Name == this.Tilesets[0])
                                           select x).First<TilesetContent>();
                 if (tileset != null)
                 {
                     this.TileWidth = tileset.TileWidth;
                     this.TileHeight = tileset.TileHeight;
                 }
             }
         }
     }
     else
     {
         // Multiple tilesets for this layer, all saved to each tile.  We want to save these up front, so we 
         // need to extract them all.
         List<XmlNode> nodes = new List<XmlNode>(tileNodes.Count);
         foreach(XmlNode tileNode in tileNodes)
             nodes.Add(tileNode);
         string[] tilesetNames = (from x in nodes
                                  where (x.Attributes["set"] != null)
                                  select x.Attributes["set"].Value).Distinct<string>().ToArray<string>();
         this.Tilesets.AddRange(tilesetNames);
     }
     foreach (XmlNode tileNode in tileNodes)
         this.Tiles.Add(new TileContent(tileNode, this, settings));
 }
 //设置关卡的图样和按键激活情况
 public void SetLevelPicture(int city)
 {
     for (int i = 0; i < m_LevelButton.Length; ++i)
     {
         LevelContent       Temp           = GetLevelByCityAndLevel(city, i + 1);
         LevelButtonManager ButtonIManager = m_LevelButton[i].GetComponent <LevelButtonManager>();
         if (!Temp.Open)
         {
             m_LevelButton[i].enabled = false;
         }
         else
         {
             m_LevelButton[i].enabled = true;
         }
         ButtonIManager.SetCoverAndStar(Temp.Open, Temp.StarNum);
     }
 }
Beispiel #15
0
        public ObjectLayerContent(XmlNode node, LevelContent level)
            : base(node)
        {
            // Construct xpath query for all available objects.
            string[] objectNames = (from x in level.Project.Objects select x.Name).ToArray <string>();
            string   xpath       = string.Join("|", objectNames);

            foreach (XmlNode objectNode in node.SelectNodes(xpath))
            {
                ObjectTemplateContent objTemplate = level.Project.Objects.First <ObjectTemplateContent>((x) => { return(x.Name.Equals(objectNode.Name)); });
                if (objTemplate != null)
                {
                    ObjectContent obj = new ObjectContent(objectNode, objTemplate);
                    foreach (ValueTemplateContent valueContent in objTemplate.Values)
                    {
                        XmlAttribute attribute = null;
                        if ((attribute = objectNode.Attributes[valueContent.Name]) != null)
                        {
                            if (valueContent is BooleanValueTemplateContent)
                            {
                                obj.Values.Add(new BooleanValueContent(valueContent.Name, bool.Parse(attribute.Value)));
                            }
                            else if (valueContent is IntegerValueTemplateContent)
                            {
                                obj.Values.Add(new IntegerValueContent(valueContent.Name,
                                                                       int.Parse(attribute.Value, CultureInfo.InvariantCulture)));
                            }
                            else if (valueContent is NumberValueTemplateContent)
                            {
                                obj.Values.Add(new NumberValueContent(valueContent.Name,
                                                                      float.Parse(attribute.Value, CultureInfo.InvariantCulture)));
                            }
                            else if (valueContent is StringValueTemplateContent)
                            {
                                obj.Values.Add(new StringValueContent(valueContent.Name, attribute.Value));
                            }
                        }
                    }
                    foreach (XmlNode nodeNode in objectNode.SelectNodes("node"))
                    {
                        obj.Nodes.Add(new NodeContent(nodeNode));
                    }
                    this.Objects.Add(obj);
                }
            }
        }
Beispiel #16
0
        private void PrepareEmptyRoom(byte newRoomId)
        {
            // Make sure the room is actually empty.
            if (Systems.handler.levelContent.data.rooms.Count > newRoomId)
            {
                return;
            }

            // If there is no data for the room, create an empty object for it.
            Systems.handler.levelContent.data.rooms.Add(LevelContent.BuildRoomData());

            // We must generate the room scene as well:
            if (!this.rooms.ContainsKey(newRoomId))
            {
                this.rooms[newRoomId] = new EditorRoomScene(this, newRoomId);
            }
        }
Beispiel #17
0
        public void CloneTile(short gridX, short gridY)
        {
            RoomFormat roomData = this.levelContent.data.rooms[this.roomID];
            Dictionary <string, Dictionary <string, ArrayList> > layerData = null;
            bool isObject = false;

            if (LevelContent.VerifyTiles(roomData.obj, gridX, gridY))
            {
                layerData = roomData.obj; isObject = true;
            }
            else if (LevelContent.VerifyTiles(roomData.main, gridX, gridY))
            {
                layerData = roomData.main;
            }
            else if (LevelContent.VerifyTiles(roomData.fg, gridX, gridY))
            {
                layerData = roomData.fg;
            }
            else if (LevelContent.VerifyTiles(roomData.bg, gridX, gridY))
            {
                layerData = roomData.bg;
            }

            // If no tile is cloned, set the current Function Tool to "Select"
            if (layerData == null)
            {
                FuncToolSelect selectFunc = (FuncToolSelect)FuncTool.funcToolMap[(byte)FuncToolEnum.Select];
                EditorTools.SetFuncTool(selectFunc);
                selectFunc.ClearSelection();
                return;
            }

            // Get the Object from the Highlighted Tile (Search Front to Back until a tile is identified)
            byte[] tileData = LevelContent.GetTileData(layerData, gridX, gridY);

            // Identify the tile, and set it as the current editing tool (if applicable)
            TileTool clonedTool = TileTool.GetTileToolFromTileData(tileData, isObject);

            if (clonedTool is TileTool == true)
            {
                byte subIndex = clonedTool.subIndex;                 // Need to save this value to avoid subIndexSaves[] tracking.
                EditorTools.SetTileTool(clonedTool, (byte)clonedTool.index);
                clonedTool.SetSubIndex(subIndex);
            }
        }
Beispiel #18
0
        // LevelContent.GetLocalLevelPath		// this returns "QC/QCALQOD10" from "QCALQOD10"

        public LevelConvert(string fromPath, string toPath)
        {
            // Folders
            this.originalFolder = fromPath;
            this.deliveryFolder = toPath;

            // Set Paths
            this.basePath     = Systems.filesLocal.localDir;
            this.originalPath = Path.Combine(basePath, this.originalFolder);
            this.deliveryPath = Path.Combine(basePath, this.deliveryFolder);

            this.levelContent = new LevelContent(this.originalPath);

            this.RunAllLevels();

            // Return Level Path to Correct Destination:
            LevelContent.SetLevelPath();
        }
Beispiel #19
0
        public async Task <bool> RunNodeReadiness()
        {
            // Can only activate if the character is at a Node.
            if (!this.character.IsAtNode)
            {
                return(false);
            }

            // Get Current Tile Data
            byte[] wtData = this.worldContent.GetWorldTileData(this.currentZone, this.character.curX, this.character.curY);

            bool isPlayableNode = NodeData.IsObjectANode(wtData[5], false, false, true);

            // If a node is not playable, continue.
            if (!isPlayableNode)
            {
                return(false);
            }

            // Identify Level Data at this node:
            int    coordId = Coords.MapToInt(this.character.curX, this.character.curY);
            string levelId = this.currentZone.nodes.ContainsKey(coordId.ToString()) ? this.currentZone.nodes[coordId.ToString()] : "";

            if (levelId.Length == 0)
            {
                return(false);
            }

            // Check if Level exists in file system.
            if (!LevelContent.LevelExists(levelId))
            {
                bool discovered = await WebHandler.LevelRequest(levelId);

                // If the level failed to be located (including online), delete the reference to it from the zone.
                if (!discovered)
                {
                    this.currentZone.nodes.Remove(coordId.ToString());
                    this.campaign.SaveCampaign();
                    return(false);
                }
            }

            return(true);
        }
 //从XML读取出来的混乱列表整理成规则列表。
 public void GetImformation(ArrayList ImformationList)
 {
     LevelList.Clear();
     for (int i = 0; i < ImformationList.Count; i++)
     {
         ArrayList Temp = ImformationList[i] as ArrayList;
         LevelContent Contenttemp = new LevelContent();
         string strTemp = Temp[0] as string;
         Contenttemp.City = (int)(strTemp[0] - '0');
         Contenttemp.Level = (int)(strTemp[2] - '0');
         strTemp = Temp[1] as string;
         Contenttemp.Open = strTemp == "true";
         strTemp = Temp[2] as string;
         Contenttemp.Pass = strTemp == "true";
         strTemp = Temp[3] as string;
         Contenttemp.StarNum = (int)(strTemp[0] - '0');
         LevelList.Add(Contenttemp);
     }
 }
 //从XML读取出来的混乱列表整理成规则列表。
 public void GetImformation(ArrayList ImformationList)
 {
     LevelList.Clear();
     for (int i = 0; i < ImformationList.Count; i++)
     {
         ArrayList    Temp        = ImformationList[i] as ArrayList;
         LevelContent Contenttemp = new LevelContent();
         string       strTemp     = Temp[0] as string;
         Contenttemp.City    = (int)(strTemp[0] - '0');
         Contenttemp.Level   = (int)(strTemp[2] - '0');
         strTemp             = Temp[1] as string;
         Contenttemp.Open    = strTemp == "true";
         strTemp             = Temp[2] as string;
         Contenttemp.Pass    = strTemp == "true";
         strTemp             = Temp[3] as string;
         Contenttemp.StarNum = (int)(strTemp[0] - '0');
         LevelList.Add(Contenttemp);
     }
 }
 public GridLayerContent(XmlNode node, LevelContent level, GridLayerSettingsContent settings)
     : base(node)
 {
     if (settings.ExportAsObjects)
     {
         this.RectangleData = new List <Rectangle>();
         foreach (XmlNode rectNode in node.SelectNodes("rect"))
         {
             Rectangle rect = Rectangle.Empty;
             if (rectNode.Attributes["x"] != null)
             {
                 rect.X = int.Parse(rectNode.Attributes["x"].Value, CultureInfo.InvariantCulture);
             }
             if (rectNode.Attributes["y"] != null)
             {
                 rect.Y = int.Parse(rectNode.Attributes["y"].Value, CultureInfo.InvariantCulture);
             }
             if (rectNode.Attributes["w"] != null)
             {
                 rect.Width = int.Parse(rectNode.Attributes["w"].Value, CultureInfo.InvariantCulture);
             }
             if (rectNode.Attributes["h"] != null)
             {
                 rect.Height = int.Parse(rectNode.Attributes["h"].Value, CultureInfo.InvariantCulture);
             }
             if (rect != Rectangle.Empty)
             {
                 this.RectangleData.Add(rect);
             }
         }
     }
     else
     {
         // Read in XML as a single un-delimited string value.
         string rawData = string.Join(string.Empty, node.InnerText.Split(new string[] { settings.NewLine }, StringSplitOptions.None));
         // Convert this string to byte data.
         byte[] data = System.Text.Encoding.UTF8.GetBytes(rawData);
         // Convert byte data to base 64 string.
         this.RawData = Convert.ToBase64String(data);
     }
 }
Beispiel #23
0
        public EditorScene() : base()
        {
            // References
            this.levelContent = Systems.handler.levelContent;
            this.limiter      = new ObjectLimiter();
            this.tutorial     = new TutorialEditor(this);

            // UI State
            UIHandler.SetUIOptions(true, false);
            UIHandler.SetMenu(null, false);

            // Create UI
            this.editorUI = new EditorUI(this);

            // Generate Each Room
            this.rooms = new Dictionary <byte, EditorRoomScene>();

            for (byte nextRoomID = 0; nextRoomID < this.levelContent.data.rooms.Count; nextRoomID++)
            {
                this.rooms[nextRoomID] = new EditorRoomScene(this, nextRoomID);
            }
        }
Beispiel #24
0
        public bool ApplyLevelDataByNumber(short levelNum)
        {
            string levelId = "__" + levelNum.ToString();

            // Check if the level has already been attached into the dictionary. If so, return TRUE.
            if (this.levels.ContainsKey(levelNum))
            {
                return(true);
            }

            // Make sure the level exists.
            LevelFormat levelData = LevelContent.GetLevelData(levelId);

            if (levelData == null)
            {
                return(false);
            }

            // Attach the level data to the levels dictionary.
            this.levels.Add(levelNum, levelData);

            return(true);
        }
Beispiel #25
0
        public EditorRoomScene(EditorScene scene, byte roomID) : base()
        {
            // References
            this.scene        = scene;
            this.levelContent = this.scene.levelContent;
            this.roomID       = roomID;

            // Build Tilemap with Correct Dimensions
            short xCount, yCount;

            RoomGenerate.DetectRoomSize(this.levelContent.data.rooms[roomID], out xCount, out yCount);

            // Initialize Object Limiter Count
            this.scene.limiter.RunRoomCount(roomID, this.levelContent.data.rooms[roomID]);

            // Sizing
            this.xCount    = xCount;
            this.yCount    = yCount;
            this.mapWidth  = xCount * (byte)TilemapEnum.TileWidth;
            this.mapHeight = yCount * (byte)TilemapEnum.TileHeight;

            // Initial Setup
            EditorUI.currentSlotGroup = 1;
        }
    //获取规则列表的某个城市某个关卡的信息
    public LevelContent GetLevelByCityAndLevel(int City, int Level)
    {
        LevelContent Temp = LevelList[(City - 1) * 8 + Level - 1] as LevelContent;

        return(Temp);
    }
Beispiel #27
0
        // Initialize Wand Data
        public static bool InitializeWandData(EditorRoomScene scene, short gridX, short gridY)
        {
            // Get Scene References
            WandData.editorScene   = scene;
            WandData.moveParamMenu = WandData.editorScene.scene.editorUI.moveParamMenu;
            WandData.actParamMenu  = WandData.editorScene.scene.editorUI.actParamMenu;
            WandData.levelContent  = WandData.editorScene.levelContent;

            RoomFormat roomData = WandData.levelContent.data.rooms[WandData.editorScene.roomID];

            // Verify that Tile is Valid:
            WandData.validTile = false;

            if (LevelContent.VerifyTiles(roomData.main, gridX, gridY))
            {
                WandData.layerData = roomData.main;
                WandData.isObject  = false;
            }

            else if (LevelContent.VerifyTiles(roomData.fg, gridX, gridY))
            {
                WandData.layerData = roomData.fg;
                WandData.isObject  = false;
            }

            else if (LevelContent.VerifyTiles(roomData.obj, gridX, gridY))
            {
                WandData.layerData = roomData.obj;
                WandData.isObject  = true;
            }

            else
            {
                return(false);
            }

            WandData.validTile = true;

            WandData.gridX = gridX;
            WandData.gridY = gridY;

            // Get Tile Content Data
            WandData.wandTileData = LevelContent.GetTileDataWithParams(WandData.layerData, WandData.gridX, WandData.gridY);

            // Get the Param Set Used
            Params moveParamSet = null;
            Params actParamSet  = null;

            if (WandData.isObject)
            {
                moveParamSet = Systems.mapper.ObjectMetaData[byte.Parse(WandData.wandTileData[0].ToString())].moveParamSet;
                actParamSet  = Systems.mapper.ObjectMetaData[byte.Parse(WandData.wandTileData[0].ToString())].actParamSet;
            }
            else
            {
                TileObject wandTile = Systems.mapper.TileDict[byte.Parse(WandData.wandTileData[0].ToString())];
                moveParamSet = wandTile.moveParamSet;
                actParamSet  = wandTile.actParamSet;
            }

            // If the tile has param sets, it can be used here. Otherwise, return.
            WandData.validTile = (moveParamSet != null || actParamSet != null);
            if (WandData.validTile == false)
            {
                return(false);
            }

            WandData.moveParamSet = moveParamSet;
            WandData.actParamSet  = actParamSet;

            return(true);
        }
Beispiel #28
0
        public PatchContent Build()
        {
            #region Local vertex buffer

            // create local vertex buffer for patch
            int numVertices = _patchSize * _patchSize;
            VertexBufferContent localVertexBuffer = new VertexBufferContent(numVertices);

            // fill vertex buffer
            VertexPositionNormalTexture2[] vertices = new VertexPositionNormalTexture2[numVertices];

            int nStartX = _patchOffsetX * (_patchSize - 1);
            int nStartY = _patchOffsetY * (_patchSize - 1);
            int nEndX   = nStartX + _patchSize;
            int nEndY   = nStartY + _patchSize;

            float fMinZ = float.MaxValue, fMaxZ = float.MinValue;
            int   index = 0;
            for (int y = nStartY; y < nEndY; y++)
            {
                for (int x = nStartX; x < nEndX; x++)
                {
                    // write local data
                    float fZ = _heightMap[x, y];

                    if (fZ < fMinZ)
                    {
                        fMinZ = fZ;
                    }
                    if (fZ > fMaxZ)
                    {
                        fMaxZ = fZ;
                    }

                    Vector2 texCoords1 = new Vector2(x / (float)(_heightMap.Width - 1), y / (float)(_heightMap.Height - 1));
                    Vector2 texCoords2 = texCoords1 * _detailTextureTiling;

                    vertices[index++] = new VertexPositionNormalTexture2(
                        new Vector3(x * _horizontalScale, fZ, y * _horizontalScale),
                        new Vector3(0, 1, 0),
                        texCoords1,
                        texCoords2);
                }
            }

            localVertexBuffer.Write(0, VertexBufferContent.SizeOf(typeof(VertexPositionNormalTexture2)), vertices);
            localVertexBuffer.VertexDeclaration = new VertexDeclarationContent();
            foreach (VertexElement vertexElement in VertexPositionNormalTexture2.VertexDeclaration.GetVertexElements())
            {
                localVertexBuffer.VertexDeclaration.VertexElements.Add(vertexElement);
            }

            #endregion

            LevelContent[] levels = new LevelContent[_numLevels];
            for (int i = 0; i < _numLevels; i++)
            {
                LevelContentBuilder levelContentBuilder = new LevelContentBuilder(_heightMap, _patchSize, _numLevels, i, nStartX,
                                                                                  nEndX, nStartY, nEndY);
                levels[i] = levelContentBuilder.Build();
            }

            #region Bounding box, centre, and offset

            BoundingBox boundingBox = new BoundingBox(
                new Vector3(nStartX * _horizontalScale, fMinZ, nStartY * _horizontalScale),
                new Vector3(nEndX * _horizontalScale, fMaxZ, nEndY * _horizontalScale));

            float fAverageZ = (fMinZ + fMaxZ) / 2.0f;

            Vector3 center = new Vector3(
                (nStartX + ((_patchSize - 1) / 2.0f)) * _horizontalScale,
                fAverageZ,
                (nStartY + ((_patchSize - 1) / 2.0f)) * _horizontalScale);

            Vector2 offset = new Vector2(
                (_patchOffsetX * (_patchSize - 1)) * _horizontalScale,
                (_patchOffsetY * (_patchSize - 1)) * _horizontalScale);

            #endregion

            return(new PatchContent
            {
                VertexBuffer = localVertexBuffer,
                Levels = levels,
                BoundingBox = boundingBox,
                Center = center,
                Offset = offset
            });
        }
Beispiel #29
0
 /**
  * addSection
  * adds a node to the branch
  * @param name="ls"
  **/
 public void addSection(LevelContent ls)
 {
     _sections.Add(ls);
 }