|
CSGWarOverlordView = CSGWarOverlordView or BaseClass(BaseView)
|
|
local CSGWarOverlordView = CSGWarOverlordView
|
|
|
|
function CSGWarOverlordView:__init()
|
|
self.base_file = "CSGWar"
|
|
self.layout_file = "CSGWarOverlordView"
|
|
self.layer_name = "UI"
|
|
self.destroy_imm = true
|
|
self.use_background = true --全屏界面默认使用这个参数
|
|
self.hide_maincancas = true --全屏界面需要放开隐藏主UI
|
|
self.change_scene_close = true
|
|
self.append_to_ctl_queue = true --是否要添加进界面堆栈
|
|
self.need_show_money = true --是否要显示顶部的金钱栏
|
|
self.blur_activity_bg = true
|
|
self.close_fog = true
|
|
|
|
self.model = CSGWarModel:getInstance()
|
|
|
|
self.load_callback = function ()
|
|
self:LoadSuccess()
|
|
end
|
|
self.open_callback = function ( )
|
|
self:OpenSuccess()
|
|
end
|
|
self.switch_callback = function(index)
|
|
self:SwitchTab(index)
|
|
end
|
|
self.destroy_callback = function ( )
|
|
self:DestroySuccess()
|
|
end
|
|
end
|
|
|
|
function CSGWarOverlordView:Open( )
|
|
--self.data = data
|
|
BaseView.Open(self)
|
|
end
|
|
|
|
function CSGWarOverlordView:LoadSuccess()
|
|
local nodes = {
|
|
"role_con2", "bg:raw", "role_con1", "role_con3", "buy_btn/price_text:tmp", "buy_btn:obj:imgex", "close_btn:obj",
|
|
"name_text1:tmp","tip_text:obj",
|
|
"name_text2:tmp",
|
|
"name_text3:tmp","con_money","image:obj",
|
|
}
|
|
self:GetChildren(nodes)
|
|
self:AddEvent()
|
|
self:CreateMoneyView()
|
|
lua_resM:setOutsideRawImage(self,self.bg_raw,GameResPath.GetViewBigBg("csgwar_overlord_bg"),false)
|
|
local function bg_back_func( ... )
|
|
if self.background_wnd and self.background_wnd:GetComponent("RawImageExtend") then
|
|
self:MoveUIToBack(self.background_wnd:GetComponent("RawImageExtend"))
|
|
self:MoveUIToBack(self.bg_raw)
|
|
end
|
|
end
|
|
if self.background_wnd then
|
|
bg_back_func()
|
|
else
|
|
self.bg_back_func = bg_back_func
|
|
end
|
|
end
|
|
|
|
function CSGWarOverlordView:AddEvent()
|
|
local function on_close( )
|
|
self:Close()
|
|
end
|
|
AddClickEvent(self.close_btn_obj,on_close)
|
|
|
|
local function on_buy( )
|
|
local is_overlord = RoleManager.Instance.mainRoleInfo.is_overlord
|
|
if is_overlord == 1 then
|
|
self:DoBuy()
|
|
else
|
|
Message.show("仅限霸主购买哦~")
|
|
end
|
|
end
|
|
AddClickEvent(self.buy_btn_obj, on_buy)
|
|
end
|
|
|
|
function CSGWarOverlordView:OpenSuccess()
|
|
self:UpdateView()
|
|
end
|
|
|
|
function CSGWarOverlordView:UpdateView()
|
|
local data = self.model:GetCSGWarOverlordInfo()
|
|
self.can_buy = data.is_buy == 1
|
|
for i,v in ipairs(data.reward) do
|
|
self:SetModel(v,i)
|
|
end
|
|
self.type1_cost = data.price[1].num
|
|
local str = string.format("%s%s",WordManager:GetMoneyFaceStr( data.price[1].type ),data.price[1].num)
|
|
self.price_text_tmp.text = str
|
|
self.buy_btn_imgex.gray = RoleManager.Instance.mainRoleInfo.is_overlord ~= 1 or not self.can_buy
|
|
self.tip_text_obj:SetActive(RoleManager.Instance.mainRoleInfo.is_overlord ~= 1 or not self.can_buy)
|
|
self.image_obj:SetActive(RoleManager.Instance.mainRoleInfo.is_overlord == 1 and self.can_buy)
|
|
end
|
|
|
|
function CSGWarOverlordView:SetModel( data,index )
|
|
local basic = GoodsModel:getInstance():GetGoodsBasicByTypeId(data.type_id)
|
|
if not basic then
|
|
print("not goods db data: ",data.type_id)
|
|
return
|
|
end
|
|
self["name_text"..index.."_tmp"].text = Trim(basic.goods_name)
|
|
if basic.type == GoodsModel.TYPE.FASHION then
|
|
local fashion_id,color_id = FashionModel:getInstance():GetFashionIdByGoodsId(data.type_id)
|
|
local cur_cfg = Config.Fashionstarup[fashion_id.."@"..color_id.."@0"]
|
|
local career = RoleManager.Instance.mainRoleInfo.career
|
|
local fashion_type = FuncOpenModel.TypeId.Clothes
|
|
local figure_id = nil
|
|
if fashion_id then
|
|
if cur_cfg.pos_id == FashionModel.FashionType.HAT then--头饰
|
|
career = 0 --目前头饰 是通用的
|
|
figure_id = FashionModel:GetInstance():GetFashionModelId(fashion_id, career, color_id)
|
|
fashion_type = FuncOpenModel.TypeId.Hat
|
|
elseif cur_cfg.pos_id == FashionModel.FashionType.CLOTHES then--服饰
|
|
figure_id = FashionModel:GetInstance():GetFashionModelId(fashion_id, career, color_id)
|
|
if figure_id < 1000 then
|
|
figure_id = figure_id + career * 1000
|
|
end
|
|
if color_id > 1 then
|
|
figure_id = figure_id .. color_id
|
|
end
|
|
elseif cur_cfg.pos_id == FashionModel.FashionType.WING then--背饰
|
|
figure_id = FashionModel:GetInstance():GetFashionModelId(fashion_id, career, color_id)
|
|
fashion_type = FuncOpenModel.TypeId.wing
|
|
elseif cur_cfg.pos_id == FashionModel.FashionType.WEAPON then--武器
|
|
fashion_type = FuncOpenModel.TypeId.Weapon
|
|
figure_id = FashionModel:GetInstance():GetFashionModelId(fashion_id, career, color_id)
|
|
if figure_id < 1000 then
|
|
figure_id = figure_id + career * 1000
|
|
end
|
|
elseif cur_cfg.pos_id == FashionModel.FashionType.HEAD then--头发
|
|
fashion_type = FuncOpenModel.TypeId.Head
|
|
figure_id = FashionModel:GetInstance():GetFashionModelId(fashion_id, career, color_id)
|
|
if figure_id < 1000 then
|
|
figure_id = figure_id + career * 1000
|
|
end
|
|
if color_id > 1 then
|
|
figure_id = figure_id .. color_id
|
|
end
|
|
end
|
|
end
|
|
local res_data = {
|
|
father_node = self,
|
|
transform = self["role_con"..index],
|
|
fashion_type = fashion_type,
|
|
layer_name = self.layer_name,
|
|
size = Vector2(720,720),
|
|
scale = 150,
|
|
figure_id = figure_id,
|
|
ui_model_type = UIModelCommon.ModelType.Model,
|
|
position = Vector3(0,-100,0)
|
|
}
|
|
FuncOpenModel:getInstance():SetModelRes(res_data)
|
|
elseif basic.type == GoodsModel.TYPE.FosterSkin then
|
|
--珍宝
|
|
local show_conf = ShapeModel:GetInstance():GetConfByGoodsId( data.type_id )
|
|
local res_data = {
|
|
father_node = self,
|
|
transform = self["role_con"..index],
|
|
fashion_type = show_conf.type + 1000,
|
|
layer_name = self.layer_name,
|
|
size = Vector2(720,720),
|
|
scale = 150,
|
|
figure_id = show_conf.model,
|
|
ui_model_type = UIModelCommon.ModelType.Model,
|
|
position = Vector3(0,-50,0)
|
|
}
|
|
FuncOpenModel:getInstance():SetModelRes(res_data)
|
|
end
|
|
end
|
|
|
|
function CSGWarOverlordView:CreateMoneyView( )
|
|
if not self.money_view then
|
|
self.money_view = UIMoneyView.New(self.con_money)
|
|
end
|
|
self.money_view:SetPosition(0,0)
|
|
self.money_view:SetData()
|
|
end
|
|
|
|
|
|
function CSGWarOverlordView:DoBuy( )
|
|
local function ok_callback()
|
|
self.model:Fire(CSGWarConst.REQ_CSGWAR_SCMD, 60123)
|
|
end
|
|
local priceText = string.format("<color=%s>%s</color> 彩钻购买", ColorUtil.YELLOW_DARK, self.type1_cost)
|
|
local data = {
|
|
insufficientText = "",
|
|
price = self.type1_cost,
|
|
priceText = priceText,
|
|
titleText = "提示",
|
|
ok_callback = ok_callback,
|
|
no_need_toggle = false,
|
|
}
|
|
if not self.can_buy then
|
|
ok_callback()
|
|
else
|
|
GlobalEventSystem:Fire(EventName.OPEN_COM_TOGGLE_TIP_VIEW, data)
|
|
end
|
|
end
|
|
|
|
function CSGWarOverlordView:DestroySuccess( )
|
|
if self.money_view then
|
|
self.money_view:DeleteMe()
|
|
self.money_view = nil
|
|
end
|
|
end
|