Exemplo n.º 1
0
        public void ExportPropsSet()
        {
            var extensions = new[]
            {
                new ExtensionFilter("Props paint set", "proppaintset")
            };

            var path = StandaloneFileBrowser.SaveFilePanel("Export props paint set", DefaultPath, "", extensions);

            if (string.IsNullOrEmpty(path))
            {
                return;
            }

            PaintButtonsSet PaintSet = new PaintButtonsSet();

            PaintSet.PaintProps = new PaintButtonsSet.PaintProp[PaintButtons.Count];

            for (int i = 0; i < PaintSet.PaintProps.Length; i++)
            {
                if (PaintPropObjects[i].BP == null)
                {
                    Debug.Log("Prop object is empty!");
                }

                PaintSet.PaintProps[i] = new PaintButtonsSet.PaintProp();

                PaintSet.PaintProps[i].Blueprint   = PaintPropObjects[i].BP.Path;
                PaintSet.PaintProps[i].ScaleMin    = PaintButtons[RandomProp].ScaleMin.value;
                PaintSet.PaintProps[i].ScaleMax    = PaintButtons[RandomProp].ScaleMin.value;
                PaintSet.PaintProps[i].RotationMin = PaintButtons[RandomProp].RotationMin.intValue;
                PaintSet.PaintProps[i].RotationMax = PaintButtons[RandomProp].RotationMax.intValue;
                PaintSet.PaintProps[i].Chance      = PaintButtons[RandomProp].Chance.intValue;
            }



            string data = JsonUtility.ToJson(PaintSet);

            File.WriteAllText(path, data);
            EnvPaths.SetLastPath(ExportPathKey, System.IO.Path.GetDirectoryName(path));
        }
Exemplo n.º 2
0
        public void ImportPropsSet()
        {
            var extensions = new[]
            {
                new ExtensionFilter("Props paint set", "proppaintset")
            };

            var paths = StandaloneFileBrowser.OpenFilePanel("Import props paint set", DefaultPath, extensions, false);


            if (paths.Length <= 0 || string.IsNullOrEmpty(paths[0]))
            {
                return;
            }

            string data = File.ReadAllText(paths[0]);

            PaintButtonsSet PaintSet = JsonUtility.FromJson <PaintButtonsSet>(data);



            while (PaintButtons.Count > 0)
            {
                RemoveProp(0);
            }



            //bool[] Exist = new bool[PaintPropObjects.Count];

            for (int i = 0; i < PaintSet.PaintProps.Length; i++)
            {
                //bool Found = false;
                int o = 0;

                /*
                 * for(o = 0; i < PaintPropObjects.Count; o++)
                 * {
                 *      if(PaintPropObjects[i].BP.Path == PaintSet.PaintProps[i].Blueprint)
                 *      {
                 *              if (o < Exist.Length)
                 *                      Exist[o] = true;
                 *              Found = true;
                 *              break;
                 *      }
                 * }*/

                //if (!Found)
                {
                    // Load
                    if (!LoadProp(GetGamedataFile.LoadProp(PaintSet.PaintProps[i].Blueprint)))
                    {
                        Debug.LogWarning("Can't load prop at path: " + PaintSet.PaintProps[i].Blueprint);
                        continue;
                    }

                    o = PaintButtons.Count - 1;
                }

                PaintButtons[o].ScaleMin.SetValue(PaintSet.PaintProps[i].ScaleMin);
                PaintButtons[o].ScaleMax.SetValue(PaintSet.PaintProps[i].ScaleMax);

                PaintButtons[o].RotationMin.SetValue(PaintSet.PaintProps[i].RotationMin);
                PaintButtons[o].RotationMax.SetValue(PaintSet.PaintProps[i].RotationMax);

                PaintButtons[o].Chance.SetValue(PaintSet.PaintProps[i].Chance);
            }

            /*
             * for(int i = Exist.Length - 1; i >= 0; i--)
             * {
             *      if (!Exist[i])
             *      {
             *              RemoveProp(i);
             *      }
             * }
             */

            EnvPaths.SetLastPath(ExportPathKey, System.IO.Path.GetDirectoryName(paths[0]));
        }
Exemplo n.º 3
0
        public void ImportPropsSet()
        {
            var extensions = new[]
            {
                new ExtensionFilter("Props paint set", "proppaintset")
            };

            var paths = StandaloneFileBrowser.OpenFilePanel("Import props paint set", EnvPaths.GetMapsPath(), extensions, false);


            if (paths.Length <= 0 || string.IsNullOrEmpty(paths[0]))
            {
                return;
            }

            string data = File.ReadAllText(paths[0]);

            PaintButtonsSet PaintSet = JsonUtility.FromJson <PaintButtonsSet>(data);

            bool[] Exist = new bool[PaintPropObjects.Count];

            for (int i = 0; i < PaintSet.PaintProps.Length; i++)
            {
                bool Found = false;
                int  o     = 0;
                for (o = 0; i < PaintPropObjects.Count; o++)
                {
                    if (PaintPropObjects[i].BP.Path == PaintSet.PaintProps[i].Blueprint)
                    {
                        if (o < Exist.Length)
                        {
                            Exist[o] = true;
                        }
                        Found = true;
                        break;
                    }
                }

                if (!Found)
                {
                    // Load
                    if (!LoadProp(GetGamedataFile.LoadProp(PaintSet.PaintProps[i].Blueprint)))
                    {
                        Debug.LogWarning("Can't load prop at path: " + PaintSet.PaintProps[i].Blueprint);
                        continue;
                    }

                    o = PaintButtons.Count - 1;
                }



                PaintButtons[o].ScaleMin.SetValue(PaintSet.PaintProps[i].ScaleMin);
                PaintButtons[o].ScaleMax.SetValue(PaintSet.PaintProps[i].ScaleMax);

                PaintButtons[o].RotationMin.SetValue(PaintSet.PaintProps[i].RotationMin);
                PaintButtons[o].RotationMax.SetValue(PaintSet.PaintProps[i].RotationMax);

                PaintButtons[o].Chance.SetValue(PaintSet.PaintProps[i].Chance);
            }

            for (int i = Exist.Length - 1; i >= 0; i--)
            {
                if (!Exist[i])
                {
                    RemoveProp(i);
                }
            }
        }