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; }
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 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 void Load(DeckMeta deckInfo, List <int> numberOfEachCard) { DestroyChildren(); Sprite[] sprites = Resources.LoadAll <Sprite>(deckInfo.deckImagePath); for (int i = 0; i < deckInfo.numberOfCards; i++) { CardListItem cardListItem = Instantiate(cardListItemPrefab, this.transform); cardListItem.Sprite = sprites[i]; if (numberOfEachCard.Count == deckInfo.numberOfCards) { cardListItem.NumberOfCards = numberOfEachCard[i]; } else { cardListItem.NumberOfCards = 1; } } }
/*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); }); } }