|
|
- -- require("game.proto.425.Require425")
- require("game.adventureBook.AdventureBookView")
- require("game.adventureBook.AdventureBookDetailView")
- require("game.adventureBook.AdventureBookItem")
- require("game.adventureBook.AdventureBookDetailItem")
- require("game.adventureBook.AdventureBookModel")
-
- AdventureBookController = AdventureBookController or BaseClass(BaseController)
-
- function AdventureBookController:__init()
- AdventureBookController.Instance = self
-
- self.model = AdventureBookModel:getInstance()
-
- self:RegisterAllProtocals()
- self:InitEvent()
- end
-
- function AdventureBookController:RegisterAllProtocals()
- -- self:RegisterProtocal(42500,"handler42500") --错误码
- -- self:RegisterProtocal(42501,"handler42501") --未激活的冒险之书
- -- self:RegisterProtocal(42502,"handler42502") --冒险之书信息列表
- -- self:RegisterProtocal(42503,"handler42503") --激活冒险之书
- -- self:RegisterProtocal(42504,"handler42504") --更新冒险之书信息
- end
-
- function AdventureBookController:InitEvent()
- --打开界面
- local function open_func(bool, type)
- if not self.AdventureBookView then
- self.AdventureBookView = AdventureBookView.New()
- end
- if bool then
- if not self.AdventureBookView:HasOpen() then
- self.AdventureBookView:Open(type)
- end
- else
- if self.AdventureBookView:HasOpen() then
- self.AdventureBookView:Close()
- end
- end
- end
- GlobalEventSystem:Bind(EventName.OPEN_ADVENTURE_BOOK_VIEW, open_func)
-
- local function open_detail_func(type, subtype,is_close)
- if is_close then
- if self.AdventureBookDetailView then
- self.AdventureBookDetailView:Close()
- return
- end
- end
- if not self.AdventureBookDetailView then
- self.AdventureBookDetailView = AdventureBookDetailView.New()
- end
- if not self.AdventureBookDetailView:HasOpen() then
- self.AdventureBookDetailView:Open(type, subtype)
- end
- end
- self.model:Bind(AdventureBookModel.UPDATE_ADVENTURE_BOOK_DETAIL_VIEW, open_detail_func)
-
- -- local function onGameStart()
- -- self.model:Fire(AdventureBookModel.REQUEST_PROTOCAL, 42501)
- -- self.model:Fire(AdventureBookModel.REQUEST_PROTOCAL, 42502, AdventureBookType.MAP)
- -- end
- -- GlobalEventSystem:Bind(EventName.GAME_START, onGameStart)
-
- -- local function requset_func(...)
- -- local args = {...}
- -- if args[1] == 42502 then
- -- self:SendFmtToGame(args[1], "c", args[2])
- -- elseif args[1] == 42503 then
- -- self:SendFmtToGame(args[1], "cc", args[2], args[3])
- -- else
- -- self:SendFmtToGame(args[1])
- -- end
- -- end
- -- self.model:Bind(AdventureBookModel.REQUEST_PROTOCAL, requset_func)
- end
-
- function AdventureBookController:handler42500()
- local scmd = SCMD42500.New(true)
- ErrorCodeShow(scmd.error_code, scmd.args)
- end
-
- function AdventureBookController:handler42501()
- local scmd = SCMD42501.New(true)
- self.model:SetUnActiveList(scmd.list)
- end
-
- function AdventureBookController:handler42502()
- local scmd = SCMD42502.New(true)
- self.model:SetBookInfo(scmd)
- self.model:Fire(AdventureBookModel.UPDATE_ADVENTURE_BOOK_INFO, scmd.type)
- end
-
- function AdventureBookController:handler42503()
- local scmd = SCMD42503.New(true)
- if scmd.error_code == 1 then
- self.model:RemoveActiveBook(scmd.type, scmd.subtype)
- local cfg = Config.Adventurebook[scmd.type.."@"..scmd.subtype]
- if cfg then
- local attr = ErlangParser:GetInstance():Parse(cfg.attr)
- if attr then
- GlobalEventSystem:Fire(EventName.OPEN_UPGRADE_SHOW_VIEW, 8, 1, "adv_text_"..scmd.type.."_"..scmd.subtype, "activate_book_"..scmd.type.."_"..scmd.subtype, GetFighting(attr), nil, cfg.attr)
- end
- end
- else
- ErrorCodeShow(scmd.error_code)
- end
- end
-
- function AdventureBookController:handler42504()
- local scmd = SCMD42504.New(true)
- self.model:UpdateBookInfo(scmd.update_list)
- end
|