Exemplo n.º 1
0
    public static PlayerItem Creat(string item)
    {
        Debug.Log("Creat from:   " + item);
        var Part1 = item.Split(MDEL);
        var Part2 = Part1[1].Split(DELEM);
        Slot slot = (Slot) Convert.ToInt32(Part2[0]);
        bool isRare = Convert.ToBoolean(Part2[1]);
        string icon = Part2[2];
        string name = Part2[3];
        int cost = Convert.ToInt32(Part2[4]);
        bool isEquped = Convert.ToBoolean(Part2[5]);

        var firstPart = Part1[0].Split(DELEM);
        Dictionary<ParamType, float> itemParameters = new Dictionary<ParamType, float>();
        //Debug.Log(">>>Part1[0]   " + Part1[0]);
        foreach (var s in firstPart)
        {
            if (s.Length < 3)
                break;
            var pp = s.Split(DPAR);
            ParamType type = (ParamType)Convert.ToInt32(pp[0]);
            float value = Convert.ToSingle(pp[1]);
            itemParameters.Add(type,value);
        }
        PlayerItem playerItem = new PlayerItem(itemParameters, slot, isRare, cost, isEquped, name, icon);
        //Debug.Log(">>>Part3[0]   :" + Part3.ToString());
        var Part3 = Part1[2];
        var spec = (SpecialAbility) Convert.ToInt32(Part3.ToString());
        playerItem.specialAbilities = spec;
        playerItem.LoadTexture();
        return playerItem;
    }