2018-06-12

---------------------------------------------------GameManager

        LuaManager.DoFile("Logic/GameRoot");
        Util.CallMethod("GameRoot", "OnAwake");

        initialize = true;

---------------------------------------------------------GameRoot
require("Common/define");
require("Common/functions");

require("View/LoginPanel");
require("View/HallPanel");

GameRoot={};
local this = GameRoot;
local transform;

function GameRoot.OnAwake()
print("hello luaFramework");

LoginPanel.New();

end
---------------------------------------------------------------define
CtrlNames = {
Prompt = "PromptCtrl",
Message = "MessageCtrl"
}

PanelNames = {
"PromptPanel",
"MessagePanel",
}

--协议类型--
ProtocalType = {
BINARY = 0,
PB_LUA = 1,
PBC = 2,
SPROTO = 3,
}
--当前使用的协议类型--
TestProtoType = ProtocalType.BINARY;

Util = LuaFramework.Util;
AppConst = LuaFramework.AppConst;
LuaHelper = LuaFramework.LuaHelper;
ByteBuffer = LuaFramework.ByteBuffer;

resMgr = LuaHelper.GetResManager();
panelMgr = LuaHelper.GetPanelManager();
soundMgr = LuaHelper.GetSoundManager();
networkMgr = LuaHelper.GetNetManager();

WWW = UnityEngine.WWW;
GameObject = UnityEngine.GameObject;
Input = UnityEngine.Input;
Sprite = UnityEngine.Sprite;

----------------------------------------------------------HallPanel
HallPanel={};
local this=HallPanel;

--统一new
function HallPanel.New()
panelMgr:CreatePanel("Hall",nil);
end
function HallPanel.OnCreate(go)
--Log("创建成功");
end

function HallPanel.OnBack()
LoginPanel.New(); --开hall
panelMgr:ClosePanel('Hall'); --关login
end

function HallPanel.Awake(go)
log("HallPanel.Awake");
this.gameObject=go;
this.transform=go.transform;
local behavior=this.transform:GetComponent('LuaBehaviour');

this.image = this.transform:Find("Image"):GetComponent('Image');              --加图片

this.backBtn=this.transform:Find("backBtn").gameObject;
behavior:AddClick(this.backBtn,this.OnBack);

end

function HallPanel.Start()
log("HallPanel.Start");

local sp = resMgr:LoadAsset('qiku_asset',"Character",typeof(Sprite)); --加图片音乐等泛型资源
this.image.sprite = sp; --加图片

end
-----------------------------------------------------------------------LoginPane
LoginPanel={};
local this=LoginPanel;

--统一new
function LoginPanel.New()
panelMgr:CreatePanel("Login",nil);
end
function LoginPanel.OnCreate(go)
--Log("创建成功");
end

function LoginPanel.OnClick()
log(this.username.text);

HallPanel.New();   --开hall
panelMgr:ClosePanel('Login');  --关login

end

function LoginPanel.Awake(go)
log("LoginPanel.Awake");
this.gameObject=go;
this.transform=go.transform;
local behavior=this.transform:GetComponent('LuaBehaviour');

this.username=this.transform:Find("UserName"):GetComponent('InputField');
this.password=this.transform:Find("PassWord"):GetComponent('InputField');

this.loginBtn=this.transform:Find("LoginBtn").gameObject;
behavior:AddClick(this.loginBtn,this.OnClick);

end

function LoginPanel.Start()
log("LoginPanel.Start");
end

你可能感兴趣的:(2018-06-12)