TakeOnEquipCommand.lua 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. local TakeOnEquipCommand = class('TakeOnEquipCommand', framework.SimpleCommand)
  2. function TakeOnEquipCommand:ctor()
  3. end
  4. function TakeOnEquipCommand:execute(notification)--穿装备
  5. local playerProxy = global.Facade:retrieveProxy(global.ProxyTable.PlayerProperty)
  6. local data = notification:getBody()
  7. if not data then
  8. return
  9. end
  10. local BagProxy = global.Facade:retrieveProxy(global.ProxyTable.Bag)
  11. if BagProxy:GetBagCollimator() then --有准星操作
  12. return
  13. end
  14. local itemData = data.itemData
  15. local EquipProxy = global.Facade:retrieveProxy(global.ProxyTable.Equip)
  16. local pos = EquipProxy:GetEquipPosByStdMode(itemData.StdMode)
  17. if data.pos then
  18. pos = data.pos
  19. else
  20. local minPowerPos, onEquipMinPower, hasEquip = EquipProxy:GetEquipTakeOnPosByStdMode(itemData.StdMode)
  21. if minPowerPos >= 0 then
  22. pos = minPowerPos
  23. end
  24. end
  25. if not pos then
  26. return
  27. end
  28. local canUse, strList, notCheckUse = CheckItemUseNeed(itemData)
  29. if not canUse and not notCheckUse then
  30. for i, v in ipairs(strList) do
  31. if not v.can and not notCheckUse then
  32. local color = GUIFunction:ItemUseConditionColor(v.can)
  33. local conditionStr = string.format(GET_STRING(80049997), color, v.str)
  34. global.Facade:sendNotification(global.NoticeTable.SystemTips, conditionStr)
  35. break
  36. end
  37. end
  38. global.Facade:sendNotification(global.NoticeTable.Layer_Moved_Cancel)
  39. return
  40. end
  41. if not EquipProxy:CheckEquipCondition(pos) then
  42. return
  43. end
  44. local MakeIndex = itemData.MakeIndex
  45. local Name = itemData.Name
  46. LuaSendMsg(global.MsgType.MSG_CS_PLAYER_EQUIP_ON_REQUEST, MakeIndex, pos, 0, 0, Name, string.len(Name))
  47. end
  48. return TakeOnEquipCommand