コード例 #1
0
    public PropertyWeightDataList GetWeightList(ItemData itemData, int role)
    {
        HeroEquipmentWeight heroWeight = null;

        if (role == 0)
        {
            heroWeight = _mageWeight;
        }
        else if (role == 1)
        {
            heroWeight = _warriorWeight;
        }
        else if (role == 2)
        {
            heroWeight = _monkWeight;
        }

        if (heroWeight != null)
        {
            if (itemData.subType == ItemSubType.weapon)
            {
                return(heroWeight._weaponWeight);
            }
            else if (itemData.subType == ItemSubType.helmet)
            {
                return(heroWeight._helmWeight);
            }
            else if (itemData.subType == ItemSubType.shoulder)
            {
                return(heroWeight._shoulderWeight);
            }
            else if (itemData.subType == ItemSubType.belt)
            {
                return(heroWeight._beltWeight);
            }
            else if (itemData.subType == ItemSubType.armpiece)
            {
                return(heroWeight._armpieceWeight);
            }
            else if (itemData.subType == ItemSubType.leggings)
            {
                return(heroWeight._leggingsWeight);
            }
            else if (itemData.subType == ItemSubType.necklace)
            {
                return(heroWeight._necklaceWeight);
            }
            else if (itemData.subType == ItemSubType.ring)
            {
                return(heroWeight._ringWeight);
            }
        }

        return(null);
    }
コード例 #2
0
    public static void ReadWeight(string sheetName, string outFileFolder, string outFileName)
    {
        Workbook workbook = Workbook.CreatWorkbook(fileName, sheetName);
        Sheet    sheet    = workbook._sheet;

        if (sheet == null)
        {
            Debug.LogError("Can't find " + sheetName + " in " + fileName);
            return;
        }

        bool newFile = false;


        HeroEquipmentWeight dataList = null;

        UnityEngine.Object oldFile = AssetDatabase.LoadAssetAtPath(outFileName, typeof(HeroEquipmentWeight));
        if (oldFile == null)
        {
            newFile  = true;
            dataList = ScriptableObject.CreateInstance(typeof(HeroEquipmentWeight)) as HeroEquipmentWeight;
        }
        else
        {
            dataList = oldFile as HeroEquipmentWeight;
        }


        dataList._weaponWeight   = ScriptableObject.CreateInstance <PropertyWeightDataList>();
        dataList._helmWeight     = ScriptableObject.CreateInstance <PropertyWeightDataList>();
        dataList._shoulderWeight = ScriptableObject.CreateInstance <PropertyWeightDataList>();
        dataList._beltWeight     = ScriptableObject.CreateInstance <PropertyWeightDataList>();
        dataList._armpieceWeight = ScriptableObject.CreateInstance <PropertyWeightDataList>();
        dataList._leggingsWeight = ScriptableObject.CreateInstance <PropertyWeightDataList>();
        dataList._necklaceWeight = ScriptableObject.CreateInstance <PropertyWeightDataList>();
        dataList._ringWeight     = ScriptableObject.CreateInstance <PropertyWeightDataList>();

        for (int i = 1; i < sheet._rows.Count; i++)
        {
            Row data = sheet._rows[i];

            PropertyWeightData newData = new PropertyWeightData();
            newData._type   = GetHitParam(data["WeaponType"]);
            newData._weight = GetInt(data["WeaponWeight"]);
            if (newData._type != AIHitParams.None && newData._weight > 0)
            {
                dataList._weaponWeight._dataList.Add(newData);
            }

            PropertyWeightData newData1 = new PropertyWeightData();
            newData1._type   = GetHitParam(data["HelmType"]);
            newData1._weight = GetInt(data["HelmWeight"]);
            if (newData1._type != AIHitParams.None && newData1._weight > 0)
            {
                dataList._helmWeight._dataList.Add(newData1);
            }

            PropertyWeightData newData2 = new PropertyWeightData();
            newData2._type   = GetHitParam(data["ShoulderType"]);
            newData2._weight = GetInt(data["ShoulderWeight"]);
            if (newData2._type != AIHitParams.None && newData2._weight > 0)
            {
                dataList._shoulderWeight._dataList.Add(newData2);
            }

            PropertyWeightData newData3 = new PropertyWeightData();
            newData3._type   = GetHitParam(data["BeltType"]);
            newData3._weight = GetInt(data["BeltWeight"]);
            if (newData3._type != AIHitParams.None && newData3._weight > 0)
            {
                dataList._beltWeight._dataList.Add(newData3);
            }

            PropertyWeightData newData4 = new PropertyWeightData();
            newData4._type   = GetHitParam(data["ArmpieceType"]);
            newData4._weight = GetInt(data["ArmpieceWeight"]);
            if (newData4._type != AIHitParams.None && newData4._weight > 0)
            {
                dataList._armpieceWeight._dataList.Add(newData4);
            }

            PropertyWeightData newData5 = new PropertyWeightData();
            newData5._type   = GetHitParam(data["LeggingsType"]);
            newData5._weight = GetInt(data["LeggingsWeight"]);
            if (newData5._type != AIHitParams.None && newData5._weight > 0)
            {
                dataList._leggingsWeight._dataList.Add(newData5);
            }

            PropertyWeightData newData6 = new PropertyWeightData();
            newData6._type   = GetHitParam(data["NecklaceType"]);
            newData6._weight = GetInt(data["NecklaceWeight"]);
            if (newData6._type != AIHitParams.None && newData6._weight > 0)
            {
                dataList._necklaceWeight._dataList.Add(newData6);
            }

            PropertyWeightData newData7 = new PropertyWeightData();
            newData7._type   = GetHitParam(data["RingType"]);
            newData7._weight = GetInt(data["RingWeight"]);
            if (newData7._type != AIHitParams.None && newData7._weight > 0)
            {
                dataList._ringWeight._dataList.Add(newData7);
            }
        }

        CreateWeightScriptObject(dataList._weaponWeight, outFileFolder, "weaponWeight");
        CreateWeightScriptObject(dataList._helmWeight, outFileFolder, "helmWeight");
        CreateWeightScriptObject(dataList._shoulderWeight, outFileFolder, "shoulderWeight");
        CreateWeightScriptObject(dataList._armpieceWeight, outFileFolder, "armpieceWeight");
        CreateWeightScriptObject(dataList._beltWeight, outFileFolder, "beltWeight");
        CreateWeightScriptObject(dataList._leggingsWeight, outFileFolder, "leggingsWeight");
        CreateWeightScriptObject(dataList._necklaceWeight, outFileFolder, "necklaceWeight");
        CreateWeightScriptObject(dataList._ringWeight, outFileFolder, "ringWeight");



        if (newFile)
        {
            AssetDatabase.CreateAsset(dataList, outFileName);
        }
        else
        {
            EditorUtility.SetDirty(dataList);
        }
    }