public DeckLayout Copy() { var ret = new DeckLayout { cardNums = this.cardNums, deckIndex = this.deckIndex }; return(ret); }
void Start() { deckInfoDp.AddOptions(decksFile.GetDeckNames()); deckInfoDp.value = currentDeckLayout.deckIndex; deckInfoDp.RefreshShownValue(); deckInfoDp.onValueChanged.AddListener((int index) => { deckMeta = Instantiate(decksFile.decks[index].deckMeta); currentDeckLayout = deckMeta.defaultDeckLayout.Copy(); cardList.Load(deckMeta, currentDeckLayout.cardNums); }); }
public DeckEntityData(Vector3 position, string name, Color color, DeckMeta deckInfo, DeckLayout deckData, Permission.PermissionType ownerTakeAwayPermissionType, Permission.PermissionType ownerShufflePermissionType, Permission.PermissionType ownerDealPermissionType, Permission.PermissionType othersTakeAwayPermissionType, Permission.PermissionType othersShufflePermissionType, Permission.PermissionType othersDealPermissionType, bool flipCardsWhenDropped) : base(position, name, color, ownerTakeAwayPermissionType, Permission.PermissionType.DENY, othersTakeAwayPermissionType, Permission.PermissionType.DENY, flipCardsWhenDropped) { this.deckData = deckData; this.deckInfo = deckInfo; this.ownerShufflePermissionType = ownerShufflePermissionType; this.ownerDealPermissionType = ownerDealPermissionType; this.othersShufflePermissionType = othersShufflePermissionType; this.othersDealPermissionType = othersDealPermissionType; //this.deckDataFileName = deckDataFileName; }
public void OnSaveButtonPressed() { TextInputDialog.Show("Save deck layout", (string text) => { if (!String.IsNullOrEmpty(text)) { string fileName = text + ".json"; DeckLayout deckLayoutToSave = currentDeckLayout; deckLayoutToSave.cardNums = cardList.getNumberOfEachCard(); SaveDeckLayoutToFile(fileName, deckLayoutToSave); } }); }
public static void SaveDeckLayoutToFile(string fileName, DeckLayout deckData) { DirectoryInfo di = new DirectoryInfo(Path.Combine(Application.persistentDataPath, "DeckLayouts")); if (!di.Exists) { di.Create(); } var sr = File.CreateText(Path.Combine(Application.persistentDataPath, Path.Combine("DeckLayouts", fileName))); sr.WriteLine(JsonUtility.ToJson(deckData)); sr.Close(); }
public override void Start() { base.Start(); if (string.IsNullOrEmpty(Name)) { Name = "Deck" + (++zoneNumber); } if (deckLayout == null) { deckLayout = decksFile.decks[0].deckMeta.defaultDeckLayout; } if (deckMeta == null) { deckMeta = decksFile.decks[0].deckMeta; } }
/*public static DeckMeta LoadDeckInfoFromFile(string fileName) * { * string dataAsJson = null; * string filePath = Path.Combine(Application.streamingAssetsPath, Path.Combine("DeckInfos", fileName)); #if UNITY_EDITOR || UNITY_IOS || UNITY_STANDALONE_WIN * dataAsJson = File.ReadAllText(filePath); * #elif UNITY_ANDROID * WWW reader = new WWW (filePath); * while (!reader.isDone) { * } * dataAsJson = reader.text; #endif * * return JsonUtility.FromJson<DeckMeta>(dataAsJson); * }*/ public void OnLoadDeckLayoutButtonPressed() { DirectoryInfo dataDir = new DirectoryInfo(Path.Combine(Application.persistentDataPath, "DeckLayouts")); List <string> fileNames = new List <string>(); if (dataDir.Exists) { FileInfo[] fileinfos = dataDir.GetFiles(); for (int i = 0; i < fileinfos.Length; i++) { string name = Path.GetFileNameWithoutExtension(fileinfos[i].Name); fileNames.Add(name); } DropdownDialog.Show(fileNames, "Select a file", (int index) => { currentDeckLayout = LoadDeckLayoutFromFile(fileinfos[index].Name); deckMeta = decksFile.decks[currentDeckLayout.deckIndex].deckMeta; cardList.Load(deckMeta, currentDeckLayout.cardNums); }); } }