Esempio n. 1
0
        /// <summary>
        /// Creates a new region with a default name.
        /// </summary>
        public void NewMapRegion()
        {
            _currentRegion = new MapRegion();
            SetLowerStory();

            DisplayMap?.Invoke(this, null);
        }
Esempio n. 2
0
    public void generateMap()
    {
        float[,] generatedMap = Noise.GenerateNoiseMap(mapChunkSize, mapChunkSize, noiseScale, Octaves, Persistance, Lacunarity, Seed, Offset);

        Color[] colorMap = new Color[mapChunkSize * mapChunkSize];
        for (int y = 0; y < mapChunkSize; y++)
        {
            for (int x = 0; x < mapChunkSize; x++)
            {
                float currentheight = generatedMap[x, y];
                for (int i = 0; i < Regiens.Length; i++)
                {
                    if (currentheight <= Regiens[i].Height)
                    {
                        colorMap[y * mapChunkSize + x] = Regiens[i].color;
                        break;
                    }
                }
            }
        }
        DisplayMap display = FindObjectOfType <DisplayMap>();

        if (drawMode == DrawMode.NoiseMap)
        {
            display.DrawTexture(Texturegenerator.TextureFromHeightMap(generatedMap));
        }
        else if (drawMode == DrawMode.ColorMap)
        {
            display.DrawTexture(Texturegenerator.TexturefromColorMap(colorMap, mapChunkSize, mapChunkSize));
        }
        else if (drawMode == DrawMode.Mesh)
        {
            display.DrawMesh(MeshGenerator.GenerateTerrainMesh(generatedMap, meshHeightMultiplier, meshHightCurve, levelOfDetail), Texturegenerator.TexturefromColorMap(colorMap, mapChunkSize, mapChunkSize));
        }
    }
 public void Run()
 {
     float[] edge      = new float[3];
     float[] centerSph = new float[3];
     GetChunks();
     for (int i = 0; i < chunkHolder.Length; i++)
     {
         chunkHolder[i].chunk.SetPosition(size);
         SetBounds(i, ref edge, ref centerSph);
         MapData    mapData = GenerateMapData(chunkHolder[i].position);
         DisplayMap display = FindObjectOfType <DisplayMap>();
         if (mode is Mode.marchingMesh)
         {
             //only for first chunk
             display.DrawMesh(MeshGen.GenerateTerrainMesh(mapData.heightMap, genocideValue, size));
             break;
         }
         else if (mode is Mode.compute)
         {
             display.DrawMesh(MeshGen.GenerateTerrainMesh(mapData.heightMapCompute, genocideValue, size, marchCubes, edge, applySandpaper),
                              chunkHolder[i].chunk, size);
         }
         else if (mode is Mode.radius)
         {
             display.DrawMesh(MeshGen.GenerateTerrainMesh(mapData.heightMapCompute, genocideValue, size, radius, marchCubes, centerSph, applySandpaper),
                              chunkHolder[i].chunk, size);
         }
     }
 }
Esempio n. 4
0
 private static void AllPopUpBoxes(DisplayMap displayMap, out Button warpButton, out Button returnFromSell, out Button returnFromBuy, out Button returnFromStory, out Button returnFromRetire, out Button returnFromQuit, out DisplayMainStatus warpSpeedBox, out DisplayMainStatus buyBox, out DisplayMainStatus sellBox, out DisplayMainStatus storyBox, out DisplayMainStatus retireBox, out DisplayMainStatus quitBox)
 {
     WarpSpeedPopBox(displayMap, out warpButton, out warpSpeedBox);
     BuyPopUpBox(displayMap, out returnFromBuy, out buyBox);
     SellPopUpBox(displayMap, out returnFromSell, out sellBox);
     StoryPopUpBox(displayMap, out returnFromStory, out storyBox);
     RetirePopUpBox(displayMap, out returnFromRetire, out retireBox);
     QuitPopUpBox(displayMap, out returnFromQuit, out quitBox);
 }
Esempio n. 5
0
 private static void PutPlanetsOnMap(List <Planet> planets, DisplayMap displayMap)
 {
     foreach (var planet in planets)
     {
         new Label(displayMap)
         {
             Text = "██ - " + planet.name, Top = planet.location.y, Left = planet.location.x
         };
     }
 }
Esempio n. 6
0
    public void generateTreasure()
    {
        do
        {
            yTRand = rand.Next(18 - 5 + 1) + 5;
            xTRand = rand.Next(18 - 5 + 1) + 5;
        } while (!DisplayMap.isMapFloor(xTRand, yTRand));

        setTreasure(xTRand, yTRand);
    }
Esempio n. 7
0
    public void generateEnemy()
    {
        do
        {
            yRand = rand.Next(18 - 5 + 1) + 5;
            xRand = rand.Next(18 - 5 + 1) + 5;
        } while (!DisplayMap.isMapFloor(xRand, yRand));

        setEnemy(xRand, yRand);
    }
Esempio n. 8
0
 private static void RetirePopUpBox(DisplayMap displayMap, out Button returnFromRetire, out DisplayMainStatus retireBox)
 {
     retireBox = new DisplayMainStatus(displayMap)
     {
         Text = "Retire", Width = 75, Height = 26, Top = 6, Left = 20, Border = BorderStyle.Thick, Visible = false
     };
     returnFromRetire = new Button(retireBox)
     {
         Text = "Exit", Width = 10, Height = 3, Top = 10, Left = 4, Visible = true
     };
 }
Esempio n. 9
0
    public void InitalizeStage()
    {
        DisplayMap.CompressBounds();
        Bounds bounds = Instance.DisplayMap.localBounds;

        stageBounds = bounds;
        InputManager.Instance.SetCameraBounds();
        WorldCanvas.GetComponent <Canvas>().worldCamera = Camera.main;
        HighlightMap.gameObject.SetActive(false);
        BattleManager.Initialize();
    }
Esempio n. 10
0
 private static void BuyPopUpBox(DisplayMap displayMap, out Button returnFromBuy, out DisplayMainStatus buyBox)
 {
     buyBox = new DisplayMainStatus(displayMap)
     {
         Text = "Buy", Width = 75, Height = 26, Top = 6, Left = 20, Border = BorderStyle.Thick, Visible = false
     };
     returnFromBuy = new Button(buyBox)
     {
         Text = "Exit", Width = 10, Height = 3, Top = 10, Left = 4, Visible = true
     };
 }
Esempio n. 11
0
 private static void WarpSpeedPopBox(DisplayMap displayMap, out Button warpButton, out DisplayMainStatus warpSpeedBox)
 {
     warpSpeedBox = new DisplayMainStatus(displayMap)
     {
         Text = "Warp Speed", Width = 75, Height = 26, Top = 6, Left = 20, Border = BorderStyle.Thick, Visible = false
     };
     warpButton = new Button(warpSpeedBox)
     {
         Text = "Travel", Width = 10, Height = 3, Top = 1, Left = 4, Visible = true
     };
 }
Esempio n. 12
0
        private static DisplayMap MapBoxInitialize(RootWindow root, List <Planet> planets)
        {
            var displayMap = new DisplayMap(root)
            {
                Text = "MAP", Width = 98, Height = 35, Top = 2, Left = 2, Border = BorderStyle.Thin
            };

            CreateStarField(displayMap);
            PutPlanetsOnMap(planets, displayMap);
            return(displayMap);
        }
Esempio n. 13
0
 private static void SellPopUpBox(DisplayMap displayMap, out Button returnFromSell, out DisplayMainStatus sellBox)
 {
     sellBox = new DisplayMainStatus(displayMap)
     {
         Text = "Sell", Width = 75, Height = 26, Top = 6, Left = 20, Border = BorderStyle.Thick, Visible = false
     };
     returnFromSell = new Button(sellBox)
     {
         Text = "Exit", Width = 10, Height = 3, Top = 10, Left = 4, Visible = true
     };
 }
Esempio n. 14
0
 private static void QuitPopUpBox(DisplayMap displayMap, out Button returnFromQuit, out DisplayMainStatus quitBox)
 {
     quitBox = new DisplayMainStatus(displayMap)
     {
         Text = "Quit", Width = 75, Height = 26, Top = 6, Left = 20, Border = BorderStyle.Thick, Visible = false
     };
     returnFromQuit = new Button(quitBox)
     {
         Text = "Exit", Width = 10, Height = 3, Top = 10, Left = 4, Visible = true
     };
 }
Esempio n. 15
0
        public static string GetSVG(DisplayMap map)
        {
            var s = new StringBuilder(GetHeaderBlock());
            var i = 0;

            foreach (var cell in map.Cells)
            {
                s.Append(GetCell(cell, i));
                i++;
            }
            s.Append(GetClosingBlock());
            return(s.ToString());
        }
Esempio n. 16
0
    // Update is called once per frame
    void Update()
    {
        if (Enemy.count <= 0 && isGameFinish == false)
        {
            //Debug.Log("Count = 0 " + Enemy.count);
            int temp = (ms.getChoosenMap() == 1) ? 0 : ms.getChoosenMap();
            Debug.Log("Temp: " + temp);
            ms.setChoosenMap(temp);
            TxtController.getInstance().updateText();
            timer        = Time.time;
            isGameFinish = true;
            //Debug.Log(timer);
        }

        if (PlayerCode.isDeath == true && isGameFinish == false)
        {
            //Debug.Log("Count = 0 " + Enemy.count);
            int temp = (ms.getChoosenMap() == 1) ? 0 : ms.getChoosenMap();
            Debug.Log("Temp: " + temp);
            ms.setChoosenMap(temp);
            TxtController.getInstance().updateText();
            timer        = Time.time;
            isGameFinish = true;
            //Debug.Log(timer);
        }

        if (isGameFinish)
        {
            lastTimer = Time.time;

            blackScreen.GetComponent <Image>().enabled = true;

            status.SetActive(true);

            UnityEngine.UI.Text textStatus = status.GetComponent <UnityEngine.UI.Text>();
            textStatus.text = Enemy.count <= 0 ? "You Win" : "You Lose";
            //Debug.Log("Last Timer : " + lastTimer + "timer : " + timer);
            //Debug.Log(lastTimer - timer);
        }

        if ((lastTimer - timer) >= 3f && isGameFinish == true)
        {
            DisplayMap.removeEnemy(DisplayMap.xRand, DisplayMap.yRand);
            ms.setToPlay(false);
            SceneManager.LoadScene("MenuScene");
        }
    }
Esempio n. 17
0
        private static void CreateStarField(DisplayMap displayMap)
        {
            var randomX     = new Random();
            var randomY     = new Random();
            var randomColor = new Random();

            for (int i = 0; i < 300; i++)
            {
                int          x         = randomX.Next(0, 98);
                int          y         = randomY.Next(0, 35);
                ConsoleColor starColor = (ConsoleColor)randomColor.Next(0, 15);
                new Label(displayMap)
                {
                    Text = ".", Top = y, Left = x, Foreground = starColor
                };
            }
        }
    public void DrawMapInEditor()
    {
        MapData _mapData = GenerateMapData(Vector2.zero);

        DisplayMap _display = FindObjectOfType <DisplayMap>();

        if (drawMode == DrawMode.NoiseMap)
        {
            _display.DrawTexture(TextureGenerator.Instance.TextureFromHeightMap(_mapData.noiseMap));
        }
        else if (drawMode == DrawMode.ColorMap)
        {
            _display.DrawTexture(TextureGenerator.Instance.TextureFromColourMap(_mapData.colorMap, MAPCHUNKSIZE, MAPCHUNKSIZE));
        }
        else if (drawMode == DrawMode.Mesh)
        {
            _display.DrawMesh(MeshGenerator.Instance.GenerateTerrainMesh(_mapData.noiseMap, meshNoiseMultiplier, meshNoiseCurve, meshSemplification), TextureGenerator.Instance.TextureFromColourMap(_mapData.colorMap, MAPCHUNKSIZE, MAPCHUNKSIZE));
        }
    }
Esempio n. 19
0
    public void GenerateTerrain()
    {
        meshHeightMultiplier = terrainGeneratorUI.heightMultiplierSlider.value;

        noiseMapGenerator = new NoiseMapGenerator();
        displayMap        = FindObjectOfType <DisplayMap>();
        textureGenerator  = new TextureGenerator();
        meshGenerator     = new MeshGenerator();

        noiseMap = noiseMapGenerator.GenerateNoiseMap(mapWidth, mapHeight, noiseScale, octaves, persistance, lacunarity, seed, offset, animate, dropdownValue);

        Color[] colorMap = new Color[mapWidth * mapHeight];
        for (int y = 0; y < mapHeight; y++)
        {
            for (int x = 0; x < mapWidth; x++)
            {
                float currHeight = noiseMap[x, y];
                for (int i = 0; i < regions.Length; i++)
                {
                    if (currHeight <= regions[i].height)
                    {
                        colorMap[y * mapWidth + x] = regions[i].color;
                        break;
                    }
                }
            }
        }

        if (drawMode == DrawMode.NoiseMap)
        {
            displayMap.DrawTexture(textureGenerator.TextureFromNoiseMap(noiseMap));
        }
        else if (drawMode == DrawMode.ColorMap)
        {
            displayMap.DrawTexture(textureGenerator.TextureFromColorMap(colorMap, mapWidth, mapHeight));
        }
        else if (drawMode == DrawMode.Mesh)
        {
            displayMap.DrawMesh(meshGenerator.GenerateTerrainMesh(noiseMap, meshHeightMultiplier, heightCurve), textureGenerator.TextureFromColorMap(colorMap, mapWidth, mapHeight));
        }
    }
    public void DrawMapInEditor()
    {
        MapData mapData = GenerateMapData(Vector2.zero);

        DisplayMap display = FindObjectOfType <DisplayMap>();

        if (drawMode == DrawMode.NoiseMap)
        {
            display.DrawTexture(TextureGenerator.TextureFromHeightMap(mapData.heightMap));
        }
        else if (drawMode == DrawMode.ColorMap)
        {
            display.DrawTexture(TextureGenerator.TextureFromColourMap(mapData.colorMap, mapChunkSize, mapChunkSize));
        }
        else if (drawMode == DrawMode.Mesh)
        {
            display.DrawMesh(MeshGenerator.GenerateTerrainMesh(mapData.heightMap, meshHeightMultiplier, meshHeightCurve, editorPreviewLOD, useFlatShading), TextureGenerator.TextureFromColourMap(mapData.colorMap, mapChunkSize, mapChunkSize));
        }
        else if (drawMode == DrawMode.FalloffMap)
        {
            display.DrawTexture(TextureGenerator.TextureFromHeightMap(IslandGenerator.GenerateIslandEffect(mapChunkSize)));
        }
    }
Esempio n. 21
0
        /// <summary>
        /// Attempts to render the map and save the progress
        /// </summary>
        /// <param name="img"></param>
        /// <param name="zoom"></param>
        /// <param name="errorList"></param>
        public bool TryRenderMapAndSave(WzImage img, double zoom, ref List <string> errorList)
        {
            string mapIdName = img.Name.Substring(0, img.Name.Length - 4);

            node = MainPanel.DataTree.SelectedNode;
            WzFile wzFile = ((WzObject)node.Tag).WzFileParent;

            // Spawnpoint foothold and portal lists
            List <SpawnPoint.Spawnpoint> MSPs = new List <SpawnPoint.Spawnpoint>();
            List <FootHold.Foothold>     FHs  = new List <FootHold.Foothold>();
            List <Portals.Portal>        Ps   = new List <Portals.Portal>();
            Size  bmpSize;
            Point center;

            WzSubProperty miniMapSubProperty = ((WzSubProperty)img["miniMap"]);

            try
            {
                bmpSize = new Size(((WzIntProperty)miniMapSubProperty["width"]).Value, ((WzIntProperty)miniMapSubProperty["height"]).Value);
                center  = new Point(((WzIntProperty)miniMapSubProperty["centerX"]).Value, ((WzIntProperty)miniMapSubProperty["centerY"]).Value);
            }
            catch (Exception exp)
            {
                if (exp is KeyNotFoundException || exp is NullReferenceException)
                {
                    try
                    {
                        WzSubProperty infoSubProperty = ((WzSubProperty)img["info"]);

                        bmpSize = new Size(((WzIntProperty)infoSubProperty["VRRight"]).Value - ((WzIntProperty)infoSubProperty["VRLeft"]).Value, ((WzIntProperty)infoSubProperty["VRBottom"]).Value - ((WzIntProperty)infoSubProperty["VRTop"]).Value);
                        center  = new Point(((WzIntProperty)infoSubProperty["VRRight"]).Value, ((WzIntProperty)infoSubProperty["VRBottom"]).Value);
                    }
                    catch
                    {
                        errorList.Add("Missing map info WzSubProperty. Path: " + mapIdName + ".img/info/VRRight; VRLeft; VRBottom; VRTop\r\n OR info/miniMap/width ; height; centerX; centerY");
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }

            // Render minimap
            Bitmap minimapRender = RenderMinimap(bmpSize, wzFile, img, mapIdName, miniMapSubProperty);

            // Render map
            Bitmap mapRender = new Bitmap(bmpSize.Width, bmpSize.Height);

            using (Graphics drawBuf = Graphics.FromImage(mapRender))
            {
                WzSubProperty ps = (WzSubProperty)img["portal"];
                foreach (WzSubProperty p in ps.WzProperties)
                {
                    //WzSubProperty p = (WzSubProperty)p10.ExtendedProperty;
                    int    x  = ((WzIntProperty)p["x"]).Value + center.X;
                    int    y  = ((WzIntProperty)p["y"]).Value + center.Y;
                    int    pt = ((WzIntProperty)p["pt"]).Value;
                    string pn = ((WzStringProperty)p["pn"]).ReadString(string.Empty);
                    int    tm = ((WzIntProperty)p["tm"]).ReadValue(999999999);

                    Color pColor = Color.Red;
                    if (pt == 0)
                    {
                        pColor = Color.Orange;
                    }
                    else if (pt == 2 || pt == 7)//Normal
                    {
                        pColor = Color.Blue;
                    }
                    else if (pt == 3)//Auto-enter
                    {
                        pColor = Color.Magenta;
                    }
                    else if (pt == 1 || pt == 8)
                    {
                        pColor = Color.BlueViolet;
                    }
                    else
                    {
                        pColor = Color.IndianRed;
                    }

                    // Draw portal preview image
                    bool drewPortalImg = false;
                    if (pn != string.Empty || pt == 2)
                    {
                        string           portalEditorImage  = wzFile.WzDirectory.Name + "/MapHelper.img/portal/editor/" + (pt == 2 ? "pv" : pn);
                        WzCanvasProperty portalEditorCanvas = (WzCanvasProperty)wzFile.GetObjectFromPath(portalEditorImage);
                        if (portalEditorCanvas != null)
                        {
                            drewPortalImg = true;

                            PointF canvasOriginPosition = portalEditorCanvas.GetCanvasVectorPosition();
                            drawBuf.DrawImage(portalEditorCanvas.GetLinkedWzCanvasBitmap(), x - canvasOriginPosition.X, y - canvasOriginPosition.Y);
                        }
                    }
                    if (!drewPortalImg)
                    {
                        drawBuf.FillRectangle(new SolidBrush(Color.FromArgb(95, pColor.R, pColor.G, pColor.B)), x - 20, y - 20, 40, 40);
                        drawBuf.DrawRectangle(new Pen(Color.Black, 1F), x - 20, y - 20, 40, 40);
                    }

                    // Draw portal name
                    drawBuf.DrawString("Portal: " + p.Name, FONT_DISPLAY_PORTAL_LFIE_FOOTHOLD, new SolidBrush(Color.Red), x - 8, y - 7.7F);

                    Portals.Portal portal = new Portals.Portal();
                    portal.Shape = new Rectangle(x - 20, y - 20, 40, 40);
                    portal.Data  = p;
                    Ps.Add(portal);
                }

                WzSubProperty SPs = (WzSubProperty)img["life"];
                foreach (WzSubProperty sp in SPs.WzProperties)
                {
                    Color MSPColor = Color.ForestGreen;

                    string type = ((WzStringProperty)sp["type"]).Value;
                    switch (type)
                    {
                    case "n":     // NPC
                    case "m":     // monster
                    {
                        bool isNPC  = type == "n";
                        int  lifeId = int.Parse(((WzStringProperty)sp["id"]).GetString());

                        int  x          = ((WzIntProperty)sp["x"]).Value + center.X;
                        int  y          = ((WzIntProperty)sp["y"]).Value + center.Y;
                        int  x_text     = x - 15;
                        int  y_text     = y - 15;
                        bool facingLeft = ((WzIntProperty)sp["f"]).ReadValue(0) == 0;         // This value is optional. If its not stated in the WZ, its assumed to be 0

                        SpawnPoint.Spawnpoint MSP = new SpawnPoint.Spawnpoint();
                        MSP.Shape = new Rectangle(x_text, y_text, 30, 30);
                        MSP.Data  = sp;
                        MSPs.Add(MSP);


                        // Render monster image
                        string lifeStrId = lifeId.ToString().PadLeft(7, '0');

                        string mobWzPath;
                        string mobLinkWzPath;
                        string mobNamePath;

                        if (!isNPC)
                        {
                            mobWzPath   = string.Format("Mob.wz/{0}.img/info/link", lifeStrId);
                            mobNamePath = string.Format("String.wz/Mob.img/{0}/name", lifeId);
                        }
                        else
                        {
                            mobWzPath   = string.Format("Npc.wz/{0}.img/info/link", lifeStrId);
                            mobNamePath = string.Format("String.wz/Npc.img/{0}/name", lifeId);
                        }

                        WzStringProperty linkInfo = (WzStringProperty)WzFile.GetObjectFromMultipleWzFilePath(mobWzPath, Program.WzMan.WzFileListReadOnly);
                        if (linkInfo != null)
                        {
                            lifeId    = int.Parse(linkInfo.GetString());
                            lifeStrId = lifeId.ToString().PadLeft(7, '0');
                        }

                        if (!isNPC)
                        {
                            mobLinkWzPath = string.Format("Mob.wz/{0}.img/stand/0", lifeStrId);
                        }
                        else
                        {
                            mobLinkWzPath = string.Format("Npc.wz/{0}.img/stand/0", lifeStrId);
                        }

                        WzCanvasProperty lifeImg = (WzCanvasProperty)WzFile.GetObjectFromMultipleWzFilePath(mobLinkWzPath, Program.WzMan.WzFileListReadOnly);
                        if (lifeImg != null)
                        {
                            PointF canvasOriginPosition = lifeImg.GetCanvasVectorPosition();
                            PointF renderXY             = new PointF(x - canvasOriginPosition.X, y - canvasOriginPosition.Y);

                            Bitmap renderMobbitmap = lifeImg.GetLinkedWzCanvasBitmap();

                            if (!facingLeft)
                            {
                                renderMobbitmap.RotateFlip(RotateFlipType.RotateNoneFlipX);
                            }

                            drawBuf.DrawImage(renderMobbitmap, renderXY);
                        }
                        else
                        {
                            //drawBuf.FillRectangle(new SolidBrush(Color.FromArgb(95, MSPColor.R, MSPColor.G, MSPColor.B)), x_text, y_text, 30, 30);
                            //drawBuf.DrawRectangle(new Pen(Color.Black, 1F), x_text, y_text, 30, 30);
                            errorList.Add("Missing monster/npc object. Path: " + mobWzPath + "\r\n" + mobLinkWzPath);
                        }

                        // Get monster name
                        WzStringProperty stringName = (WzStringProperty)WzFile.GetObjectFromMultipleWzFilePath(mobNamePath, Program.WzMan.WzFileListReadOnly);
                        if (stringName != null)
                        {
                            drawBuf.DrawString(string.Format("SP: {0}, Name: {1}, ID: {2}", sp.Name, stringName.GetString(), lifeId), FONT_DISPLAY_PORTAL_LFIE_FOOTHOLD, new SolidBrush(Color.Red), x_text + 7, y_text + 7.3F);
                        }
                        else
                        {
                            errorList.Add("Missing monster/npc string object. Path: " + mobNamePath);
                        }
                        break;
                    }

                    default:
                    {
                        break;
                    }
                    }
                }


                WzSubProperty fhs = (WzSubProperty)img["foothold"];
                foreach (WzImageProperty fhspl0 in fhs.WzProperties)
                {
                    foreach (WzImageProperty fhspl1 in fhspl0.WzProperties)
                    {
                        Color c = Color.FromArgb(95, Color.FromArgb(GetPseudoRandomColor(fhspl1.Name)));
                        foreach (WzSubProperty fh in fhspl1.WzProperties)
                        {
                            int x      = ((WzIntProperty)fh["x1"]).Value + center.X;
                            int y      = ((WzIntProperty)fh["y1"]).Value + center.Y;
                            int width  = ((((WzIntProperty)fh["x2"]).Value + center.X) - x);
                            int height = ((((WzIntProperty)fh["y2"]).Value + center.Y) - y);

                            if (width < 0)
                            {
                                x    += width;// *2;
                                width = -width;
                            }
                            if (height < 0)
                            {
                                y     += height;// *2;
                                height = -height;
                            }
                            if (width == 0 || width < 15)
                            {
                                width = 15;
                            }
                            height += 10;

                            FootHold.Foothold nFH = new FootHold.Foothold();
                            nFH.Shape = new Rectangle(x, y, width, height);
                            nFH.Data  = fh;
                            FHs.Add(nFH);

                            //drawBuf.FillRectangle(new SolidBrush(Color.FromArgb(95, Color.Gray.R, Color.Gray.G, Color.Gray.B)), x, y, width, height);
                            drawBuf.FillRectangle(new SolidBrush(c), x, y, width, height);
                            drawBuf.DrawRectangle(new Pen(Color.Black, 1F), x, y, width, height);
                            drawBuf.DrawString(fh.Name, FONT_DISPLAY_PORTAL_LFIE_FOOTHOLD, new SolidBrush(Color.Red), new PointF(x + (width / 2) - 8, y + (height / 2) - 7.7F));
                        }
                    }
                }
            }
            mapRender.Save("Renders\\" + mapIdName + "\\" + mapIdName + "_footholdRender.bmp");

            Bitmap backgroundRender = new Bitmap(bmpSize.Width, bmpSize.Height);

            using (Graphics tileBuf = Graphics.FromImage(backgroundRender))
            {
                WzSubProperty backImg = (WzSubProperty)img["back"];
                if (backImg != null)
                {
                    foreach (WzSubProperty bgItem in backImg.WzProperties)
                    {
                        string bS         = ((WzStringProperty)bgItem["bS"]).Value;
                        int    front      = ((WzIntProperty)bgItem["front"]).Value;
                        int    ani        = ((WzIntProperty)bgItem["ani"]).Value;
                        int    no         = ((WzIntProperty)bgItem["no"]).Value;
                        int    x          = ((WzIntProperty)bgItem["x"]).Value;
                        int    y          = ((WzIntProperty)bgItem["y"]).Value;
                        int    rx         = ((WzIntProperty)bgItem["rx"]).Value;
                        int    ry         = ((WzIntProperty)bgItem["ry"]).Value;
                        int    type       = ((WzIntProperty)bgItem["type"]).Value;
                        int    cx         = ((WzIntProperty)bgItem["cx"]).Value;
                        int    cy         = ((WzIntProperty)bgItem["cy"]).Value;
                        int    a          = ((WzIntProperty)bgItem["a"]).Value;
                        bool   facingLeft = ((WzIntProperty)bgItem["f"]).ReadValue(0) == 0;

                        if (bS == string.Empty)
                        {
                            continue;
                        }

                        string           bgObjImagePath = "Map.wz/Back/" + bS + ".img/Back/" + no;
                        WzCanvasProperty wzBgCanvas     = (WzCanvasProperty)WzFile.GetObjectFromMultipleWzFilePath(bgObjImagePath, Program.WzMan.WzFileListReadOnly);
                        if (wzBgCanvas != null)
                        {
                            PointF canvasOriginPosition = wzBgCanvas.GetCanvasVectorPosition();
                            PointF renderXY             = new PointF(x + canvasOriginPosition.X + center.X, y + canvasOriginPosition.X + center.Y);

                            Bitmap drawImage = wzBgCanvas.GetLinkedWzCanvasBitmap();

                            if (!facingLeft)
                            {
                                drawImage.RotateFlip(RotateFlipType.RotateNoneFlipX);
                            }

                            tileBuf.DrawImage(drawImage, renderXY);
                        }
                        else
                        {
                            errorList.Add("Missing Map BG object. Path: " + bgObjImagePath);
                        }
                    }
                }
            }
            backgroundRender.Save("Renders\\" + mapIdName + "\\" + mapIdName + "_backgroundRender.bmp");


            // Render tooltip
            WzSubProperty tooltipProperty = (WzSubProperty)img["ToolTip"];
            Bitmap        toolTip         = null;

            if (tooltipProperty != null)
            {
                toolTip = new Bitmap(bmpSize.Width, bmpSize.Height);
                using (Graphics toolTipBuf = Graphics.FromImage(toolTip))
                {
                    string        stringTooltipPath = "String.wz/ToolTipHelp.img/Mapobject/" + mapIdName;
                    WzSubProperty wzToolTip         = (WzSubProperty)WzFile.GetObjectFromMultipleWzFilePath(stringTooltipPath, Program.WzMan.WzFileListReadOnly);

                    if (wzToolTip == null)
                    {
                        errorList.Add("Map tooltip object is missing. Path: " + stringTooltipPath);
                    }

                    for (int i = 0; i < 99; i++) // starts from 0
                    {
                        WzSubProperty toolTipItem = (WzSubProperty)tooltipProperty[i.ToString()];
                        if (toolTipItem == null)
                        {
                            break;
                        }

                        int x1 = toolTipItem["x1"].ReadValue();
                        int x2 = toolTipItem["x2"].ReadValue();
                        int y1 = toolTipItem["y1"].ReadValue();
                        int y2 = toolTipItem["y2"].ReadValue();

                        // Check String.wz
                        WzSubProperty wzToolTipForI = (WzSubProperty)wzToolTip[i.ToString()];
                        if (wzToolTipForI == null)
                        {
                            errorList.Add("Map tooltip is missing. Path: " + stringTooltipPath + "/" + i);
                        }
                        string title = wzToolTipForI["Title"].ReadString(null);
                        string desc  = wzToolTipForI["Desc"].ReadString(null);

                        if (title == null)
                        {
                            errorList.Add("Map tooltip is missing. Path: " + stringTooltipPath + "/" + i + "/Title");
                        }
                        toolTipBuf.DrawString(string.Format("{0}\n{1}", title, desc == null ? string.Empty : desc), FONT_GAME_TOOLTIP, new SolidBrush(Color.Black), new PointF(x1 + center.X, y1 + center.Y));
                    }
                }
                toolTip.Save("Renders\\" + mapIdName + "\\" + mapIdName + "_tooltip.bmp");
            }

            // Render Tiles
            Bitmap tileRender = new Bitmap(bmpSize.Width, bmpSize.Height);

            using (Graphics tileBuf = Graphics.FromImage(tileRender))
            {
                for (int i = 0; i < 7; i++)
                {
                    // The below code was commented out because it was creating problems when loading certain maps. When debugging it would throw an exception at line 469.
                    // Objects first
                    WzSubProperty iProperty      = (WzSubProperty)img[i.ToString()];
                    WzSubProperty objProperties  = ((WzSubProperty)iProperty["obj"]);
                    WzSubProperty infoProperties = ((WzSubProperty)iProperty["info"]);
                    WzSubProperty tileProperties = ((WzSubProperty)iProperty["tile"]);

                    if (objProperties.WzProperties.Count > 0)
                    {
                        foreach (WzSubProperty obj in objProperties.WzProperties)
                        {
                            //WzSubProperty obj = (WzSubProperty)oe.ExtendedProperty;
                            string imgName = ((WzStringProperty)obj["oS"]).Value + ".img";
                            string l0      = ((WzStringProperty)obj["l0"]).Value;
                            string l1      = ((WzStringProperty)obj["l1"]).Value;
                            string l2      = ((WzStringProperty)obj["l2"]).Value;
                            int    x       = ((WzIntProperty)obj["x"]).Value + center.X;
                            int    y       = ((WzIntProperty)obj["y"]).Value + center.Y;

                            PointF           origin;
                            WzCanvasProperty png;

                            string imgObjPath = string.Format("{0}/Obj/{1}/{2}/{3}/{4}/0", wzFile.WzDirectory.Name, imgName, l0, l1, l2);

                            WzImageProperty objData = (WzImageProperty)WzFile.GetObjectFromMultipleWzFilePath(imgObjPath, Program.WzMan.WzFileListReadOnly);
tryagain:
                            if (objData is WzCanvasProperty)
                            {
                                png    = ((WzCanvasProperty)objData);
                                origin = ((WzCanvasProperty)objData).GetCanvasVectorPosition();
                            }
                            else if (objData is WzUOLProperty)
                            {
                                WzObject currProp = objData.Parent;
                                foreach (string directive in ((WzUOLProperty)objData).Value.Split("/".ToCharArray()))
                                {
                                    if (directive == "..")
                                    {
                                        currProp = currProp.Parent;
                                    }
                                    else
                                    {
                                        if (currProp.GetType() == typeof(WzSubProperty))
                                        {
                                            currProp = ((WzSubProperty)currProp)[directive];
                                        }
                                        else if (currProp.GetType() == typeof(WzCanvasProperty))
                                        {
                                            currProp = ((WzCanvasProperty)currProp)[directive];
                                        }
                                        else if (currProp.GetType() == typeof(WzImage))
                                        {
                                            currProp = ((WzImage)currProp)[directive];
                                        }
                                        else if (currProp.GetType() == typeof(WzConvexProperty))
                                        {
                                            currProp = ((WzConvexProperty)currProp)[directive];
                                        }
                                        else
                                        {
                                            errorList.Add("UOL error at map renderer");
                                            return(false);
                                        }
                                    }
                                }
                                objData = (WzImageProperty)currProp;
                                goto tryagain;
                            }
                            else
                            {
                                errorList.Add("Unknown Wz type at map renderer");
                                return(false);
                            }

                            //WzVectorProperty origin = (WzVectorProperty)wzFile.GetObjectFromPath(wzFile.WzDirectory.Name + "/Obj/" + imgName + "/" + l0 + "/" + l1 + "/" + l2 + "/0");
                            //WzPngProperty png = (WzPngProperty)wzFile.GetObjectFromPath(wzFile.WzDirectory.Name + "/Obj/" + imgName + "/" + l0 + "/" + l1 + "/" + l2 + "/0/PNG");
                            tileBuf.DrawImage(png.GetLinkedWzCanvasBitmap(), x - origin.X, y - origin.Y);
                        }
                    }
                    if (infoProperties.WzProperties.Count == 0)
                    {
                        continue;
                    }

                    if (tileProperties.WzProperties.Count == 0)
                    {
                        continue;
                    }

                    // Ok, we have some tiles and a tileset
                    string tileSetName = ((WzStringProperty)infoProperties["tS"]).Value;

                    // Browse to the tileset
                    string  tilePath = wzFile.WzDirectory.Name + "/Tile/" + tileSetName + ".img";
                    WzImage tileSet  = (WzImage)WzFile.GetObjectFromMultipleWzFilePath(tilePath, Program.WzMan.WzFileListReadOnly);
                    if (!tileSet.Parsed)
                    {
                        tileSet.ParseImage();
                    }

                    foreach (WzSubProperty tile in tileProperties.WzProperties)
                    {
                        //WzSubProperty tile = (WzSubProperty)te.ExtendedProperty;

                        int    x            = ((WzIntProperty)tile["x"]).Value + center.X;
                        int    y            = ((WzIntProperty)tile["y"]).Value + center.Y;
                        string tilePackName = ((WzStringProperty)tile["u"]).Value;
                        string tileID       = ((WzIntProperty)tile["no"]).Value.ToString();

                        WzSubProperty    tilePack   = ((WzSubProperty)tileSet[tilePackName]);
                        WzCanvasProperty tileCanvas = (WzCanvasProperty)tilePack[tileID];
                        if (tileCanvas == null)
                        {
                            errorList.Add(string.Format("Tile {0}, ID: {1} is not found.", tilePackName, tileID));
                        }
                        PointF tileVector = tileCanvas.GetCanvasVectorPosition();
                        tileBuf.DrawImage(tileCanvas.GetBitmap(), x - tileVector.X, y - tileVector.Y);
                    }
                }
            }
            tileRender.Save("Renders\\" + mapIdName + "\\" + mapIdName + "_tileRender.bmp");

            // Render nodeInfo
            Bitmap        nodeInfoRender   = null;
            WzSubProperty nodeInfoProperty = (WzSubProperty)img["nodeInfo"];

            if (nodeInfoProperty != null)
            {
                nodeInfoRender = new Bitmap(bmpSize.Width, bmpSize.Height);
                using (Graphics nodeInfoBuffer = Graphics.FromImage(nodeInfoRender))
                {
                    int start = 0;
                    int end   = 0;

                    foreach (WzImageProperty nodeInfoImg in nodeInfoProperty.WzProperties)
                    {
                        switch (nodeInfoImg.Name)
                        {
                        case "edgeInfo":
                        {
                            break;
                        }

                        case "end":
                        {
                            end = ((WzIntProperty)nodeInfoImg).ReadValue();
                            break;
                        }

                        case "start":
                        {
                            start = ((WzIntProperty)nodeInfoImg).ReadValue();
                            break;
                        }

                        default:
                        {
                            int nodeInfoImgFileName = -1;
                            if (int.TryParse(nodeInfoImg.Name, out nodeInfoImgFileName))
                            {
                                int attr = ((WzIntProperty)nodeInfoImg["attr"]).ReadValue();
                                int key  = ((WzIntProperty)nodeInfoImg["key"]).ReadValue();
                                int x    = ((WzIntProperty)nodeInfoImg["x"]).ReadValue() + center.X;
                                int y    = ((WzIntProperty)nodeInfoImg["y"]).ReadValue() + center.Y;

                                List <int> edges = new List <int>();
                                foreach (WzImageProperty edge in nodeInfoImg["edge"].WzProperties)
                                {
                                    edges.Add(edge.ReadValue());
                                }

                                const int width  = 200;
                                const int height = 20;

                                nodeInfoBuffer.FillRectangle(new SolidBrush(Color.Wheat), x, y, width, height);
                                nodeInfoBuffer.DrawRectangle(new Pen(Color.Black, 1F), x, y, width, height);
                                nodeInfoBuffer.DrawString(
                                    string.Format("Key: {0}, x: {1}, y: {1}", key, x, y),
                                    FONT_DISPLAY_PORTAL_LFIE_FOOTHOLD, new SolidBrush(Color.Black), new PointF(x + (width / 2) - 8, y + (height / 2) - 7.7F));
                            }
                            break;
                        }
                        }
                    }
                }
                nodeInfoRender.Save("Renders\\" + mapIdName + "\\" + mapIdName + "_nodeInfoRender.bmp");
            }


            // Render everything combined
            Bitmap fullBmp = new Bitmap(bmpSize.Width, bmpSize.Height + 10);

            using (Graphics fullBuf = Graphics.FromImage(fullBmp))
            {
                fullBuf.FillRectangle(new SolidBrush(Color.CornflowerBlue), 0, 0, bmpSize.Width, bmpSize.Height + 10);
                fullBuf.DrawImage(backgroundRender, 0, 0);
                fullBuf.DrawImage(tileRender, 0, 0);
                fullBuf.DrawImage(mapRender, 0, 0);
                if (toolTip != null)
                {
                    fullBuf.DrawImage(toolTip, 0, 0);
                }
                if (nodeInfoRender != null)
                {
                    fullBuf.DrawImage(nodeInfoRender, 0, 0);
                }
                fullBuf.DrawImage(minimapRender, 0, 0);
            }
            //pbx_Foothold_Render.Image = fullBmp;
            fullBmp.Save("Renders\\" + mapIdName + "\\" + mapIdName + "_fullRender.bmp");

            // Cleanup resources
            backgroundRender.Dispose();
            tileRender.Dispose();
            mapRender.Dispose();
            toolTip?.Dispose();
            minimapRender.Dispose();

            if (errorList.Count() > 0)
            {
                return(false);
            }

            // Display render map
            DisplayMap showMap = new DisplayMap();

            showMap.map            = fullBmp;
            showMap.Footholds      = FHs;
            showMap.thePortals     = Ps;
            showMap.settings       = settings;
            showMap.MobSpawnPoints = MSPs;
            showMap.FormClosed    += new FormClosedEventHandler(DisplayMapClosed);
            try
            {
                showMap.scale = zoom;
                showMap.Show();
                return(true);
            }
            catch (FormatException)
            {
                MessageBox.Show("You must set the render scale to a valid number.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }
        }
        public void SaveMap(WzImage img, double zoom)
        {
            node = MainPanel.DataTree.SelectedNode;
            WzFile wzFile = (WzFile)((WzObject)node.Tag).WzFileParent;
            // Spawnpoint foothold and portal lists
            List <SpawnPoint.Spawnpoint> MSPs = new List <SpawnPoint.Spawnpoint>();
            List <FootHold.Foothold>     FHs  = new List <FootHold.Foothold>();
            List <Portals.Portal>        Ps   = new List <Portals.Portal>();
            Size  bmpSize;
            Point center;

            try
            {
                bmpSize = new Size(((WzIntProperty)((WzSubProperty)img["miniMap"])["width"]).Value, ((WzIntProperty)((WzSubProperty)img["miniMap"])["height"]).Value);
                center  = new Point(((WzIntProperty)((WzSubProperty)img["miniMap"])["centerX"]).Value, ((WzIntProperty)((WzSubProperty)img["miniMap"])["centerY"]).Value);
            }
            catch (KeyNotFoundException)
            {
                try
                {
                    bmpSize = new Size(((WzIntProperty)((WzSubProperty)img["info"])["VRRight"]).Value - ((WzIntProperty)((WzSubProperty)img["info"])["VRLeft"]).Value, ((WzIntProperty)((WzSubProperty)img["info"])["VRBottom"]).Value - ((WzIntProperty)((WzSubProperty)img["info"])["VRTop"]).Value);
                    center  = new Point(((WzIntProperty)((WzSubProperty)img["info"])["VRRight"]).Value, ((WzIntProperty)((WzSubProperty)img["info"])["VRBottom"]).Value);
                    //center = new Point(0, 0);
                }
                catch
                {
                    return;
                }
            }
            catch
            {
                return;
            }
            Bitmap mapRender = new Bitmap(bmpSize.Width, bmpSize.Height + 10);

            using (Graphics drawBuf = Graphics.FromImage(mapRender))
            {
                //drawBuf.FillRectangle(new SolidBrush(Color.CornflowerBlue), 0, 0, bmpSize.Width, bmpSize.Height);
                drawBuf.DrawString("Map " + img.Name.Substring(0, img.Name.Length - 4), FONT_DISPLAY_MAPID, new SolidBrush(Color.Black), new PointF(10, 10));
                try
                {
                    drawBuf.DrawImage(((WzCanvasProperty)((WzSubProperty)img["miniMap"])["canvas"]).PngProperty.GetPNG(false), 10, 45);
                }
                catch (KeyNotFoundException)
                {
                    drawBuf.DrawString("Minimap not availible", FONT_DISPLAY_MINIMAP_NOT_AVAILABLE, new SolidBrush(Color.Black), new PointF(10, 45));
                }
                WzSubProperty ps = (WzSubProperty)img["portal"];
                foreach (WzSubProperty p in ps.WzProperties)
                {
                    //WzSubProperty p = (WzSubProperty)p10.ExtendedProperty;
                    int   x      = ((WzIntProperty)p["x"]).Value + center.X;
                    int   y      = ((WzIntProperty)p["y"]).Value + center.Y;
                    int   type   = ((WzIntProperty)p["pt"]).Value;
                    Color pColor = Color.Red;
                    if (type == 0)
                    {
                        pColor = Color.Orange;
                    }
                    else if (type == 2 || type == 7)//Normal
                    {
                        pColor = Color.Blue;
                    }
                    else if (type == 3)//Auto-enter
                    {
                        pColor = Color.Magenta;
                    }
                    else if (type == 1 || type == 8)
                    {
                        pColor = Color.BlueViolet;
                    }
                    else
                    {
                        pColor = Color.IndianRed;
                    }
                    drawBuf.FillRectangle(new SolidBrush(Color.FromArgb(95, pColor.R, pColor.G, pColor.B)), x - 20, y - 20, 40, 40);
                    drawBuf.DrawRectangle(new Pen(Color.Black, 1F), x - 20, y - 20, 40, 40);
                    drawBuf.DrawString(p.Name, FONT_DISPLAY_PORTAL_LFIE_FOOTHOLD, new SolidBrush(Color.Red), x - 8, y - 7.7F);
                    Portals.Portal portal = new Portals.Portal();
                    portal.Shape = new Rectangle(x - 20, y - 20, 40, 40);
                    portal.Data  = p;
                    Ps.Add(portal);
                }
                try
                {
                    WzSubProperty SPs = (WzSubProperty)img["life"];
                    foreach (WzSubProperty sp in SPs.WzProperties)
                    {
                        Color MSPColor = Color.ForestGreen;
                        if (((WzStringProperty)sp["type"]).Value == "m")// Only mobs (NPC = "n")
                        {
                            int x = ((WzIntProperty)sp["x"]).Value + center.X - 15;
                            int y = ((WzIntProperty)sp["y"]).Value + center.Y - 15;
                            drawBuf.FillRectangle(new SolidBrush(Color.FromArgb(95, MSPColor.R, MSPColor.G, MSPColor.B)), x, y, 30, 30);
                            drawBuf.DrawRectangle(new Pen(Color.Black, 1F), x, y, 30, 30);
                            drawBuf.DrawString(sp.Name, FONT_DISPLAY_PORTAL_LFIE_FOOTHOLD, new SolidBrush(Color.Red), x + 7, y + 7.3F);
                            SpawnPoint.Spawnpoint MSP = new SpawnPoint.Spawnpoint();
                            MSP.Shape = new Rectangle(x, y, 30, 30);
                            MSP.Data  = sp;
                            MSPs.Add(MSP);
                        }
                    }
                }
                catch
                {
                }
                WzSubProperty fhs = (WzSubProperty)img["foothold"];
                foreach (WzImageProperty fhspl0 in fhs.WzProperties)
                {
                    foreach (WzImageProperty fhspl1 in fhspl0.WzProperties)
                    {
                        Color c = Color.FromArgb(95, Color.FromArgb(GetPseudoRandomColor(fhspl1.Name)));
                        foreach (WzSubProperty fh in fhspl1.WzProperties)
                        {
                            int x      = ((WzIntProperty)fh["x1"]).Value + center.X;
                            int y      = ((WzIntProperty)fh["y1"]).Value + center.Y;
                            int width  = ((((WzIntProperty)fh["x2"]).Value + center.X) - x);
                            int height = ((((WzIntProperty)fh["y2"]).Value + center.Y) - y);
                            if (width < 0)
                            {
                                x    += width;// *2;
                                width = -width;
                            }
                            if (height < 0)
                            {
                                y     += height;// *2;
                                height = -height;
                            }
                            if (width == 0 || width < 15)
                            {
                                width = 15;
                            }
                            height += 10;
                            FootHold.Foothold nFH = new FootHold.Foothold();
                            nFH.Shape = new Rectangle(x, y, width, height);
                            nFH.Data  = fh;
                            FHs.Add(nFH);
                            //drawBuf.FillRectangle(new SolidBrush(Color.FromArgb(95, Color.Gray.R, Color.Gray.G, Color.Gray.B)), x, y, width, height);
                            drawBuf.FillRectangle(new SolidBrush(c), x, y, width, height);
                            drawBuf.DrawRectangle(new Pen(Color.Black, 1F), x, y, width, height);
                            drawBuf.DrawString(fh.Name, FONT_DISPLAY_PORTAL_LFIE_FOOTHOLD, new SolidBrush(Color.Red), new PointF(x + (width / 2) - 8, y + (height / 2) - 7.7F));
                        }
                    }
                }
            }

            mapRender.Save("Renders\\" + img.Name.Substring(0, img.Name.Length - 4) + "\\" + img.Name.Substring(0, img.Name.Length - 4) + "_footholdRender.bmp");

            Bitmap tileRender = new Bitmap(bmpSize.Width, bmpSize.Height);

            using (Graphics tileBuf = Graphics.FromImage(tileRender))
            {
                for (int i = 0; i < 7; i++)
                {
                    // The below code was commented out because it was creating problems when loading certain maps. When debugging it would throw an exception at line 469.
                    // Objects first
                    if (((WzSubProperty)((WzSubProperty)img[i.ToString()])["obj"]).WzProperties.Count > 0)
                    {
                        foreach (WzSubProperty obj in ((WzSubProperty)((WzSubProperty)img[i.ToString()])["obj"]).WzProperties)
                        {
                            //WzSubProperty obj = (WzSubProperty)oe.ExtendedProperty;
                            string           imgName = ((WzStringProperty)obj["oS"]).Value + ".img";
                            string           l0      = ((WzStringProperty)obj["l0"]).Value;
                            string           l1      = ((WzStringProperty)obj["l1"]).Value;
                            string           l2      = ((WzStringProperty)obj["l2"]).Value;
                            int              x       = ((WzIntProperty)obj["x"]).Value + center.X;
                            int              y       = ((WzIntProperty)obj["y"]).Value + center.Y;
                            WzVectorProperty origin;
                            WzPngProperty    png;
                            WzImageProperty  objData = (WzImageProperty)wzFile.GetObjectFromPath(wzFile.WzDirectory.Name + "/Obj/" + imgName + "/" + l0 + "/" + l1 + "/" + l2 + "/0");
tryagain:
                            if (objData is WzCanvasProperty)
                            {
                                png    = ((WzCanvasProperty)objData).PngProperty;
                                origin = (WzVectorProperty)((WzCanvasProperty)objData)["origin"];
                            }
                            else if (objData is WzUOLProperty)
                            {
                                WzObject currProp = objData.Parent;
                                foreach (string directive in ((WzUOLProperty)objData).Value.Split("/".ToCharArray()))
                                {
                                    if (directive == "..")
                                    {
                                        currProp = currProp.Parent;
                                    }
                                    else
                                    {
                                        switch (currProp.GetType().Name)
                                        {
                                        case "WzSubProperty":
                                            currProp = ((WzSubProperty)currProp)[directive];
                                            break;

                                        case "WzCanvasProperty":
                                            currProp = ((WzCanvasProperty)currProp)[directive];
                                            break;

                                        case "WzImage":
                                            currProp = ((WzImage)currProp)[directive];
                                            break;

                                        case "WzConvexProperty":
                                            currProp = ((WzConvexProperty)currProp)[directive];
                                            break;

                                        default:
                                            throw new Exception("UOL error at map renderer");
                                        }
                                    }
                                }
                                objData = (WzImageProperty)currProp;
                                goto tryagain;
                            }
                            else
                            {
                                throw new Exception("unknown type at map renderer");
                            }
                            //WzVectorProperty origin = (WzVectorProperty)wzFile.GetObjectFromPath(wzFile.WzDirectory.Name + "/Obj/" + imgName + "/" + l0 + "/" + l1 + "/" + l2 + "/0");
                            //WzPngProperty png = (WzPngProperty)wzFile.GetObjectFromPath(wzFile.WzDirectory.Name + "/Obj/" + imgName + "/" + l0 + "/" + l1 + "/" + l2 + "/0/PNG");
                            tileBuf.DrawImage(png.GetPNG(false), x - origin.X.Value, y - origin.Y.Value);
                        }
                    }
                    if (((WzSubProperty)((WzSubProperty)img[i.ToString()])["info"]).WzProperties.Count == 0)
                    {
                        continue;
                    }

                    if (((WzSubProperty)((WzSubProperty)img[i.ToString()])["tile"]).WzProperties.Count == 0)
                    {
                        continue;
                    }

                    // Ok, we have some tiles and a tileset

                    string tileSetName = ((WzStringProperty)((WzSubProperty)((WzSubProperty)img[i.ToString()])["info"])["tS"]).Value;

                    // Browse to the tileset

                    WzImage tileSet = (WzImage)wzFile.GetObjectFromPath(wzFile.WzDirectory.Name + "/Tile/" + tileSetName + ".img");
                    if (!tileSet.Parsed)
                    {
                        tileSet.ParseImage();
                    }

                    foreach (WzSubProperty tile in ((WzSubProperty)((WzSubProperty)img[i.ToString()])["tile"]).WzProperties)
                    {
                        //WzSubProperty tile = (WzSubProperty)te.ExtendedProperty;

                        int x = ((WzIntProperty)tile["x"]).Value + center.X;

                        int y = ((WzIntProperty)tile["y"]).Value + center.Y;

                        string tilePackName = ((WzStringProperty)tile["u"]).Value;

                        string tileID = ((WzIntProperty)tile["no"]).Value.ToString();

                        Point origin = new Point(((WzVectorProperty)((WzCanvasProperty)((WzSubProperty)tileSet[tilePackName])[tileID])["origin"]).X.Value, ((WzVectorProperty)((WzCanvasProperty)((WzSubProperty)tileSet[tilePackName])[tileID])["origin"]).Y.Value);

                        tileBuf.DrawImage(((WzCanvasProperty)((WzSubProperty)tileSet[tilePackName])[tileID]).PngProperty.GetPNG(false), x - origin.X, y - origin.Y);
                    }
                }
            }

            tileRender.Save("Renders\\" + img.Name.Substring(0, img.Name.Length - 4) + "\\" + img.Name.Substring(0, img.Name.Length - 4) + "_tileRender.bmp");

            Bitmap fullBmp = new Bitmap(bmpSize.Width, bmpSize.Height + 10);

            using (Graphics fullBuf = Graphics.FromImage(fullBmp))
            {
                fullBuf.FillRectangle(new SolidBrush(Color.CornflowerBlue), 0, 0, bmpSize.Width, bmpSize.Height + 10);

                fullBuf.DrawImage(tileRender, 0, 0);

                fullBuf.DrawImage(mapRender, 0, 0);
            }
            //pbx_Foothold_Render.Image = fullBmp;
            fullBmp.Save("Renders\\" + img.Name.Substring(0, img.Name.Length - 4) + "\\" + img.Name.Substring(0, img.Name.Length - 4) + "_fullRender.bmp");

            DisplayMap showMap = new DisplayMap();

            showMap.map            = fullBmp;
            showMap.Footholds      = FHs;
            showMap.thePortals     = Ps;
            showMap.settings       = settings;
            showMap.MobSpawnPoints = MSPs;
            showMap.FormClosed    += new FormClosedEventHandler(DisplayMapClosed);
            try
            {
                showMap.scale = zoom;
                showMap.Show();
            }
            catch (FormatException)
            {
                MessageBox.Show("You must set the render scale to a valid number.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Esempio n. 23
0
    void Update()
    {
        DisplayMap.map.coor[playerRow, playerCol].value = DesignController.FLOOR;
        playerRow = Mathf.RoundToInt(transform.position.x);
        playerCol = Mathf.RoundToInt(transform.position.z);

        //Debug.Log(playerX + "dan y : " + playerY);
        DisplayMap.map.coor[playerRow, playerCol].value = DesignController.PLAYER;
        //Debug.Log(DisplayMap.map.coor[2, 9].value);
        //Map.getSpot(playerY, playerX)= DesignController.PLAYER;

        UnityEngine.UI.Text change = txt.GetComponent <UnityEngine.UI.Text>();
        change.text = "Health : " + health;

        if (health <= 0)
        {
            isDeath = true;
        }


        moveY += 2 * Input.GetAxis("Mouse X");
        moveX -= 2 * Input.GetAxis("Mouse Y");
        transform.eulerAngles = new Vector3(moveX, moveY, 0);

        if (Input.GetKey(KeyCode.W))
        {
            //animator.SetBool("isWalk", true);
            if (Input.GetKey(KeyCode.LeftShift))
            {
                transform.Translate(new Vector3(0, 0, Time.deltaTime * 2f));
            }
            transform.Translate(new Vector3(0, 0, Time.deltaTime * 4f));
        }
        if (Input.GetKey(KeyCode.A))
        {
            //animator.SetBool("isWalk", true);
            if (Input.GetKey(KeyCode.LeftShift))
            {
                transform.Translate(new Vector3(Time.deltaTime * -2f, 0, 0));
            }
            transform.Translate(new Vector3(Time.deltaTime * -4f, 0, 0));
        }
        if (Input.GetKey(KeyCode.S))
        {
            //animator.SetBool("isWalk", true);
            if (Input.GetKey(KeyCode.LeftShift))
            {
                transform.Translate(new Vector3(0, 0, Time.deltaTime * -2f));
            }
            transform.Translate(new Vector3(0, 0, Time.deltaTime * -4f));
        }
        if (Input.GetKey(KeyCode.D))
        {
            //animator.SetBool("isWalk", true);
            if (Input.GetKey(KeyCode.LeftShift))
            {
                transform.Translate(new Vector3(Time.deltaTime * 2f, 0, 0));
            }
            transform.Translate(new Vector3(Time.deltaTime * 4f, 0, 0));
        }

        if (Input.GetKeyUp(KeyCode.W) || Input.GetKeyUp(KeyCode.A) || Input.GetKeyUp(KeyCode.S) || Input.GetKeyUp(KeyCode.D))
        {
            //animator.SetBool("isWalk", false);
        }

        if (Input.GetKey(KeyCode.Space))
        {
            transform.Translate(new Vector3(0, Time.deltaTime * 4f, 0));
        }

        if (Input.GetKey(KeyCode.Escape))
        {
            DisplayMap.removeEnemy(DisplayMap.xRand, DisplayMap.yRand);
            DisplayMap.removeTreasure(DisplayMap.xTRand, DisplayMap.yTRand);
            MapStatus.getInstance().setToPlay(false);
            if (MapStatus.getInstance().getChoosenMap() == 1)
            {
                MapStatus.getInstance().setChoosenMap(0);
            }
            TxtController.getInstance().updateText();
            SceneManager.LoadScene("MenuScene");
        }
    }
Esempio n. 24
0
 // Use this for initialization
 void Start()
 {
     displayMap = GameObject.Find("Map").GetComponent <DisplayMap>();
 }
    void RunCubes()
    {
        DisplayMap display = FindObjectOfType <DisplayMap>();

        display.DrawMesh(MeshGen.GenerateTerrainMesh(sphere));
    }
Esempio n. 26
0
 void OnEnable()
 {
     _target = (DisplayMap)target;
 }
Esempio n. 27
0
        public SetMap(ActiveMap map, int floor)
        {
            this.map          = new DisplayMap();
            this.map.MapArray = new Tile[map.Width, map.Height];
            for (int y = 0; y < map.Height; y++)
            {
                for (int x = 0; x < map.Width; x++)
                {
                    this.map.MapArray[x, y] = new Tile(map.MapArray[x, y]);
                }
            }

            this.map.GroundLayers = new List <TileAnim[, ]>();
            for (int i = 0; i < map.GroundLayers.Count; i++)
            {
                this.map.GroundLayers.Add(new TileAnim[map.Width, map.Height]);
                for (int y = 0; y < map.Height; y++)
                {
                    for (int x = 0; x < map.Width; x++)
                    {
                        this.map.GroundLayers[i][x, y] = map.GroundLayers[i].Tiles[x, y];
                    }
                }
            }

            this.map.PropBackLayers = new List <TileAnim[, ]>();
            for (int i = 0; i < map.PropBackLayers.Count; i++)
            {
                this.map.PropBackLayers.Add(new TileAnim[map.Width, map.Height]);
                for (int y = 0; y < map.Height; y++)
                {
                    for (int x = 0; x < map.Width; x++)
                    {
                        this.map.PropBackLayers[i][x, y] = map.PropBackLayers[i].Tiles[x, y];
                    }
                }
            }

            this.map.PropFrontLayers = new List <TileAnim[, ]>();
            for (int i = 0; i < map.PropFrontLayers.Count; i++)
            {
                this.map.PropFrontLayers.Add(new TileAnim[map.Width, map.Height]);
                for (int y = 0; y < map.Height; y++)
                {
                    for (int x = 0; x < map.Width; x++)
                    {
                        this.map.PropFrontLayers[i][x, y] = map.PropFrontLayers[i].Tiles[x, y];
                    }
                }
            }

            this.map.FringeLayers = new List <TileAnim[, ]>();
            for (int i = 0; i < map.FringeLayers.Count; i++)
            {
                this.map.FringeLayers.Add(new TileAnim[map.Width, map.Height]);
                for (int y = 0; y < map.Height; y++)
                {
                    for (int x = 0; x < map.Width; x++)
                    {
                        this.map.FringeLayers[i][x, y] = map.FringeLayers[i].Tiles[x, y];
                    }
                }
            }

            this.floor = floor;
        }