Ejemplo n.º 1
0
    public static Extra_Weapon GetExtraMelee(int exId)
    {
        string[][]   strs = ReadTxt.ReadText("extra_melee");
        Extra_Weapon ex   = new Extra_Weapon();

        for (int i = 0; i < strs.Length - 1; i++)
        {
            ex.id = int.Parse(ReadTxt.GetDataByRowAndCol(strs, i + 1, 0));
            if (ex.id != exId)
            {
                continue;
            }

            ex.name = ReadTxt.GetDataByRowAndCol(strs, i + 1, 1);
            string[][] prop = ReadTxt.GetRequire(ReadTxt.GetDataByRowAndCol(strs, i + 1, 2));
            if (prop != null)
            {
                ex.property = new Dictionary <int, float> ();
                for (int j = 0; j < prop.Length; j++)
                {
                    ex.property.Add(int.Parse(prop [j] [0]), float.Parse(prop [j] [1]));
                }
            }
            return(ex);
        }
        Debug.Log("没有找到近战武器后缀--" + exId);
        return(new Extra_Weapon());
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Shows item tips.
    /// </summary>
    /// <param name="itemId">type:0 warehouseCell;1 bpCell in warehouse;2 bpCell in Backpack;3 character Cell;4 character Ammo</param>
    public void ShowNormalTips(int itemId, int type)
    {
        ShowTipPanel();
        ClearCommonTipTexts();

        int  orgId = (int)(itemId / 10000);
        int  ex    = (int)((itemId % 10000) / 1000);
        Mats m     = LoadTxt.MatDic [orgId];

        string itemName = m.name;

        if (itemId % 10000 != 0)
        {
            if (LoadTxt.MatDic [orgId].type == 3)
            {
                itemName += "[" + LoadTxt.GetExtraMelee(ex).name + "]";
            }
            if (LoadTxt.MatDic [orgId].type == 4)
            {
                itemName += "[" + LoadTxt.GetExtraRanged(ex).name + "]";
            }
        }

        commonTipText [0].text  = itemName + ((type == 4) ? (" ×" + GameData._playerData.AmmoNum) : "");
        commonTipText [0].color = GameConfigs.MatColor [m.quality];
        commonTipText[1].text   = m.description;
        commonTipText[1].color  = new Color(24f / 255f, 193f / 255f, 172f / 255f, 1f);
        int i = 4;

        if (m.property != null)
        {
            foreach (int key in m.property.Keys)
            {
                commonTipText [i].text  = PlayerData.GetPropName(key) + " " + (m.property [key] > 0 ? "+" : "-") + m.property [key];
                commonTipText [i].color = Color.white;
                i++;
            }
        }
        else
        {
            commonTipText[i].text   = "Can not use directly.";
            commonTipText [i].color = Color.white;
            i++;
        }

        //附加属性
        string de = "";
        float  p;

        if (itemId % 10000 != 0)
        {
            if (LoadTxt.MatDic [orgId].type == 3)
            {
                Extra_Weapon extraM = LoadTxt.GetExtraMelee(ex);
                foreach (int key in extraM.property.Keys)
                {
                    de  = PlayerData.GetPropName(key) + " ";
                    p   = extraM.property [key];
                    de += (p > 0 ? "+" : "");
                    if (key < 25)
                    {
                        de += p.ToString();
                    }
                    else
                    {
                        de += ((int)(p * 100f)).ToString() + "%";
                    }
                    commonTipText [i].text = de;

                    if (p > 0)
                    {
                        commonTipText [i].color = Color.green;
                    }
                    else
                    {
                        commonTipText [i].color = Color.red;
                    }
                    i++;
                }
            }
            if (LoadTxt.MatDic [orgId].type == 4)
            {
                Extra_Weapon extraR = LoadTxt.GetExtraRanged(ex);
                foreach (int key in extraR.property.Keys)
                {
                    de  = PlayerData.GetPropName(key) + " ";
                    p   = extraR.property [key];
                    de += (p > 0 ? "+" : "-");
                    if (key < 25)
                    {
                        de += p.ToString();
                    }
                    else
                    {
                        de += ((int)(p * 100f)).ToString() + "%";
                    }
                    commonTipText [i].text = de;

                    if (p > 0)
                    {
                        commonTipText [i].color = Color.green;
                    }
                    else
                    {
                        commonTipText [i].color = Color.red;
                    }
                    i++;
                }
            }
        }

        commonTipButton [0].gameObject.GetComponentInChildren <Text> ().text = "Pray";
        commonTipButton [1].gameObject.SetActive(true);
        commonTipButton[2].gameObject.GetComponentInChildren <Text>().text = "Cancel";
        commonTipButton [2].gameObject.SetActive(true);
        switch (type)
        {
        case 0:
            commonTipButton[0].gameObject.SetActive(true);
            commonTipButton[0].gameObject.name = "warehouse_warehouse|" + itemId;
            commonTipButton[1].gameObject.GetComponentInChildren <Text>().text = "Withdraw";
            commonTipButton[1].interactable = true;
            break;

        case 1:
            commonTipButton[0].gameObject.SetActive(true);
            commonTipButton[0].gameObject.name = "warehouse_backpack|" + itemId;
            commonTipButton[1].gameObject.GetComponentInChildren <Text>().text = "Store";
            commonTipButton[1].interactable = true;
            break;

        case 2:
            commonTipButton[0].gameObject.SetActive(true);
            commonTipButton[0].gameObject.name = "backpack_backpack|" + itemId;
            commonTipButton[1].gameObject.GetComponentInChildren <Text>().text = "Use";
            bool canUse = !(m.property == null);
            commonTipButton[1].interactable = canUse;
            break;

        case 3:
        case 4:
            commonTipButton[0].gameObject.SetActive(false);
            commonTipButton[1].gameObject.GetComponentInChildren <Text>().text = "TakeOff";
            commonTipButton[1].interactable = true;
            break;

        default:
            break;
        }
        commonTipButton [1].gameObject.name = itemId.ToString();
    }