Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions Assets/StriveGame/Editor/CustomSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ public static class CustomSettings
//_GT(typeof(KeyValuePair<int, TestAccount>)),
//-------------------------------------------------------------------

_GT(typeof(Debugger)),

_GT(typeof(Debugger)),

_GT(typeof(Color)),
_GT(typeof(Component)),
_GT(typeof(Behaviour)),
_GT(typeof(MonoBehaviour)),
Expand Down Expand Up @@ -82,7 +83,7 @@ public static class CustomSettings
_GT(typeof(KeyCode)),
_GT(typeof(SkinnedMeshRenderer)),
_GT(typeof(Space)),

_GT(typeof(MeshRenderer)),
_GT(typeof(ParticleEmitter)),
_GT(typeof(ParticleRenderer)),
Expand Down Expand Up @@ -114,7 +115,8 @@ public static class CustomSettings
_GT(typeof(InputField)),
_GT(typeof(Toggle)),
_GT(typeof(Scrollbar)),

_GT(typeof(Slider)),

_GT(typeof(Util)),
_GT(typeof(AppConst)),
_GT(typeof(LuaHelper)),
Expand All @@ -135,7 +137,12 @@ public static class CustomSettings
_GT(typeof(KBEngine.PersistentInofs)),
_GT(typeof(EasyJoystick)),
_GT(typeof(MovingJoystick)),
_GT(typeof(NcEffectFlying)),


//UGUI HUD TEXT
_GT(typeof(bl_HUDText)).SetBaseType(typeof(System.Object)),

};

public static List<Type> dynamicList = new List<Type>()
Expand Down
10 changes: 8 additions & 2 deletions Assets/StriveGame/Editor/Packager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,11 @@ public static void BuildAssetResource(BuildTarget target) {
AssetDatabase.Refresh();

maps.Clear();
if (AppConst.LuaBundleMode) {
if (AppConst.LuaBundleMode)
{
HandleLuaBundle();
} else {
}
else {
HandleLuaFile();
}

Expand Down Expand Up @@ -166,9 +168,13 @@ static void HandleResBundle()

AddBuildMap("CreateAvatar" + AppConst.ExtName, "CreateAvatarPanel.prefab", "Assets/StriveGame/Res/View");
AddBuildMap("Login" + AppConst.ExtName, "LoginPanel.prefab", "Assets/StriveGame/Res/View");
AddBuildMap("MessageBox" + AppConst.ExtName, "MessageBoxPanel.prefab", "Assets/StriveGame/Res/View");
AddBuildMap("SelectAvatar" + AppConst.ExtName, "SelectAvatarPanel.prefab", "Assets/StriveGame/Res/View");
AddBuildMap("GameWorld" + AppConst.ExtName, "GameWorldPanel.prefab", "Assets/StriveGame/Res/View");
AddBuildMap("PlayerHead" + AppConst.ExtName, "PlayerHeadPanel.prefab", "Assets/StriveGame/Res/View");
AddBuildMap("TargetHead" + AppConst.ExtName, "TargetHeadPanel.prefab", "Assets/StriveGame/Res/View");
AddBuildMap("Model" + AppConst.ExtName, "*.prefab", "Assets/StriveGame/Res/Model");
AddBuildMap("Skill" + AppConst.ExtName, "*.prefab", "Assets/StriveGame/Res/Skill");
AddBuildMap("Terrain" + AppConst.ExtName, "*.prefab", "Assets/StriveGame/Res/Terrain");
}

Expand Down
10 changes: 8 additions & 2 deletions Assets/StriveGame/Lua/Common/define.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,20 @@ CtrlNames = {
Login = "LoginCtrl",
SelectAvatar = "SelectAvatarCtrl",
CreateAvatar = "CreateAvatarCtrl",
GameWorld = "GameWorldCtrl",
GameWorld = "GameWorldCtrl",
MsgBox = "MessageBoxCtrl",
PlayerHead = "PlayerHeadCtrl",
TargetHead = "TargetHeadCtrl",
}

PanelNames = {
"LoginPanel",
"SelectAvatarPanel",
"CreateAvatarPanel",
"GameWorldPanel",
"GameWorldPanel",
"MessageBoxPanel",
"PlayerHeadPanel",
"TargetHeadPanel",
}

--协议类型--
Expand Down
137 changes: 130 additions & 7 deletions Assets/StriveGame/Lua/Controller/GameWorldCtrl.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require "Common/define"
require "Controller/MessageBoxCtrl"

GameWorldCtrl = {};
local this = GameWorldCtrl;
Expand All @@ -9,13 +10,15 @@ local gameObject;

--构建函数--
function GameWorldCtrl.New()
logWarn("GameWorldCtrl.New--->>");
return this;
logWarn("GameWorldCtrl.New--->>");
GameWorldCtrl.hasAwake = 0;
return this;
end

function GameWorldCtrl.Awake()
logWarn("GameWorldCtrl.Awake--->>");
panelMgr:CreatePanel('GameWorld', this.OnCreate);
logWarn("GameWorldCtrl.Awake--->>");
panelMgr:CreatePanel('GameWorld', this.OnCreate);
GameWorldCtrl.hasAwake = 1;
end

--启动事件--
Expand All @@ -27,23 +30,67 @@ function GameWorldCtrl.OnCreate(obj)
GameWorld:AddClick(GameWorldPanel.btnRelive, this.OnRelive);
GameWorld:AddClick(GameWorldPanel.btnClose, this.OnClose);
GameWorld:AddClick(GameWorldPanel.btnSend, this.OnSendMessage);

logWarn("Start lua--->>"..gameObject.name);
GameWorld:AddClick(GameWorldPanel.btnResetView, this.OnResetView);
GameWorld:AddClick(GameWorldPanel.btnSkill1, this.OnAttackSkill1);
GameWorld:AddClick(GameWorldPanel.btnSkill2, this.OnAttackSkill2);
GameWorld:AddClick(GameWorldPanel.btnSkill3, this.OnAttackSkill3);
GameWorld:AddClick(GameWorldPanel.btnTabTarget, this.OnTabTarget);

logWarn("Start lua--->>"..gameObject.name);
Event.AddListener("OnDie", this.OnDie);
Event.AddListener("Set_HP", this.Set_HP);
Event.AddListener("Set_HP_Max", this.Set_HP_Max);
Event.AddListener("Set_PlayerName", this.Set_PlayerName);
Event.AddListener("ReceiveChatMessage", this.ReceiveChatMessage);

Event.AddListener("OnDie", this.OnDie);
Event.AddListener("ReceiveChatMessage", this.ReceiveChatMessage);

--做一些初始化工作
local p = KBEngineLua.player();
if p ~= nil then
this.OnDie(p.state);
end
this.SetSkillButton();
end

--切换选择对象
function GameWorldCtrl.OnTabTarget( )
local player = KBEngineLua.player();
if (player == nil) then
return;
end

local target = TargetHeadCtrl.target;

local mindis = 10000;
local minEntity = nil;
for i, entity in pairs(KBEngineLua.entities) do
local obj = entity.renderObj;
if (obj ~= nil and obj.layer == LayerMask.NameToLayer("CanAttack") and entity.className == "Monster" and entity.HP > 0) then
local dis = Vector3.Distance(player.position, obj.transform.position);
if (mindis > dis and (target == nil or target ~= nil and target ~= entity)) then
mindis = dis;
minEntity = entity;
end
end
end
if minEntity ~= nil then
TargetHeadCtrl.target = minEntity;
TargetHeadCtrl.UpdateTargetUI();
end
end

function GameWorldCtrl.onclick()
print("rensiwei onclick callback")
end

--复活--
function GameWorldCtrl.OnRelive(go)

local p = KBEngineLua.player();
MessageBoxCtrl.SetInfo("0000","123456789",GameWorldCtrl.onclick);
MessageBoxCtrl.Show();
local p = KBEngineLua.player();
if p ~= nil then
p:relive(1);
end
Expand All @@ -62,13 +109,61 @@ function GameWorldCtrl.OnSendMessage(go)
end
end

--重置视角
function GameWorldCtrl.OnResetView(go)
CameraFollow:ResetView();
end

--关闭事件--
function GameWorldCtrl.Close()
--panelMgr:ClosePanel(CtrlNames.Login);
destroy(gameObject);
Event.RemoveListener("onConnectStatus", this.onConnectStatus);
end

--设置技能按钮--
function GameWorldCtrl.SetSkillButton()
if #SkillBox.skills == 3 then
GameWorldPanel.btnSkill1.transform:FindChild("Text"):GetComponent("Text").text = SkillBox.skills[1].name;
GameWorldPanel.btnSkill2.transform:FindChild("Text"):GetComponent("Text").text = SkillBox.skills[2].name;
GameWorldPanel.btnSkill3.transform:FindChild("Text"):GetComponent("Text").text = SkillBox.skills[3].name;
end
end

function GameWorldCtrl.AttackSkill(skillID )
local player = KBEngineLua.player();

if (player == nil) then
return;
end

local target = TargetHeadCtrl.target;
if (player ~= nil) then
local errorCode = player:useTargetSkill(skillID, target);
if (errorCode == 1) then
log("目标太远");
--逼近目标
SkillControl.MoveTo(target.renderObj.transform, SkillBox.Get(skillID).canUseDistMax-1, skillID);
end
if (errorCode == 2) then
log("技能冷却");
end
if (errorCode == 3) then
log("目标已死亡");
end
end
end

function GameWorldCtrl.OnAttackSkill1( )
this.AttackSkill(SkillBox.skills[1].id);
end
function GameWorldCtrl.OnAttackSkill2( )
this.AttackSkill(SkillBox.skills[2].id);
end
function GameWorldCtrl.OnAttackSkill3( )
this.AttackSkill(SkillBox.skills[3].id);
end

------------事件--
--死亡--
function GameWorldCtrl.OnDie(v)
Expand All @@ -79,6 +174,32 @@ function GameWorldCtrl.OnDie(v)
end
end

--------主角头像---
function GameWorldCtrl.Set_HP(hp)
local slider_hp = GameWorldPanel.Panel_PlayerHead.transform:FindChild("Slider_HP"):GetComponent("Slider");
local hp_player = GameWorldPanel.Panel_PlayerHead.transform:FindChild("Text_HP"):GetComponent("Text");
if hp >= 0 then
slider_hp.value = hp;
hp_player.text = hp.. "/" .. slider_hp.maxValue;
end
end
-------设置HP最大值--
function GameWorldCtrl.Set_HP_Max(value)
local slider_hp = GameWorldPanel.Panel_PlayerHead.transform:FindChild("Slider_HP"):GetComponent("Slider");
if value > 0 then
slider_hp.maxValue = value;
end
end
----- 设置主角名字--
function GameWorldCtrl.Set_PlayerName(name)
if (nil ~= GameWorldPanel.Panel_PlayerHead) then
local name_text = GameWorldPanel.Panel_PlayerHead.transform:FindChild("Text_PlayerName"):GetComponent("Text");
if(string.len(name) >= 0 ) then
name_text.text = name;
end
end
end

--接受信息
function GameWorldCtrl.ReceiveChatMessage(msg)
local text = GameWorldPanel.textContent:GetComponent("Text");
Expand All @@ -96,3 +217,5 @@ function GameWorldCtrl.ReceiveChatMessage(msg)
GameWorldPanel.sb_vertical.value = 0;
GameWorldPanel.input_content.text = "";
end


4 changes: 3 additions & 1 deletion Assets/StriveGame/Lua/Controller/LoginCtrl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ function LoginCtrl.OnCreate(obj)
Event.AddListener("onLoginSuccessfully", this.onLoginSuccessfully);
Event.AddListener("onLoginFailed", this.onLoginFailed);
Event.AddListener("onCreateAccountResult", this.onCreateAccountResult);
Event.AddListener("onReqAvatarList", this.onReqAvatarList);
Event.AddListener("onReqAvatarList", this.onReqAvatarList);

LoginPanel.inputUsername:GetComponent('InputField').text = "zl111";
LoginPanel.inputPassword:GetComponent('InputField').text = "123456";
end

--登录--
Expand Down
72 changes: 72 additions & 0 deletions Assets/StriveGame/Lua/Controller/MessageBoxCtrl.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
require "Common/define"

MessageBoxCtrl = {};
local this = MessageBoxCtrl;

local MessageBox;
local transform;
local gameObject;

--构建函数--
function MessageBoxCtrl.New()
logWarn("MessageBoxCtrl.New--->>");
return this;
end

function MessageBoxCtrl.Awake()
local canvas = find("Canvas");
if (canvas.transform:Find("MessageBoxPanel") ~= nil) then
this.Show();
print("MessageBoxPanel have been created!");
return;
end
logWarn("MessageBoxCtrl.Awake--->>");
panelMgr:CreatePanel('MessageBox', this.OnCreate);
end

--启动事件--
function MessageBoxCtrl.OnCreate(obj)
gameObject = obj;

MessageBox = gameObject:GetComponent('LuaBehaviour');
MessageBox:AddClick(MessageBoxPanel.btnOK, this.OnOK);
MessageBox:AddClick(MessageBoxPanel.btnCancle, this.OnCancle);

logWarn("Start lua--->>"..gameObject.name);

MessageBoxPanel.txtTitle:GetComponent('Text').text = "title";
MessageBoxPanel.txtContent:GetComponent('Text').text = "content";
end


function MessageBoxCtrl.OnOK(go)
if (MessageBoxPanel.onClick ~= nil) then
MessageBoxPanel.onClick();
end
this.Hide();
end

function MessageBoxCtrl.OnCancle(go)
this.Hide();
end

function MessageBoxCtrl.Hide()
local panel_MsgBox = find("MessageBoxPanel");
if panel_MsgBox ~= nil then
panel_MsgBox:SetActive(false);
end
end

function MessageBoxCtrl.Show()
local canvas = find("Canvas");
local panel_MsgBox = canvas.transform:Find("MessageBoxPanel").gameObject;
if panel_MsgBox ~= nil then
panel_MsgBox:SetActive(true);
end;
end

function MessageBoxCtrl.SetInfo(strTitle, strContent,onClick)
MessageBoxPanel.txtTitle:GetComponent('Text').text = strTitle;
MessageBoxPanel.txtContent:GetComponent('Text').text = strContent;
MessageBoxPanel.onClick = onClick;
end
Loading