Пример #1
0
    public void SetBoxingList()
    {
        BoxingViewData min = null;
        //筛选第一个
        Hashtable h = new Hashtable();

        System.Collections.IDictionaryEnumerator enumerator = UserManager.Instance.boxTable.GetEnumerator();
        while (enumerator.MoveNext())
        {
            BoxingViewData r = UserManager.Instance.boxTable[enumerator.Key] as BoxingViewData;
            r.sort = GetSort(r);
            if (min == null)
            {
                min = r;
            }
            else
            {
                if (r.sort < min.sort)
                {
                    min = r;
                }
            }
            if (r.data.comm == 2 && r.data.csv_id == pop.curRoleView.data.starData.skill_csv_id)
            {
                h.Add(r.data.csv_id, r);
            }
            else
            {
                h.Add(r.data.csv_id, r);
            }
        }
        pop.SetBoxingList(h);
        pop.curBoxView = pop.GetBoxView(min.data.csv_id);
        SetSelectBoxing(pop.curBoxView);
    }
Пример #2
0
 public void SetBoxingList(Hashtable list)
 {
     while (boxTable.transform.childCount > 0)
     {
         DestroyImmediate(boxTable.transform.GetChild(0).gameObject);
     }
     if (list != null)
     {
         boxViewTable = new Hashtable();
         System.Collections.IDictionaryEnumerator enumerator = UserManager.Instance.RoleTable.GetEnumerator();
         while (enumerator.MoveNext())
         {
             //设置格子 roleTable
             BoxingViewData r = list[enumerator.Key] as BoxingViewData;
             if (r != null)
             {
                 GameObject obj = Instantiate(boxPrefabe);
                 obj.SetActive(true);
                 BoxingView pop = obj.GetComponent <BoxingView>();
                 pop.InitData(r, true);
                 obj.name                 = r.sort.ToString();
                 pop.transform.parent     = boxTable.transform;
                 pop.transform.position   = Vector3.zero;
                 pop.transform.localScale = Vector3.one;
                 if (!boxViewTable.Contains(r.data.csv_id))
                 {
                     boxViewTable.Add(r.data.csv_id, pop);
                 }
             }
         }
         boxScrollView.ResetPosition();
         boxTable.Reposition();
         boxTable.repositionNow = true;
     }
 }
Пример #3
0
 public void RestEquipEmpty(int i)
 {
     equip            = new BoxingEquipData();
     equip.position   = i;
     data             = null;
     icon.spriteName  = "";
     kuang.spriteName = "";
     SetFous(false);
     this.name = "None";
 }
Пример #4
0
    public int GetSort(BoxingViewData r)
    {
        int tt = 1;

        if (r.level < 1)
        {
            tt = 2;
        }
        return((tt * 1000000) + ((100 - r.level) * 1000) + r.data.csv_id);
    }
Пример #5
0
    public void InitBoxingData(C2sSprotoType.user u)
    {
        System.Collections.IDictionaryEnumerator enumerator = GameShared.Instance.boxingTable.GetEnumerator();
        while (enumerator.MoveNext())
        {
            BoxingViewData v = new BoxingViewData();
            v.frag_num = 0;
            v.level    = 0;
            BoxingData r = GameShared.Instance.boxingTable[enumerator.Key] as BoxingData;
            v.data = r;
            int id = (r.csv_id * 1000) + v.level;
            r.levelData = GameShared.Instance.GetBoxingLevelById(id);

            boxTable.Add(v.data.csv_id, v);
        }

        if (u.kungfu_list != null)
        {
            for (int i = 0; i < u.kungfu_list.Count; i++)
            {
                int id = (int)u.kungfu_list[i].csv_id;
                if (id != 0)
                {
                    C2sSprotoType.kungfu_content c = u.kungfu_list[i];
                    if (UserManager.Instance.boxTable.Contains(id))
                    {
                        BoxingViewData v = new BoxingViewData();
                        v.level    = (int)c.k_level;
                        v.frag_num = (int)c.k_sp_num;
                        v.type     = (int)c.k_type;
                        v.data     = GameShared.Instance.GetBoxingById((int)c.csv_id);
                        int levelid = (1000 * v.data.csv_id) + v.level;
                        v.data.levelData = GameShared.Instance.GetBoxingLevelById(levelid);
                        UserManager.Instance.boxTable[v.data.csv_id] = v;
                    }
                    else
                    {
                        BoxingViewData v = new BoxingViewData();
                        v.level    = (int)c.k_level;
                        v.frag_num = (int)c.k_sp_num;
                        v.type     = (int)c.k_type;
                        v.data     = GameShared.Instance.GetBoxingById((int)c.csv_id);
                        int levelid = (1000 * v.data.csv_id) + v.level;
                        v.data.levelData = GameShared.Instance.GetBoxingLevelById(levelid);
                        UserManager.Instance.boxTable.Add(id, v);
                    }
                }
            }
        }
        else
        {
            Debug.Log("kungfu_list空");
        }
    }
Пример #6
0
 public void RestEmpty()
 {
     if (equip != null)
     {
         equip.viewdata = null;
     }
     data             = null;
     icon.spriteName  = "";
     kuang.spriteName = "";
     SetFous(false);
     this.name = "None";
 }
Пример #7
0
    /// <summary>
    /// 拳法装备提升战斗力固定值
    /// </summary>
    /// <param name="attrtype"></param>
    /// <returns></returns>
    public float GetEquipBoxingAttrByType(int attrtype)
    {
        float num = 0;

        for (int i = 0; i < UserManager.Instance.curRole.boxingList.Count; i++)
        {
            BoxingViewData r = UserManager.Instance.curRole.boxingList[i].viewdata as BoxingViewData;
            if (r.data.levelData != null && r.level > 0)
            {
                num += r.data.levelData.equipAttrArr[attrtype];
            }
        }
        return(num);
    }
Пример #8
0
    public double critRate;    //c 暴击几率

    public float GetBoxingEffectPreByType()
    {
        float num = 0;

        for (int i = 0; i < boxingList.Count; i++)
        {
            BoxingViewData r = this.boxingList[i].viewdata as BoxingViewData;
            if (r.data.levelData != null && r.level > 0)
            {
                num += r.data.levelData.effect_pre;
            }
        }
        return(num);
    }
Пример #9
0
    /// <summary>
    /// 拳法手机提升百分比
    /// </summary>
    /// <param name="attrtype"></param>
    /// <returns></returns>
    public float GetBoxingEffectPreByType(int attrtype)
    {
        float num = 0;

        for (int i = 0; i < UserManager.Instance.curRole.boxingList.Count; i++)
        {
            BoxingViewData r = UserManager.Instance.curRole.boxingList[i].viewdata as BoxingViewData;
            if (r.data.levelData != null && r.level > 0)
            {
                num += r.data.levelData.effect_pre;
            }
        }
        return(num);
    }
Пример #10
0
    /// <summary>
    /// 拳法提升战斗力固定值
    /// </summary>
    /// <param name="attrtype"></param>
    /// <returns></returns>
    public float GetBoxingAttrByType(int attrtype)
    {
        float num = 0;

        System.Collections.IDictionaryEnumerator enumerator = UserManager.Instance.boxTable.GetEnumerator();
        while (enumerator.MoveNext())
        {
            BoxingViewData r = UserManager.Instance.boxTable[enumerator.Key] as BoxingViewData;
            if (r.data.levelData != null && r.level > 0)
            {
                num += r.data.levelData.attrArr[attrtype];
            }
        }
        return(num);
    }
Пример #11
0
    public void UpLevelCallback(C2sSprotoType.kungfu_levelup.response resp)
    {
        //拳法升级
        pop.upLevelBtn.isEnabled = true;
        if (resp.errorcode == 1)
        {
            BoxingViewData v = pop.curBoxView.data;

            v.level++;
            int id = (v.data.csv_id * 1000) + v.level;
            v.data.levelData = GameShared.Instance.GetBoxingLevelById(id);

            pop.GetBoxView(v.data.csv_id).data.sort       = GetSort(v);
            pop.GetBoxView(v.data.csv_id).gameObject.name = GetSort(v).ToString();

            UserManager.Instance.SubResByType(v.data.levelData.coin_type, v.data.levelData.coin);
            BagMgr.Instance.SubItemNumById(v.data.levelData.item_id, v.data.levelData.item_num);
            v.frag_num = BagMgr.Instance.GetItemNumById(v.data.levelData.item_id);
            Debug.Log(v.sort + "/" + v.data.csv_id);
            //获得下一级的碎片数
            int             ind = v.data.levelData.g_csv_id + 1;
            BoxingLevelData l   = GameShared.Instance.GetBoxingLevelByIdCon(ind);
            if (v.level < Def.BoxLevelMax)
            {
                //查找背包有多少item
                //v.frag_num = BagMgr.Instance.GetItemNumById(v.data.item_id);
                if (v.frag_num >= l.item_num)
                {
                    v.fra_value = 1.0f;
                }
                else
                {
                    float a = (float)v.frag_num / (float)l.item_num;
                    v.fra_value = a;
                }
            }
            else
            {
                v.fra_value = 1.0f;
            }
            pop.boxingIcon.RestItem(v);
            pop.SetBoxingInfo(v, GetAttr(v.data));
            pop.SetFragNum(v.frag_num + "/" + l.item_num);
            pop.boxTable.Reposition();
            pop.boxTable.repositionNow = true;
        }
    }
Пример #12
0
 public void RestItem(BoxingViewData d)
 {
     if (equip != null)
     {
         equip.viewdata = d;
     }
     data = d;
     SetFous(false);
     if (data != null && data.data != null)
     {
         this.name = d.sort.ToString();
         SetBgQuality(data.data.levelData.quality);
         icon.spriteName = data.data.levelData.skill_icon.ToString();
     }
     else
     {
         RestEmpty();
     }
 }
Пример #13
0
 public void InitData(BoxingViewData d, bool click = true)
 {
     data    = d;
     isClick = click;
     SetFous(false);
     data.view = this;
     if (data.data != null && data.data.levelData != null)
     {
         SetUnlock();
         this.name = d.sort.ToString();
         type      = data.data.levelData.skill_type;
         SetBgQuality(data.data.levelData.quality);
         icon.spriteName = data.data.levelData.skill_icon.ToString();
         SetType(data.data.levelData.skill_type);
     }
     else
     {
         RestEmpty();
     }
 }
Пример #14
0
 public void InitData(BoxingEquipData e, int p, bool click = true)
 {
     equip   = e;
     data    = e.viewdata;
     isClick = click;
     SetFous(false);
     if (data.data != null && data.data.levelData != null)
     {
         SetUnlock();
         this.name = data.sort.ToString();
         type      = data.data.levelData.skill_type;
         SetBgQuality(data.data.levelData.quality);
         icon.spriteName = data.data.levelData.skill_icon.ToString();
         SetType(data.data.levelData.skill_type);
     }
     else
     {
         RestEmpty();
     }
 }
Пример #15
0
    //选中显示
    public void SetSelectBoxing(BoxingView view)
    {
        BoxingViewData v = view.data;

        Debug.Log(v.sort + "/" + v.data.csv_id);
        if (v.frag_num < 1)
        {
            v.frag_num = BagMgr.Instance.GetItemNumById(view.data.data.levelData.item_id);
        }

        int             ind = view.data.data.levelData.g_csv_id;
        BoxingLevelData bld = null;

        if (v.level < Def.BoxLevelMax)
        {
            //查找背包有多少item
            ind++;
            bld = GameShared.Instance.GetBoxingLevelByIdCon(ind);
            if (v.frag_num >= bld.item_num)
            {
                v.fra_value = 1.0f;
            }
            else
            {
                float a = (float)v.frag_num / (float)bld.item_num;
                v.fra_value = a;
            }
        }
        else
        {
            bld         = GameShared.Instance.GetBoxingLevelByIdCon(ind);
            v.fra_value = 1.0f;
        }

        pop.boxingIcon.RestItem(v);
        pop.SetBoxingInfo(v, GetAttr(v.data));
        pop.curBoxView.SetFous(true);
        pop.SetFragNum(v.frag_num + "/" + bld.item_num);
        //CheckBtn();
    }
Пример #16
0
    public bool CheckHaveBoxing(BoxingViewData d)
    {
        bool flag = false;

        for (int i = 0; i < pop.passiveArr.Length; i++)
        {
            if (pop.passiveArr[i].data != null &&
                pop.passiveArr[i].data.data.csv_id == d.data.csv_id)
            {
                flag = true;
            }
        }
        for (int i = 0; i < pop.activeArr.Length; i++)
        {
            if (pop.activeArr[i].data != null &&
                pop.activeArr[i].data.data.csv_id == d.data.csv_id)
            {
                flag = true;
            }
        }
        return(flag);
    }
Пример #17
0
    public void SetBoxingInfo(BoxingViewData data, List <string> strs)
    {
        ItemViewData item = new ItemViewData();

        item.curCount = data.data.levelData.item_num;
        item.data     = GameShared.Instance.GetItemData(data.data.levelData.item_id);
        Debug.Log("id" + data.data.csv_id + "fra" + data.fra_value);
        if (item != null)
        {
            itemIcon.InitData(item, false);
            itemName.text    = item.data.name;
            itemProcess.text = data.frag_num + "/" + data.data.levelData.item_num;
            fraSilder.value  = data.fra_value;
        }
        else
        {
            itemName.text    = "";
            itemProcess.text = "";
            fraSilder.value  = 0;
        }

        //upLevelBtn.isEnabled = data.canUpLevel;

        if (strs != null && strs.Count > 0)
        {
            for (int i = 0; i < strs.Count; i++)
            {
                if (i < attrs.Length)
                {
                    attrs[i].text = strs[i];
                }
            }
        }
        desc.text  = data.data.levelData.skill_desc;
        name.text  = data.data.name;
        level.text = data.data.levelData.skill_level.ToString();
        boxingIcon.InitData(data, false);
    }
Пример #18
0
    //public bool BoxingCanSwap(BoxingView cur)
    //{
    //    bool flag = false;
    //    if (cur != null && cur.data != null && cur.data.level > 0 && pop.curRoleView.data.id)
    //    {

    //    }

    //    return flag;
    //}
    //设置技能
    public bool SwapBoxingList(ref BoxingView v1, ref BoxingView v2, GameObject sourceParent, Vector3 oriPos)
    {
        bool flag = false;//是否回归原位

        if (v1 != null && v1.data != null)
        {
            bool have = CheckHaveBoxing(v1.data);
            if (!have &&
                v1.tag != Def.BoxingSave
                )
            {
                UIWidget w = v1.GetComponent <UIWidget>();
                Debug.Log(w.depth);
                //
                if (v2 != null && v1.data.data.levelData.skill_type == v2.type && v1.tag != Def.BoxingSave && v2.tag == Def.BoxingSave)
                {
                    //移入装备技能
                    v2.RestItem(v1.data);
                    flag = true;
                }
                else if (v2 != null && v2.tag == Def.BoxingSave)//从上面移入装备栏 但类型不对
                {
                    ToastManager.Instance.Show("不可以放这个类型");
                }
                else
                {
                    //在上面的表移动
                    flag = true;
                }
            }
            else if (!have)//不用和才可移入装备
            {
                //交换两个
                BoxingDragView dr = v1.GetComponent <BoxingDragView>();
                if (v2 != null && v2.tag == Def.BoxingSave && dr != null)
                {
                    //在装备技能中移动
                    if (v2.data == null)
                    {
                        v2.RestItem(v1.data);
                        v1.RestEmpty();
                    }
                    else
                    {
                        BoxingViewData temp = v2.data;
                        v2.RestItem(v1.data);
                        v1.RestItem(temp);
                    }
                    v1.gameObject.transform.localPosition = dr.oriPos;
                } //移除
                else
                {//从一个移入一个空的
                    v1.RestEmpty();
                    v1.gameObject.transform.localPosition = dr.oriPos;
                }
            }
            else
            {
                //移除移入的不是下面的装备栏
                if ((v2 == null || v2.tag != Def.BoxingSave) && v1.tag == Def.BoxingSave)
                {
                    v1.RestEmpty();
                    flag = true;
                    v1.gameObject.transform.localPosition = oriPos;
                }
                else if (v2 != null && v1.type == v2.type && v1.tag == Def.BoxingSave && v2.tag == Def.BoxingSave) //同类互换
                {
                    flag = true;
                    v1.gameObject.transform.localPosition = oriPos;
                }
                else
                {
                    //非同类互换
                    if (v1.tag == Def.BoxingSave && v2.tag == Def.BoxingSave && v1.type != v2.type)
                    {
                        flag = true;
                        v1.gameObject.transform.localPosition = oriPos;
                        ToastManager.Instance.Show("不可以放这个类型");
                    }
                    else
                    {
                        //从上面移入装备栏 以存在
                        if ((v2.data == null || v1.data.data.csv_id != v2.data.data.csv_id) && !have)
                        {
                            v1.RestEmpty();
                            flag = true;
                            v1.gameObject.transform.localPosition = oriPos;
                        }
                    }
                }
            }
        }
        else
        {
        }
        pop.boxTable.Reposition();
        pop.boxTable.repositionNow = true;
        return(flag);
    }
Пример #19
0
 public void InitBoxingListCallback(C2sSprotoType.kungfu.response resp)
 {
     //用户拳法表
     if (resp.k_list != null)
     {
         for (int i = 0; i < resp.k_list.Count; i++)
         {
             int id = (int)resp.k_list[i].csv_id;
             C2sSprotoType.kungfu_content c = resp.k_list[i];
             Debug.Log("id" + resp.k_list[i].csv_id + "num" + resp.k_list[i].k_sp_num + "level" + resp.k_list[i].k_level);
             if (UserManager.Instance.boxTable.Contains(id))
             {
                 BoxingViewData v = UserManager.Instance.boxTable[id] as BoxingViewData;
                 v.level    = (int)c.k_level;
                 v.frag_num = (int)c.k_sp_num;
                 v.type     = (int)c.k_type;
                 int levelid = (1000 * v.data.csv_id) + v.level;
                 v.data.levelData = GameShared.Instance.GetBoxingLevelById(levelid);
                 v.sort           = GetSort(v);
                 UserManager.Instance.boxTable[v.data.csv_id] = v;
             }
             else
             {
                 BoxingViewData v = new BoxingViewData();
                 v.level    = (int)c.k_level;
                 v.frag_num = (int)c.k_sp_num;
                 v.type     = (int)c.k_type;
                 v.data     = GameShared.Instance.GetBoxingById((int)c.csv_id);
                 int levelid = (1000 * v.data.csv_id) + v.level;
                 v.sort           = GetSort(v);
                 v.data.levelData = GameShared.Instance.GetBoxingLevelById(levelid);
                 UserManager.Instance.boxTable.Add(id, v);
             }
         }
     }
     //用户角色表
     if (resp.role_kid_list != null)
     {
         roleList = new List <RoleData>();
         for (int i = 0; i < resp.role_kid_list.Count; i++)
         {
             int id = (int)resp.role_kid_list[i].r_csv_id;
             C2sSprotoType.kungfu_role_list c = resp.role_kid_list[i];
             Debug.Log(c.r_csv_id);
             RoleData r = UserManager.Instance.GetRoleById((int)c.r_csv_id);
             if (r != null && resp.role_kid_list[i].pos_list != null)
             {
                 r.boxingList = new List <BoxingEquipData>();
                 for (int j = 0; j < c.pos_list.Count; j++)
                 {
                     int dd = (int)c.pos_list[j].k_csv_id / 1000;
                     Debug.Log("roleid" + resp.role_kid_list[i].r_csv_id + "boxid" + c.pos_list[j].k_csv_id + "pos" + c.pos_list[j].position);
                     BoxingViewData  b  = UserManager.Instance.GetBoxingById(dd);
                     BoxingEquipData eq = new BoxingEquipData();
                     eq.viewdata = b;
                     eq.position = (int)c.pos_list[j].position;
                     r.boxingList.Add(eq);
                 }
             }
             roleList.Add(r);
         }
     }
     if (pop != null && roleList != null)
     {
         RoleListCallBack(ref roleList);
         SetBoxingList();
         SetEquipBoxingList(ref pop.curRoleView.data);
     }
     else
     {
         Debug.Log("用户空");
     }
 }