|
|
- TurnCareerView = TurnCareerView or BaseClass(BaseView)
-
- function TurnCareerView:__init()
- self.base_file = "mainRole"
- self.layout_file = "TurnCareerView"
- self.layer_name = "UI"
- self.append_to_ctl_queue = true --添加进入控制队列
- self.use_background = true -- 窗口背景 用灰色半透明背景
-
- self.model = MainRoleModel:getInstance()
- self.event_list = {}
- self.mainVo = RoleManager.Instance.mainRoleInfo
-
- self.turn_id = 38040027
- self.enough = false
- self.state = nil
-
- self.load_callback = function()
- self:LoadSuccess()
- self:InitEvent()
- end
-
- self.open_callback = function()
- self.model:Fire(MainRoleModel.SEND_TURN_CAREER_PROTOCAL, 13046)
- self:SetDescription()
- self:SetConsumable()
- end
-
- self.close_callback = function()
-
- end
-
- self.destroy_callback = function()
- self:Remove()
- end
- end
-
- function TurnCareerView:Remove()
- self:CancelCountDown()
-
- for i, v in ipairs(self.event_list) do
- self.model:UnBind(v)
- end
- self.event_list = {}
-
- if self.consumable_item then
- self.consumable_item:DeleteMe()
- self.consumable_item = nil
- end
-
- if self.goods_event_cbl then
- GoodsModel:getInstance():UnBind(self.goods_event_cbl)
- self.goods_event_cbl = nil
- end
- end
-
- function TurnCareerView:LoadSuccess()
- self.bg = self:GetChild("bg"):GetComponent("Image")
- lua_resM:setOutsideImageSprite(self, self.bg, GameResPath.GetJpgImage("bg_turncareer.jpg"))
-
- self.description = self:GetChild("scrollView/Viewport/Content"):GetComponent("Text")
- self.countdown = self:GetChild("countdown"):GetComponent("Text")
- self.turnBtn = self:GetChild("turnBtn").gameObject
- self.turnBtn_image = self:GetChild("turnBtn"):GetComponent("Image")
- self.turnBtn_image_2 = self:GetChild("turnBtn/image"):GetComponent("Image")
- self.effect = self:GetChild("effect")
-
- self.consumable_item = ShowIconItem.New(self:GetChild("consumable"))
- end
-
- function TurnCareerView:InitEvent()
- local function OnClick(target)
- if target == self.turnBtn then
- if self.state == 0 then --正常转职
- if self.enough then
- local function ok_callback()
- local sex
- if self.mainVo.sex == 1 then
- sex = 2
- elseif self.mainVo.sex == 2 then
- sex = 1
- end
- self.model:Fire(MainRoleModel.SEND_TURN_CAREER_PROTOCAL, 13045, self.mainVo.career, sex)
- end
- Alert.show("是否确认变性?\n成功后1小时内无法再次变性",Alert.Type.Two, ok_callback)
- else
- local function ok_callback()
- GlobalEventSystem:Fire(EventName.OPEN_SHOP_VIEW, 2, self.turn_id)
- end
- Alert.show("您的变性秘卷不足,是否前往商城购买?",Alert.Type.Two, ok_callback)
- end
- elseif self.state == 1 then --冷却期
- Message.show("处于变性冷却期内,无法变性")
- end
- end
- end
- AddClickEvent(self.turnBtn, OnClick)
-
- --刷新消耗
- self.goods_event_cbl = GoodsModel:getInstance():Bind(GoodsModel.CHANGE_BAGLIST, function()
- if self._use_delete_method then return end
- self:SetConsumable()
- end)
-
- table.insert(self.event_list, self.model:Bind(MainRoleModel.GET_TURN_CAREER_TIME, function(time)
- self:SetState(time)
- end))
-
- --[[table.insert(self.event_list, self.model:Bind(MainRoleModel.TURN_CAREER_SUCCESS, function(career, sex)
- --self:AddUIEffect("effect_zhuanzhichenggong_00"..sex, self.effect, self.layer_name, nil, nil, false)
- end))--]]
- end
-
- function TurnCareerView:SetConsumable()
- if self.turn_id then
- self.consumable_item:SetData(self.turn_id)
- local enough, str = EquipModel:getInstance():GetConsumableNum({0, self.turn_id, 1})
- self.consumable_item:SetItemNum(str)
- self.consumable_item:SetGray(not enough)
- --self.consumable_item:IsGetGoods(not enough)
- self.enough = enough
- end
- end
-
- function TurnCareerView:SetState(time)
- local now_time = TimeUtil:getServerTime()
- local bool = time > now_time
-
- self.turnBtn_image.gray = bool
- self.turnBtn_image_2.gray = bool
- if bool then
- self.state = 1
- self:StartCountDown(time)
- else
- self.state = 0
- self:CancelCountDown()
- end
- end
-
- function TurnCareerView:StartCountDown(time)
- if not self.timer then
- local function countdown()
- local re_time = time - TimeUtil:getServerTime()
- if re_time > 0 then
- self.countdown.text = "<color=#ff3232>变性冷却:"..TimeUtil:timeConversion(re_time, "MM-ss").."</color>"
- else
- self:SetState(time)
- end
- end
- self.countdown.text = "<color=#ff3232>变性冷却:"..TimeUtil:timeConversion(time - TimeUtil:getServerTime(), "MM-ss").."</color>"
- self.timer = GlobalTimerQuest:AddPeriodQuest(countdown, 1, -1)
- end
- end
-
- function TurnCareerView:CancelCountDown()
- if self.countdown then
- self.countdown.text = ""
- end
- if self.timer then
- GlobalTimerQuest:CancelQuest(self.timer)
- self.timer = nil
- end
- end
-
- function TurnCareerView:SetDescription()
- self.description.text = self:GetDescription()
- self.description.transform.sizeDelta = Vector2(self.description.transform.sizeDelta.x, self.description.preferredHeight)
- end
-
- function TurnCareerView:GetDescription()
- return "\n1、装备:<color=#48f07b>身上穿戴的装备</color>会转化为新性别装备,继承所有属性;背包、仓库、市场、邮件内的装备不会转化\n"
- .."\n\n2、技能:主动技能和被动技能——转化,<color=#48f07b>天赋技能全部重置,返还所有天赋点</color><color=#ff6262>(重置后战力降低,重新加天赋后战力回归)</color>\n"
- .."\n\n3、称号、时装都将转化为新性别,魅力榜信息更新\n"
- .."\n\n4、套装:已穿戴的套装会转化为新性别,但背包、仓库、市场、邮件内的套装石不会转化\n"
- end
|