Exemple #1
0
        public static List <ItemInfomation> LoadItemInfomation(string path)
        {
            TextAsset textAsset = (TextAsset)Resources.Load("data");

            List <ItemInfomation> itemInfomationList = new List <ItemInfomation>();

            // 解析jsonnode 文件
            foreach (JSONNode product in JSONNode.Parse(textAsset.text)["dailyProduct"])
            {
                ItemInfomation itemInfomation = new ItemInfomation();
                itemInfomation.rewardType  = (RewardType)(int)product["type"];
                itemInfomation.num         = product["num"];
                itemInfomation.type        = product["type"];
                itemInfomation.isPurchased = product["isPurchased"];
                if ((RewardType)(int)product["type"] == RewardType.Cards)
                {
                    // 存储专属与人物卡片的信息
                    itemInfomation.productId = product["productId"];
                    itemInfomation.subType   = product["subType"];
                    itemInfomation.costGold  = product["costGold"];
                }

                itemInfomationList.Add(itemInfomation);
            }
            return(itemInfomationList);
        }
Exemple #2
0
    void Start()
    {
        // 加载数据,初始化UI信息
        itemInfomation = JsonController.LoadItemInfomation("ranklist");
        InitTitle();

        // 列表item更新回调
        scrollList.ItemCallback = UpdateItem;// 设置数据,此时列表会执行更新
        scrollList.RowCount     = itemInfomation.rankList.Count;
    }
Exemple #3
0
    public static ItemInfomation LoadItemInfomation(string path)
    {
        TextAsset textAsset = (TextAsset)Resources.Load(path);

        // 新建并初始化
        ItemInfomation itemInfomation = new ItemInfomation();

        itemInfomation.rankList  = new List <RankInfomation>();
        itemInfomation.countDown = JSONNode.Parse(textAsset.text)["countDown"];
        itemInfomation.seasonID  = JSONNode.Parse(textAsset.text)["seasonID"];
        itemInfomation.selfRank  = JSONNode.Parse(textAsset.text)["selfRank"];


        // 添加list内容
        RankInfomation rankInfomation;

        foreach (JSONNode rank in JSONNode.Parse(textAsset.text)["list"])
        {
            rankInfomation             = new RankInfomation();
            rankInfomation.uid         = rank["uid"];
            rankInfomation.nickName    = rank["nickName"];
            rankInfomation.avatar      = rank["avatar"];
            rankInfomation.trophy      = rank["trophy"];
            rankInfomation.thirdAvatar = rank["thirdAvatar"];
            rankInfomation.role        = rank["role"];
            rankInfomation.abb         = rank["abb"];
            itemInfomation.rankList.Add(rankInfomation);
        }

        // 给排行榜排序
        itemInfomation.rankList.Sort((x, y) =>
        {
            if (x.trophy > y.trophy)
            {
                return(-1);
            }
            if (x.trophy == y.trophy)
            {
                return(0);
            }
            return(1);
        });

        // 排完顺序,标号
        for (int i = 0; i < itemInfomation.rankList.Count; ++i)
        {
            itemInfomation.rankList[i].rank = i + 1;
        }
        return(itemInfomation);
    }
    public Player(string id, string Name, int hp, int mp, int atk, int def, int StartLv)
    {
        Debug.Log("플레이어 클래스 진입");
        PlayerID     = id;
        PlayerLevel  = StartLv;
        PlayerExp    = 0;
        PlayerExpMax = 100 * _Lv;

        NAME = Name;
        HP   = HPMAX = hp;
        MP   = MPMAX = mp;
        ATK  = atk;
        DEF  = def;

        PlayerItem  = new ItemInfomation();
        SelectSkill = (int)SkilleType.NML_SK;
    }
Exemple #5
0
    // 根据json文件设置信息,例如:是否购买等;并更新UI的购买状态
    public void Initialize(ItemInfomation itemInfomation)
    {
        this.itemInfomation = itemInfomation;
        // 调整字号
        itemUI.name.fontSize = itemUIConfig.fontSize;
        // 金币和钻石都需要调整:名称、字体颜色、整个卡片背景、图标背景
        if (itemInfomation.rewardType == RewardType.Coins || itemInfomation.rewardType == RewardType.Diamonds)
        {
            itemUI.name.text  = itemInfomation.rewardType.ToString();
            itemUI.name.color = itemUIConfig.coinsUIConfig.coinsNameFontColor;
            itemUI.cardBackgroundImage.sprite = itemUIConfig.coinsUIConfig.cardBackgroundImage;
            itemUI.iconBackgroundImage.sprite = itemUIConfig.coinsUIConfig.iconBackgroundImage;
        }
        // 进一步调整UI配置
        switch (itemInfomation.rewardType)
        {
        case RewardType.Coins:
            // 更换金币的图标
            itemUI.iconFront.sprite = itemUIConfig.coinsUIConfig.iconCoins;
            break;

        case RewardType.Diamonds:
            // 更换钻石的图标
            itemUI.iconFront.sprite = itemUIConfig.coinsUIConfig.iconDiamonds;
            break;

        case RewardType.Cards:
            // 设定金币消耗量
            itemUI.costText.text = itemInfomation.costGold.ToString();
            // 更新名称,以及名称的颜色
            itemUI.name.text  = (string)GetInformationBySubType <string>(itemInfomation.subType);
            itemUI.name.color = itemUIConfig.characterUIConfig.nameFontColor;
            // 更新人物的图片
            itemUI.iconFront.sprite = (Sprite)GetInformationBySubType <Sprite>(itemInfomation.subType);
            break;
        }

        // 已购买时: isPurchased != -1; 此时激活购买画面
        ActivePurchasedPanel(itemInfomation.isPurchased != -1);
        gameObject.SetActive(true);
    }