2020.10.23 max按钮
This commit is contained in:
parent
a9f0c3de76
commit
29d523d233
File diff suppressed because it is too large
Load Diff
@ -96,6 +96,13 @@ function UIRoleInfoView:Init()
|
||||
self["ajustItem" .. i].subBtn.repeatButton:AddRepeatClickEventListener(function(idx, isOver)
|
||||
self:ChangeAttrPreview(i, false)
|
||||
end)
|
||||
|
||||
self["ajustItem" .. i].btn_max.button.onClick:AddListener(function()
|
||||
local max = self:CalcMaxAttr2(i)
|
||||
for j = 1, max do
|
||||
self:ChangeAttrPreview(i, true)
|
||||
end
|
||||
end)
|
||||
--self.uiBase:AddButtonUniqueEventListener(self["ajustItem"..i].addBtn.button, self, self.OnChangeAttr, i, 1)
|
||||
--self.uiBase:AddButtonUniqueEventListener(self["ajustItem"..i].subBtn.button, self, self.OnChangeAttr, i, -1)
|
||||
end
|
||||
@ -115,7 +122,7 @@ function UIRoleInfoView:Init()
|
||||
end)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- local vikingItemCount = 10
|
||||
@ -803,7 +810,7 @@ function UIRoleInfoView:RefreshNatureInfo()
|
||||
local heroData = self.controller:GetHeroLogicData(heroId)
|
||||
|
||||
--名字加载放在属性加载这里
|
||||
|
||||
|
||||
LogError("heroId: " .. tostring(heroId))
|
||||
if heroId == 1 then
|
||||
self.bg_Name.text_name.text.text = ManagerContainer.DataMgr.UserData:GetUserNickname()
|
||||
@ -817,16 +824,13 @@ function UIRoleInfoView:RefreshNatureInfo()
|
||||
--名字加载放在属性加载这里
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if self.oneAttrAddDic == nil then
|
||||
self.oneAttrAddDic = {}
|
||||
for i = Enum.HeroAttrType.STR, Enum.HeroAttrType.LUK do
|
||||
self.oneAttrAddDic[i] = 0
|
||||
end
|
||||
end
|
||||
|
||||
self.remainPoint.text.text = tostring(self.controller:GetRemainPoint())
|
||||
for i = Enum.HeroAttrType.STR, Enum.HeroAttrType.LUK do
|
||||
local v = GetBaseAttrsByType(baseAttrs, i)
|
||||
@ -872,13 +876,24 @@ function UIRoleInfoView:RefreshNatureInfo()
|
||||
end
|
||||
end
|
||||
|
||||
local tempattr = 0
|
||||
for i = Enum.HeroAttrType.STR, Enum.HeroAttrType.LUK do
|
||||
tempattr = tempattr + self.oneAttrAddDic[i]
|
||||
end
|
||||
|
||||
if tempattr == 0 then
|
||||
self.uIAnimator.natureTab.btn_SaveNature:SetActive(false)
|
||||
else
|
||||
self.uIAnimator.natureTab.btn_SaveNature:SetActive(true)
|
||||
end
|
||||
|
||||
self:RefreshAttrHexagon()
|
||||
end
|
||||
|
||||
--属性,保存属性信息
|
||||
function UIRoleInfoView:SaveNatureInfo()
|
||||
if self.oneAttrAddDic == nil or #self.oneAttrAddDic == 0 then return end
|
||||
--if self.oneAttrAddDic == nil or #self.oneAttrAddDic == 0 then return end
|
||||
if self.oneAttrAddDic == nil then return end
|
||||
local saveInfo = {}
|
||||
local baseAttrs = self.controller:GetLastBaseAttrs()
|
||||
for i = Enum.HeroAttrType.STR, Enum.HeroAttrType.LUK do
|
||||
@ -924,21 +939,32 @@ end
|
||||
--属性,重置属性
|
||||
function UIRoleInfoView:BtnResetNature()
|
||||
ManagerContainer.NetManager:SendMessage(ProtoMsgId.CS_RESET_ATTR_POINT_REQ,
|
||||
{ hero_id = self.controller:GetRoleUid() })
|
||||
{ hero_id = self.controller:GetRoleUid() }, function(data)
|
||||
end)
|
||||
|
||||
|
||||
for i = Enum.HeroAttrType.STR, Enum.HeroAttrType.LUK do
|
||||
self.oneAttrAddDic[i] = 0
|
||||
end
|
||||
self.twoAttrAddDic = {}
|
||||
self.controller:ResetRemainPoints()
|
||||
self:SaveNatureInfo()
|
||||
self:RefreshNatureInfo()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
--RefreshNatureInfo更新的属性有一定滞后性,需要手动更新文字和六边形
|
||||
for i = Enum.HeroAttrType.STR, Enum.HeroAttrType.LUK do
|
||||
if self.oneAttrAddDic then
|
||||
self["ajustItem" .. i].text_old.text.text = " " .. 1
|
||||
self["ajustItem" .. i].text_add.text.text = " +" .. self.oneAttrAddDic[i]
|
||||
end
|
||||
|
||||
self["ajustItem" .. i].text_add.text.text = " +" .. self.oneAttrAddDic[i]
|
||||
if self.oneAttrAddDic[i] == 0 then self["ajustItem" .. i].text_add.text.text = "" end
|
||||
|
||||
local maxAttr = CommonUtil.ToNumber(self:CalcMaxAttr2(i))
|
||||
self["ajustItem" .. i].text_max.text.text = maxAttr
|
||||
end
|
||||
end
|
||||
self.naturePointHexagon.strStart.transform.localPosition = self:RefreshAttrPlanePercentVec(
|
||||
0, self.naturePointHexagon.strEnd.transform.localPosition)
|
||||
@ -954,18 +980,15 @@ function UIRoleInfoView:BtnResetNature()
|
||||
0, self.naturePointHexagon.lukEnd.transform.localPosition)
|
||||
|
||||
self.naturePointHexagon.attr_plane.cUIPolygon:RefreshPolygonVertexs()
|
||||
|
||||
|
||||
end
|
||||
|
||||
function UIRoleInfoView:BtnSaveNature()
|
||||
|
||||
for i = Enum.HeroAttrType.STR, Enum.HeroAttrType.LUK do
|
||||
local baseAttrs = self.controller:GetLastBaseAttrs()
|
||||
local v = GetBaseAttrsByType(baseAttrs, i)
|
||||
if self.oneAttrAddDic then
|
||||
self["ajustItem".. i].text_old.text.text = " ".. (v+self.oneAttrAddDic[i])
|
||||
self["ajustItem".. i].text_add.text.text = " +".. 0
|
||||
self["ajustItem" .. i].text_old.text.text = " " .. (v + self.oneAttrAddDic[i])
|
||||
self["ajustItem" .. i].text_add.text.text = ""
|
||||
end
|
||||
end
|
||||
self:SaveNatureInfo()
|
||||
@ -977,15 +1000,38 @@ function UIRoleInfoView:RefreshAddPointText(attrtype)
|
||||
local v = GetBaseAttrsByType(baseAttrs, attrtype)
|
||||
if self.oneAttrAddDic then
|
||||
self["ajustItem" .. attrtype].text_old.text.text = " " .. v
|
||||
|
||||
self["ajustItem" .. attrtype].text_add.text.text = " +" .. self.oneAttrAddDic[attrtype]
|
||||
local maxAttr = CommonUtil.ToNumber(self:CalcMaxAttr(self.controller:GetHeroId(), attrtype))
|
||||
if self.oneAttrAddDic[attrtype] == 0 then self["ajustItem" .. attrtype].text_add.text.text = "" end
|
||||
|
||||
local maxAttr = CommonUtil.ToNumber(self:CalcMaxAttr2(attrtype))
|
||||
self["ajustItem" .. attrtype].text_max.text.text = maxAttr
|
||||
end
|
||||
end
|
||||
|
||||
function UIRoleInfoView:CalcMaxAttr2(type)
|
||||
local remain = tonumber(tostring(self.controller:GetRemainPoint()))
|
||||
--LogError("remain: "..remain)
|
||||
local baseAttrs = self.controller:GetLastBaseAttrs()
|
||||
local curlv = GetBaseAttrsByType(baseAttrs, type)
|
||||
local addlv = self.oneAttrAddDic[type]
|
||||
local lv = 0
|
||||
while (remain > 0) do
|
||||
local cost = ManagerContainer.CfgMgr:GetHeroQualityPointByLv(curlv + addlv + lv).cost
|
||||
|
||||
if remain - cost < 0 then
|
||||
break
|
||||
end
|
||||
remain = remain - cost
|
||||
lv = lv + 1
|
||||
end
|
||||
return lv
|
||||
end
|
||||
|
||||
--[[
|
||||
function UIRoleInfoView:CalcMaxAttr(heroId, maxAttrType)
|
||||
--self:RefreshAddPointAttr(heroId)
|
||||
local totalPoint = CommonUtil.ToNumber(self:CalcTotalPoint(heroId))
|
||||
local totalPoint = CommonUtil.ToNumber(self:CalcTotalPoint(heroId, maxAttrType))
|
||||
--local baseAttrs = self:GetLastBaseAttrs(heroId)
|
||||
local baseAttrs = { 1, 1, 1, 1, 1, 1 }
|
||||
|
||||
@ -1039,10 +1085,11 @@ function UIRoleInfoView:CalcMaxAttr(heroId, maxAttrType)
|
||||
return maxAttrPoint
|
||||
end
|
||||
|
||||
local function Attr2Points(totalCount, attr, pointData)
|
||||
if attr > 1 then
|
||||
local function Attr2Points(totalCount, attr,lv, pointData)
|
||||
if attr>1 then
|
||||
attr = attr - 1
|
||||
totalCount = SDataUtil.Add(totalCount, pointData[attr].cost)
|
||||
--totalCount=totalCount+1
|
||||
-- totalCount = totalCount + pointData[attr].cost
|
||||
else
|
||||
return totalCount
|
||||
@ -1051,7 +1098,7 @@ local function Attr2Points(totalCount, attr, pointData)
|
||||
return Attr2Points(totalCount, attr, pointData)
|
||||
end
|
||||
|
||||
function UIRoleInfoView:CalcTotalPoint(heroId)
|
||||
function UIRoleInfoView:CalcTotalPoint(heroId, maxAttrType)
|
||||
local baseAttrs = self.controller:GetLastBaseAttrs(heroId)
|
||||
local pointData = ManagerContainer.CfgMgr.QualityPointCfg
|
||||
|
||||
@ -1062,26 +1109,27 @@ function UIRoleInfoView:CalcTotalPoint(heroId)
|
||||
local dex = SDataUtil.InvConvert(baseAttrs[Enum.HeroAttrType.DEX])
|
||||
local luk = SDataUtil.InvConvert(baseAttrs[Enum.HeroAttrType.LUK])
|
||||
|
||||
local totalCount = self.controller:GetRoleDataAttrPoints(heroId)
|
||||
remainPoints = totalCount
|
||||
local totalCount = self.controller:GetRemainPoint()
|
||||
|
||||
|
||||
local oldTotalCount = 0
|
||||
local curTotalCountMap = {}
|
||||
for k, v in pairs(baseAttrs) do
|
||||
local type = k
|
||||
local curTotalCount = 0
|
||||
local curTotalCount = GetBaseAttrsByType(baseAttrs, type) + self.oneAttrAddDic[type]
|
||||
local lv = GetBaseAttrsByType(baseAttrs, type) + self.oneAttrAddDic[type]
|
||||
if type == Enum.HeroAttrType.STR then
|
||||
curTotalCount = Attr2Points(curTotalCount, str, pointData)
|
||||
curTotalCount = Attr2Points(curTotalCount, str,lv, pointData)
|
||||
elseif type == Enum.HeroAttrType.AGI then
|
||||
curTotalCount = Attr2Points(curTotalCount, agi, pointData)
|
||||
curTotalCount = Attr2Points(curTotalCount, agi, lv, pointData)
|
||||
elseif type == Enum.HeroAttrType.INT then
|
||||
curTotalCount = Attr2Points(curTotalCount, int, pointData)
|
||||
curTotalCount = Attr2Points(curTotalCount, int, lv, pointData)
|
||||
elseif type == Enum.HeroAttrType.VIT then
|
||||
curTotalCount = Attr2Points(curTotalCount, vit, pointData)
|
||||
curTotalCount = Attr2Points(curTotalCount, vit, lv, pointData)
|
||||
elseif type == Enum.HeroAttrType.DEX then
|
||||
curTotalCount = Attr2Points(curTotalCount, dex, pointData)
|
||||
curTotalCount = Attr2Points(curTotalCount, dex, lv, pointData)
|
||||
elseif type == Enum.HeroAttrType.LUK then
|
||||
curTotalCount = Attr2Points(curTotalCount, luk, pointData)
|
||||
curTotalCount = Attr2Points(curTotalCount, luk, lv, pointData)
|
||||
end
|
||||
curTotalCountMap[type] = curTotalCount
|
||||
oldTotalCount = SDataUtil.Add(oldTotalCount, curTotalCount)
|
||||
@ -1100,8 +1148,13 @@ function UIRoleInfoView:CalcTotalPoint(heroId)
|
||||
|
||||
local newTotalCount = SDataUtil.Add(oldTotalCount, totalCount)
|
||||
|
||||
return newTotalCount
|
||||
return curTotalCountMap[maxAttrType]
|
||||
end
|
||||
]]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
--endregion 属性
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user