hch
7 小时以前 5b8a8c82864d4ea7e2f93484bd26f293dd31979d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
 
public class CommonFunc
{
    public static Dictionary<int, long> AddDict(Dictionary<int, long> dic1, Dictionary<int, long> dic2)
    {
        var resultDic = new Dictionary<int, long>(dic1);
        foreach (var data in dic2)
        {
            if (resultDic.ContainsKey(data.Key))
            {
                resultDic[data.Key] = resultDic[data.Key] + data.Value;
                continue;
            }
            resultDic[data.Key] = data.Value;
        }
        return resultDic;
    }
 
 
 
    public static List<Item> ChangeToItemList(Dictionary<int, long> dict)
    {
        List<Item> itemlist = new List<Item>();
        if (dict == null)
            return itemlist;
        foreach (var data in dict)
        {
            itemlist.Add(new Item(data.Key, data.Value));
        }
        return itemlist;
    }
}