From 9ec7d07fbb8231c2f71232d5a2fa4bcb8f589848 Mon Sep 17 00:00:00 2001 From: gaoxin Date: Fri, 10 Dec 2021 11:58:42 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E8=BA=AB=E5=A4=96=E5=8C=96=E8=BA=AB?= =?UTF-8?q?=E5=89=A7=E6=83=85=E3=80=91=E5=AD=99=E6=82=9F=E7=A9=BA=E5=8F=AF?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E4=B8=BA=E4=B8=BB=E8=A7=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../~Lua/Modules/Battle/BattleManager.lua | 10 ++- .../Modules/Battle/View/Unit/MonsterView.lua | 67 ++++++++++--------- 2 files changed, 42 insertions(+), 35 deletions(-) diff --git a/Assets/ManagedResources/~Lua/Modules/Battle/BattleManager.lua b/Assets/ManagedResources/~Lua/Modules/Battle/BattleManager.lua index 8eb0cf5afd..57eb4928f4 100644 --- a/Assets/ManagedResources/~Lua/Modules/Battle/BattleManager.lua +++ b/Assets/ManagedResources/~Lua/Modules/Battle/BattleManager.lua @@ -175,6 +175,7 @@ end --获取怪物数据(战斗用) function this.GetMonsterData(monsterId) + LogRed("GetMonsterData :"..monsterId) local monsterConfig = MonsterConfig[monsterId] return { roleId = monsterConfig.MonsterId, @@ -676,11 +677,16 @@ function this.GetMonsterDataFromGroup(gId, camp) list[i] = this.PokemonUnitAdapter(mUnit, camp) end end - -- 主角 + -- 技能 local RoleSkills = MonsterGroup[gId].Role if RoleSkills and #RoleSkills > 0 then + -- 主角ID + local CharacterId = MonsterGroup[gId].CharacterId + if not CharacterId or CharacterId == 0 then + CharacterId = 20100 + end local mUnit = { - unitId = 20100, + unitId = CharacterId, position = 100, star = 1, playerSex = NameManager.roleSex, diff --git a/Assets/ManagedResources/~Lua/Modules/Battle/View/Unit/MonsterView.lua b/Assets/ManagedResources/~Lua/Modules/Battle/View/Unit/MonsterView.lua index 7065cc0c0f..65d700bb97 100644 --- a/Assets/ManagedResources/~Lua/Modules/Battle/View/Unit/MonsterView.lua +++ b/Assets/ManagedResources/~Lua/Modules/Battle/View/Unit/MonsterView.lua @@ -29,26 +29,37 @@ function MonsterView:onCreate(go, role, position, root) self.icon = Util.GetGameObject(go, "icon"):GetComponent("Image") self.turnEffect=role.camp == 0 and self.RootPanel.lingshouDownEffect or self.RootPanel.lingshouUpEffect -- 获取数据 - local live=0 + self.livePath = nil if position==100 then - if role.sex==ROLE_SEX.BOY then - self.livePath="live2d_npc_boy" - else - self.livePath="live2d_npc_girl" - end - --self.livePath="live2d_npc_girl" - role.roleData.id=20100 - else - self.livePath = GetResourcePath(SpiritAnimal[role.roleData.id].Live) - self.icon.sprite = self.spLoader:LoadSprite(GetResourcePath(SpiritAnimal[role.roleData.id].Icon)) + 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.play_liveScale = SpiritAnimal[role.roleData.id].play_liveScale - self.enemy_liveScale = SpiritAnimal[role.roleData.id].enemy_liveScale - self.offset = SpiritAnimal[role.roleData.id].offset - self.outOffset = SpiritAnimal[role.roleData.id].enemy_offset - self.spAtkTime = SpiritAnimal[role.roleData.id].CastingSkills/1000 - self.atkSoundTime = SpiritAnimal[role.roleData.id].CastingAudio/1000 - self.attackSound = SpiritAnimal[role.roleData.id].sond + -- 配置表数据 + self.config = SpiritAnimal[role.roleData.id] + + -- 如果不是男女主角 + 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 -- 人物立绘 @@ -139,12 +150,7 @@ function MonsterView:PlaySpineAnim(gog, time, name, isLoop) local _complete = nil _complete = function(state) gog.AnimationState.Complete = gog.AnimationState.Complete - _complete - if self.role.roleData.id==20100 then - gog.AnimationState:SetAnimation(0, "idle", true) - else - gog.AnimationState:SetAnimation(0, "attack", true) - end - + gog.AnimationState:SetAnimation(0, "idle", true) end gog.AnimationState:ClearTracks() -- 清除上一个动画的影响(修复概率攻击动画播放错误的问题) gog.AnimationState:SetAnimation(time, name, isLoop) @@ -182,7 +188,7 @@ function MonsterView:OnSkillCastStart(skill) 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 SpiritAnimal[20100].offset or SpiritAnimal[20100].enemy_offset + 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) @@ -219,10 +225,6 @@ function MonsterView:OnSkillCastingStart(skill) -- 提前进入下一阶段 self.turnEffect:SetActive(false) self.RoleLiveGO2:SetActive(true) - local animName="attack" - if self.role.roleData.id==20100 then - animName="idle" - end 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 @@ -245,16 +247,15 @@ function MonsterView:OnSkillCastingStart(skill) self.RoleLiveGO3.transform:DORotate(Vector3.New(0,0, 0),0.5) end self.castingNameNode:GetComponent("Image").sprite = self.spLoader:LoadSprite(self.combat.skillname) - animName="attack" - self:PlaySpineAnim(self.RoleLiveGOGraphic3, 0,animName , false) - coroutine.wait(1.5) + 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) else - self:PlaySpineAnim(self.RoleLiveGOGraphic2, 0,animName , false) + self:PlaySpineAnim(self.RoleLiveGOGraphic2, 0, "attack" , false) end