miduo_client/Assets/ManagedResources/~Lua/Modules/Battle/View/Unit/WeaponView.lua

296 lines
12 KiB
Lua

local RoleConfig = ConfigManager.GetConfig(ConfigName.RoleConfig)
local ShenBing = ConfigManager.GetConfig(ConfigName.ShenBing)
local SkillLogicConfig = ConfigManager.GetConfig(ConfigName.SkillLogicConfig)
local healEffect = "c_xy_0012_skeff_tapsk_healeff"
local rageEffect = "s_jieling_hs_3006_skeff_casting_buff_nuqi"
WeaponView = BattleUnit.New()
function WeaponView.New(go, role, position, root)
local o = BattleUnit.New(go, role, position, root)
setmetatable(o, WeaponView)
WeaponView.__index = WeaponView
o:ctor(go, role, position, root)
return o
end
function WeaponView:onCreate(go, role, position, root)
self.spLoader = SpriteLoader.New()
self.RootPanel = root
self.GameObject = go
self.role = role
self.camp = role.camp
-- 创建技能播放器
self.castingEfectNode = role.camp == 0 and self.RootPanel.lingshouCastDown or self.RootPanel.lingshouCastUp
self.castingNameNode = Util.GetGameObject(self.castingEfectNode, role.camp == 0 and "EFFECT_Casting_LingShou_Xia/DongHua/MingZi" or "EFFECT_Casting_LingShou_Shang/DongHua/MingZi")
self.skillCastRoot = role.camp == 0 and self.RootPanel.lingshouCastDownRoot or self.RootPanel.lingshouCastUpRoot
self.liveRoot = role.camp == 0 and Util.GetGameObject(self.RootPanel.gameObject, "playerMonster/live") or Util.GetGameObject(self.RootPanel.gameObject, "enemyMonster/live")
--self.icon = Util.GetGameObject(go, "icon"):GetComponent("Image")
self.turnEffect=role.camp == 0 and self.RootPanel.lingshouDownEffect or self.RootPanel.lingshouUpEffect
-- 获取数据
-- self.livePath = nil
-- if position==100 then
-- if not role.roleData.id or role.roleData.id == 0 then
-- role.roleData.id = 20100
-- end
-- if role.roleData.id == 20100 then
-- if role.sex == ROLE_SEX.BOY then
-- self.livePath = "live2d_npc_boy"
-- else
-- self.livePath = "live2d_npc_girl"
-- end
-- -- 确定是主角
-- self.isMainPlayer = true
-- end
-- end
-- -- 配置表数据
-- self.config = SpiritAnimal[role.roleData.id]
self.weaponIcon=Util.GetGameObject(go,"Image"):GetComponent("Image")
LogError("role.uid====================="..role.uid)
if ShenBing[role.uid] then
self.weaponIcon.sprite=self.spLoader:LoadSprite(GetResourcePath(ShenBing[role.uid].Icon))
end
-- -- 如果不是男女主角
-- if not self.livePath then
-- self.livePath = GetResourcePath(self.config.Live)
-- self.icon.sprite = self.spLoader:LoadSprite(GetResourcePath(self.config.Icon))
-- end
-- self.play_liveScale = self.config.play_liveScale
-- self.enemy_liveScale = self.config.enemy_liveScale
-- self.offset = self.config.offset
-- self.outOffset = self.config.enemy_offset
-- self.spAtkTime = self.config.CastingSkills/1000
-- self.atkSoundTime = self.config.CastingAudio/1000
-- self.attackSound = self.config.sond
-- -- casting技能立绘
-- self.RoleLiveGO2=nil
-- local aaa=Util.GetGameObject(self.skillCastRoot.gameObject.transform.parent,self.livePath)
-- if aaa then
-- self.RoleLiveGO2=aaa
-- else
-- self.RoleLiveGO2 = poolManager:LoadLive(self.livePath, self.skillCastRoot.gameObject.transform.parent, Vector3.one, Vector3.zero)
-- end
-- self.RoleLiveGO2.transform:SetParent(self.skillCastRoot.gameObject.transform)
-- local offset = self.camp == 0 and self.offset or self.outOffset
-- self.RoleLiveGO2:GetComponent("RectTransform").anchoredPosition = Vector2.New(offset[1], offset[2])
-- if self.camp==1 then
-- self.RoleLiveGO2.transform.rotation=Vector3.New(0,180,0)
-- end
-- local scale = self.camp == 0 and self.play_liveScale or self.enemy_liveScale
-- self.RoleLiveGO2.transform.localScale = Vector3.one * scale --* 2
-- self.RoleLiveGO2:SetActive(false)
-- self.RoleLiveGOGraphic2 = self.RoleLiveGO2:GetComponent("SkeletonGraphic")
-- self.RoleLiveGOTran2 = self.RoleLiveGO2:GetComponent("RectTransform")
-- self.RoleLiveGOGraphic2.AnimationState:SetAnimation(0, "idle", true)
-- self.RoleLiveGOTran2.sizeDelta = Vector2.New(1000, 1000)
-- 创建技能播放器
self.SkillCaster = SkillCaster.New(self, self.spAtkTime, self.atkSoundTime, self.attackSound, self.castingEfectNode, self.castingNameNode)
-- if IsOpenBattleDebug then
-- local URoleProperty = go:GetComponent(typeof(RoleProperty))
-- if not URoleProperty then
-- URoleProperty = go:AddComponent(typeof(RoleProperty))
-- end
-- self.URoleProperty = URoleProperty
-- self.URoleProperty.uid = role.uid
-- role.data:Foreach(function (name, value)
-- self.URoleProperty:AddProperty(name, value)
-- end)
-- end
self.combat=nil
end
--
function WeaponView:OnSortingOrderChange(battleSorting)
end
function WeaponView:Update()
if IsOpenBattleDebug then
self.role.data:Foreach(function (name, value)
--self.URoleProperty:SetValue(name, value)
end)
end
end
-- 缩放
function WeaponView:DoScale(scale, dur, func)
if func then
func()
end
end
-- 设置高亮
function WeaponView:SetHighLight(isLight, eScale, dur, func)
if func then
func()
end
end
-- 播放动画
function WeaponView:PlaySpineAnim(gog, time, name, isLoop)
if isLoop then
gog.AnimationState:SetAnimation(time, name, isLoop)
else
local _complete = nil
_complete = function(state)
gog.AnimationState.Complete = gog.AnimationState.Complete - _complete
gog.AnimationState:SetAnimation(0, "idle", true)
end
gog.AnimationState:ClearTracks() -- 清除上一个动画的影响(修复概率攻击动画播放错误的问题)
gog.AnimationState:SetAnimation(time, name, isLoop)
gog.AnimationState.Complete = gog.AnimationState.Complete + _complete
end
end
local heroConfig=nil
function WeaponView:OnSkillCastStart(skill)
-- self.RoleLiveGO:SetActive(true)
local name=nil
local roleConfig=nil
if skill and skill.id and skill.id~=0 then
local aaa=SkillLogicConfig[skill.id].Hero
if aaa and aaa~=0 then
heroConfig=ConfigManager.GetConfigData(ConfigName.HeroConfig,aaa)
local liveId=heroConfig.Live
roleConfig=ConfigManager.GetConfigData(ConfigName.RoleConfig,aaa)
if liveId then
name=ConfigManager.GetConfigData(ConfigName.ArtResourcesConfig,liveId).Name
end
end
end
local offset = self.camp == 0 and self.offset or self.outOffset
-- self.RoleLiveGO2:GetComponent("RectTransform").anchoredPosition = Vector2.New(offset[1], offset[2])
-- if name then
-- self.RoleLiveGO3=nil
-- local aaa1=Util.GetGameObject(self.skillCastRoot.gameObject.transform.parent,name)
-- if aaa1 then
-- self.RoleLiveGO3=aaa1
-- else
-- self.RoleLiveGO3 = poolManager:LoadLive(name, self.skillCastRoot.gameObject.transform.parent, Vector3.one, Vector3.zero)
-- end
-- self.RoleLiveGO3.transform:SetParent(self.skillCastRoot.gameObject.transform)
-- self.RoleLiveGO3.transform:SetSiblingIndex(0)
-- --self.RoleLiveGO3.transform.position=Vector3.zero
-- local offset = self.camp == 0 and self.config.offset or self.config.enemy_offset
-- local add=roleConfig.enemy_offset
-- if self.camp==1 then
-- self.RoleLiveGO3.transform.rotation=Vector3.New(0,180,0)
-- self.RoleLiveGO3:GetComponent("RectTransform").anchoredPosition = Vector2.New(0, offset[2]+add[2]+180)
-- else
-- self.RoleLiveGO2:GetComponent("RectTransform").anchoredPosition = Vector2.New(offset[1], offset[2]+300)
-- self.RoleLiveGO3:GetComponent("RectTransform").anchoredPosition = Vector2.New(0, offset[2]+add[2]+480)
-- end
-- local scale = roleConfig.enemy_liveScale
-- self.RoleLiveGO3.transform.localScale = Vector3.one * scale --* 2
-- self.RoleLiveGO3:SetActive(false)
-- self.RoleLiveGOGraphic3 = self.RoleLiveGO3:GetComponent("SkeletonGraphic")
-- self.RoleLiveGOTran3 = self.RoleLiveGO3:GetComponent("RectTransform")
-- self.RoleLiveGOGraphic3.AnimationState:SetAnimation(0, "attack", true)
-- self.RoleLiveGOTran3.sizeDelta = Vector2.New(1000, 1000)
-- self.castingNameNode:GetComponent("Image").sprite = self.spLoader:LoadSprite("c_swhs_00000_t9")
-- local eid = BattleManager.GetCombatIdBySkin(skill.id, skill.owner.skinId)
-- self.combat = BattleManager.GetSkillCombat(eid)
-- else
-- self.RoleLiveGO3=nil
-- end
end
--
function WeaponView:OnSkillPlay()
--self:PlaySpineAnim(self.RoleLiveGOGraphic, 0, "attack", false)
end
--
function WeaponView:OnSkillEnd()
-- self.RoleLiveGO:SetActive(false)
end
function WeaponView:OnSkillCastingStart(skill)
if self.RoleLiveGO2 then
-- 提前进入下一阶段
self.turnEffect:SetActive(false)
self.RoleLiveGO2:SetActive(true)
self.RoleLiveGO2:GetComponent("RectTransform").rotation = Quaternion.Euler(Vector3.New(0, 0, 0))
if self.RoleLiveGO3 then
if (self.camp==0 and heroConfig and heroConfig.Toward==1) or (self.camp==1 and heroConfig and heroConfig.Toward==2) then
self.RoleLiveGO3:GetComponent("RectTransform").rotation = Quaternion.Euler(Vector3.New(0, 90, 0))
else
self.RoleLiveGO3:GetComponent("RectTransform").rotation = Quaternion.Euler(Vector3.New(0, -90, 0))
end
coroutine.start(function()
coroutine.wait(0.7)
-- self.RoleLiveGO2.transform:DOLocalMoveY(0, 0.2, false):OnComplete(function()
-- rightList[i].transform:DOLocalMoveX(10, 0.3, false)
self.RoleLiveGO2.transform:DORotate(Vector3.New(0, 90, 0),0.5):OnComplete(function()
self.RoleLiveGO2.gameObject:SetActive(false)
self.RoleLiveGO3.gameObject:SetActive(true)
if (self.camp==0 and heroConfig and heroConfig.Toward==1) or (self.camp==1 and heroConfig and heroConfig.Toward==2) then
self.RoleLiveGO3.transform:DORotate(Vector3.New(0,180, 0),0.5)
else
self.RoleLiveGO3.transform:DORotate(Vector3.New(0,0, 0),0.5)
end
if self.combat.skillname then
self.castingNameNode:SetActive(true)
self.castingNameNode:GetComponent("Image").sprite = self.spLoader:LoadSprite(self.combat.skillname)
else
self.castingNameNode:SetActive(false)
end
self:PlaySpineAnim(self.RoleLiveGOGraphic3, 0, "attack" , false)
-- coroutine.wait(1.5)
--self.turnEffect:SetActive(false)
end)
coroutine.wait(0.1)
self.turnEffect:SetActive(true)
end)
-- 延长Casting时间
return 0.6
else
if self.isMainPlayer then
self:PlaySpineAnim(self.RoleLiveGOGraphic2, 0, "idle" , false)
else
self:PlaySpineAnim(self.RoleLiveGOGraphic2, 0, "attack" , false)
end
end
end
end
function WeaponView:OnSkillCastingEnd()
if self.RoleLiveGO2 then
self.RoleLiveGO2:SetActive(false)
end
if self.RoleLiveGO3 then
self.RoleLiveGO3:SetActive(false)
end
end
function WeaponView:onDispose()
self.spLoader:Destroy()
--
Util.SetSpineGray(self.RoleLiveGOGraphic2, false)
Util.SetColor(self.RoleLiveGOGraphic2, Color.New(1, 1, 1, 1))
self.RoleLiveGOGraphic2.freeze = false
-- poolManager:UnLoadLive(self.livePath, self.RoleLiveGO2)
GameObject.DestroyImmediate(self.RoleLiveGO2)
self.RoleLiveGO2 = nil
heroConfig=nil
-- 回收本节点
BattlePool.RecycleItem(self.GameObject, BATTLE_POOL_TYPE.ENEMY_ROLE)
end