diff --git a/Yosin_Engine.exe b/Yosin_Engine.exe index 2230b34..68d37ce 100644 Binary files a/Yosin_Engine.exe and b/Yosin_Engine.exe differ diff --git a/sqr/Core/UI_Class/UI_Core.nut b/sqr/Core/UI_Class/UI_Core.nut index ae39aba..78f3fab 100644 --- a/sqr/Core/UI_Class/UI_Core.nut +++ b/sqr/Core/UI_Class/UI_Core.nut @@ -57,66 +57,77 @@ class Yosin_BaseWindow extends Layer { //鼠标事件回调 function OnMouseProc(MousePos_X, MousePos_Y) { + if (!Visible) return; foreach(Window in UI_Childrens) { Window.OnMouseProc(MousePos_X, MousePos_Y); } } //鼠标左键按下回调 function OnMouseLbDown(MousePos_X, MousePos_Y) { + if (!Visible) return; foreach(Window in UI_Childrens) { Window.OnMouseLbDown(MousePos_X, MousePos_Y); } } //鼠标左键单击回调 function OnMouseLbClick(MousePos_X, MousePos_Y) { + if (!Visible) return; foreach(Window in UI_Childrens) { Window.OnMouseLbClick(MousePos_X, MousePos_Y); } } //鼠标左键弹起回调 function OnMouseLbUp(MousePos_X, MousePos_Y) { + if (!Visible) return; foreach(Window in UI_Childrens) { Window.OnMouseLbUp(MousePos_X, MousePos_Y); } } //鼠标右键按下回调 function OnMouseRbDown(MousePos_X, MousePos_Y) { + if (!Visible) return; foreach(Window in UI_Childrens) { Window.OnMouseRbDown(MousePos_X, MousePos_Y); } } //鼠标右键单击回调 function OnMouseRbClick(MousePos_X, MousePos_Y) { + if (!Visible) return; foreach(Window in UI_Childrens) { Window.OnMouseRbClick(MousePos_X, MousePos_Y); } } //鼠标右键弹起回调 function OnMouseRbUp(MousePos_X, MousePos_Y) { + if (!Visible) return; foreach(Window in UI_Childrens) { Window.OnMouseRbUp(MousePos_X, MousePos_Y); } } //鼠标中键按下回调 function OnMouseMbDown(MousePos_X, MousePos_Y) { + if (!Visible) return; foreach(Window in UI_Childrens) { Window.OnMouseMbDown(MousePos_X, MousePos_Y); } } //鼠标中键单击回调 function OnMouseMbClick(MousePos_X, MousePos_Y) { + if (!Visible) return; foreach(Window in UI_Childrens) { Window.OnMouseMbClick(MousePos_X, MousePos_Y); } } //鼠标中键弹起回调 function OnMouseMbUp(MousePos_X, MousePos_Y) { + if (!Visible) return; foreach(Window in UI_Childrens) { Window.OnMouseMbUp(MousePos_X, MousePos_Y); } } //鼠标滚轮事件回调 function OnMouseWheel(Wheel, MousePos_X, MousePos_Y) { + if (!Visible) return; foreach(Window in UI_Childrens) { Window.OnMouseWheel(Wheel, MousePos_X, MousePos_Y); } diff --git a/sqr/Core/UI_Class/UI_Widget.nut b/sqr/Core/UI_Class/UI_Widget.nut index ea74b68..d550cc4 100644 --- a/sqr/Core/UI_Class/UI_Widget.nut +++ b/sqr/Core/UI_Class/UI_Widget.nut @@ -206,7 +206,7 @@ class Yosin_EmeStretch extends CL_CanvasObject { //按钮状态 SpriteList = null; - constructor( W, H, Path, Idx, Direction = true) { + constructor(W, H, Path, Idx, Direction = true) { this.Path = Path; this.Idx = Idx; base.constructor(); @@ -256,105 +256,105 @@ class Yosin_EmeStretch extends CL_CanvasObject { } -// 九宫格拉伸 -// function Yosin_NineBoxStretch(width, height, path, imgId) { +//九宫格拉伸 +function Yosin_NineBoxStretch(width, height, path, imgId) { -// // 创建画布 -// local Canvas = CL_CanvasObject(); -// // 重设大小并清空 -// Canvas.ResizeAndClear(width, height); -// // 开始绘制 -// Canvas.BeginDraw(); + // 创建画布 + local Canvas = CL_CanvasObject(); + // 重设大小并清空 + Canvas.ResizeAndClear(width, height); + // 开始绘制 + Canvas.BeginDraw(); -// // 左上角 -// // local backgroundTopLeft = CL_SpriteObject(path, imgId); -// local backgroundTopLeft = CL_SpriteObject(path, imgId); -// // 上边 -// local backgroundTop = CL_SpriteObject(path, imgId + 1); -// // 右上角 -// local backgroundTopRight = CL_SpriteObject(path, imgId + 2); -// // 左边 -// local backgroundLeft = CL_SpriteObject(path, imgId + 3); -// // 中间 -// local backgroundCenter = CL_SpriteObject(path, imgId + 4); -// // 右边 -// local backgroundRight = CL_SpriteObject(path, imgId + 5); -// // 左下角 -// local backgroundBottomLeft = CL_SpriteObject(path, imgId + 6); -// // 下边 -// local backgroundBottom = CL_SpriteObject(path, imgId + 7); -// // 右下角 -// local backgroundBottomRight = CL_SpriteObject(path, imgId + 8); + // 左上角 + // local backgroundTopLeft = CL_SpriteObject(path, imgId); + local backgroundTopLeft = CL_SpriteObject(path, imgId); + // 上边 + local backgroundTop = CL_SpriteObject(path, imgId + 1); + // 右上角 + local backgroundTopRight = CL_SpriteObject(path, imgId + 2); + // 左边 + local backgroundLeft = CL_SpriteObject(path, imgId + 3); + // 中间 + local backgroundCenter = CL_SpriteObject(path, imgId + 4); + // 右边 + local backgroundRight = CL_SpriteObject(path, imgId + 5); + // 左下角 + local backgroundBottomLeft = CL_SpriteObject(path, imgId + 6); + // 下边 + local backgroundBottom = CL_SpriteObject(path, imgId + 7); + // 右下角 + local backgroundBottomRight = CL_SpriteObject(path, imgId + 8); -// // 左上角 -// Canvas.DrawSprite(backgroundTopLeft); + // 左上角 + Canvas.DrawSprite(backgroundTopLeft); -// local TopLeftSize = backgroundTopLeft.GetSize(); -// local TopLeftBottom = TopLeftSize.h; -// local TopLeftRight = TopLeftSize.w; + local TopLeftSize = backgroundTopLeft.GetSize(); + local TopLeftBottom = TopLeftSize.h; + local TopLeftRight = TopLeftSize.w; -// // 中间图片大小 -// local centerImgSize = backgroundCenter.GetSize(); -// local centerImgWidth = centerImgSize.w; -// local centerImgHeight = centerImgSize.h; + // 中间图片大小 + local centerImgSize = backgroundCenter.GetSize(); + local centerImgWidth = centerImgSize.w; + local centerImgHeight = centerImgSize.h; -// local centerWidth = width - backgroundTopLeft.GetSize().w - backgroundTopRight.GetSize().w; -// local centerHeight = height - backgroundTopLeft.GetSize().h - backgroundBottomLeft.GetSize().h; + local centerWidth = width - backgroundTopLeft.GetSize().w - backgroundTopRight.GetSize().w; + local centerHeight = height - backgroundTopLeft.GetSize().h - backgroundBottomLeft.GetSize().h; -// local scaleW = (centerWidth - 1).tofloat() / centerImgWidth.tofloat(); -// local scaleH = (centerHeight - 1).tofloat() / centerImgHeight.tofloat(); + local scaleW = (centerWidth - 1).tofloat() / centerImgWidth.tofloat(); + local scaleH = (centerHeight - 1).tofloat() / centerImgHeight.tofloat(); -// // 上边 -// backgroundTop.SetScale(scaleW, 1); -// backgroundTop.SetPosition(TopLeftRight, 0); -// Canvas.DrawSprite(backgroundTop); + // 上边 + backgroundTop.SetScale(scaleW, 1); + backgroundTop.SetPosition(TopLeftRight, 0); + Canvas.DrawSprite(backgroundTop); -// // 右上角 -// backgroundTopRight.SetPosition(width - backgroundTopRight.GetSize().w - 1, 0); -// Canvas.DrawSprite(backgroundTopRight); + // 右上角 + backgroundTopRight.SetPosition(width - backgroundTopRight.GetSize().w - 1, 0); + Canvas.DrawSprite(backgroundTopRight); -// // 左边 -// backgroundLeft.SetScale(1, scaleH); -// backgroundLeft.SetPosition(0, TopLeftBottom); -// Canvas.DrawSprite(backgroundLeft); + // 左边 + backgroundLeft.SetScale(1, scaleH); + backgroundLeft.SetPosition(0, TopLeftBottom); + Canvas.DrawSprite(backgroundLeft); -// // 中间 -// backgroundCenter.SetScale(scaleW, scaleH); -// // Addchild(backgroundCenter); -// backgroundCenter.SetPosition(TopLeftRight, backgroundLeft.Y); -// Canvas.DrawSprite(backgroundCenter); + // 中间 + backgroundCenter.SetScale(scaleW, scaleH); + // Addchild(backgroundCenter); + backgroundCenter.SetPosition(TopLeftRight, backgroundLeft.Y); + Canvas.DrawSprite(backgroundCenter); -// // 右边 -// backgroundRight.SetScale(1, scaleH); -// backgroundRight.SetPosition(width - backgroundRight.GetSize().w - 1, backgroundCenter.Y); -// Canvas.DrawSprite(backgroundRight); + // 右边 + backgroundRight.SetScale(1, scaleH); + backgroundRight.SetPosition(width - backgroundRight.GetSize().w - 1, backgroundCenter.Y); + Canvas.DrawSprite(backgroundRight); -// // 左下角 -// backgroundBottomLeft.SetPosition(0, height - backgroundBottomLeft.GetSize().h - 1); -// Canvas.DrawSprite(backgroundBottomLeft); + // 左下角 + backgroundBottomLeft.SetPosition(0, height - backgroundBottomLeft.GetSize().h - 1); + Canvas.DrawSprite(backgroundBottomLeft); -// // 下边 -// backgroundBottom.SetScale(scaleW, 1); -// backgroundBottom.SetPosition(TopLeftRight, backgroundBottomLeft.Y); -// Canvas.DrawSprite(backgroundBottom); + // 下边 + backgroundBottom.SetScale(scaleW, 1); + backgroundBottom.SetPosition(TopLeftRight, backgroundBottomLeft.Y); + Canvas.DrawSprite(backgroundBottom); -// // 右下角 -// backgroundBottomRight.SetPosition(width - backgroundBottomRight.GetSize().w - 1, backgroundBottomLeft.Y); -// Canvas.DrawSprite(backgroundBottomRight); - -// // 结束绘制 -// Canvas.EndDraw(); -// // 添加画布 -// // Addchild(Canvas); -// local Sp = CL_SpriteObject(); -// Sp.SetFrame(Canvas.ExportSpriteFrame()); -// return Sp; -// } + // 右下角 + backgroundBottomRight.SetPosition(width - backgroundBottomRight.GetSize().w - 1, backgroundBottomLeft.Y); + Canvas.DrawSprite(backgroundBottomRight); + // 结束绘制 + Canvas.EndDraw(); + // 添加画布 + // Addchild(Canvas); + local Sp = CL_SpriteObject(); + Sp.SetFrame(Canvas.ExportSpriteFrame()); + return Sp; +} +/* //九宫格拉伸 class Yosin_NineBoxStretch extends CL_CanvasObject { @@ -451,6 +451,7 @@ class Yosin_NineBoxStretch extends CL_CanvasObject { } } +*/ //拼接按钮 class Yosin_SplicingButton extends Yosin_CommonUi { @@ -474,14 +475,14 @@ class Yosin_SplicingButton extends Yosin_CommonUi { SpriteList = array(4); //普通态 - SpriteList[0] = Yosin_EmeStretch( W, H, Path, Idx, Direction); + SpriteList[0] = Yosin_EmeStretch(W, H, Path, Idx, Direction); //悬停态 - SpriteList[1] = Yosin_EmeStretch( W, H, Path, Idx + (UnavailableFlag ? 4 : 3), Direction); + SpriteList[1] = Yosin_EmeStretch(W, H, Path, Idx + (UnavailableFlag ? 4 : 3), Direction); //按下态 - SpriteList[2] = Yosin_EmeStretch( W, H, Path, Idx + (UnavailableFlag ? 8 : 6), Direction); + SpriteList[2] = Yosin_EmeStretch(W, H, Path, Idx + (UnavailableFlag ? 8 : 6), Direction); if (UnavailableFlag) { //不可用态 - SpriteList[3] = Yosin_EmeStretch( W, H, Path, Idx + 12, Direction); + SpriteList[3] = Yosin_EmeStretch(W, H, Path, Idx + 12, Direction); } } @@ -635,15 +636,15 @@ class Yosin_StretchTitleButton extends Yosin_CommonUi { SpriteList = array(3); //普通态 - SpriteList[0] = Yosin_EmeStretch( W, H, Path, Idx); + SpriteList[0] = Yosin_EmeStretch(W, H, Path, Idx); Addchild(SpriteList[0]); //悬停态 - SpriteList[1] = Yosin_EmeStretch( W, H, Path, Idx + 3); + SpriteList[1] = Yosin_EmeStretch(W, H, Path, Idx + 3); SpriteList[1].SetVisible(false) Addchild(SpriteList[1]); //按下态 - SpriteList[2] = Yosin_EmeStretch( W, H, Path, Idx + 6); + SpriteList[2] = Yosin_EmeStretch(W, H, Path, Idx + 6); SpriteList[2].SetVisible(false) Addchild(SpriteList[2]); @@ -739,17 +740,17 @@ class Yosin_RowMoreTitleBtn extends Yosin_CommonUi { titleBtn.index = i; titleBtn.LBDownOnClick = function(btn) { - btn.Parent.LBDownOnClick(btn.Parent, btn.index); + LBDownOnClick(btn.Parent, btn.index); - for (local i = 0; i< btn.Parent.btns.len(); i++) { - btn.Parent.btns[i].SetSelect(false); - btn.Parent.btns[i].titleText.SetFillColor(sq_RGBA(130, 114, 84, 255)); + for (local i = 0; i< btns.len(); i++) { + btns[i].SetSelect(false); + btns[i].titleText.SetFillColor(sq_RGBA(130, 114, 84, 255)); } btn.SetSelect(true); - btn.Parent.btns[btn.index].titleText.SetFillColor(sq_RGBA(187, 176, 149, 255)); + btns[btn.index].titleText.SetFillColor(sq_RGBA(187, 176, 149, 255)); - }; + }.bindenv(this); btns.push(titleBtn); btnX += btnW; diff --git a/sqr/User/Asset/AssetManager.nut b/sqr/User/Asset/AssetManager.nut index fa849fd..d5cfcde 100644 --- a/sqr/User/Asset/AssetManager.nut +++ b/sqr/User/Asset/AssetManager.nut @@ -16,6 +16,8 @@ class _AssetManager_ { TownList = null; //装备列表 EquipmentList = null; + //消耗品列表 + StackableList = null; //NPC列表 NpcList = null; @@ -211,6 +213,20 @@ class _AssetManager_ { }); } + function InitStackableList() { + StackableList = ScriptData.GetFileData("stackable/stackable.lst", function(DataTable, Data) { + while (!Data.Eof()) { + local Key = Data.Get(); + //注册装备列表 路径写入 数据未读取 + DataTable.rawset(Key, { + Path = Data.Get(), + Data = null + }); + } + if (_DEBUG_) print("加载消耗品List完成, 共" + DataTable.len() + "个"); + }); + } + function InitNpcList() { NpcList = ScriptData.GetFileData("npc/npc.lst", function(DataTable, Data) { while (!Data.Eof()) { @@ -248,6 +264,8 @@ class _AssetManager_ { InitCharacter(); //初始化装备列表 InitEquipmentList(); + //初始化消耗品列表 + InitStackableList(); //初始化NPC列表 InitNpcList(); @@ -283,8 +301,8 @@ class _AssetManager_ { DataTable.usable_job.append(Ret.slice(1, -1).tolower()); } } - //读取三攻 - else if (Pack == "[equipment physical attack]" || Pack == "[equipment magical attack]" || Pack == "[separate attack]") { + //读取三攻 和 双防 + else if (Pack == "[equipment physical attack]" || Pack == "[equipment magical attack]" || Pack == "[separate attack]" || Pack == "[equipment physical defense]" || Pack == "[equipment magical defense]") { local RealKey = Pack.slice(1, -1); DataTable[RealKey] <- [Data.Get(), Data.Get()]; } @@ -347,6 +365,60 @@ class _AssetManager_ { return m_data; } + //获取消耗品信息 + function GetStackable(Idx) { + //如果没有这件消耗品则返回 + if (!(StackableList.rawin(Idx))) return; + //如果装备数据已经读取过存在了则直接返回 + if (StackableList[Idx].Data) return StackableList[Idx].Data; + local Path = StackableList[Idx].Path; + local m_data = ScriptData.GetFileData("stackable/" + Path, function(DataTable, Data) { + DataTable.DirPath <- DataTable.filepath.slice(0, DataTable.filepath.lastfind("/") + 1); + while (!Data.Eof()) { + local Pack = Data.Get(); + //名称 + if (Pack == "[name]" || Pack == "[item group name]" || Pack == "[explain]") { + local RealKey = Pack.slice(1, -1); + DataTable[RealKey] <- Data.Get(); + } + //适用角色 + else if (Pack == "[usable job]") { + DataTable.usable_job <- []; + while (true) { + local Ret = Data.Get(); + if (Ret == "[/usable job]") break; + DataTable.usable_job.append(Ret.slice(1, -1).tolower()); + } + } + //图标 + else if (Pack == "[icon]") { + DataTable.icon <- {}; + local Ret = Data.Get(); + DataTable.icon.path <- "sprite/" + Ret.tolower(); + Ret = Data.Get(); + DataTable.icon.index <- Ret.tointeger(); + } + //消耗品类型 + else if (Pack == "[stackable type]") { + DataTable.type <- {}; + local Ret = Data.Get(); + DataTable.type.path <- Ret.tolower().slice(1, -1); + Ret = Data.Get(); + DataTable.type.index <- Ret.tointeger(); + } + //交易类型 + else if (Pack == "[attach type]") { + local Ret = Data.Get(); + if (Ret == "[free]") DataTable.trade_type <- 0; + else if (Ret == "[trade]") DataTable.trade_type <- 1; + else if (Ret == "[sealing]") DataTable.trade_type <- 2; + else if (Ret == "[account]") DataTable.trade_type <- 3; + } + } + }); + StackableList[Idx].Data = m_data; + return m_data; + } //Public:: diff --git a/sqr/User/Asset/Item/Equipment.nut b/sqr/User/Asset/Item/Equipment.nut index e1c345c..31209cd 100644 --- a/sqr/User/Asset/Item/Equipment.nut +++ b/sqr/User/Asset/Item/Equipment.nut @@ -20,7 +20,7 @@ class GameItem.EquipmentIcon extends CL_CanvasObject { DrawSpriteFrame(Icon, 0, 0); //是否封装 - local IsPackage = Equipment.Property ? Equipment.Property.IsPackage : 1; + local IsPackage = Equipment.IsWrap; if (IsPackage && (Equipment.Rarity == 2 || Equipment.Rarity == 3)) { local IconFrame = CL_SpriteObject("sprite/interface/lenheartwindowcommon.img", 634); IconFrame.SetMode(0); @@ -70,7 +70,13 @@ class GameItem.EquipmentInfo extends Yosin_Window { //绘制装备名称 if (Equipment.Name.len() > 0) { - local EquName = FontAssetManager.GenerateNormal(Equipment.Name, false, { + local UpgradeName = ""; + local SeparateLevelName = ""; + local DrawName = Equipment.Name; + if (Equipment.Upgrade > 0) UpgradeName = "+" + Equipment.Upgrade; + if (Equipment.SeparateLevel > 0) SeparateLevelName = "(" + Equipment.SeparateLevel + ")"; + if ((Equipment.Upgrade + Equipment.SeparateLevel) > 0) DrawName = UpgradeName + SeparateLevelName + " " + DrawName; + local EquName = FontAssetManager.GenerateNormal(DrawName, false, { color = GameItem.EquipmentInfoTag.rarity_color[Equipment.Rarity] }); Canvas.DrawActor(EquName, 41, 7); @@ -80,7 +86,7 @@ class GameItem.EquipmentInfo extends Yosin_Window { Canvas.DrawLine(3, 37, 207, 38); //绘制品级 - local Percentage = Equipment.Property ? Equipment.Property.Percentage : 100; + local Percentage = Equipment.Percentage; //品级文字 local PercentageGradeText = FontAssetManager.GenerateNormal(GetPercentageText(Percentage), false, { color = sq_RGBA(255, 240, 0, 255) @@ -115,7 +121,7 @@ class GameItem.EquipmentInfo extends Yosin_Window { Canvas.DrawActor(MinUseLevelText, 210 - MinUseLevelText.GetSize().w - 6, 57); //绘制交易类型 如果有主体属性读取 否则一律为封装 - local TradeType = Equipment.Property ? Equipment.Property.TradeType : 0; + local TradeType = Equipment.TradeType; local TradeTypeText = FontAssetManager.GenerateNormal(GameItem.EquipmentInfoTag.trade_type_text[TradeType], false, { color = GameItem.EquipmentInfoTag.trade_type_color[TradeType] }); @@ -135,7 +141,7 @@ class GameItem.EquipmentInfo extends Yosin_Window { Canvas.DrawActor(SellPriceText, 210 - SellPriceText.GetSize().w - 6, 105); //绘制耐久度 - local DurabilityText = FontAssetManager.GenerateNormal("耐久度 " + (Equipment.Property ? Equipment.Property.Durability : Equipment.Durability) + "/" + Equipment.Durability, false, { + local DurabilityText = FontAssetManager.GenerateNormal("耐久度 " + (Equipment.CurrentDurability == -1 ? Equipment.Durability : Equipment.CurrentDurability) + "/" + Equipment.Durability, false, { color = sq_RGBA(133, 121, 80, 255) }); Canvas.DrawActor(DurabilityText, 6, 121); @@ -157,6 +163,24 @@ class GameItem.EquipmentInfo extends Yosin_Window { //绘制分割 AddSliceLine(); + //绘制强化和增幅逻辑 + if ((Equipment.Upgrade + Equipment.SeparateLevel) > 0) { + local UpgradeInfo; + if (Equipment.Upgrade > 0) { + UpgradeInfo = FontAssetManager.GenerateNormal("+" + Equipment.Upgrade + " 强化 ,", false, { + color = sq_RGBA(103, 214, 236, 255) + }); + Canvas.DrawActor(UpgradeInfo, 6, RealCanvasHeight); + } + if (Equipment.SeparateLevel > 0) { + local SeparateLevelInfo = FontAssetManager.GenerateNormal("+" + Equipment.SeparateLevel + " 锻造", false, { + color = sq_RGBA(180, 106, 254, 255) + }); + Canvas.DrawActor(SeparateLevelInfo, UpgradeInfo ? UpgradeInfo.GetSize().w : 6, RealCanvasHeight); + } + AddHeight(); + } + //绘制物理攻击力 DrawAttack("EquipmentPhysicalAttack", "物理攻击力"); //绘制魔法攻击力 @@ -289,12 +313,11 @@ class GameItem.EquipmentInfo extends Yosin_Window { if (typeof Equipment[Type] == "array") { local MaxValue = Equipment[Type][0]; local MinValue = Equipment[Type][1]; - local Rate = Equipment.Property ? Equipment.Property[Type + "Rate"] : 100; - Rate = Rate.tofloat() / 100.0; + local Rate = 1.0; RealValue = (MinValue + ((MaxValue - MinValue).tofloat() * Rate).tointeger()); } //百分比计算过的数据 - else if (typeof Equipment[Type] == "integer") { + else if (typeof Equipment[Type] == "integer" || typeof Equipment[Type] == "float") { RealValue = Equipment[Type]; } local AttackText = FontAssetManager.GenerateNormal(TypeName + " " + RealValue, false, { @@ -351,6 +374,18 @@ class GameItem.Equipment extends GameItem.Item { Idx = -1; //装备名称 Name = ""; + //强化或增幅等级 + Upgrade = 0; + //锻造等级 + SeparateLevel = 0; + //增幅属性 0 无 1 力量 2 智力 3 体力 4 精神 + EquipIncrease = 0; + //是否封装 + IsWrap = 0; + //在封装次数 + WrapCount = 0; + //交易类型 + TradeType = 0; //装备类型 Type = -1; //装备槽位 @@ -373,6 +408,10 @@ class GameItem.Equipment extends GameItem.Item { SellPrice = -1; //耐久度 Durability = -1; + //当前耐久度 + CurrentDurability = -1; + //装备品质 + Percentage = 100; //冒险家名望 AdventurerFame = 0; //装备可穿戴职业 @@ -416,6 +455,10 @@ class GameItem.Equipment extends GameItem.Item { EquipmentMagicalAttack = 0; //独立攻击力 SeparateAttack = 0; + //物理防御力 + EquipmentPhysicalDefense = 0; + //魔法防御力 + EquipmentMagicalDefense = 0; //攻击速度 AttackSpeed = 0; @@ -446,6 +489,11 @@ class GameItem.Equipment extends GameItem.Item { //描述 FlavorText = null; + + function _typeof() { + return "Equipment"; + } + constructor(...) { //直接裸构造 if (vargv.len() == 0) { @@ -453,81 +501,155 @@ class GameItem.Equipment extends GameItem.Item { } //通过参数构造 else if (vargv.len() == 1) { + local EquInfo; //通过ID构造 if (typeof vargv[0] == "integer") { - local EquInfo = AssetManager.GetEquipment(vargv[0]); - if (EquInfo) { - Idx = vargv[0]; - //名称 - if (EquInfo.rawin("name")) Name = EquInfo["name"]; - //类型 - if (EquInfo.rawin("type")) GetRealEquipmentType(EquInfo["type"].path); - //最低使用等级 - if (EquInfo.rawin("minimum level")) Minimum_level = EquInfo["minimum level"]; - //等级组 - if (EquInfo.rawin("grade")) Grade = EquInfo["grade"]; - //稀有度 - if (EquInfo.rawin("rarity")) Rarity = EquInfo["rarity"]; - //重量 - if (EquInfo.rawin("weight")) Weight = EquInfo["weight"]; - //组名 - if (EquInfo.rawin("item group name")) GroupName = EquInfo["item group name"]; - //购买价格 - if (EquInfo.rawin("price")) Price = EquInfo["price"]; - //维修价格 - if (EquInfo.rawin("repair price")) RepairPrice = EquInfo["repair price"]; - //出售价格 - if (EquInfo.rawin("value")) SellPrice = EquInfo["value"]; - //耐久度 - if (EquInfo.rawin("durability")) Durability = EquInfo["durability"]; - //冒险家名望 - if (EquInfo.rawin("adventurerfame")) AdventurerFame = EquInfo["adventurerfame"]; - //职业 - if (EquInfo.rawin("usable_job")) Job = EquInfo["usable_job"]; - //图标 - if (EquInfo.rawin("icon")) Icon = EquInfo["icon"]; - if (EquInfo.rawin("Ani")) Animation_Job = EquInfo["Ani"]; - if (EquInfo.rawin("DirPath")) DirPath = EquInfo["DirPath"]; - if (EquInfo.rawin("aurora_effects")) Aurora_effects = EquInfo["aurora_effects"]; - - //四维 - if (EquInfo.rawin("physical attack")) PhysicalAttack = EquInfo["physical attack"]; - if (EquInfo.rawin("magical attack")) MagicalAttack = EquInfo["magical attack"]; - if (EquInfo.rawin("physical defense")) PhysicalDefense = EquInfo["physical defense"]; - if (EquInfo.rawin("magical defense")) MagicalDefense = EquInfo["magical defense"]; - //属强 - if (EquInfo.rawin("all elemental attack")) AllElementalAttack = EquInfo["all elemental attack"]; - if (EquInfo.rawin("dark attack")) DarkAttack = EquInfo["dark attack"]; - if (EquInfo.rawin("light attack")) LightAttack = EquInfo["light attack"]; - if (EquInfo.rawin("water attack")) WaterAttack = EquInfo["water attack"]; - if (EquInfo.rawin("fire attack")) FireAttack = EquInfo["fire attack"]; - //三攻 - if (EquInfo.rawin("equipment physical attack")) EquipmentPhysicalAttack = EquInfo["equipment physical attack"]; - if (EquInfo.rawin("equipment magical attack")) EquipmentMagicalAttack = EquInfo["equipment magical attack"]; - if (EquInfo.rawin("separate attack")) SeparateAttack = EquInfo["separate attack"]; - //三速 - if (EquInfo.rawin("attack speed")) AttackSpeed = EquInfo["attack speed"]; - if (EquInfo.rawin("cast speed")) CastSpeed = EquInfo["cast speed"]; - if (EquInfo.rawin("move speed")) MoveSpeed = EquInfo["move speed"]; - //双暴 - if (EquInfo.rawin("physical critical hit")) PhysicalCriticalHit = EquInfo["physical critical hit"]; - if (EquInfo.rawin("magical critical hit")) MagicalCriticalHit = EquInfo["magical critical hit"]; - //命中率 - if (EquInfo.rawin("stuck")) Stuck = -EquInfo["stuck"]; - //四属抗 - if (EquInfo.rawin("dark resistance")) DarkResistance = EquInfo["dark resistance"]; - if (EquInfo.rawin("light resistance")) LightResistance = EquInfo["light resistance"]; - if (EquInfo.rawin("water resistance")) WaterResistance = EquInfo["water resistance"]; - if (EquInfo.rawin("fire resistance")) FireResistance = EquInfo["fire resistance"]; - //属性攻击 - if (EquInfo.rawin("elemental property")) ElementalProperty = EquInfo["elemental property"]; - //描述 - if (EquInfo.rawin("flavor text")) FlavorText = EquInfo["flavor text"]; - } + EquInfo = AssetManager.GetEquipment(vargv[0]); + Idx = vargv[0]; + ConstructEquipmentFromScript(EquInfo); + } + //通过Table来构造 + else if (typeof vargv[0] == "table") { + local Info = vargv[0]; + EquInfo = AssetManager.GetEquipment(Info.EquipId); + Idx = Info.EquipId; + ConstructEquipmentFromScript(EquInfo); + IterateEquipmentBasedOnActualEquipmentInformation(Info); } } } + //根据装备实际信息迭代装备 + function IterateEquipmentBasedOnActualEquipmentInformation(Info) { + //装备附魔 //TODO + //装备强化等级或增幅等级 + this.Upgrade = Info.EquipUpgrade; + //装备锻造等级 + this.SeparateLevel = Info.EquipSeparate; + //装备增幅属性 + this.EquipIncrease = Info.EquipIncrease; + //装备力量百分比 + this.PhysicalAttack *= (Info.EquipPowerPercentage.tofloat() / 100.0); + //装备智力百分比 + this.MagicalAttack *= (Info.EquipIntellectPercentage.tofloat() / 100.0); + //装备体力百分比 + this.PhysicalDefense *= (Info.EquipStaminaPercentage.tofloat() / 100.0); + //装备精神百分比 + this.MagicalDefense *= (Info.EquipSpiritPercentage.tofloat() / 100.0); + + //装备物理攻击百分比 + this.EquipmentPhysicalAttack = this.EquipmentPhysicalAttack[0] + ((this.EquipmentPhysicalAttack[1] - this.EquipmentPhysicalAttack[0]) * (Info.EquipPhysicalAttackPercentage.tofloat() / 100.0)); + //装备魔法攻击百分比 + this.EquipmentMagicalAttack = this.EquipmentMagicalAttack[0] + ((this.EquipmentMagicalAttack[1] - this.EquipmentMagicalAttack[0]) * (Info.EquipMagicAttackPercentage.tofloat() / 100.0)); + //装备独立攻击百分比 + this.SeparateAttack = this.SeparateAttack[0] + ((this.SeparateAttack[1] - this.SeparateAttack[0]) * (Info.EquipIndependentAttackPercentage.tofloat() / 100.0)); + //装备物理防御百分比 + this.EquipmentPhysicalDefense = this.EquipmentPhysicalDefense[0] + ((this.EquipmentPhysicalDefense[1] - this.EquipmentPhysicalDefense[0]) * (Info.EquipPhysicalDefensePercentage.tofloat() / 100.0)); + //装备魔法防御百分比 + this.EquipmentMagicalDefense = this.EquipmentMagicalDefense[0] + ((this.EquipmentMagicalDefense[1] - this.EquipmentMagicalDefense[0]) * (Info.EquipMagicDefensePercentage.tofloat() / 100.0)); + + //装备全属强 + this.AllElementalAttack += Info.EquipAllElementalAttack; + //装备水属强 + this.WaterAttack += Info.EquipWaterAttack; + //装备火属强 + this.FireAttack += Info.EquipFireAttack; + //装备光属强 + this.LightAttack += Info.EquipLightAttack; + //装备暗属强 + this.DarkAttack += Info.EquipDarkAttack; + //装备品质 + this.Percentage = Info.EquipPercentage; + //装备再封装次数 + this.WrapCount = Info.EquipWrapCount; + //装备是否封装 + this.IsWrap = Info.EquipIsWrap; + //耐久度 + this.CurrentDurability = Info.EquipDurability; + //交易类型 + this.TradeType = Info.EquipTradeType; + } + + //根据装备脚本信息构造装备 + function ConstructEquipmentFromScript(EquInfo) { + //如果获取到对应的装备脚本信息 + if (EquInfo) { + //名称 + if (EquInfo.rawin("name")) Name = EquInfo["name"]; + //类型 + if (EquInfo.rawin("type")) GetRealEquipmentType(EquInfo["type"].path); + //最低使用等级 + if (EquInfo.rawin("minimum level")) Minimum_level = EquInfo["minimum level"]; + //等级组 + if (EquInfo.rawin("grade")) Grade = EquInfo["grade"]; + //稀有度 + if (EquInfo.rawin("rarity")) Rarity = EquInfo["rarity"]; + //重量 + if (EquInfo.rawin("weight")) Weight = EquInfo["weight"]; + //组名 + if (EquInfo.rawin("item group name")) GroupName = EquInfo["item group name"]; + //购买价格 + if (EquInfo.rawin("price")) Price = EquInfo["price"]; + //维修价格 + if (EquInfo.rawin("repair price")) RepairPrice = EquInfo["repair price"]; + //出售价格 + if (EquInfo.rawin("value")) SellPrice = EquInfo["value"]; + //耐久度 + if (EquInfo.rawin("durability")) Durability = EquInfo["durability"]; + //冒险家名望 + if (EquInfo.rawin("adventurerfame")) AdventurerFame = EquInfo["adventurerfame"]; + //职业 + if (EquInfo.rawin("usable_job")) Job = EquInfo["usable_job"]; + //图标 + if (EquInfo.rawin("icon")) Icon = EquInfo["icon"]; + if (EquInfo.rawin("Ani")) Animation_Job = EquInfo["Ani"]; + if (EquInfo.rawin("DirPath")) DirPath = EquInfo["DirPath"]; + if (EquInfo.rawin("aurora_effects")) Aurora_effects = EquInfo["aurora_effects"]; + + //四维 + if (EquInfo.rawin("physical attack")) PhysicalAttack = EquInfo["physical attack"]; + if (EquInfo.rawin("magical attack")) MagicalAttack = EquInfo["magical attack"]; + if (EquInfo.rawin("physical defense")) PhysicalDefense = EquInfo["physical defense"]; + if (EquInfo.rawin("magical defense")) MagicalDefense = EquInfo["magical defense"]; + //属强 + if (EquInfo.rawin("all elemental attack")) AllElementalAttack = EquInfo["all elemental attack"]; + if (EquInfo.rawin("dark attack")) DarkAttack = EquInfo["dark attack"]; + if (EquInfo.rawin("light attack")) LightAttack = EquInfo["light attack"]; + if (EquInfo.rawin("water attack")) WaterAttack = EquInfo["water attack"]; + if (EquInfo.rawin("fire attack")) FireAttack = EquInfo["fire attack"]; + //三攻 + if (EquInfo.rawin("equipment physical attack")) EquipmentPhysicalAttack = EquInfo["equipment physical attack"]; + else EquipmentPhysicalAttack = [0, 0]; + if (EquInfo.rawin("equipment magical attack")) EquipmentMagicalAttack = EquInfo["equipment magical attack"]; + else EquipmentMagicalAttack = [0, 0]; + if (EquInfo.rawin("separate attack")) SeparateAttack = EquInfo["separate attack"]; + else SeparateAttack = [0, 0]; + //物理防御和魔法防御 + if (EquInfo.rawin("equipment physical defense")) EquipmentPhysicalDefense = EquInfo["equipment physical defense"]; + else EquipmentPhysicalDefense = [0, 0]; + if (EquInfo.rawin("equipment magical defense")) EquipmentMagicalDefense = EquInfo["equipment magical defense"]; + else EquipmentMagicalDefense = [0, 0]; + //三速 + if (EquInfo.rawin("attack speed")) AttackSpeed = EquInfo["attack speed"]; + if (EquInfo.rawin("cast speed")) CastSpeed = EquInfo["cast speed"]; + if (EquInfo.rawin("move speed")) MoveSpeed = EquInfo["move speed"]; + //双暴 + if (EquInfo.rawin("physical critical hit")) PhysicalCriticalHit = EquInfo["physical critical hit"]; + if (EquInfo.rawin("magical critical hit")) MagicalCriticalHit = EquInfo["magical critical hit"]; + //命中率 + if (EquInfo.rawin("stuck")) Stuck = -EquInfo["stuck"]; + //四属抗 + if (EquInfo.rawin("dark resistance")) DarkResistance = EquInfo["dark resistance"]; + if (EquInfo.rawin("light resistance")) LightResistance = EquInfo["light resistance"]; + if (EquInfo.rawin("water resistance")) WaterResistance = EquInfo["water resistance"]; + if (EquInfo.rawin("fire resistance")) FireResistance = EquInfo["fire resistance"]; + //属性攻击 + if (EquInfo.rawin("elemental property")) ElementalProperty = EquInfo["elemental property"]; + //描述 + if (EquInfo.rawin("flavor text")) FlavorText = EquInfo["flavor text"]; + } else error("没有对应的装备信息"); + } + //设置真实装备类型 function SetRealEquipmentType(AType, BType) { SlotType = AType; @@ -548,16 +670,6 @@ class GameItem.Equipment extends GameItem.Item { else if (EType == "aurora avatar") SetRealEquipmentType("aurora", "aurora"); } - //获取装备信息窗口 - function GetEquipmentInfoWindow() { - return GameItem.EquipmentInfo(this); - } - - //获取装备图标精灵 - function GetEquipmentIconSprite() { - return GameItem.EquipmentIcon(this); - } - //穿戴装备回调 function OnWearStart() { diff --git a/sqr/User/Asset/Item/Item.nut b/sqr/User/Asset/Item/Item.nut index 8bd94ed..900159f 100644 --- a/sqr/User/Asset/Item/Item.nut +++ b/sqr/User/Asset/Item/Item.nut @@ -7,4 +7,31 @@ GameItem <- {}; class GameItem.Item { + function _typeof() { + return "Item"; + } + + + //获取信息窗口 + function GetInfoWindow() { + if (typeof this == "Equipment") { + return GameItem.EquipmentInfo(this); + } else if (typeof this == "Stackable") { + return GameItem.StackableInfo(this); + } + + error("GameItem::Info:: 未知物品类型"); + } + + //获取图标精灵 + function GetIconSprite() { + if (typeof this == "Equipment") { + return GameItem.EquipmentIcon(this); + } else if (typeof this == "Stackable") { + return GameItem.StackableIcon(this); + } + error("GameItem::Icon:: 未知物品类型"); + } + + } \ No newline at end of file diff --git a/sqr/User/Asset/Item/Stackable.nut b/sqr/User/Asset/Item/Stackable.nut new file mode 100644 index 0000000..fc4b7a9 --- /dev/null +++ b/sqr/User/Asset/Item/Stackable.nut @@ -0,0 +1,264 @@ +/* +文件名:Stackable.nut +路径:User/Asset/Item/Stackable.nut +创建日期:2025-01-18 01:46 +文件用途:可堆叠物品 +*/ +//消耗品图标窗口 +class GameItem.StackableIcon extends CL_CanvasObject { + + constructor(Stackable, RenderCount = true) { + base.constructor(); + ResizeAndClear(32, 32); + BeginDraw(); + //构造图标 及图标边框 + if (Stackable.Icon) { + //图标 + local Icon = CL_SpriteFrameObject(Stackable.Icon.path, Stackable.Icon.index); + DrawSpriteFrame(Icon, 0, 0); + + //边框 + local IconFrame = CL_SpriteFrameObject("sprite/item/iconmark.img", 62 + GameItem.EquipmentInfoTag.rarityframe_color_idx[Stackable.Rarity]); + DrawSpriteFrame(IconFrame, 0, 0); + + //数量 + if (RenderCount && Stackable.Count > 0) { + local CountText = Yosin_Mininumber(Stackable.Count); + DrawActor(CountText, 28 - CountText.GetSize().w, 0); + } + } + EndDraw(); + } +} + +//消耗品信息窗口 +class GameItem.StackableInfo extends Yosin_Window { + //消耗品 + Stackable = null; + //画布 + Canvas = null; + //画布实际高度 + RealCanvasHeight = 0; + + constructor(Stackable) { + this.Stackable = Stackable.weakref(); + base.constructor(clock() + "StackableInfo" + Stackable.Idx, 0, 0, 0, 0, 0); + + Init(); + + local background = Yosin_NineBoxStretch(211, RealCanvasHeight + 10, "sprite/interface/lenheartwindowcommon.img", 213); + background.SetZOrder(-1); + Addchild(background); + } + + function Init() { + Canvas = CL_CanvasObject(); + Canvas.ResizeAndClear(210, 600); + Canvas.SetFillBrush(sq_RGBA(59, 56, 57, 250)); + Canvas.SetStrokeBrush(sq_RGBA(59, 56, 57, 250)); + Canvas.BeginDraw(); + + //构造图标 及图标边框 + if (Stackable.Icon) { + local Icon = GameItem.StackableIcon(Stackable, false); + Canvas.DrawActor(Icon, 7, 7); + } + + //绘制名称 + if (Stackable.Name.len() > 0) { + local DrawName = Stackable.Name; + local EquName = FontAssetManager.GenerateNormal(DrawName, false, { + color = GameItem.EquipmentInfoTag.rarity_color[Stackable.Rarity] + }); + Canvas.DrawActor(EquName, 41, 7); + } + + //绘制分割线 + Canvas.DrawLine(3, 37, 207, 38); + + + //绘制稀有度名称 + local RarityTagName = FontAssetManager.GenerateNormal(GameItem.EquipmentInfoTag.rarity_name_tag[Stackable.Rarity], false, { + color = GameItem.EquipmentInfoTag.rarity_color[Stackable.Rarity] + }); + Canvas.DrawActor(RarityTagName, 210 - RarityTagName.GetSize().w - 6, 41); + + //绘制类型 + local RealGroupName = Stackable.GroupName ? Stackable.GroupName : "cube stuff"; + local GroupNameText = FontAssetManager.GenerateNormal(GameItem.EquipmentInfoTag.item_group_name_table[RealGroupName], false, { + color = sq_RGBA(194, 161, 56, 255) + }); + Canvas.DrawActor(GroupNameText, 6, 41); + + + //下面的绘制逻辑开始使用行put来做 + RealCanvasHeight = 64; + + + //绘制交易类型 如果有主体属性读取 否则一律为封装 + local TradeType = Stackable.TradeType; + local TradeTypeText = FontAssetManager.GenerateNormal(GameItem.EquipmentInfoTag.trade_type_text[TradeType], false, { + color = GameItem.EquipmentInfoTag.trade_type_color[TradeType] + }); + Canvas.DrawActor(TradeTypeText, 6, 60); + + //绘制售价 + local RealSellPrice = (Stackable.SellPrice == -1 ? (Stackable.Price == -1 ? 0 : Stackable.Price) : Stackable.SellPrice) / 5; + local SellPriceText = FontAssetManager.GenerateNormal(RealSellPrice + "金币", false, { + color = sq_RGBA(133, 121, 78, 255) + }); + Canvas.DrawActor(SellPriceText, 210 - SellPriceText.GetSize().w - 6, 60); + + //绘制分割 + AddSliceLine(); + + //绘制描述 + if (Stackable.FlavorText) { + // //绘制分割 + // Canvas.DrawLine(3, RealCanvasHeight + 3, 207, RealCanvasHeight + 3); + // RealCanvasHeight += 6; + + local Text = FontAssetManager.GenerateNormal(Stackable.FlavorText, false, { + color = sq_RGBA(133, 121, 80, 255), + wrap_width = 200 + }); + Canvas.DrawActor(Text, 6, RealCanvasHeight); + RealCanvasHeight += Text.GetSize().h; + } + + Canvas.EndDraw(); + Addchild(Canvas); + } + + //增加行高 + function AddHeight() { + RealCanvasHeight += 16; + } + //增加分割行 + function AddSliceLine() { + RealCanvasHeight += 18; + Canvas.DrawLine(3, RealCanvasHeight, 207, RealCanvasHeight); + RealCanvasHeight += 2; + } + +} + + +class GameItem.Stackable extends GameItem.Item { + + //物品ID + Idx = -1; + //物品名称 + Name = ""; + //数量 + Count = 0; + + //物品类型 + Type = null; + //交易类型 + TradeType = 0; + + //物品最低使用等级 + Minimum_level = 0; + //物品等级组 + Grade = 0; + //物品稀有度 + Rarity = 0; + //物品重量 + Weight = 0; + //物品组名 + GroupName = null; + //物品购买价格 + Price = 0; + //物品维修价格 + RepairPrice = 0; + //物品出售价格 + SellPrice = 0; + //物品职业 + Job = null; + //物品图标 + Icon = null; + //物品描述 + FlavorText = ""; + + function _typeof() { + return "Stackable"; + } + + constructor(...) { + //直接裸构造 + if (vargv.len() == 0) { + + } + //通过参数构造 + else if (vargv.len() == 1) { + local StkInfo; + //通过ID构造 + if (typeof vargv[0] == "integer") { + Idx = vargv[0]; + ConstructStackableFromScript(AssetManager.GetStackable(Idx)); + } + //通过脚本信息构造 + else if (typeof vargv[0] == "table") { + Idx = vargv[0].ItemId; + ConstructStackableFromScript(AssetManager.GetStackable(Idx)); + IterateStackableBasedOnActualStackableInformation(vargv[0]); + } + + } + } + + //根据消耗品脚本信息构造消耗品 + function ConstructStackableFromScript(StkInfo) { + //如果获取到对应的消耗品脚本信息 + if (StkInfo) { + //名称 + if (StkInfo.rawin("name")) Name = StkInfo["name"]; + //类型 + // if (StkInfo.rawin("type")) GetRealStackableType(StkInfo["type"].path); + //最低使用等级 + if (StkInfo.rawin("minimum level")) Minimum_level = StkInfo["minimum level"]; + //等级组 + if (StkInfo.rawin("grade")) Grade = StkInfo["grade"]; + //稀有度 + if (StkInfo.rawin("rarity")) Rarity = StkInfo["rarity"]; + //重量 + if (StkInfo.rawin("weight")) Weight = StkInfo["weight"]; + //组名 + if (StkInfo.rawin("item group name")) GroupName = StkInfo["item group name"]; + //购买价格 + if (StkInfo.rawin("price")) Price = StkInfo["price"]; + //维修价格 + if (StkInfo.rawin("repair price")) RepairPrice = StkInfo["repair price"]; + //出售价格 + if (StkInfo.rawin("value")) SellPrice = StkInfo["value"]; + //职业 + if (StkInfo.rawin("usable_job")) Job = StkInfo["usable_job"]; + //图标 + if (StkInfo.rawin("icon")) Icon = StkInfo["icon"]; + //描述 + if (StkInfo.rawin("explain")) FlavorText = StkInfo["explain"]; + //交易类型 + if (StkInfo.rawin("trade_type")) TradeType = StkInfo["trade_type"]; + } + } + + //根据实际的消耗品信息迭代消耗品 + function IterateStackableBasedOnActualStackableInformation(Info) { + Count = Info.ItemCount; + TradeType = Info.ItemTradeType; + } +} + + +if (!getroottable().rawin("chongzaiflag")) { + getroottable()["chongzaiflag"] <- true; +} else { + //遍历窗口队列 如果可见则调用Show + for (local i = 0; i< _SYS_WINDOW_LIST_.len(); i++) { + local Window = _SYS_WINDOW_LIST_[i]; + Window.Visible = false; + Window.RemoveSelf(); + } + TestStage(); +} \ No newline at end of file diff --git a/sqr/User/Object/ActiveObject/CharacterObjectClass.nut b/sqr/User/Object/ActiveObject/CharacterObjectClass.nut index 0729ec7..c977e6f 100644 --- a/sqr/User/Object/ActiveObject/CharacterObjectClass.nut +++ b/sqr/User/Object/ActiveObject/CharacterObjectClass.nut @@ -246,7 +246,7 @@ GameObject.CreateCharacter <- function(Job = 0, EquIdList = [], IsPlayer = false //通过Cid获取当前地图的角色 GameObject.GetCharacterByCid <- function(cid) { - //从全局地图中找到城镇并设置角色移动状态 + //从全局地图中找到角色 if (GlobalTownManager.CurrentMap) { //遍历所有角色 foreach(obj in GlobalTownManager.CurrentMap.PlayerList) { diff --git a/sqr/User/Object/Map/MapObject.nut b/sqr/User/Object/Map/MapObject.nut index 76909da..16c4cc3 100644 --- a/sqr/User/Object/Map/MapObject.nut +++ b/sqr/User/Object/Map/MapObject.nut @@ -423,7 +423,6 @@ class Map extends Actor { m_camera.MovableAreaY = m_height - m_data.wide_mode_camer_vertical_correction; m_camera.BackgroundOffset = m_data.background_pos; - // OpenMovableAreaBorder(); } diff --git a/sqr/User/Socket/FunctionalPack.nut b/sqr/User/Socket/FunctionalPack.nut index 8eb58fe..9894975 100644 --- a/sqr/User/Socket/FunctionalPack.nut +++ b/sqr/User/Socket/FunctionalPack.nut @@ -71,10 +71,10 @@ function RegisterFunctionalPack() { //背包类型 local InventoryType = Pack.Get_Byte(); //背包道具数量 - local InventoryItemCount = Pack.Get_Int(); + local InventoryItemCount = Pack.Get_Short(); //项目List - local ItemList = []; + local ItemList = {}; //道具数据 for (local i = 0; i< InventoryItemCount; i++) { @@ -87,6 +87,8 @@ function RegisterFunctionalPack() { Pos = Pack.Get_Short(), //装备ID EquipId = Pack.Get_Int(), + //交易类型 + EquipTradeType = Pack.Get_Byte(), //装备附魔编号 EquipEnchant = Pack.Get_Int(), //装备强化等级或增幅等级 @@ -113,23 +115,47 @@ function RegisterFunctionalPack() { EquipPhysicalDefensePercentage = Pack.Get_Byte(), //装备魔法防御百分比 EquipMagicDefensePercentage = Pack.Get_Byte(), + //装备全属强 + EquipAllElementalAttack = Pack.Get_Byte(), + //装备水属强 + EquipWaterAttack = Pack.Get_Byte(), + //装备火属强 + EquipFireAttack = Pack.Get_Byte(), + //装备光属强 + EquipLightAttack = Pack.Get_Byte(), + //装备暗属强 + EquipDarkAttack = Pack.Get_Byte(), + //装备品质 + EquipPercentage = Pack.Get_Byte(), //装备再封装次数 EquipWrapCount = Pack.Get_Byte(), + //装备是否封装 + EquipIsWrap = Pack.Get_Byte(), + //耐久度 + EquipDurability = Pack.Get_Byte(), + } + ItemList[EquInfo.Pos] <- GameItem.Equipment(EquInfo); + //装备栏 + if (InventoryType == 2) { + ClientCharacterInventory.PageList[0].SetItemCollectionList(0, ItemList); } - ItemList.push(EquInfo); - print("构造装备"); } //消耗品类型 - if (Type == 2) { + if (Type == 2 || Type == 3) { local ItemInfo = { //道具位置 Pos = Pack.Get_Short(), //道具ID ItemId = Pack.Get_Int(), + //交易类型 + ItemTradeType = Pack.Get_Byte(), //道具数量 ItemCount = Pack.Get_Int(), } - ItemList.push(ItemInfo); + ItemList[ItemInfo.Pos] <- GameItem.Stackable(ItemInfo); + + + ClientCharacterInventory.PageList[0].SetItemCollectionList(InventoryType - 2, ItemList); } } }); diff --git a/sqr/User/Stage/LodingStage.nut b/sqr/User/Stage/LodingStage.nut index 1ba3ff7..0ed237b 100644 --- a/sqr/User/Stage/LodingStage.nut +++ b/sqr/User/Stage/LodingStage.nut @@ -13,8 +13,8 @@ function InitGame() { // MySocket("127.0.0.1", 19666); //设定全局默认音量 - _Globa_Audio_Volume_ = 0.03; - _Globa_Sound_Volume_ = 0.03; + _Globa_Audio_Volume_ = 0.001; + _Globa_Sound_Volume_ = 0.001; Script(); @@ -28,6 +28,8 @@ function InitGame() { _GameController_(); //初始化顶部工具条UI Sq_CreateWindow(_Top_tool, "窗口顶部工具条", 208, 0, 650, 20, 0); + //初始化聊天窗口 + Sq_CreateWindow(_PlayerChat, "玩家聊天窗口", 1066, 0, 332, 600, 0); //预加载 Animation("ui/charactercreate/dust.ani"); diff --git a/sqr/User/Stage/TestStage.nut b/sqr/User/Stage/TestStage.nut index d00d5a4..b275ef9 100644 --- a/sqr/User/Stage/TestStage.nut +++ b/sqr/User/Stage/TestStage.nut @@ -9,12 +9,77 @@ function TestStage() { T.SetName("测试舞台"); 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); + // local Stk = GameItem.Stackable(3037); + // Stk.Count = 10; + // local Window = Stk.GetInfoWindow(); + // Window.SetPosition(300, 80); + // Window.ResetFocus(); + + // local EquInfo = { + // //装备位置 + // Pos = 0, + // //装备ID + // EquipId = 27675, + // //交易类型 + // EquipTradeType = 0, + // //装备附魔编号 + // EquipEnchant = 1, + // //装备强化等级或增幅等级 + // EquipUpgrade = 12, + // //装备锻造 + // EquipSeparate = 6, + // //装备增幅属性 0 无 1 力量 2 智力 3 体力 4 精神 + // EquipIncrease = 1, + // //装备力量百分比 + // EquipPowerPercentage = 95, + // //装备智力百分比 + // EquipIntellectPercentage = 95, + // //装备体力百分比 + // EquipStaminaPercentage = 60, + // //装备精神百分比 + // EquipSpiritPercentage = 75, + // //装备物理攻击百分比 + // EquipPhysicalAttackPercentage = 90, + // //装备魔法攻击百分比 + // EquipMagicAttackPercentage = 90, + // //装备独立攻击百分比 + // EquipIndependentAttackPercentage = 80, + // //装备物理防御百分比 + // EquipPhysicalDefensePercentage = 80, + // //装备魔法防御百分比 + // EquipMagicDefensePercentage = 77, + // ///装备全属强 + // EquipAllElementalAttack = 15, + // //装备水属强 + // EquipWaterAttack = 15, + // //装备火属强 + // EquipFireAttack = 15, + // //装备光属强 + // EquipLightAttack = 15, + // //装备暗属强 + // EquipDarkAttack = 15, + // //装备品质 + // EquipPercentage = 15, + // //装备再封装次数 + // EquipWrapCount = 2, + // //装备是否封装 + // EquipIsWrap = 1, + // //耐久度 + // EquipDurability = 15, + // } + // local Equ = GameItem.Equipment(EquInfo); + // local Window = Equ.GetInfoWindow(); + // Window.SetPosition(100, 80); + // Window.ResetFocus(); + // local Equ = GameItem.Equipment(27675); // local Window = Equ.GetEquipmentInfoWindow(); // Window.SetPosition(100, 80); @@ -38,9 +103,8 @@ function TestStage() { // local Window = Sq_CreateWindow(_Inventory, "背包窗口", 150, 12, 262, 548, 20); - local MessageWindow = Sq_CreateWindow(_Message, "聊天窗口", 1066, 0, 332, 600, 0); - // Window.equipmentPage.ItemCollection.SetItemList([{ + // Window.EquipmentPage.ItemCollection.SetItemList([{ // ItemId = 27675 // }, { // ItemId = 101020048 diff --git a/sqr/User/UI/Widget/Mininumber.nut b/sqr/User/UI/Widget/Mininumber.nut new file mode 100644 index 0000000..d6d6056 --- /dev/null +++ b/sqr/User/UI/Widget/Mininumber.nut @@ -0,0 +1,39 @@ +/* +文件名:Mininumber.nut +路径:User/UI/Widget/Mininumber.nut +创建日期:2025-01-20 17:49 +文件用途: +*/ +//迷你数字 +class Yosin_Mininumber extends CL_CanvasObject { + + //图片数字宽度 + Yosin_Mininumber_NumberWidth = [6, 4, 6, 6, 6, 6, 6, 6, 6, 6]; + + // 构造函数 + constructor(Number) { + + if (typeof Number != "integer") error("参数错误"); + local NumberString = Number.tostring(); + + base.constructor(); + + // 创建画布 + CL_CanvasObject(); + // 重设大小并清空 + ResizeAndClear(NumberString.len() * 6, 10); + // 开始绘制 + BeginDraw(); + + local DrawTextWidth = 0; + foreach(value in NumberString) { + local realnum = value - 48; + DrawSpriteFrame(CL_SpriteFrameObject("sprite/interface/mininumberset.img", realnum), DrawTextWidth, 0); + DrawTextWidth += Yosin_Mininumber_NumberWidth[realnum]; + } + + + // 结束绘制 + EndDraw(); + } +} \ No newline at end of file diff --git a/sqr/User/UI/Window/5_Inventory/5_Inventory.nut b/sqr/User/UI/Window/5_Inventory/5_Inventory.nut index c316016..c5335a2 100644 --- a/sqr/User/UI/Window/5_Inventory/5_Inventory.nut +++ b/sqr/User/UI/Window/5_Inventory/5_Inventory.nut @@ -4,13 +4,125 @@ 创建日期:2025-01-06 14:06 文件用途: 背包窗口 */ + +//钱包类 +class Inventory_Wallet extends Yosin_CommonUi { + + //复活币数量 + ReviveCoinCount = 0; + ReviveCoinText = null; + //胜利的证明数量 + WinCoinCount = 0; + WinCoinText = null; + //点卷数量 + CeraCount = 0; + CeraText = null; + //金币数量 + GoldCount = 0; + GoldText = null; + + //override + function _set(idx, val) { + switch (idx) { + case "ReviveCoin": { + ReviveCoinCount = val; + ReviveCoinText.SetText(ReviveCoinCount + "个"); + ReviveCoinText.SetPosition(120 - ReviveCoinText.GetSize().w, 2); + break; + } + case "WinCoin": { + WinCoinCount = val; + WinCoinText.SetText(WinCoinCount + "个"); + WinCoinText.SetPosition(245 - WinCoinText.GetSize().w, 2); + break; + } + case "Cera": { + CeraCount = val; + CeraText.SetText(CeraCount + "点券"); + CeraText.SetPosition(120 - CeraText.GetSize().w, 27); + break; + } + case "Gold": { + GoldCount = val; + GoldText.SetText(GoldCount + "金币"); + GoldText.SetPosition(245 - GoldText.GetSize().w, 27); + break; + } + default: + throw null; + break; + } + } + + constructor(x, y, w, h) { + base.constructor(x, y, w, h); + + RegisterWidget(); + } + + + // 钱包 + function RegisterWidget() { + + local txtColor = sq_RGBA(130, 105, 61, 255); + local bg = CL_SpriteObject("sprite/interface/newstyle/windows/inventory/inventory.img", 27); + Addchild(bg); + + // 复活币个数 + ReviveCoinText = FontAssetManager.GenerateNormal(ReviveCoinCount + "个", true, { + color = txtColor + }); + ReviveCoinText.SetPosition(120 - ReviveCoinText.GetSize().w + bg.X, 2); + Addchild(ReviveCoinText); + + + // 胜利的证明 + WinCoinText = FontAssetManager.GenerateNormal(WinCoinCount + "个", true, { + color = txtColor + }); + WinCoinText.SetPosition(245 - WinCoinText.GetSize().w + bg.X, 2); + Addchild(WinCoinText); + + + // 商城 + local storeBtn = Yosin_BaseButton(1 + bg.X, 25, 23, 23 "sprite/interface/newstyle/windows/inventory/inventory.img", 3); + //点击事件回调 + // storeBtn.OnClick = function(Button) { + // }.bindenv(this); + AddUIChild(storeBtn); + + + // 点券 + CeraText = FontAssetManager.GenerateNormal(CeraCount + "点券", true, { + color = txtColor + }); + CeraText.SetPosition(120 - CeraText.GetSize().w, 27); + Addchild(CeraText); + + // 金币按钮 + local moneyBtn = Yosin_BaseButton(126 + bg.X, storeBtn.Y, 23, 23 "sprite/interface/newstyle/windows/inventory/inventory.img", 7); + //点击事件回调 + // moneyBtn.OnClick = function(Button) { + // }.bindenv(this); + AddUIChild(moneyBtn); + + // 金币数量 + GoldText = FontAssetManager.GenerateNormal(GoldCount + "金币", true, { + color = txtColor + }); + GoldText.SetPosition(245 - GoldText.GetSize().w, 27); + Addchild(GoldText); + } +} + + //主类 class _Inventory extends Yosin_Window { - // 装备页 /物品栏 - EquipmentPage = null; - // 装扮页E - DressUpPage = null; + //分页集合 0装备 1装扮 2宠物 + PageList = null; + //钱包 + Wallet = null; // 物品栏排列按钮 permutationBtn = null; @@ -19,23 +131,22 @@ class _Inventory extends Yosin_Window { // 物品栏搜索按钮 saerchBtn = null; - PageIndex = null; - uiPageIndex = null; - // 物品栏排列搜索按钮 在显示物品栏页 时的Y坐标 itemSetBtnY = 467; //是否可见 Visible = false; constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) { + PageList = []; + //调用父类构造函数 base.constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH); - PageIndex = 1; - uiPageIndex = 1; - //注册控件 RegisterWidget(); + //注册背包页面 + RegisterPage(); + //注册按键回调事件 Input.RegisterGameKeyCode(CONTROLLER.OPTION_HOTKEY_ITEM_INVENTORY, function(Flag) { //抬起的时候 @@ -63,160 +174,80 @@ class _Inventory extends Yosin_Window { closeBtn.SetZOrder(1); closeBtn.OnClick = function(btn) { CloseWindow(); - } + }.bindenv(this); AddUIChild(closeBtn); //置顶按钮 local topBtn = Yosin_BaseButton(Width - 35, 2, 13, 13, "sprite/interface/lenheartwindowcommon.img", 455); topBtn.DownSimulateOffset = false; - topBtn.OnClick = function(btn) { - // btn.Parent.PageIndex += 1; - print(btn.Parent.PageIndex); - } + topBtn.OnClick = function(btn) {} AddUIChild(topBtn); //分页按钮 local titlesBtn = Yosin_RowMoreTitleBtn(5, 25, 250, ["物品栏", "装扮", "宠物", "护石"], "sprite/interface/lenheartwindowcommon.img", 160); AddUIChild(titlesBtn); - titlesBtn.LBDownOnClick = function(btns, index) { - btns.Parent.PageIndex = index; - }; + ChangPage(index); + }.bindenv(this); - //物品栏 装备页 - EquipmentPage = Inventory_EquipmentPage(2, titlesBtn.bottom(), 300, 441); - AddUIChild(EquipmentPage); - EquipmentPage.SetVisible(false); - // 装扮页 - DressUpPage = Inventory_DressUpPage(4, titlesBtn.bottom(), 300, 441); - AddUIChild(DressUpPage); - - // 钱包 - AddMoneyItem(); - - // 添加设置物品栏的按钮 - AddItemCollectSetBtn(); - } - - // 添加设置物品栏的按钮 - function AddItemCollectSetBtn() { // 排列按钮 permutationBtn = Yosin_BaseButton(226, itemSetBtnY, 28, 23 "sprite/interface/newstyle/windows/inventory/inventory.img", 73); + permutationBtn.SetZOrder(1); AddUIChild(permutationBtn); // 设置 setBtn = Yosin_BaseButton(permutationBtn.X - 20, permutationBtn.Y, 18, 23 "sprite/interface/newstyle/windows/inventory/inventory.img", 77); + setBtn.SetZOrder(1); AddUIChild(setBtn); // 搜索 saerchBtn = Yosin_BaseButton(setBtn.X - 24, permutationBtn.Y, 23, 23 "sprite/interface/newstyle/windows/inventory/inventory.img", 94); + saerchBtn.SetZOrder(1); AddUIChild(saerchBtn); + + //钱包类 + Wallet = Inventory_Wallet(7, Height - 55, 248, 49); + AddUIChild(Wallet); } - // 钱包 - function AddMoneyItem() { - - local txtColor = sq_RGBA(130, 105, 61, 255); - - local bg = CL_SpriteObject("sprite/interface/newstyle/windows/inventory/inventory.img", 27); - bg.SetPosition(7, Height - 55); - Addchild(bg); - - // 复活币个数 - local ReviveNum = FontAssetManager.GenerateNormal("23434个", true, { - color = txtColor - }); - ReviveNum.SetPosition(120 - ReviveNum.GetSize().w + bg.X, bg.Y + 2); - Addchild(ReviveNum); - - - // 胜利的证明 - local winNum = FontAssetManager.GenerateNormal("23434个", true, { - color = txtColor - }); - 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); - //点击事件回调 - // storeBtn.OnClick = function(Button) { - // }.bindenv(this); - AddUIChild(storeBtn); - - - // 点券 - local storeNum = FontAssetManager.GenerateNormal("23434点券", true, { - color = txtColor - }); - storeNum.SetPosition(bg.X + 120 - storeNum.GetSize().w, bg.Y + 27); - Addchild(storeNum); - - // 金币按钮 - local moneyBtn = Yosin_BaseButton(126 + bg.X, storeBtn.Y, 23, 23 "sprite/interface/newstyle/windows/inventory/inventory.img", 7); - //点击事件回调 - // moneyBtn.OnClick = function(Button) { - // }.bindenv(this); - AddUIChild(moneyBtn); - - // 金币数量 - local storeNum = FontAssetManager.GenerateNormal("23434金币", true, { - color = txtColor - }); - storeNum.SetPosition(bg.X + 245 - storeNum.GetSize().w, bg.Y + 27); - Addchild(storeNum); + function RegisterPage() { + //物品栏 装备页 + local EquipmentPage = Inventory_EquipmentPage(2, 46, 300, 441); + PageList.push(EquipmentPage); + AddUIChild(EquipmentPage); + // 装扮页 + local DressUpPage = Inventory_DressUpPage(4, 46, 300, 441); + PageList.push(DressUpPage); + AddUIChild(DressUpPage); + DressUpPage.SetVisible(false); } - - + //override //逻辑入口 function Proc(Dt) { SyncPos(X, Y); base.Proc(Dt); - - if (PageIndex != uiPageIndex) { - uiPageIndex = PageIndex; - ChangPage(); - } - } + // 切换页面 - function ChangPage() { - - EquipmentPage.SetVisible(false); - DressUpPage.SetVisible(false); - - - if (PageIndex == 0) { - EquipmentPage.SetVisible(true); - permutationBtn.SetPosition(permutationBtn.X, itemSetBtnY); - setBtn.SetPosition(setBtn.X, itemSetBtnY); - saerchBtn.SetPosition(saerchBtn.X, itemSetBtnY); - } else if (PageIndex == 1) { - DressUpPage.SetVisible(true); - permutationBtn.SetPosition(permutationBtn.X, itemSetBtnY + 28); - setBtn.SetPosition(setBtn.X, permutationBtn.Y); - saerchBtn.SetPosition(saerchBtn.X, permutationBtn.Y); + function ChangPage(gIndex) { + foreach(Index, Page in PageList) { + Page.SetVisible(false); + if (gIndex == Index) { + Page.SetVisible(true); + if (gIndex == 0) { + permutationBtn.SetPosition(permutationBtn.X, itemSetBtnY); + setBtn.SetPosition(setBtn.X, itemSetBtnY); + saerchBtn.SetPosition(saerchBtn.X, itemSetBtnY); + } else if (gIndex == 1) { + permutationBtn.SetPosition(permutationBtn.X, itemSetBtnY + 28); + setBtn.SetPosition(setBtn.X, permutationBtn.Y); + saerchBtn.SetPosition(saerchBtn.X, permutationBtn.Y); + } + } } } - - - -} - -// if (!getroottable().rawin("chongzaiflag")) { -// getroottable()["chongzaiflag"] <- true; -// } else { -// //遍历窗口队列 如果可见则调用Show -// for (local i = 0; i< _SYS_WINDOW_LIST_.len(); i++) { -// local Window = _SYS_WINDOW_LIST_[i]; -// Window.Visible = false; -// Window.RemoveSelf(); -// } -// TestStage(); -// } \ No newline at end of file +} \ No newline at end of file diff --git a/sqr/User/UI/Window/5_Inventory/Inventory_DressUpPage.nut b/sqr/User/UI/Window/5_Inventory/Inventory_DressUpPage.nut index b6f2d39..3a6c3ec 100644 --- a/sqr/User/UI/Window/5_Inventory/Inventory_DressUpPage.nut +++ b/sqr/User/UI/Window/5_Inventory/Inventory_DressUpPage.nut @@ -30,7 +30,9 @@ class Inventory_DressUpPage extends Yosin_CommonUi { local titlesBtn = Yosin_RowMoreTitleBtn(2, 180, 250, ["装扮", "徽章"], "sprite/interface/lenheartwindowcommon.img", 160); AddUIChild(titlesBtn); + // titlesBtn.LBDownOnClick = function(btns, index) { + // }; } // 添加按钮 @@ -78,7 +80,7 @@ class Inventory_CharactersDressUp extends CL_CanvasObject { // 魔法阵 local MagicLight = CL_SpriteFrameObject("sprite/interface/newstyle/windows/inventory/inventory.img", 179); - DrawSpriteFrame(MagicLight, 5,55); + DrawSpriteFrame(MagicLight, 5, 55); // 人物打光 local CharacterLight = CL_SpriteFrameObject("sprite/interface/newstyle/windows/inventory/inventory.img", 178); @@ -87,18 +89,4 @@ class Inventory_CharactersDressUp extends CL_CanvasObject { } -} - - - -// if (!getroottable().rawin("chongzaiflag")) { -// getroottable()["chongzaiflag"] <- true; -// } else { -// //遍历窗口队列 如果可见则调用Show -// for (local i = 0; i< _SYS_WINDOW_LIST_.len(); i++) { -// local Window = _SYS_WINDOW_LIST_[i]; -// Window.Visible = false; -// Window.RemoveSelf(); -// } -// TestStage(); -// } \ No newline at end of file +} \ No newline at end of file diff --git a/sqr/User/UI/Window/5_Inventory/Inventory_EquipmentPage.nut b/sqr/User/UI/Window/5_Inventory/Inventory_EquipmentPage.nut index 84191c2..0a1285d 100644 --- a/sqr/User/UI/Window/5_Inventory/Inventory_EquipmentPage.nut +++ b/sqr/User/UI/Window/5_Inventory/Inventory_EquipmentPage.nut @@ -67,8 +67,14 @@ class Inventory_EquipmentPage extends Yosin_CommonUi { AddUIChild(itemBtns); itemBtns.LBDownOnClick = function(btns, index) { - print(index); - }; + foreach(Iindex, ItemCollectionBuffer in ItemCollection) { + if (Iindex == index) { + ItemCollectionBuffer.SetVisible(true); + } else { + ItemCollectionBuffer.SetVisible(false); + } + } + }.bindenv(this); // 物品栏边框 local itemBg = Yosin_NineBoxStretch(253, 245, "sprite/interface/lenheartwindowcommon.img", 97); @@ -78,9 +84,11 @@ class Inventory_EquipmentPage extends Yosin_CommonUi { // 物品栏 ItemCollection = []; for (local i = 0; i< 5; i++) { - ItemCollection.push(_ItemCollection(itemBg.X + 7, itemBg.Y + 3, 7)); + local ItemCollectionBuffer = _ItemCollection(itemBg.X + 7, itemBg.Y + 3, 7); + ItemCollection.push(ItemCollectionBuffer); + AddUIChild(ItemCollectionBuffer); + if (i != 0) ItemCollectionBuffer.SetVisible(false); } - AddUIChild(ItemCollection[0]); local itemBgBottom = itemBg.bottom(); diff --git a/sqr/User/UI/Window/5_Inventory/ItemCollect.nut b/sqr/User/UI/Window/5_Inventory/ItemCollect.nut index aab35ac..0eb4152 100644 --- a/sqr/User/UI/Window/5_Inventory/ItemCollect.nut +++ b/sqr/User/UI/Window/5_Inventory/ItemCollect.nut @@ -29,12 +29,12 @@ class ItemSlot { function SetItem(Item) { this.Item = Item; - this.ItemIcon = this.Item.GetEquipmentIconSprite(); + this.ItemIcon = this.Item.GetIconSprite(); } //生成详细信息 function GenerateInfo() { - this.ItemInfo = this.Item.GetEquipmentInfoWindow(); + this.ItemInfo = this.Item.GetInfoWindow(); } //显示详细信息 @@ -124,11 +124,8 @@ class _ItemCollection extends Yosin_CommonUi { //创建道具 foreach(Index, ItemObject in gItemList) { - local ItemId = ItemObject.ItemId; - //TODO - local Item = GameItem.Equipment(ItemId); ItemList[Index] = ItemSlot(); - ItemList[Index].SetItem(Item); + ItemList[Index].SetItem(ItemObject); } RefreshItemList(); @@ -163,6 +160,7 @@ class _ItemCollection extends Yosin_CommonUi { //override //鼠标事件回调 function OnMouseProc(MousePos_X, MousePos_Y) { + if (!Visible) return; base.OnMouseProc(MousePos_X, MousePos_Y); if (isInRect) { @@ -170,6 +168,8 @@ class _ItemCollection extends Yosin_CommonUi { local xx = MousePos_X - WorldPosition.x; local yy = MousePos_Y - WorldPosition.y; local column = (yy / 30).tointeger(); + //悬停的时候有可能悬停到最下面的最后一条缝 会导致判定行数多了一行 所以这里做限制 + column = (column <= (RowNum - 1) ? column : (RowNum - 1)); local row = (xx / 30).tointeger(); //指向的项目位置 local Idx = column * 8 + row; @@ -190,7 +190,7 @@ class _ItemCollection extends Yosin_CommonUi { //如果当前没有拖拽物品时才打开详细信息窗口 if (!DragItem) { //显示详细信息 - ItemList[Idx].ShowInfo(MousePos_X - 50, MousePos_Y - 150); + ItemList[Idx].ShowInfo(MousePos_X - 50, MousePos_Y - ((ItemList[Idx].ItemInfo.RealCanvasHeight + 10) / 2)); //记录当前显示的对象 CurrentShowItem = ItemList[Idx]; } @@ -231,7 +231,7 @@ class _ItemCollection extends Yosin_CommonUi { DragItem = ItemList[ItemPos]; DragItemPos = ItemPos; ItemList[ItemPos] = null; - local IconBuffer = DragItem.Item.GetEquipmentIconSprite(); + local IconBuffer = DragItem.Item.GetIconSprite(); IconBuffer.SetPosition(-15, -15); IMouse.AttachObjectBottom("ItemCollectDragItem", IconBuffer); RefreshItemList(); diff --git a/sqr/User/UI/Window/6_Message.nut b/sqr/User/UI/Window/6_Message.nut index 406d3fd..13ccdb3 100644 --- a/sqr/User/UI/Window/6_Message.nut +++ b/sqr/User/UI/Window/6_Message.nut @@ -125,7 +125,8 @@ class Message_Backgournd extends CL_CanvasObject { // 系统 local SystemBround = Yosin_NineBoxStretch( 321, 72, "sprite/interface/newstyle/windows/chatting/chatting_ver4.img", 265); - DrawSprite(SystemBround, 6, 35); + SystemBround.SetPosition(6, 35); + DrawSprite(SystemBround); // 喇叭按钮 local megaphoneBtnBackground = Yosin_EmeStretch(53, 21, "sprite/interface/lenheartwindowcommon.img", 166); @@ -139,11 +140,13 @@ class Message_Backgournd extends CL_CanvasObject { // 喇叭 local megaphoneBround = Yosin_NineBoxStretch(321, 72, "sprite/interface/newstyle/windows/chatting/chatting_ver4.img", 265); - DrawSprite(megaphoneBround, 6, 130); + megaphoneBround.SetPosition(6, 130); + DrawSprite(megaphoneBround, 6); // 消息 local MessageBround = Yosin_NineBoxStretch(321, 345, "sprite/interface/newstyle/windows/chatting/chatting_ver4.img", 265); - DrawSprite(MessageBround, 6, 225); + MessageBround.SetPosition(6, 225); + DrawSprite(MessageBround); // 结束绘制 diff --git a/sqr/User/UI/Window/6_PlayerChat.nut b/sqr/User/UI/Window/6_PlayerChat.nut new file mode 100644 index 0000000..1d25ff8 --- /dev/null +++ b/sqr/User/UI/Window/6_PlayerChat.nut @@ -0,0 +1,269 @@ +/* +文件名:6_PlayerChat.nut +路径:User/UI/Window/6_PlayerChat.nut +创建日期:2025-01-20 18:03 +文件用途: +*/ + +//主类 +class _PlayerChat extends Yosin_Window { + + //是否为顶层窗口 + IsTop = true; + + constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) { + base.constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH); + + local background = PlayerChat_Backgournd(); + Addchild(background); + + RegisterWidget(); + } + + function RegisterWidget() { + + // 普通 + local ordinary = PlayerChat_SplicingButton(6, 206, 53, 20, 8, "普通", sq_RGBA(255, 255, 255, 255)); + AddUIChild(ordinary); + ordinary.LBDownOnClick = function(btn) { + print(111); + } + ordinary.OnTriangleClick = function(btn) { + print(222); + } + + // 公会 + local notice = PlayerChat_SplicingButton(60, 206, 53, 20, 47, "公会", sq_RGBA(254, 77, 245, 255)); + AddUIChild(notice); + notice.LBDownOnClick = function(btn) { + print(111); + } + notice.OnTriangleClick = function(btn) { + print(222); + } + + // 频道 + local channel = PlayerChat_SplicingButton(114, 206, 53, 20, 48, "频道", sq_RGBA(221, 153, 197, 255)); + AddUIChild(channel); + channel.LBDownOnClick = function(btn) { + print(111); + } + channel.OnTriangleClick = function(btn) { + print(222); + } + + // 募集 + local raise = PlayerChat_SplicingButton(168, 206, 53, 20, 49, "募集", sq_RGBA(105, 212, 238, 255)); + AddUIChild(raise); + raise.LBDownOnClick = function(btn) { + print(111); + } + raise.OnTriangleClick = function(btn) { + print(222); + } + + } + + //逻辑入口 + function Proc(Dt) { + SyncPos(X, Y); + base.Proc(Dt); + + } + + +} + + + +// 背景 +class PlayerChat_Backgournd extends CL_CanvasObject { + + constructor() { + base.constructor(); + + DrawBackground(); + + } + + + // 绘制背景 + function DrawBackground() { + + // 创建画布 + CL_CanvasObject(); + // 重设大小并清空 + ResizeAndClear(332, 600); + // 开始绘制 + BeginDraw(); + + + local topLine = CL_SpriteFrameObject("sprite/interface/newstyle/windows/chatting/chatting_ver4.img", 159); + DrawSpriteFrame(topLine, 0, 0); + + local topBg = CL_SpriteObject("sprite/interface/newstyle/windows/chatting/chatting_ver4.img", 160); + topBg.SetPosition(0, 2); + topBg.SetScale(1, 28); + DrawSprite(topBg); + + local bimg = CL_SpriteFrameObject("sprite/interface/newstyle/windows/chatting/chatting_ver4.img", 161); + DrawSpriteFrame(bimg, 0, 30); + + local bottomBg = CL_SpriteObject("sprite/interface/newstyle/windows/chatting/chatting_ver4.img", 162); + bottomBg.SetPosition(0, 561); + bottomBg.SetScale(1, 38); + DrawSprite(bottomBg); + + local bottomLine = CL_SpriteFrameObject("sprite/interface/newstyle/windows/chatting/chatting_ver4.img", 163); + DrawSpriteFrame(bottomLine, 0, 598); + + // 系统按钮 + local systemBtnBackground = Yosin_EmeStretch(53, 21, "sprite/interface/lenheartwindowcommon.img", 166); + DrawSprite(systemBtnBackground, 6, 15); + + local systemText = FontAssetManager.GenerateNormal("系统", true, { + color = sq_RGBA(200, 173, 134, 255) + }); + DrawActor(systemText, 18, 18); + + // 系统 + local SystemBround = Yosin_NineBoxStretch(321, 72, "sprite/interface/newstyle/windows/chatting/chatting_ver4.img", 265); + DrawSprite(SystemBround, 6, 35); + + // 喇叭按钮 + local megaphoneBtnBackground = Yosin_EmeStretch(53, 21, "sprite/interface/lenheartwindowcommon.img", 166); + DrawSprite(megaphoneBtnBackground, 6, 109); + + // 喇叭 + local megaphoneext = FontAssetManager.GenerateNormal("喇叭", true, { + color = sq_RGBA(255, 239, 1, 255) + }); + DrawActor(megaphoneext, 18, 112); + + // 喇叭 + local megaphoneBround = Yosin_NineBoxStretch(321, 72, "sprite/interface/newstyle/windows/chatting/chatting_ver4.img", 265); + DrawSprite(megaphoneBround, 6, 130); + + // 消息 + local PlayerChatBround = Yosin_NineBoxStretch(321, 345, "sprite/interface/newstyle/windows/chatting/chatting_ver4.img", 265); + DrawSprite(PlayerChatBround, 6, 225); + + + // 结束绘制 + EndDraw(); + + } + + +} + + + + +// 消息分类按钮 +class PlayerChat_SplicingButton extends Yosin_CommonUi { + + //按钮状态 + State = 0; + + Sprite = null; + SpriteState = -1; + FrameList = null; + + select = false; + cacheY = null; + + + LBDownOnClick = null; + OnTriangleClick = null; + + + constructor(X, Y, W, H, Idx, title, titleColor) { + base.constructor(X, Y, W, H); + + cacheY = Y; + FrameList = []; + Sprite = CL_SpriteObject(); + Addchild(Sprite); + + for (local i = 0; i< 3; i++) { + + local canvas = Yosin_EmeStretch(W, H, "sprite/interface/lenheartwindowcommon.img", 160 + i * 3); + local Sf = canvas.ExportSpriteFrame(); + FrameList.push(Sf); + } + + // 文字 + local Text = FontAssetManager.GenerateNormal(title, true, { + color = titleColor + }); + Text.SetPosition(12, 1); + Addchild(Text); + + // 三角 + local triangle = CL_SpriteObject("sprite/interface/newstyle/windows/chatting/chatting_new.img", Idx); + triangle.SetPosition(W - 15, 8); + Addchild(triangle); + + // 按钮 + local bigButton = Yosin_BaseButton(0, 0, W - 15, H, "sprite/interface/lenheartwindowcommon.img", 70); + AddUIChild(bigButton); + bigButton.OnClick = function(btn) { + if (LBDownOnClick) { + LBDownOnClick(this); + }; + }.bindenv(this); + + // 三角按钮 + local triangleButton = Yosin_BaseButton(W - 15, 0, 15, H, "sprite/interface/lenheartwindowcommon.img", 70); + AddUIChild(triangleButton); + triangleButton.OnClick = function(btn) { + if (OnTriangleClick) { + OnTriangleClick(this); + }; + }.bindenv(this); + + } + + function ChangeFrame() { + //状态更改 刷新精灵帧 + if (State != SpriteState) { + if (State == 2) { + Y = cacheY - 1; + SyncPos(X, Y); + } else if (SpriteState == 2) { + Y = cacheY; + SyncPos(X, Y); + } + SpriteState = State; + Sprite.SetFrame(FrameList[SpriteState]); + Sprite.SetPosition(0, 0); + } + } + + function Proc(Dt) { + + if (select) return; + + //不可用 + if (State == 3) { + + } else { + //按下 + if (isLBDown) { + State = 2; + select = true; + } + //悬停 + else if (isInRect) { + State = 1; + } + //普通 + else { + State = 0; + } + } + ChangeFrame(); + } + +} \ No newline at end of file diff --git a/sqr/User/main.nut b/sqr/User/main.nut index fcac026..d95e08f 100644 --- a/sqr/User/main.nut +++ b/sqr/User/main.nut @@ -14,8 +14,7 @@ function main(args) { local Game = GameWindow(); Game.title = "Yosin & Kiwano"; Game.bg_color = [255.0, 255.0, 255.0, 255.0]; - Game.size = [1398, 600]; - // Game.size = [1066, 600]; + Game.size = [1066 + 332, 600]; Game.v_sync = false; Game.frame_interval = 10000; Game.debug_mode = true; diff --git a/sqr/folder-alias.json b/sqr/folder-alias.json index cb84e2b..f768587 100644 --- a/sqr/folder-alias.json +++ b/sqr/folder-alias.json @@ -286,5 +286,11 @@ }, "User/UI/Window/5_Inventory/Inventory_DressUpPage.nut": { "description": "背包装扮页" + }, + "User/Asset/Item/Stackable.nut": { + "description": "消耗品及材料" + }, + "User/UI/Window/6_PlayerChat.nut": { + "description": "聊天消息窗口" } } \ No newline at end of file