yyl
1 天以前 5d3366f2e0f687995eb7ad2107c4379fe7acd4e8
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
using System.Collections.Generic;
using UnityEngine;
 
public class ItemCost
{
    public int itemId;
    public int costNum;
 
    public ItemCost(int _itemId, int _costNum)
    {
        itemId = _itemId;
        costNum = _costNum;
    }
 
    public static List<ItemCost> GetList(int[] array)
    {
        List<ItemCost> retList = new List<ItemCost>();
 
        if (array.Length % 2 != 0)
        {
            Debug.LogError("ItemCost.GetList Failure, because array % 2 != 0");
            return retList;
        }
 
        for (int i = 0; i < array.Length; i += 2)
        {    
            retList.Add(new ItemCost(array[i], array[i+1]));
        }
 
        return retList;
    }
}