コード例 #1
0
    public void OnClickGatyaButton()
    {
        if (userData.point < gatyaPoint)
        {
            //ガチャポイントたりない
            TwoButtonDialogData data = new TwoButtonDialogData();
            data.title   = "ポイント不足";
            data.content = addPoint + " ポイントが足りません。\nポイントを獲得するボタンを押してポイントを獲得してください。";
            StartCoroutine(DialogManager.instance.DialogShow(DialogSelector.DialogType.TwoButtonDialog, data));
        }
        else
        {
            //ポイントがあったらガチャを引く
            userData.point -= gatyaPoint;
            pointText.text  = userData.point.ToString();
            ClassDataFomater.Seialize <GatyaUserData>(UnityEngine.Application.persistentDataPath + "/GatyaData", userData);

            List <float> lotList = new List <float>();
            for (int i = 0; i < masterData.sheets[0].list.Count; i++)
            {
                lotList.Add(masterData.sheets[0].list[i].probability);
            }
            int id = LotterySystem.Lottery(lotList);
            GatyaMasterData.Param targetParam = masterData.GetGatyaMasterParam(id);

            TwoButtonDialogData data = new TwoButtonDialogData();
            data.title   = "ガチャを引きました";
            data.content = targetParam.Rarity + "レアの" + targetParam.itemName + "\n";
            StartCoroutine(DialogManager.instance.DialogShow(DialogSelector.DialogType.TwoButtonDialog, data));
        }
    }
コード例 #2
0
    static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
    {
        foreach (string asset in importedAssets)
        {
            if (!filePath.Equals(asset))
            {
                continue;
            }

            GatyaMasterData data = (GatyaMasterData)AssetDatabase.LoadAssetAtPath(exportPath, typeof(GatyaMasterData));
            if (data == null)
            {
                data = ScriptableObject.CreateInstance <GatyaMasterData> ();
                AssetDatabase.CreateAsset((ScriptableObject)data, exportPath);
                data.hideFlags = HideFlags.NotEditable;
            }

            data.sheets.Clear();
            using (FileStream stream = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) {
                IWorkbook book = null;
                if (Path.GetExtension(filePath) == ".xls")
                {
                    book = new HSSFWorkbook(stream);
                }
                else
                {
                    book = new XSSFWorkbook(stream);
                }

                foreach (string sheetName in sheetNames)
                {
                    ISheet sheet = book.GetSheet(sheetName);
                    if (sheet == null)
                    {
                        Debug.LogError("[QuestData] sheet not found:" + sheetName);
                        continue;
                    }

                    GatyaMasterData.Sheet s = new GatyaMasterData.Sheet();
                    s.name = sheetName;

                    for (int i = 1; i <= sheet.LastRowNum; i++)
                    {
                        IRow  row  = sheet.GetRow(i);
                        ICell cell = null;

                        GatyaMasterData.Param p = new GatyaMasterData.Param();

                        cell = row.GetCell(0); p.index = (int)(cell == null ? 0 : cell.NumericCellValue);
                        cell = row.GetCell(1); p.itemName = (cell == null ? "" : cell.StringCellValue);
                        cell = row.GetCell(2); p.Rarity = (int)(cell == null ? 0 : cell.NumericCellValue);
                        cell = row.GetCell(3); p.probability = (float)(cell == null ? 0 : cell.NumericCellValue);
                        s.list.Add(p);
                    }
                    data.sheets.Add(s);
                }
            }

            ScriptableObject obj = AssetDatabase.LoadAssetAtPath(exportPath, typeof(ScriptableObject)) as ScriptableObject;
            EditorUtility.SetDirty(obj);
        }
    }