背包联网(未完成)
This commit is contained in:
parent
c0f62e5be3
commit
383c07e61b
|
|
@ -29,5 +29,8 @@ function _Yosin_Game_Logic_(Dt, GameListener) {
|
|||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
remove("Yosin_Game_Reloading.Sign");
|
||||
} catch (exception) {
|
||||
|
||||
remove("Yosin_Game_Reloading.Sign");
|
||||
}
|
||||
|
|
@ -255,6 +255,7 @@ class Yosin_Window extends Yosin_BaseWindow {
|
|||
//切换到最上层窗口 即得到焦点时 全局窗口才调用 子窗口请不要调用此函数
|
||||
function ResetFocus() {
|
||||
this.Visible = true;
|
||||
SetVisible(true);
|
||||
//遍历全局窗口数组将自己移除重新添加在末尾
|
||||
foreach(Index, WindowObj in _SYS_WINDOW_LIST_) {
|
||||
WindowObj.SetZOrder(10000000 + Index + (WindowObj.IsTop ? 10000000 : 0));
|
||||
|
|
@ -402,7 +403,7 @@ function Sq_CreateWindow(ClassName, gObjectId, gX, gY, gWidth, gHeight, gTitleH)
|
|||
|
||||
//窗口逻辑入口 C回调
|
||||
function _Yosin_Windows_Logic_(Dt, Ui_Layer) {
|
||||
_UiObject_ = Actor(Ui_Layer);
|
||||
if (!_UiObject_) _UiObject_ = Actor(Ui_Layer);
|
||||
//遍历窗口队列 如果可见则调用Show
|
||||
for (local i = 0; i< _SYS_WINDOW_LIST_.len(); i++) {
|
||||
local Window = _SYS_WINDOW_LIST_[i];
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
class _GameController_ extends _Input_ {
|
||||
|
||||
//最新键码输入
|
||||
|
||||
|
||||
|
||||
KeyCode = null;
|
||||
GameKeyCode = null;
|
||||
|
|
@ -39,12 +39,9 @@ class _GameController_ extends _Input_ {
|
|||
this.KeyCode[Code] = Status;
|
||||
|
||||
//只遍历有回调的键码
|
||||
foreach(Code, Callback in GameKeyCodeCallback) {
|
||||
//是否按下传递不同指令
|
||||
if (GetGameKeyCode(Code)) {
|
||||
Callback(true);
|
||||
} else {
|
||||
Callback(false);
|
||||
foreach(RCode, Callback in GameKeyCodeCallback) {
|
||||
if (RCode == Code) {
|
||||
Callback(Status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,15 @@ function RegisterFunctionalPack() {
|
|||
Charc.Cid = Info.cid;
|
||||
TownObj.AddObject(Charc, true);
|
||||
ClientCharacter = Charc;
|
||||
|
||||
//以下是角色应当初始化的各项东西
|
||||
{
|
||||
//初始化背包
|
||||
if (ClientCharacterInventory) {
|
||||
ClientCharacterInventory.DestroyWindow();
|
||||
}
|
||||
ClientCharacterInventory = _Inventory("背包窗口", 150, 12, 262, 548, 20);
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
|
|
@ -68,7 +77,7 @@ function RegisterFunctionalPack() {
|
|||
local ItemList = [];
|
||||
|
||||
//道具数据
|
||||
for (local i = 0; i< ItemCount; i++) {
|
||||
for (local i = 0; i< InventoryItemCount; i++) {
|
||||
local Type = Pack.Get_Byte();
|
||||
|
||||
//装备类型
|
||||
|
|
@ -108,6 +117,7 @@ function RegisterFunctionalPack() {
|
|||
EquipWrapCount = Pack.Get_Byte(),
|
||||
}
|
||||
ItemList.push(EquInfo);
|
||||
print("构造装备");
|
||||
}
|
||||
//消耗品类型
|
||||
if (Type == 2) {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ function TestStage() {
|
|||
T.Enter();
|
||||
|
||||
|
||||
// local Window = Sq_CreateWindow(_Login_Window, "登录界面窗口", 0, 0, 1066, 600, 0);
|
||||
local Window = Sq_CreateWindow(_Login_Window, "登录界面窗口", 0, 0, 1066, 600, 0);
|
||||
|
||||
// local BackGround = CL_SpriteObject("sprite/loding.img", 0);
|
||||
// T.Addchild(BackGround);
|
||||
|
|
@ -31,21 +31,21 @@ function TestStage() {
|
|||
// Window.SetPosition(580, 80);
|
||||
// Window.ResetFocus();
|
||||
|
||||
local TownObj = Town(2);
|
||||
local Charc = GameObject.CreateCharacter(0, [101590007, 27675, 601500060, 601550060, 601560058, 601570053, 601520052, 601500060, 601510059, 601530051, 601540060, 601580023]);
|
||||
TownObj.AddObject(Charc, true);
|
||||
ClientCharacter = Charc;
|
||||
// local TownObj = Town(2);
|
||||
// local Charc = GameObject.CreateCharacter(0, [101590007, 27675, 601500060, 601550060, 601560058, 601570053, 601520052, 601500060, 601510059, 601530051, 601540060, 601580023]);
|
||||
// TownObj.AddObject(Charc, true);
|
||||
// ClientCharacter = Charc;
|
||||
|
||||
|
||||
local Window = Sq_CreateWindow(_Inventory, "背包窗口", 150, 12, 257, 555, 20);
|
||||
// local Window = Sq_CreateWindow(_Inventory, "背包窗口", 150, 12, 262, 548, 20);
|
||||
|
||||
Window.equipmentPage.Item.ItemCollection.SetItemList([{
|
||||
ItemId = 27675
|
||||
}, {
|
||||
ItemId = 101020048
|
||||
}, {
|
||||
ItemId = 24144
|
||||
}]);
|
||||
// Window.equipmentPage.ItemCollection.SetItemList([{
|
||||
// ItemId = 27675
|
||||
// }, {
|
||||
// ItemId = 101020048
|
||||
// }, {
|
||||
// ItemId = 24144
|
||||
// }]);
|
||||
|
||||
// local Window = Sq_CreateWindow(_Inventory, "背包窗口", 150, 12, 257, 555, 20);
|
||||
// //大背景
|
||||
|
|
|
|||
|
|
@ -86,10 +86,12 @@ class _Login_Window extends Yosin_Window {
|
|||
function RegisterWidget() {
|
||||
//账号输入框
|
||||
AccountInputBox = Yosin_InputBox(752, 240, 200);
|
||||
AccountInputBox.str = "1"; //TODO 临时账户
|
||||
AddUIChild(AccountInputBox);
|
||||
|
||||
//密码输入框
|
||||
PasswordInputBox = Yosin_InputBox(752, 280, 200);
|
||||
PasswordInputBox.str = "1"; //TODO 临时账户
|
||||
AddUIChild(PasswordInputBox);
|
||||
|
||||
//登录按钮
|
||||
|
|
|
|||
|
|
@ -4,19 +4,34 @@
|
|||
创建日期:2025-01-06 14:06
|
||||
文件用途: 背包窗口
|
||||
*/
|
||||
|
||||
// local Window = Sq_CreateWindow(_Inventory, "背包窗口", 150, 12, 262, 548, 20);
|
||||
//主类
|
||||
class _Inventory extends Yosin_Window {
|
||||
|
||||
equipmentPage = null;
|
||||
//物品栏
|
||||
EquipmentPage = null;
|
||||
//是否可见
|
||||
Visible = false;
|
||||
|
||||
constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) {
|
||||
base.constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH);
|
||||
|
||||
|
||||
|
||||
//注册控件
|
||||
RegisterWidget();
|
||||
|
||||
//注册按键回调事件
|
||||
Input.RegisterGameKeyCode(CONTROLLER.OPTION_HOTKEY_ITEM_INVENTORY, function(Flag) {
|
||||
//抬起的时候
|
||||
if (Flag == 0) {
|
||||
//如果窗口已经打开
|
||||
if (this.Visible) {
|
||||
//关闭窗口
|
||||
CloseWindow();
|
||||
} else {
|
||||
//打开窗口
|
||||
ResetFocus();
|
||||
}
|
||||
}
|
||||
}.bindenv(this));
|
||||
}
|
||||
|
||||
function RegisterWidget() {
|
||||
|
|
@ -29,7 +44,7 @@ class _Inventory extends Yosin_Window {
|
|||
closeBtn.DownSimulateOffset = false;
|
||||
closeBtn.SetZOrder(1);
|
||||
closeBtn.OnClick = function(btn) {
|
||||
print(13123123);
|
||||
CloseWindow();
|
||||
}
|
||||
AddUIChild(closeBtn);
|
||||
//置顶按钮
|
||||
|
|
@ -50,9 +65,9 @@ class _Inventory extends Yosin_Window {
|
|||
|
||||
|
||||
|
||||
//物品栏 装备页
|
||||
equipmentPage = Inventory_EquipmentPage(2, titlesBtn.bottom(), 300, 441);
|
||||
AddUIChild(equipmentPage);
|
||||
//物品栏
|
||||
EquipmentPage = Inventory_EquipmentPage(2, titlesBtn.bottom(), 300, 441);
|
||||
AddUIChild(EquipmentPage);
|
||||
|
||||
// 添加设置物品栏的按钮
|
||||
AddItemCollectSetBtn();
|
||||
|
|
@ -89,7 +104,7 @@ class _Inventory extends Yosin_Window {
|
|||
local ReviveNum = FontAssetManager.GenerateNormal("23434个", true, {
|
||||
color = txtColor
|
||||
});
|
||||
ReviveNum.SetPosition(120 - ReviveNum.GetSize().w + bg.X , bg.Y + 2);
|
||||
ReviveNum.SetPosition(120 - ReviveNum.GetSize().w + bg.X, bg.Y + 2);
|
||||
Addchild(ReviveNum);
|
||||
|
||||
|
||||
|
|
@ -97,13 +112,13 @@ class _Inventory extends Yosin_Window {
|
|||
local winNum = FontAssetManager.GenerateNormal("23434个", true, {
|
||||
color = txtColor
|
||||
});
|
||||
winNum.SetPosition(245 - winNum.GetSize().w + bg.X, bg.Y + 2);
|
||||
winNum.SetPosition(245 - winNum.GetSize().w + bg.X, bg.Y + 2);
|
||||
Addchild(winNum);
|
||||
|
||||
|
||||
|
||||
// 商城
|
||||
local storeBtn = Yosin_BaseButton(1 + bg.X, bg.Y + 25, 23, 23 "sprite/interface/newstyle/windows/inventory/inventory.img", 3);
|
||||
local storeBtn = Yosin_BaseButton(1 + bg.X, bg.Y + 25, 23, 23 "sprite/interface/newstyle/windows/inventory/inventory.img", 3);
|
||||
//点击事件回调
|
||||
// storeBtn.OnClick = function(Button) {
|
||||
// }.bindenv(this);
|
||||
|
|
@ -114,7 +129,7 @@ class _Inventory extends Yosin_Window {
|
|||
local storeNum = FontAssetManager.GenerateNormal("23434点券", true, {
|
||||
color = txtColor
|
||||
});
|
||||
storeNum.SetPosition( bg.X + 120 - storeNum.GetSize().w , bg.Y + 27);
|
||||
storeNum.SetPosition(bg.X + 120 - storeNum.GetSize().w, bg.Y + 27);
|
||||
Addchild(storeNum);
|
||||
|
||||
// 金币按钮
|
||||
|
|
@ -128,7 +143,7 @@ class _Inventory extends Yosin_Window {
|
|||
local storeNum = FontAssetManager.GenerateNormal("23434金币", true, {
|
||||
color = txtColor
|
||||
});
|
||||
storeNum.SetPosition( bg.X + 245 - storeNum.GetSize().w, bg.Y + 27);
|
||||
storeNum.SetPosition(bg.X + 245 - storeNum.GetSize().w, bg.Y + 27);
|
||||
Addchild(storeNum);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,31 +2,37 @@
|
|||
文件名:Inventory_EquipmentPage.nut
|
||||
路径:User/UI/Window/5_Inventory/Inventory_EquipmentPage.nut
|
||||
创建日期:2025-01-06 13:50
|
||||
文件用途: 背包装备页面
|
||||
文件用途: 背包物品栏页面
|
||||
*/
|
||||
|
||||
// 背包装备页面
|
||||
// 背包物品栏页面
|
||||
class Inventory_EquipmentPage extends Yosin_CommonUi {
|
||||
|
||||
// Item = null;
|
||||
|
||||
//人物装备
|
||||
CharactersEquipment = null;
|
||||
//物品栏
|
||||
ItemCollection = null;
|
||||
//重量进度条
|
||||
WeightSchedule = null;
|
||||
//总可承载重量
|
||||
TotalLoadCapacity = 1.0;
|
||||
//当前承载重量
|
||||
CurrentLoadCapacity = 0.0;
|
||||
|
||||
constructor(x, y, w, h) {
|
||||
base.constructor(x, y, w, h);
|
||||
|
||||
|
||||
// 人物装备
|
||||
local charactersEquipment = Inventory_CharactersEquipment();
|
||||
charactersEquipment.SetPosition(5, 0);
|
||||
Addchild(charactersEquipment);
|
||||
CharactersEquipment = Inventory_CharactersEquipment();
|
||||
CharactersEquipment.SetPosition(5, 0);
|
||||
Addchild(CharactersEquipment);
|
||||
|
||||
// 添加书本按钮
|
||||
AddBookButton();
|
||||
|
||||
// 物品栏
|
||||
AddItem();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -34,9 +40,6 @@ class Inventory_EquipmentPage extends Yosin_CommonUi {
|
|||
function AddBookButton() {
|
||||
// 称号
|
||||
local designation = Yosin_BaseButton(7, 145, 18, 20 "sprite/interface/newstyle/windows/inventory/inventory.img", 50);
|
||||
//点击事件回调
|
||||
// permutationBtn.OnClick = function(Button) {
|
||||
// }.bindenv(this);
|
||||
AddUIChild(designation);
|
||||
|
||||
// 增益强化
|
||||
|
|
@ -73,8 +76,11 @@ class Inventory_EquipmentPage extends Yosin_CommonUi {
|
|||
Addchild(itemBg);
|
||||
|
||||
// 物品栏
|
||||
ItemCollection = _ItemCollection(itemBg.X + 7, itemBg.Y + 3, 7);
|
||||
AddUIChild(ItemCollection);
|
||||
ItemCollection = [];
|
||||
for (local i = 0; i< 5; i++) {
|
||||
ItemCollection.push(_ItemCollection(itemBg.X + 7, itemBg.Y + 3, 7));
|
||||
}
|
||||
AddUIChild(ItemCollection[0]);
|
||||
|
||||
|
||||
local itemBgBottom = itemBg.bottom();
|
||||
|
|
@ -82,14 +88,28 @@ class Inventory_EquipmentPage extends Yosin_CommonUi {
|
|||
local weight = FontAssetManager.GenerateNormal("重量", true, {
|
||||
color = sq_RGBA(160, 132, 75, 255)
|
||||
});
|
||||
weight.SetPosition(ItemCollection.X + 5, itemBgBottom - weight.GetSize().h - 5);
|
||||
weight.SetPosition(12, itemBgBottom - weight.GetSize().h - 5);
|
||||
Addchild(weight);
|
||||
|
||||
// 重量进度条
|
||||
local weightSchedule = Yosin_Schedule(weight.right() + 2, weight.Y + 4, 125, 10, "sprite/interface/newstyle/windows/inventory/inventory.img", 1);
|
||||
weightSchedule.SetPercentage(0.6);
|
||||
Addchild(weightSchedule);
|
||||
WeightSchedule = Yosin_Schedule(weight.right() + 2, weight.Y + 4, 125, 10, "sprite/interface/newstyle/windows/inventory/inventory.img", 1);
|
||||
WeightSchedule.SetPercentage(0.0);
|
||||
Addchild(WeightSchedule);
|
||||
}
|
||||
|
||||
//刷新重量进度
|
||||
function RefreshWeightProgress() {
|
||||
WeightSchedule.SetPercentage(CurrentLoadCapacity / TotalLoadCapacity);
|
||||
}
|
||||
|
||||
//设定总可承载重量
|
||||
function SetTotalLoadCapacity(capacity) {
|
||||
TotalLoadCapacity = capacity;
|
||||
}
|
||||
|
||||
//设定物品栏列表
|
||||
function SetItemCollectionList(Type, List) {
|
||||
ItemCollection[Type].SetItemList(List);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ enum CONTROLLER {
|
|||
OPTION_HOTKEY_CREATURE_SKILL = 8 // 宠物技能键
|
||||
OPTION_HOTKEY_STATUS_WINDOW = 9 // (M)
|
||||
OPTION_HOTKEY_SKILL_WINDOW = 10 // (K)
|
||||
OPTION_HOTKEY_ITEM_INVENTORY = 11 // (I)
|
||||
OPTION_HOTKEY_ITEM_INVENTORY = 23 // (I)
|
||||
OPTION_HOTKEY_OPTION_WINDOW = 12 // (O)
|
||||
OPTION_HOTKEY_NORMAL_QUEST_WINDOW = 13 // (Q)
|
||||
OPTION_HOTKEY_AVATAR_INVENTORY = 14 // (U)
|
||||
|
|
|
|||
|
|
@ -6,4 +6,6 @@
|
|||
*/
|
||||
|
||||
//客户端角色对象
|
||||
ClientCharacter <- null;
|
||||
ClientCharacter <- null;
|
||||
//客户端角色的背包
|
||||
ClientCharacterInventory <- null;
|
||||
Loading…
Reference in New Issue