Esempio n. 1
0
    public void LoadAchivementConditionDatas()
    {
        CsvReader reader = LoadCSVtoPath("UI/AchievementCondition");

        if (reader == null)
        {
            return;
        }

        string[] headers                    = reader.GetFieldHeaders();
        int      index_id                   = System.Array.IndexOf(headers, "id");
        int      index_parent               = System.Array.IndexOf(headers, "parent");
        int      index_order                = System.Array.IndexOf(headers, "order");
        int      index_level                = System.Array.IndexOf(headers, "level");
        int      index_counter              = System.Array.IndexOf(headers, "counter");
        int      index_condition            = System.Array.IndexOf(headers, "condition");
        int      index_reward_kingdom_point = System.Array.IndexOf(headers, "reward kingdom_point");
        int      index_reward_exp           = System.Array.IndexOf(headers, "reward exp");
        int      index_reward_gold          = System.Array.IndexOf(headers, "reward gold");
        int      index_reward_cash          = System.Array.IndexOf(headers, "reward cash");
        int      index_reward_food          = System.Array.IndexOf(headers, "reward food");
        int      index_reward_items         = System.Array.IndexOf(headers, "reward items");
        int      index_option               = System.Array.IndexOf(headers, "option");

        AchivementConditionDatas.Clear();

        while (reader.ReadNextRecord())
        {
            AchivementConditionData data = new AchivementConditionData();

            data.Set(reader[index_id],
                     reader[index_parent], reader[index_order], reader[index_level],
                     reader[index_counter],
                     reader[index_condition], reader[index_reward_kingdom_point],
                     reader[index_reward_exp], reader[index_reward_gold],
                     reader[index_reward_cash], reader[index_reward_food],
                     reader[index_reward_items],
                     reader[index_option]);

            AchivementConditionDatas.Add(reader[index_id], data);
        }
    }
Esempio n. 2
0
    public void Set(int order, AchivementConditionData conditionData, VIPInfo vipInfo)
    {
        Reward            reward = new Reward();
        List <RewardItem> items  = reward.GetItems();

        label_Vip_Level.text = order.ToString();

        if (conditionData._reward_items.Length != 0)
        {
            // split items
            string[] str_Items = conditionData._reward_items.Split('\n');

            for (int i = 0; i < str_Items.Length; i++)
            {
                RewardItem rewardItem = new RewardItem();

                //split itemKind, Id, count
                string[] item = str_Items[i].Split(' ');

                if (item[0] == "HeroLetter")
                {
                    rewardItem.itemKind = "HeroLetter";
                    rewardItem.itemId   = item[1];
                    rewardItem.star     = item[2];
                    rewardItem.count    = 1;
                }
                else
                {
                    rewardItem.itemKind = "GameItemType";
                    rewardItem.itemId   = item[0];
                    rewardItem.count    = uint.Parse(item[1]);
                }
                items.Add(rewardItem);
            }
        }
        //split end

        // check overlap
        items.Sort(SortByID);
        for (int j = items.Count - 1; j > 0; j--)
        {
            if (items[j].itemId == items[j - 1].itemId)
            {
                items[j - 1].count += items[j].count;
                items.Remove(items[j]);
            }
        }

        RewardItem goods = new RewardItem();

        if (conditionData._reward_gold > 0)
        {
            goods.count  = conditionData._reward_gold;
            goods.itemId = "hud_gold";
        }
        else if (conditionData._reward_food > 0)
        {
            goods.count  = conditionData._reward_food;
            goods.itemId = "icon_bread";
        }
        else if (conditionData._reward_cash > 0)
        {
            goods.count  = conditionData._reward_cash;
            goods.itemId = "ui_cash";
        }
        goods.itemKind = "";
        items.Add(goods);
        SetRewardItemBox(reward);

        SetDaily(vipInfo);

        // mask
        if (!VIPRewardPanel.Instance.CheckVipRewarded(order - 1))
        {
            mask.SetActive(false);
        }
        else
        {
            mask.SetActive(true);
        }
    }