Esempio n. 1
0
  public void Load()
  {
      LoadFileName = UILoadInputField.text;
      PlayGrid LoadedGrig = BinaryDataHandler.Load <PlayGrid>(BinaryDataHandler.UnityFolder.stremingAsset,
                                                              LoadFileName, BinaryDataHandler.DataFileExtention.map);

      Debug.Log(LoadedGrig._hight);
      _PlayGridHolder.PlayGrid = LoadedGrig;
      for (int x = 0; x < LoadedGrig._hight; x++)
      {
          for (int y = 0; y < LoadedGrig._width; y++)
          {
              if (LoadedGrig.PlayTiles[x, y].Tag1 != 0)
              {
                  SetTile(TempletBuilder.EditPlayTiles[LoadedGrig.PlayTiles[x, y].Tag1], new Vector2Int(x, y), LoadedGrig.PlayTiles[x, y].Tag1);
              }
              if (LoadedGrig.PlayTiles[x, y].Tag2 != 0)
              {
                  SetTile(TempletBuilder.EditPlayTiles[LoadedGrig.PlayTiles[x, y].Tag2], new Vector2Int(x, y), LoadedGrig.PlayTiles[x, y].Tag2);
              }
              if (LoadedGrig.PlayTiles[x, y].Tag3 != 0)
              {
                  SetTile(TempletBuilder.EditPlayTiles[LoadedGrig.PlayTiles[x, y].Tag3], new Vector2Int(x, y), LoadedGrig.PlayTiles[x, y].Tag3);
              }
              if (LoadedGrig.PlayTiles[x, y].ActorIndex != 0)
              {
                  SetActor(TempletActors.EditGridActors[LoadedGrig.PlayTiles[x, y].ActorIndex], new Vector2Int(x, y), LoadedGrig.PlayTiles[x, y].ActorIndex);
              }
          }
      }
  }
Esempio n. 2
0
 public void SaveMap()
 {
     if (_player != null)
     {
         SaveFileName = UISaveInputField.text;
         BinaryDataHandler.Save(BinaryDataHandler.UnityFolder.stremingAsset, _PlayGridHolder.PlayGrid, SaveFileName,
                                BinaryDataHandler.DataFileExtention.map);
         MapSaveInfo.alpha = 1;
     }
     else
     {
         MapSaveErrorInfo.alpha = 0;
     }
 }
Esempio n. 3
0
 public void UIToPlayMode()
 {
     PannelLoad.SetActive(true);
     //List<GameObject> oldSaves = new List<GameObject>();
     foreach (Transform child in PannelDesSaves.transform)
     {
         Destroy(child.gameObject, 0.01f);
     }
     string[] saves = BinaryDataHandler.CheckForFiles(BinaryDataHandler.UnityFolder.stremingAsset);
     foreach (var save in saves)
     {
         if (Path.GetExtension(save) == ".map")
         {
             GameObject bouton = Instantiate(BoutonSave, PannelDesSaves.transform);
             bouton.GetComponentInChildren <TMP_Text>().text = Path.GetFileNameWithoutExtension(save);
             bouton.GetComponent <Button>().onClick.AddListener(delegate
             {
                 PlayGrid = BinaryDataHandler.Load <PlayGrid>(BinaryDataHandler.UnityFolder.stremingAsset, Path.GetFileNameWithoutExtension(save), BinaryDataHandler.DataFileExtention.map);
                 SceneManager.LoadScene(1);
             });
         }
     }
 }
Esempio n. 4
0
        public static ProtectedBinary Open(string strName, ProtectedBinary pb,
                                           BinaryDataOpenOptions opt)
        {
            if (string.IsNullOrEmpty(strName))
            {
                Debug.Assert(false); return(null);
            }
            if (pb == null)
            {
                Debug.Assert(false); return(null);
            }
            if (opt == null)
            {
                opt = new BinaryDataOpenOptions();
            }

            byte[] pbData = pb.ReadData();
            if (pbData == null)
            {
                Debug.Assert(false); return(null);
            }

            BinaryDataHandler h = opt.Handler;

            if (h == BinaryDataHandler.Default)
            {
                h = ChooseHandler(strName, pbData, opt);
            }

            byte[] pbModData = null;
            if (h == BinaryDataHandler.InternalViewer)
            {
                DataViewerForm dvf = new DataViewerForm();
                dvf.InitEx(strName, pbData);
                UIUtil.ShowDialogAndDestroy(dvf);
            }
            else if (h == BinaryDataHandler.InternalEditor)
            {
                DataEditorForm def = new DataEditorForm();
                def.InitEx(strName, pbData);
                def.ShowDialog();

                if (def.EditedBinaryData != null)
                {
                    pbModData = def.EditedBinaryData;
                }

                UIUtil.DestroyForm(def);
            }
            else if (h == BinaryDataHandler.ExternalApp)
            {
                pbModData = OpenExternal(strName, pbData, opt);
            }
            else
            {
                Debug.Assert(false);
            }

            if ((pbModData != null) && !MemUtil.ArraysEqual(pbData, pbModData) &&
                !opt.ReadOnly)
            {
                return(new ProtectedBinary(pb.IsProtected, pbModData));
            }
            return(null);
        }
Esempio n. 5
0
        public static ProtectedBinary Open(string strName, ProtectedBinary pb,
                                           BinaryDataOpenOptions opt)
        {
            if (string.IsNullOrEmpty(strName))
            {
                Debug.Assert(false); return(null);
            }
            if (pb == null)
            {
                Debug.Assert(false); return(null);
            }
            if (opt == null)
            {
                opt = new BinaryDataOpenOptions();
            }

            byte[] pbData = pb.ReadData();
            if (pbData == null)
            {
                Debug.Assert(false); return(null);
            }

            BinaryDataHandler h = opt.Handler;

            if (h == BinaryDataHandler.Default)
            {
                h = ChooseHandler(strName, pbData, opt);
            }

            byte[] pbModData = null;
            if (h == BinaryDataHandler.InternalViewer)
            {
                DataViewerForm dvf = new DataViewerForm();
                dvf.InitEx(strName, pbData);
                UIUtil.ShowDialogAndDestroy(dvf);
            }
            else if (h == BinaryDataHandler.InternalEditor)
            {
                DataEditorForm def = new DataEditorForm();
                def.InitEx(strName, pbData);
                def.ShowDialog();

                if (def.EditedBinaryData != null)
                {
                    pbModData = def.EditedBinaryData;
                }

                UIUtil.DestroyForm(def);
            }
            else if (h == BinaryDataHandler.ExternalApp)
            {
                pbModData = OpenExternal(strName, pbData, opt);
            }
            else
            {
                Debug.Assert(false);
            }

            ProtectedBinary r = null;

            if ((pbModData != null) && !MemUtil.ArraysEqual(pbData, pbModData) &&
                !opt.ReadOnly)
            {
                if (FileDialogsEx.CheckAttachmentSize(pbModData.LongLength,
                                                      KPRes.AttachFailed + MessageService.NewParagraph + strName))
                {
                    r = new ProtectedBinary(pb.IsProtected, pbModData);
                }
            }

            if (pb.IsProtected)
            {
                MemUtil.ZeroByteArray(pbData);
            }
            return(r);
        }