HeadInfo.lua
1.78 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
cc.exports.HeadInfo = {}
local xml = require("core.utils.pl.xml")
local headList = {};
local headFrameList = {};
local create_reward = "";
function init()
local configStr = cc.FileUtils:getInstance():getStringFromFile("res/config/head.xml");
local data = xml.parse(configStr, false, true);
headList = {};
headFrameList = {};
for k,v in pairs(data) do
if k ~= "attr" and k ~= "tag" then
if v.tag == "head" then
headList[#headList+1] = {id=tonumber(v.attr.id),needCard=tonumber(v.attr.needCard),sex=tonumber(v.attr.sex)};
elseif v.tag == "headFrame" then
local needScore = 0;
local needCharm = 0;
if v.attr.needScore then
needScore = tonumber(v.attr.needScore);
end
if v.attr.needCharm then
needCharm = tonumber(v.attr.needCharm);
end
headFrameList[#headFrameList+1] = {id=tonumber(v.attr.id),needScore=needScore,needCharm=needCharm};
end
end
end
end
init();
--通过ID获取头像信息
function HeadInfo.getHeadInfo(id)
local info = nil;
for i,v in ipairs(headList) do
if v.id == id then
info = v;
end
end
return info;
end
--通过头像列表
function HeadInfo.headList()
return headList;
end
function HeadInfo.freeHeadList()
local arr = {};
for i,v in ipairs(headList) do
if v.needCard == 0 then
arr[#arr + 1] = v;
end
end
return arr;
end
--通过ID获取头像信息
function HeadInfo.getHeadFrameInfo(id)
local info = nil;
for i,v in ipairs(headFrameList) do
if v.id == id then
info = v;
end
end
return info;
end
return HeadInfo