示例#1
0
    public void onForgingButtonClick()
    {
        EquipmentData._preconditions = Convert.ToString(Forging.GetSheet((int)Forging.SheetName.Sheet1).GetData(int.Parse(EquipmentData._currentForging)).Preconditions);
        //循环遍历前置条件
        for (i = 0; i < 5; i++)
        {
            //判断是否满足前置条件或是第一个改造
            if (EquipmentData._hasForging[i].Equals(EquipmentData._preconditions))
            {
                flag = true;
                break;
            }
            else if (int.Parse(EquipmentData._currentForging) % 5 == 1)
            {
                flag = true;
                break;
            }
            else
            {
                flag = false;
            }
        }

        if (flag)
        {
            GameObject.Find(EquipmentData._currentForging).GetComponent <Image>().color = Color.black;
            EquipmentData._count -= 1;
            GameObject.Find("Point").GetComponent <Text>().text = Convert.ToString(EquipmentData._count);
            GameObject.Find(EquipmentData._currentForging).GetComponent <Button>().enabled = false;
        }

        if (flag)
        {
            for (i = 0; i < 5; i++)
            {
                if (EquipmentData._hasForging[i].Equals(str))
                {
                    EquipmentData._hasForging.RemoveAt(i);
                    EquipmentData._hasForging.Add(EquipmentData._currentForging);
                    break;
                }
            }
        }
        else
        {
            UnityEditor.EditorUtility.DisplayDialog("Tips", "不满足条件,未解锁前置技能", "确定");
        }

        for (i = 0; i < 5; i++)
        {
            Debug.LogError(EquipmentData._hasForging[i]);
        }
        //保存改造信息
        EquipmentData.equ[RoleData._roleId]   = EquipmentData._hasForging;
        EquipmentData.count[RoleData._roleId] = EquipmentData._count;
        EquipmentData.dic[RoleData._roleId]   = EquipmentData.equ;
        GameObject.Destroy(layer);
    }
示例#2
0
    /// <summary>
    /// 锻造装备更新数据
    /// </summary>
    /// <param name="_id"></param>
    public static void ForgingItem(int _id)
    {
        GoodsModel gm = GoodsList.Find(x => x.Id == _id);//在背包找到这个物品

        if (gm.Num > 2)
        {
            gm.Num -= 2;
            Forging fg   = ForgingList.Find(x => x.id == _id);
            Item    item = DataMgr.GetInstance().GetItemByID(fg.ID);
            BuyItem(item);
        }
    }
    // Start is called before the first frame update
    void Start()
    {
        flag      = true;
        str       = "0";
        Material1 = GameObject.Find("Material1").GetComponentInChildren <Text>();
        EquipmentData._material1    = Forging.GetSheet((int)Forging.SheetName.Sheet1).GetData(EquipmentData._forgingId).Material1;
        EquipmentData._material1Get = EquipmentData.count[RoleData._roleId + 1000];
        EquipmentData._material1Num = Forging.GetSheet((int)Forging.SheetName.Sheet1).GetData(EquipmentData._forgingId).num1;
        Material1.text = EquipmentData._material1Get + "/" + EquipmentData._material1Num;

        Material2 = GameObject.Find("Material2").GetComponentInChildren <Text>();
        EquipmentData._material2    = Forging.GetSheet((int)Forging.SheetName.Sheet1).GetData(EquipmentData._forgingId).Material2;
        EquipmentData._material2Get = EquipmentData.count[RoleData._roleId + 2000];
        EquipmentData._material2Num = Forging.GetSheet((int)Forging.SheetName.Sheet1).GetData(EquipmentData._forgingId).num2;
        Material2.text = EquipmentData._material2Get + "/" + EquipmentData._material2Num;

        Material3 = GameObject.Find("Material3").GetComponentInChildren <Text>();
        EquipmentData._material3    = Forging.GetSheet((int)Forging.SheetName.Sheet1).GetData(EquipmentData._forgingId).Material3;
        EquipmentData._material3Get = EquipmentData.count[RoleData._roleId + 3000];

        EquipmentData._material3Num = Forging.GetSheet((int)Forging.SheetName.Sheet1).GetData(EquipmentData._forgingId).num3;
        Material3.text = EquipmentData._material3Get + "/" + EquipmentData._material3Num;
    }
示例#4
0
    static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
    {
        foreach (string asset in importedAssets)
        {
            if (!filePath.Equals(asset))
            {
                continue;
            }

            Directory.CreateDirectory("Assets/ReadExcel/Config/Resources/DataConfig/ ");
            Forging data = (Forging)AssetDatabase.LoadAssetAtPath(exportPath, typeof(Forging));
            if (data == null)
            {
                data = ScriptableObject.CreateInstance <Forging> ();
                AssetDatabase.CreateAsset((ScriptableObject)data, exportPath);
                data.hideFlags = HideFlags.NotEditable;
            }

            ReadExcel.CreatDataInitCs();
            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;
                    }

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

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

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

                        cell = row.GetCell(0); p.id = (int)(cell == null ? 0 : cell.NumericCellValue);
                        cell = row.GetCell(1); p.forgingType = (int)(cell == null ? 0 : cell.NumericCellValue);
                        cell = row.GetCell(2); p.Preconditions = (int)(cell == null ? 0 : cell.NumericCellValue);
                        cell = row.GetCell(3); p.Material1 = (int)(cell == null ? 0 : cell.NumericCellValue);
                        cell = row.GetCell(4); p.num1 = (int)(cell == null ? 0 : cell.NumericCellValue);
                        cell = row.GetCell(5); p.Material2 = (int)(cell == null ? 0 : cell.NumericCellValue);
                        cell = row.GetCell(6); p.num2 = (int)(cell == null ? 0 : cell.NumericCellValue);
                        cell = row.GetCell(7); p.Material3 = (int)(cell == null ? 0 : cell.NumericCellValue);
                        cell = row.GetCell(8); p.num3 = (int)(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);
        }
    }