From 5bc2cc9a3e007b96a0de96e70e87f25bc5a254a2 Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期一, 21 七月 2025 19:22:45 +0800
Subject: [PATCH] 125 【战斗】战斗系统 战斗系统迭代 协议接入 阵容部分代码
---
Main/System/Battle/BattleField/RecordActions/EditorSkillRecordAction.cs.meta | 2
Main/System/Battle/Bullet/BulletFactory.cs | 12
Main/System/Battle/Motion/MotionBase.cs | 134 -
Main/System/Battle/Bullet/CloseCombatBullet.cs.meta | 2
Main/Config/Configs/SkillConfig.cs | 40
Main/System/Hero/HeroInfo.Lineup.cs | 35
Main/System/Battle/Bullet/TrajectoryBullet.cs | 0
Main/System/Battle/Bullet/Bullet.cs | 95 +
Main/System/Battle/Skill/SkillEffectAnchor.cs | 7
Main/System/Battle/Skill/SkillType.cs | 17
Main/System/Battle/SkillEffect.meta | 8
Main/System/Battle/Skill/SkillEffectAnchor.cs.meta | 2
Main/System/Battle/BattleTweenMgr.cs.meta | 2
Main/System/Battle/Define/PlayEffectType.cs | 8
Main/System/Team/TeamConst.cs | 2
Main/System/Battle/SkillEffect/SkillEffect.cs.meta | 2
Main/System/Battle/Bullet/CloseCombatBullet.cs | 81 +
Main/System/Battle/SkillEffect/BulletSkillEffect.cs | 101 +
Main/System/Battle/Skill/SkillEffectType.cs | 7
Main/Utility/MathUtility.cs | 2
Main/System/Battle/Skill/SkillBase.cs | 203 +++
Main/Config/PartialConfigs/SkillConfig.Partial.cs.meta | 2
Main/Core/NetworkPackage/DTCFile/ServerPack/H04_Scene/DTC0407_tagNPCDisappear.cs | 8
Main/System/Battle/Skill/SkillCastMode.cs | 9
Main/System/Battle/BattleField/RecordActions/DeathRecordAction.cs | 35
Main/Core/NetworkPackage/DTCFile/ServerPack/HB4_FightDefine/DTCB421_tagMCTurnFightObjAction.cs | 4
Main/System/Battle/Define/PlayEffectType.cs.meta | 2
Main/Core/NetworkPackage/DTCFile/ServerPack/HB4_FightDefine/DTCB422_tagMCTurnFightObjDead.cs | 4
Main/System/Hero/HeroInfo.Lineup.cs.meta | 2
Main/System/Battle/BattleFieldFactory.cs | 29
Main/System/Team/TeamBase.Properties.cs | 35
Main/System/Battle/Buff/BuffFactory.cs | 24
Main/System/Battle/SkillEffect/BulletSkillEffect.cs.meta | 2
Main/System/Team/TeamManager.cs | 135 ++
Main/System/Hero/HeroManager.cs | 19
Main/System/Battle/BattleEffectMgr.cs | 88 +
Main/System/Battle/BattleField/RecordActions/EditorSkillRecordAction.cs | 89 +
Main/System/Battle/Define/BattleType.cs.meta | 2
Main/System/Battle/Bullet.meta | 8
Main/System/Battle/Skill/DirectlyDamageSkill.cs | 79 +
Main/System/Battle/Motion/MotionName.cs | 1
Main/System/Battle/Skill/SkillType.cs.meta | 2
Main/System/Battle/Buff/BuffBase.cs | 41
Main/Core/NetworkPackage/DataToCtl/PackageRegedit.cs | 28
Main/System/Battle/BattleObject/BattleObjMgr.cs | 34
Main/System/Battle/Define/BattleType.cs | 7
Main/System/Team/TeamHero.cs | 97 +
Main/Core/NetworkPackage/DTCFile/ServerPack/H04_Scene/DTC0418_tagObjInfoRefresh.cs | 47
Main/System/Battle/Skill/SkillCastMode.cs.meta | 2
Main/Utility/UniTaskExtension.cs | 9
Main/Core/NetworkPackage/GameNetPackBasic.cs | 15
Main/System/Battle/SkillEffect/SkillEffectFactory.cs.meta | 2
Main/System/Battle/BattleField/BattleRootNode.cs | 15
Main/System/Battle/BattleField/RecordActions/DeathRecordAction.cs.meta | 2
Main/System/Battle/UIComp/DamageLine.cs | 4
Main/System/Battle/BattleField/StoryBattleField.cs | 77 +
Main/Core/NetworkPackage/DTCFile/ServerPack/HB4_FightDefine/DTCB425_tagSCTurnFightReportSign.cs | 10
Main/System/Battle/SkillEffect/SkillEffectFactory.cs | 25
Main/Core/NetworkPackage/DTCFile/ServerPack/HB4_FightDefine/DTCB420_tagMCTurnFightState.cs | 11
Main/System/Battle/Bullet/TrajectoryBullet.cs.meta | 2
Main/Core/NetworkPackage/DTCFile/ServerPack/HB4_FightDefine/DTCB424_tagSCTurnFightInit.cs | 22
Main/System/Battle/BattleObject/BattleObject.cs | 194 +--
Main/System/Hero/HeroFetterInfo.cs | 2
Main/System/Battle/Buff/BuffBase.cs.meta | 2
Main/System/Battle/Bullet/BulletFactory.cs.meta | 2
Main/System/Battle/Skill/SkillFactory.cs | 9
Main/Core/NetworkPackage/DTCFile/ServerPack/H06_PlayerVsNPC/DTC0604_tagUseSkillAttack.cs | 18
Main/System/Hero/HeroInfo.cs | 10
Main/Core/NetworkPackage/DTCFile/ServerPack/H06_PlayerVsNPC/DTC0605_tagObjAddBuff.cs | 20
Main/System/Battle/Skill/SkillEffectType.cs.meta | 2
Main/System/Battle/BattleField/RecordActions/SkillRecordAction.cs | 52
Main/System/Battle/SkillEffect/NormalSkillEffect.cs | 89 +
Main/System/Battle/UIComp/DamageContent.cs | 2
Main/System/Battle/BattleObject/BattleObjectFactory.cs | 14
Main/System/Battle/Buff/BattleObjectBuffMgr.cs | 39
Main/System/MainLevel.meta | 8
Main/System/Battle/BattleField/BattleField.cs | 131 ++
Main/System/Battle/SkillEffect/NormalSkillEffect.cs.meta | 2
Main/System/Battle/BattleTweenMgr.cs | 54
Main/System/GeneralConfig/GeneralDefine.cs | 5
Main/Config/PartialConfigs/SkillConfig.Partial.cs | 24
Main/Component/UI/Effect/EffectPlayer.cs | 163 ++
Main/System/Team/TeamBase.cs | 400 ++++--
Main/System/Battle/BattleUtility.cs.meta | 2
Main/Core/NetworkPackage/DTCFile/ServerPack/HB4_FightDefine/DTCB430_tagSCTurnFightReport.cs | 72 +
Main/Core/NetworkPackage/DTCFile/ServerPack/H04_Scene/DTC0423_tagObjPropertyRefreshView.cs | 13
Main/System/Battle/BattleManager.cs | 194 +++
Main/System/Battle/BattleUtility.cs | 32
Main/System/Battle/Buff/BattleObjectBuffMgr.cs.meta | 2
Main/System/Battle/SkillEffect/SkillEffect.cs | 53
Main/System/Battle/Buff/BuffFactory.cs.meta | 2
Main/System/Battle/Bullet/Bullet.cs.meta | 2
/dev/null | 35
Main/System/Battle/RecordPlayer/RecordAction.cs | 6
Main/Core/NetworkPackage/DTCFile/ServerPack/HB4_FightDefine/DTCB423_tagMCTurnFightObjReborn.cs | 5
Main/System/Battle/BattleEffectMgr.cs.meta | 2
Main/System/Battle/BattleFieldFactory.cs.meta | 2
97 files changed, 2,799 insertions(+), 656 deletions(-)
diff --git a/Main/Component/UI/Effect/EffectPlayer.cs b/Main/Component/UI/Effect/EffectPlayer.cs
index 65cf69e..cc2211a 100644
--- a/Main/Component/UI/Effect/EffectPlayer.cs
+++ b/Main/Component/UI/Effect/EffectPlayer.cs
@@ -1,26 +1,33 @@
+using System;
using System.Collections;
using System.Collections.Generic;
+using Spine.Unity;
using UnityEngine;
+using Spine;
public class EffectPlayer : MonoBehaviour
{
- public int effectId;
+ public int effectId;
- public bool autoDestroy = false;
+ public bool autoDestroy = false;
- public float destroyDelay = 0f;
+ public float destroyDelay = 0f;
- [HideInInspector] public Canvas canvas = null;
+ public Action<EffectPlayer> onDestroy;
+
+ [HideInInspector] public Canvas canvas = null;
[HideInInspector] public GameObject effectTarget = null;
+ protected EffectPenetrationBlocker blocker = null;
+
protected void Start()
- {
+ {
ReStart();
}
public void Stop()
- {
+ {
if (null != effectTarget)
{
DestroyImmediate(effectTarget);
@@ -30,9 +37,12 @@
public void Play()
{
+ if (!isActiveAndEnabled)
+ {
+ gameObject.SetActive(true);
+ }
ReStart();
}
-
protected void ReStart()
@@ -80,7 +90,7 @@
}
// 娣诲姞鐗规晥绌块�忛樆鎸″櫒
- EffectPenetrationBlocker blocker = effectTarget.AddComponent<EffectPenetrationBlocker>();
+ blocker = effectTarget.AddMissingComponent<EffectPenetrationBlocker>();
blocker.parentCanvas = canvas;
// 寤惰繜涓�甯ф墠鐢熸晥
@@ -95,4 +105,141 @@
}
}
+ public void SetSortingOrderOffset(int offset)
+ {
+ // 琚獶estroy涔嬪悗effectTarget == null 涓� true 浣嗘槸璁块棶鍐呭浼氭姤閿�
+ if (blocker != null && effectTarget != null)
+ {
+ blocker.sortingOrderOffset = offset;
+ blocker.UpdateSortingOrder();
+ }
+ else
+ {
+ blocker = null;
+ effectTarget = null;
+ }
+ }
+
+ protected void OnDestroy()
+ {
+ if (onDestroy != null)
+ {
+ onDestroy.Invoke(this);
+ onDestroy = null;
+ }
+ }
+
+ // 鍒涘缓鍚庣殑鐗规晥浼氳嚜鍔ㄩ殣钘� 闇�瑕佹墜鍔ㄨ皟鐢≒lay鎵嶈兘鎾斁
+ public static EffectPlayer Create(int effectId, Transform parent, bool createNewChild = false, bool _autoDestroy = true, float _destroyDelay = 5f)
+ {
+ EffectPlayer effectPlayer = null;
+
+ if (createNewChild)
+ {
+ GameObject newGo = new GameObject("EffectPlayer_" + effectId);
+ newGo.transform.SetParent(parent, false);
+ effectPlayer = newGo.AddComponent<EffectPlayer>();
+ }
+ else
+ {
+ effectPlayer = parent.AddMissingComponent<EffectPlayer>();
+ effectPlayer.effectId = effectId;
+ effectPlayer.autoDestroy = _autoDestroy;
+ effectPlayer.destroyDelay = _destroyDelay;
+ }
+ effectPlayer.SetActive(false);
+ return effectPlayer;
+ }
+
+ public void Pause()
+ {
+ if (effectTarget == null) return;
+
+ // Spine鍔ㄧ敾
+ var spineGraphics = effectTarget.GetComponentsInChildren<SkeletonGraphic>(true);
+ foreach (var sg in spineGraphics)
+ {
+ sg.timeScale = 0f;
+ }
+
+ // Animator鍔ㄧ敾
+ var animators = effectTarget.GetComponentsInChildren<Animator>(true);
+ foreach (var animator in animators)
+ {
+ animator.speed = 0f;
+ }
+
+ // 绮掑瓙鐗规晥
+ var particles = effectTarget.GetComponentsInChildren<ParticleSystem>(true);
+ foreach (var ps in particles)
+ {
+ ps.Pause();
+ }
+ }
+
+ public void Resume()
+ {
+ if (effectTarget == null) return;
+
+ // Spine鍔ㄧ敾
+ var spineGraphics = effectTarget.GetComponentsInChildren<SkeletonGraphic>(true);
+ foreach (var sg in spineGraphics)
+ {
+ sg.timeScale = 1f;
+ }
+
+ // Animator鍔ㄧ敾
+ var animators = effectTarget.GetComponentsInChildren<Animator>(true);
+ foreach (var animator in animators)
+ {
+ animator.speed = 1f;
+ }
+
+ // 绮掑瓙鐗规晥
+ var particles = effectTarget.GetComponentsInChildren<ParticleSystem>(true);
+ foreach (var ps in particles)
+ {
+ ps.Play();
+ }
+ }
+
+ public bool IsFinish()
+ {
+ if (effectTarget == null) return true;
+
+ // Spine鍔ㄧ敾
+ var spineGraphics = effectTarget.GetComponentsInChildren<SkeletonGraphic>(true);
+ foreach (var sg in spineGraphics)
+ {
+ if (!sg.AnimationState.GetCurrent(0).IsComplete)
+ {
+ return false;
+ }
+ }
+
+ // Animator鍔ㄧ敾
+ var animators = effectTarget.GetComponentsInChildren<Animator>(true);
+ foreach (var animator in animators)
+ {
+ AnimatorStateInfo stateInfo = animator.GetCurrentAnimatorStateInfo(0);
+
+ // 寰幆鍔ㄧ敾涓嶈�冭檻缁撴潫鐨勯棶棰�
+ if (!stateInfo.loop && stateInfo.normalizedTime < 1f)
+ {
+ return false;
+ }
+ }
+
+ // 绮掑瓙鐗规晥
+ var particles = effectTarget.GetComponentsInChildren<ParticleSystem>(true);
+ foreach (var ps in particles)
+ {
+ if (ps.IsAlive())
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
}
diff --git a/Main/Config/Configs/SkillConfig.cs b/Main/Config/Configs/SkillConfig.cs
index 037b71b..55c63d0 100644
--- a/Main/Config/Configs/SkillConfig.cs
+++ b/Main/Config/Configs/SkillConfig.cs
@@ -1,6 +1,6 @@
锘�//--------------------------------------------------------
// [Author]: YYL
-// [ Date ]: Friday, June 27, 2025
+// [ Date ]: 2025骞�7鏈�17鏃�
//--------------------------------------------------------
using System.Collections.Generic;
@@ -85,9 +85,15 @@
public string IconName;
public string Description;
public string BuffDescription;
- public int Skillactmark;
public int BuffDisplay;
public int CastPosition;
+ public int CastDistance;
+ public int[] TriggerFrames;
+ public int[][] DamageDivide;
+ public string SkillMotionName;
+ public int EffectId;
+ public int ExplotionEffectId;
+ public float FlyTime;
public override int LoadKey(string _key)
{
@@ -243,11 +249,35 @@
BuffDescription = tables[71];
- int.TryParse(tables[72],out Skillactmark);
+ int.TryParse(tables[72],out BuffDisplay);
- int.TryParse(tables[73],out BuffDisplay);
+ int.TryParse(tables[73],out CastPosition);
- int.TryParse(tables[74],out CastPosition);
+ int.TryParse(tables[74],out CastDistance);
+
+ if (tables[75].Contains("["))
+ {
+ TriggerFrames = JsonMapper.ToObject<int[]>(tables[75]);
+ }
+ else
+ {
+ string[] TriggerFramesStringArray = tables[75].Trim().Split(StringUtility.splitSeparator,StringSplitOptions.RemoveEmptyEntries);
+ TriggerFrames = new int[TriggerFramesStringArray.Length];
+ for (int i=0;i<TriggerFramesStringArray.Length;i++)
+ {
+ int.TryParse(TriggerFramesStringArray[i],out TriggerFrames[i]);
+ }
+ }
+
+ DamageDivide = JsonMapper.ToObject<int[][]>(tables[76].Replace("(", "[").Replace(")", "]"));
+
+ SkillMotionName = tables[77];
+
+ int.TryParse(tables[78],out EffectId);
+
+ int.TryParse(tables[79],out ExplotionEffectId);
+
+ float.TryParse(tables[80],out FlyTime);
}
catch (Exception exception)
{
diff --git a/Main/Config/PartialConfigs/SkillConfig.Partial.cs b/Main/Config/PartialConfigs/SkillConfig.Partial.cs
new file mode 100644
index 0000000..7e5d604
--- /dev/null
+++ b/Main/Config/PartialConfigs/SkillConfig.Partial.cs
@@ -0,0 +1,24 @@
+锘�//--------------------------------------------------------
+// [Author]: YYL
+// [ Date ]: 2025骞�7鏈�11鏃�
+//--------------------------------------------------------
+
+using System.Collections.Generic;
+using System.IO;
+using System.Threading;
+using System;
+using UnityEngine;
+using LitJson;
+
+public partial class SkillConfig : ConfigBase<int, SkillConfig>
+{
+ public SkillType skillType;
+ public SkillCastMode castMode;
+ public SkillEffectType effectType;
+ public SkillEffectAnchor effectAnchor;
+
+ public MotionName GetMotionName()
+ {
+ return Enum.Parse<MotionName>(SkillMotionName);
+ }
+}
diff --git a/Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta b/Main/Config/PartialConfigs/SkillConfig.Partial.cs.meta
similarity index 83%
copy from Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta
copy to Main/Config/PartialConfigs/SkillConfig.Partial.cs.meta
index ee23e52..836030a 100644
--- a/Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta
+++ b/Main/Config/PartialConfigs/SkillConfig.Partial.cs.meta
@@ -1,5 +1,5 @@
fileFormatVersion: 2
-guid: 0c39e10c6d11822409ee2e39b684f89d
+guid: 80ceeaf1ce130d946a2e79320bdc9919
MonoImporter:
externalObjects: {}
serializedVersion: 2
diff --git a/Main/Core/NetworkPackage/DTCFile/ServerPack/H04_Scene/DTC0407_tagNPCDisappear.cs b/Main/Core/NetworkPackage/DTCFile/ServerPack/H04_Scene/DTC0407_tagNPCDisappear.cs
index d73e18d..e503144 100644
--- a/Main/Core/NetworkPackage/DTCFile/ServerPack/H04_Scene/DTC0407_tagNPCDisappear.cs
+++ b/Main/Core/NetworkPackage/DTCFile/ServerPack/H04_Scene/DTC0407_tagNPCDisappear.cs
@@ -7,5 +7,13 @@
public override void Done(GameNetPackBasic vNetPack) {
base.Done(vNetPack);
H0407_tagNPCDisappear vNetData = vNetPack as H0407_tagNPCDisappear;
+
+ //鐜╁涓诲姩鐐瑰嚮浼戞伅鏃讹紝鍚庣浼氬洖鏀跺垱寤虹殑鎴樻枟涓婚樀瀹规灏嗗疄渚嬶紝鍓嶇鏀跺埌//04 07 NPC娑堝け#tagNPCDisappear鏃惰繘琛岃В缁�
+
+ BattleField battleField = BattleManager.Instance.GetBattleField(vNetPack.packUID);
+
+ // 鎻愬墠缁撴潫鎴樻枟 鍒犻櫎NPCID锛堬級瀹為檯涓婃槸瀵硅薄鐨凮bjID
+ battleField.FinishBattleInAdvance(vNetData.NPCID);
+
}
}
diff --git a/Main/Core/NetworkPackage/DTCFile/ServerPack/H04_Scene/DTC0418_tagObjInfoRefresh.cs b/Main/Core/NetworkPackage/DTCFile/ServerPack/H04_Scene/DTC0418_tagObjInfoRefresh.cs
index a417869..aa62164 100644
--- a/Main/Core/NetworkPackage/DTCFile/ServerPack/H04_Scene/DTC0418_tagObjInfoRefresh.cs
+++ b/Main/Core/NetworkPackage/DTCFile/ServerPack/H04_Scene/DTC0418_tagObjInfoRefresh.cs
@@ -2,18 +2,33 @@
using System.Collections;
using static UnityEditor.Experimental.GraphView.GraphView;
-//04 18 鍛ㄥ洿瀵硅薄鍒锋柊#tagObjInfoRefresh
-
-public class DTC0418_tagObjInfoRefresh : DtcBasic {
- public override void Done(GameNetPackBasic vNetPack) {
- base.Done(vNetPack);
- H0418_tagObjInfoRefresh vNetData = vNetPack as H0418_tagObjInfoRefresh;
- Update0418(vNetData);
- }
-
-
+//04 18 鍛ㄥ洿瀵硅薄鍒锋柊#tagObjInfoRefresh
+
+public class DTC0418_tagObjInfoRefresh : DtcBasic {
+ public override void Done(GameNetPackBasic vNetPack) {
+ base.Done(vNetPack);
+ H0418_tagObjInfoRefresh vNetData = vNetPack as H0418_tagObjInfoRefresh;
+
+ // 1 - 鐜╁锛堜富鍏級
+ // 2 - NPC锛堟灏嗘垨鎬墿锛�
+
+ switch (vNetData.ObjType)
+ {
+ case 1:
+ Update0418(vNetData);
+ break;
+ case 2:
+ UpdateBattleField(vNetData);
+ break;
+ default:
+ Debug.LogError("DTC0418_tagObjInfoRefresh 鏈嶅姟绔悓姝ヤ簡涓�涓湭鐭ョ被鍨嬬殑ObjType鐨勫埛鏂� " + vNetData.ObjType);
+ break;
+ }
+ }
+
+
public static void Update0418(H0418_tagObjInfoRefresh vNetData)
- {
+ {
if (PlayerDatas.Instance.PlayerId == vNetData.ObjID)
{
@@ -24,5 +39,11 @@
//鍏朵粬鐜╁鏁版嵁锛屽鏋滈渶瑕佸悓鍦烘櫙澶勭悊
//_player.UpdateData(vNetData);
}
- }
-}
+ }
+
+ public static void UpdateBattleField(H0418_tagObjInfoRefresh vNetData)
+ {
+ BattleField battleField = BattleManager.Instance.GetBattleField(vNetData.packUID);
+ battleField.ObjInfoRefresh(vNetData);
+ }
+}
diff --git a/Main/Core/NetworkPackage/DTCFile/ServerPack/H04_Scene/DTC0423_tagObjPropertyRefreshView.cs b/Main/Core/NetworkPackage/DTCFile/ServerPack/H04_Scene/DTC0423_tagObjPropertyRefreshView.cs
index d18de2a..971c280 100644
--- a/Main/Core/NetworkPackage/DTCFile/ServerPack/H04_Scene/DTC0423_tagObjPropertyRefreshView.cs
+++ b/Main/Core/NetworkPackage/DTCFile/ServerPack/H04_Scene/DTC0423_tagObjPropertyRefreshView.cs
@@ -7,5 +7,18 @@
public override void Done(GameNetPackBasic vNetPack) {
base.Done(vNetPack);
H0423_tagObjPropertyRefreshView vNetData = vNetPack as H0423_tagObjPropertyRefreshView;
+
+ // public uint ObjID; //瀵硅薄ID
+ // public byte ObjType; //瀵硅薄绫诲瀷
+ // public uint SkillID; //鎶�鑳絀D
+ // public uint DiffValue; //鍊�
+ // public uint DiffValueEx; //瓒呬嚎鍊�
+ // public byte AttackType; //鏀诲嚮绫诲瀷
+ // public uint SrcObjID; //椋樿鏉ユ簮
+ // public byte SrcObjType;
+ // public uint HP; //鍓╀綑琛�閲�
+ // public uint HPEx; //鍓╀綑琛�閲� 浜�
+ BattleField battleField = BattleManager.Instance.GetBattleField(vNetPack.packUID);
+ battleField.ObjPropertyRefreshView(vNetData);
}
}
diff --git a/Main/Core/NetworkPackage/DTCFile/ServerPack/H06_PlayerVsNPC/DTC0602_tagObjBaseAttack.cs b/Main/Core/NetworkPackage/DTCFile/ServerPack/H06_PlayerVsNPC/DTC0602_tagObjBaseAttack.cs
deleted file mode 100644
index 2329326..0000000
--- a/Main/Core/NetworkPackage/DTCFile/ServerPack/H06_PlayerVsNPC/DTC0602_tagObjBaseAttack.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using UnityEngine;
-using System.Collections;
-
-//06 02 鏅�氭敾鍑�#tagObjBaseAttack
-
-public class DTC0602_tagObjBaseAttack : DtcBasic {
- public override void Done(GameNetPackBasic vNetPack) {
- base.Done(vNetPack);
- H0602_tagObjBaseAttack vNetData = vNetPack as H0602_tagObjBaseAttack;
- }
-}
diff --git a/Main/Core/NetworkPackage/DTCFile/ServerPack/H06_PlayerVsNPC/DTC0602_tagObjBaseAttack.cs.meta b/Main/Core/NetworkPackage/DTCFile/ServerPack/H06_PlayerVsNPC/DTC0602_tagObjBaseAttack.cs.meta
deleted file mode 100644
index d1ce3bd..0000000
--- a/Main/Core/NetworkPackage/DTCFile/ServerPack/H06_PlayerVsNPC/DTC0602_tagObjBaseAttack.cs.meta
+++ /dev/null
@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: d552ea2be2de457479d2b005af75b862
-MonoImporter:
- externalObjects: {}
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Main/Core/NetworkPackage/DTCFile/ServerPack/H06_PlayerVsNPC/DTC0604_tagUseSkillAttack.cs b/Main/Core/NetworkPackage/DTCFile/ServerPack/H06_PlayerVsNPC/DTC0604_tagUseSkillAttack.cs
index 912e13e..7b8aae0 100644
--- a/Main/Core/NetworkPackage/DTCFile/ServerPack/H06_PlayerVsNPC/DTC0604_tagUseSkillAttack.cs
+++ b/Main/Core/NetworkPackage/DTCFile/ServerPack/H06_PlayerVsNPC/DTC0604_tagUseSkillAttack.cs
@@ -7,5 +7,23 @@
public override void Done(GameNetPackBasic vNetPack) {
base.Done(vNetPack);
H0604_tagUseSkillAttack vNetData = vNetPack as H0604_tagUseSkillAttack;
+
+
+ // public uint ObjID;
+ // public byte ObjType;
+ // public byte BattleType; //鐗╃悊/榄旀硶
+ // public ushort SkillID;
+ // public uint AttackID; //涓绘敾鍑荤洰鏍�
+ // public byte AttackObjType; //涓绘敾鍑荤洰鏍�
+ // public ushort HurtCount; //浼ゅ鏁扮洰
+ // public tagSkillHurtObj[] HurtList; //size = HurtCount
+
+ // ObjType绫诲瀷鐨凮bjID浣跨敤BattleType绫绘妧鑳絊killID鏀诲嚮浜咥ttackObjType绫诲瀷鐨凙ttackID 浼ゅ鏁板瓧鏄疕urtList
+
+ BattleField battleField = BattleManager.Instance.GetBattleField(vNetPack.packUID);
+
+ battleField.ProcessUseSkillAttack(vNetData);
+
+
}
}
diff --git a/Main/Core/NetworkPackage/DTCFile/ServerPack/H06_PlayerVsNPC/DTC0605_tagObjAddBuff.cs b/Main/Core/NetworkPackage/DTCFile/ServerPack/H06_PlayerVsNPC/DTC0605_tagObjAddBuff.cs
index fefa5a6..d760c3b 100644
--- a/Main/Core/NetworkPackage/DTCFile/ServerPack/H06_PlayerVsNPC/DTC0605_tagObjAddBuff.cs
+++ b/Main/Core/NetworkPackage/DTCFile/ServerPack/H06_PlayerVsNPC/DTC0605_tagObjAddBuff.cs
@@ -1,11 +1,23 @@
-using UnityEngine;
-using System.Collections;
-
+using UnityEngine;
+using System.Collections;
+
//06 05 瀵硅薄澧炲姞Buf#tagObjAddBuff
public class DTC0605_tagObjAddBuff : DtcBasic {
- public override void Done(GameNetPackBasic vNetPack) {
+ public override void Done(GameNetPackBasic vNetPack)
+ {
base.Done(vNetPack);
H0605_tagObjAddBuff vNetData = vNetPack as H0605_tagObjAddBuff;
+
+ BattleField battleField = BattleManager.Instance.GetBattleField(vNetData.packUID);
+
+ BattleObject vBattleObject = battleField.battleObjMgr.GetBattleObject((int)vNetData.ObjID);
+
+ if (null == vBattleObject)
+ {
+ return;
+ }
+
+ vBattleObject.buffMgr.AddBuff(vNetData);
}
}
diff --git a/Main/Core/NetworkPackage/DTCFile/ServerPack/HB4_FightDefine/DTCB420_tagMCTurnFightState.cs b/Main/Core/NetworkPackage/DTCFile/ServerPack/HB4_FightDefine/DTCB420_tagMCTurnFightState.cs
index 81c56e3..7abe5b1 100644
--- a/Main/Core/NetworkPackage/DTCFile/ServerPack/HB4_FightDefine/DTCB420_tagMCTurnFightState.cs
+++ b/Main/Core/NetworkPackage/DTCFile/ServerPack/HB4_FightDefine/DTCB420_tagMCTurnFightState.cs
@@ -1,5 +1,6 @@
using UnityEngine;
using System.Collections;
+using LitJson;
// B4 20 鍥炲悎鍒舵垬鏂楃姸鎬� #tagMCTurnFightState
@@ -7,5 +8,15 @@
public override void Done(GameNetPackBasic vNetPack) {
base.Done(vNetPack);
HB420_tagMCTurnFightState vNetData = vNetPack as HB420_tagMCTurnFightState;
+ BattleField battleField = BattleManager.Instance.GetBattleField(vNetPack.packUID);
+
+ // MapID; // 鑷畾涔夊湴鍥綢D锛屽彲鐢ㄤ簬缁戝畾鎴樻枟鍦板浘鍦烘櫙鍔熻兘锛堝涓荤嚎鍏冲崱銆佷富绾縝oss銆佺埇濉斻�佺珵鎶�鍦虹瓑锛�
+ // FuncLineID; // MapID瀵瑰簲鐨勬墿灞曞�硷紝濡傚叿浣撴煇涓叧鍗$瓑 绔犺妭*10000+鍏冲崱缂栧彿*100+绗瑇娉紝濡傜涓�绔狅紝绗�10鍏冲崱鐨刡oss鍊� = 11001
+ // State; // 0-璧峰鐘舵�佹爣璁帮紱1-鍑嗗瀹屾瘯锛�2-鎴樻枟涓紱3-鎴樻枟缁撴潫锛�4-缁撶畻濂栧姳锛�5-缁撴潫鐘舵�佹爣璁�
+ // TurnNum; // 褰撳墠杞
+ // Len;
+ // Msg; //size = Len
+ JsonData extendData = JsonMapper.ToObject(vNetData.Msg);
+ battleField.OnTurnFightState(vNetData.TurnNum, vNetData.State, (int)vNetData.FuncLineID, extendData);
}
}
diff --git a/Main/Core/NetworkPackage/DTCFile/ServerPack/HB4_FightDefine/DTCB421_tagMCTurnFightObjAction.cs b/Main/Core/NetworkPackage/DTCFile/ServerPack/HB4_FightDefine/DTCB421_tagMCTurnFightObjAction.cs
index 06f26e8..a19ab02 100644
--- a/Main/Core/NetworkPackage/DTCFile/ServerPack/HB4_FightDefine/DTCB421_tagMCTurnFightObjAction.cs
+++ b/Main/Core/NetworkPackage/DTCFile/ServerPack/HB4_FightDefine/DTCB421_tagMCTurnFightObjAction.cs
@@ -1,5 +1,6 @@
using UnityEngine;
using System.Collections;
+using LitJson;
// B4 21 鍥炲悎鎴樻枟瀵硅薄寮�濮嬭鍔� #tagMCTurnFightObjAction
@@ -7,5 +8,8 @@
public override void Done(GameNetPackBasic vNetPack) {
base.Done(vNetPack);
HB421_tagMCTurnFightObjAction vNetData = vNetPack as HB421_tagMCTurnFightObjAction;
+ BattleField battleField = BattleManager.Instance.GetBattleField(vNetPack.packUID);
+ battleField.OnTurnFightObjAction(vNetData.TurnNum, (int)vNetData.ObjID);
+ // BattleManager.Instance.OnTurnFightObjAction(vNetData.TurnNum, (int)vNetData.ObjID);
}
}
diff --git a/Main/Core/NetworkPackage/DTCFile/ServerPack/HB4_FightDefine/DTCB422_tagMCTurnFightObjDead.cs b/Main/Core/NetworkPackage/DTCFile/ServerPack/HB4_FightDefine/DTCB422_tagMCTurnFightObjDead.cs
index bd3c3c8..2296213 100644
--- a/Main/Core/NetworkPackage/DTCFile/ServerPack/HB4_FightDefine/DTCB422_tagMCTurnFightObjDead.cs
+++ b/Main/Core/NetworkPackage/DTCFile/ServerPack/HB4_FightDefine/DTCB422_tagMCTurnFightObjDead.cs
@@ -7,5 +7,9 @@
public override void Done(GameNetPackBasic vNetPack) {
base.Done(vNetPack);
HB422_tagMCTurnFightObjDead vNetData = vNetPack as HB422_tagMCTurnFightObjDead;
+
+ BattleField battleField = BattleManager.Instance.GetBattleField(vNetPack.packUID);
+
+ battleField.OnObjDead((int)vNetData.ObjID);
}
}
diff --git a/Main/Core/NetworkPackage/DTCFile/ServerPack/HB4_FightDefine/DTCB423_tagMCTurnFightObjReborn.cs b/Main/Core/NetworkPackage/DTCFile/ServerPack/HB4_FightDefine/DTCB423_tagMCTurnFightObjReborn.cs
index 28c5cbf..b707515 100644
--- a/Main/Core/NetworkPackage/DTCFile/ServerPack/HB4_FightDefine/DTCB423_tagMCTurnFightObjReborn.cs
+++ b/Main/Core/NetworkPackage/DTCFile/ServerPack/HB4_FightDefine/DTCB423_tagMCTurnFightObjReborn.cs
@@ -6,6 +6,11 @@
public class DTCB423_tagMCTurnFightObjReborn : DtcBasic {
public override void Done(GameNetPackBasic vNetPack) {
base.Done(vNetPack);
+
+ // 鏈嶅姟绔鏆傛椂娌″仛鍒拌繖杈� 鏆傛斁 TODO YYL
+
HB423_tagMCTurnFightObjReborn vNetData = vNetPack as HB423_tagMCTurnFightObjReborn;
+ BattleField battleField = BattleManager.Instance.GetBattleField(vNetPack.packUID);
+ // battleField.OnObjReborn(vNetData.ObjID);
}
}
diff --git a/Main/Core/NetworkPackage/DTCFile/ServerPack/HB4_FightDefine/DTCB424_tagSCTurnFightInit.cs b/Main/Core/NetworkPackage/DTCFile/ServerPack/HB4_FightDefine/DTCB424_tagSCTurnFightInit.cs
index eb4b282..29781ed 100644
--- a/Main/Core/NetworkPackage/DTCFile/ServerPack/HB4_FightDefine/DTCB424_tagSCTurnFightInit.cs
+++ b/Main/Core/NetworkPackage/DTCFile/ServerPack/HB4_FightDefine/DTCB424_tagSCTurnFightInit.cs
@@ -33,13 +33,6 @@
// FactionCnt;
// FactionList; // 闃佃惀鍒楄〃锛岄�氬父鍥哄畾鍙湁涓や釜闃佃惀
-
-
- uint chapter = vNetData.FuncLineID / 10000;
- uint wave = vNetData.MapID == 1 ? vNetData.FuncLineID % 100 : 1;//绗嚑娉㈡��
- uint level = (vNetData.FuncLineID % 10000) / 100;
- JsonData extendData = JsonMapper.ToObject(vNetData.Msg);
-
List<TeamBase> redTeamList = new List<TeamBase>();
List<TeamBase> blueTeamList = new List<TeamBase>();
@@ -64,5 +57,20 @@
}
}
+
+ // 涓荤嚎
+ // if (vNetData.MapID <= 2)
+ // {
+ // int chapter = (int)vNetData.FuncLineID / 10000;
+ // int wave = (int)(vNetData.MapID == 1 ? vNetData.FuncLineID % 100 : 1);//绗嚑娉㈡��
+ // int level = (int)(vNetData.FuncLineID % 10000) / 100;
+ JsonData extendData = JsonMapper.ToObject(vNetData.Msg);
+
+ // BattleManager.Instance.CreateStoryBattle(chapter, wave, level, extendData, redTeamList[0], blueTeamList[0]);
+ // }
+
+ string guid = BattleManager.Instance.GetGUID(vNetPack.packUID);
+
+ BattleManager.Instance.CreateBattleField(guid, (int)vNetData.MapID, (int)vNetData.FuncLineID, extendData, redTeamList, blueTeamList);
}
}
diff --git a/Main/Core/NetworkPackage/DTCFile/ServerPack/HB4_FightDefine/DTCB425_tagSCTurnFightReportSign.cs b/Main/Core/NetworkPackage/DTCFile/ServerPack/HB4_FightDefine/DTCB425_tagSCTurnFightReportSign.cs
index 3a646a8..b67d135 100644
--- a/Main/Core/NetworkPackage/DTCFile/ServerPack/HB4_FightDefine/DTCB425_tagSCTurnFightReportSign.cs
+++ b/Main/Core/NetworkPackage/DTCFile/ServerPack/HB4_FightDefine/DTCB425_tagSCTurnFightReportSign.cs
@@ -7,5 +7,15 @@
public override void Done(GameNetPackBasic vNetPack) {
base.Done(vNetPack);
HB425_tagSCTurnFightReportSign vNetData = vNetPack as HB425_tagSCTurnFightReportSign;
+
+
+ // 鎴柇 PackageRegedit Distribute 閲岀殑灏佸寘
+
+ // 鐩村埌sign = 1;
+ }
+
+ public static bool IsCorrectType(GameNetPackBasic vNetPack)
+ {
+ return vNetPack is HB425_tagSCTurnFightReportSign;
}
}
diff --git a/Main/Core/NetworkPackage/DTCFile/ServerPack/HB4_FightDefine/DTCB430_tagSCTurnFightReport.cs b/Main/Core/NetworkPackage/DTCFile/ServerPack/HB4_FightDefine/DTCB430_tagSCTurnFightReport.cs
index 026708f..3c94a80 100644
--- a/Main/Core/NetworkPackage/DTCFile/ServerPack/HB4_FightDefine/DTCB430_tagSCTurnFightReport.cs
+++ b/Main/Core/NetworkPackage/DTCFile/ServerPack/HB4_FightDefine/DTCB430_tagSCTurnFightReport.cs
@@ -1,11 +1,79 @@
using UnityEngine;
using System.Collections;
-
+using System;
// B4 30 鏌ョ湅鎴樻姤缁撴灉 #tagSCTurnFightReportRet
+
public class DTCB430_tagSCTurnFightReport : DtcBasic {
- public override void Done(GameNetPackBasic vNetPack) {
+ private static GameNetEncode encoder = new GameNetEncode();
+
+ static byte[] vCmdBytes = new byte[2];
+
+ public override void Done(GameNetPackBasic vNetPack)
+ {
base.Done(vNetPack);
HB430_tagSCTurnFightReport vNetData = vNetPack as HB430_tagSCTurnFightReport;
+
+ // 鎴樻姤缁撴灉
+ string guid = vNetData.GUID;
+
+ try
+ {
+ byte[] reportBytes = GameNetPackBasic.StrEncoding.GetBytes(vNetData.Report);
+
+ int vReadIndex = 0;
+ byte[] vPackBytes;
+ int vLeavingLeng = 0;
+ int vBodyLeng = 0;
+ int vTotalLeng = reportBytes.Length;
+
+ while (vReadIndex < vTotalLeng)
+ {
+ if (vLeavingLeng < 6)
+ {
+ Debug.LogError("DTCB430_tagSCTurnFightReport: vLeavingLeng < 6 瑙e寘澶辫触");
+ break;
+ }
+
+ vBodyLeng = BitConverter.ToInt32(reportBytes, vReadIndex + 2);
+ if (vBodyLeng > vLeavingLeng - 6)// 鏈畬鏁寸殑鍖� 鎶ラ敊
+ {
+ Debug.LogError("DTCB430_tagSCTurnFightReport: vBodyLeng > vLeavingLeng - 6 瑙e寘澶辫触");
+ break;
+ }
+
+ vPackBytes = new byte[vBodyLeng];
+ Array.Copy(reportBytes, vReadIndex + 6, vPackBytes, 0, vBodyLeng);
+ vPackBytes = encoder.BaseXorSub(vPackBytes);
+
+ Array.Copy(vPackBytes, 0, vCmdBytes, 0, 2);
+ var cmd = (ushort)((ushort)(vCmdBytes[0] << 8) + vCmdBytes[1]);
+ bool isRegist = false; // 鏈敞鍐屽皝鍖呭鐞�
+
+ if (PackageRegedit.Contain(cmd))
+ {
+ GameNetPackBasic vNetpack = PackageRegedit.TransPack(ServerType.Main, cmd, vPackBytes);
+ if (vNetpack != null)
+ {
+ BattleManager.Instance.PushPackage(guid, vNetpack);
+ isRegist = true;
+ }
+ }
+
+ vReadIndex += 6 + vBodyLeng;
+
+ // 鏈敞鍐屽皝鍖呭鐞�
+ if (!isRegist)
+ {
+#if UNITY_EDITOR
+ PackageRegedit.TransPack(ServerType.Main, cmd, vPackBytes);
+#endif
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ Debug.LogErrorFormat("DTCB430_tagSCTurnFightReport 瑙e寘寮傚父锛歿0}", e);
+ }
}
}
diff --git a/Main/Core/NetworkPackage/DataToCtl/PackageRegedit.cs b/Main/Core/NetworkPackage/DataToCtl/PackageRegedit.cs
index 76c01b0..fec1e43 100644
--- a/Main/Core/NetworkPackage/DataToCtl/PackageRegedit.cs
+++ b/Main/Core/NetworkPackage/DataToCtl/PackageRegedit.cs
@@ -1,8 +1,6 @@
锘縰sing UnityEngine;
using System;
-using System.Collections;
using System.Collections.Generic;
-//using ILCrossBinding;
public class PackageRegedit
{
@@ -29,7 +27,7 @@
public static void Init()
{
- // 鐧昏鐩稿簲鐨勬暟鎹綋鍙婂搴旂殑鏁版嵁杞�昏緫绫�
+ // 鐧昏鐩稿簲鐨勬暟鎹綋鍙婂搴旂殑鏁版嵁杞�昏緫绫伙紙鍘婚噸鍚庯級
Register(typeof(H0102_tagCDBPlayer), typeof(DTC0102_tagCDBPlayer));
Register(typeof(HA004_tagServerDateTime), typeof(DTCA004_tagServerDateTime));
Register(typeof(HA005_tagOpenServerDay), typeof(DTCA005_tagOpenServerDay));
@@ -94,11 +92,17 @@
Register(typeof(HA921_tagUpdatePlayerNameResult), typeof(DTCA921_tagUpdatePlayerNameResult));
Register(typeof(H3202_tagServerResponse), typeof(DTC3202_tagServerResponse));
Register(typeof(HA130_tagMCViewBillboardRet), typeof(DTCA130_tagMCViewBillboardRet));
-
+ Register(typeof(HB420_tagMCTurnFightState), typeof(DTCB420_tagMCTurnFightState));
+ Register(typeof(HB421_tagMCTurnFightObjAction), typeof(DTCB421_tagMCTurnFightObjAction));
+ Register(typeof(HB422_tagMCTurnFightObjDead), typeof(DTCB422_tagMCTurnFightObjDead));
+ Register(typeof(HB423_tagMCTurnFightObjReborn), typeof(DTCB423_tagMCTurnFightObjReborn));
+ Register(typeof(HB424_tagSCTurnFightInit), typeof(DTCB424_tagSCTurnFightInit));
+ Register(typeof(HB425_tagSCTurnFightReportSign), typeof(DTCB425_tagSCTurnFightReportSign));
+ Register(typeof(HB430_tagSCTurnFightReport), typeof(DTCB430_tagSCTurnFightReport));
+ Register(typeof(H0407_tagNPCDisappear), typeof(DTC0407_tagNPCDisappear));
+ Register(typeof(H0423_tagObjPropertyRefreshView), typeof(DTC0423_tagObjPropertyRefreshView));
+ Register(typeof(H0604_tagUseSkillAttack), typeof(DTC0604_tagUseSkillAttack));
}
-
-
-
//涓诲伐绋嬫敞鍐屽皝鍖�
public static void Register(Type _pack, Type _business)
@@ -116,8 +120,6 @@
}
}
-
-
public static bool Contain(ushort _cmd)
{
return packToBusinessTable.ContainsKey(_cmd);
@@ -127,8 +129,9 @@
try
{
//鎵ц涓诲伐绋嬬殑灏佸寘
- if (packToBusinessTable.ContainsKey(_package.cmd))
+ if (packToBusinessTable.ContainsKey(_package.cmd) && BattleManager.Instance.IsCanDistributePackage(_package))
packToBusinessTable[_package.cmd].Done(_package);
+
}
catch (Exception ex)
{
@@ -178,7 +181,4 @@
}
return null;
}
-
-
-
-}
+}
\ No newline at end of file
diff --git a/Main/Core/NetworkPackage/GameNetPackBasic.cs b/Main/Core/NetworkPackage/GameNetPackBasic.cs
index 92e3ee2..78c5db7 100644
--- a/Main/Core/NetworkPackage/GameNetPackBasic.cs
+++ b/Main/Core/NetworkPackage/GameNetPackBasic.cs
@@ -8,6 +8,21 @@
public class GameNetPackBasic
{
+ static ulong AutoIncreaseUID = 0;
+
+ public ulong packUID
+ {
+ get;
+ private set;
+ }
+
+ public GameNetPackBasic()
+ {
+ packUID = AutoIncreaseUID++;
+ }
+
+
+
public ServerType socketType = ServerType.Main; //榛樿涓斿敮涓�
/** 鍗忚鍙� */
diff --git a/Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs b/Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs
deleted file mode 100644
index ad58459..0000000
--- a/Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-using UnityEngine;
-using System.Collections;
-
-//06 02 鏅�氭敾鍑�#tagObjBaseAttack
-
-public class H0602_tagObjBaseAttack : GameNetPackBasic {
- public uint AttackerID;
- public byte AttackerObjType;
- public byte BattleType; //鏀诲嚮绫诲瀷 鐗╃悊/榄旀硶
- public uint ObjID; //瀵硅薄ID
- public byte ObjType; //瀵硅薄绫诲瀷
- public byte AttackType; //鏅敾, 闂翰, 鑷村懡 绫诲瀷
- public uint Value;
- public uint ValueEx;
- public uint RemainHP; //瀵规柟鍓╀綑鐨勮
- public uint RemainHPEx; //瀵规柟鍓╀綑鐨勮, 瓒呬嚎鏀寔
-
- public H0602_tagObjBaseAttack () {
- _cmd = (ushort)0x0602;
- }
-
- public override void ReadFromBytes (byte[] vBytes) {
- TransBytes (out AttackerID, vBytes, NetDataType.DWORD);
- TransBytes (out AttackerObjType, vBytes, NetDataType.BYTE);
- TransBytes (out BattleType, vBytes, NetDataType.BYTE);
- TransBytes (out ObjID, vBytes, NetDataType.DWORD);
- TransBytes (out ObjType, vBytes, NetDataType.BYTE);
- TransBytes (out AttackType, vBytes, NetDataType.BYTE);
- TransBytes (out Value, vBytes, NetDataType.DWORD);
- TransBytes (out ValueEx, vBytes, NetDataType.DWORD);
- TransBytes (out RemainHP, vBytes, NetDataType.DWORD);
- TransBytes (out RemainHPEx, vBytes, NetDataType.DWORD);
- }
-
-}
diff --git a/Main/System/Battle/BattleEffectMgr.cs b/Main/System/Battle/BattleEffectMgr.cs
new file mode 100644
index 0000000..494d4d9
--- /dev/null
+++ b/Main/System/Battle/BattleEffectMgr.cs
@@ -0,0 +1,88 @@
+using System;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class BattleEffectMgr : MonoBehaviour
+{
+ private BattleField battleField;
+
+ private Dictionary<int, List<EffectPlayer>> effectDict = new Dictionary<int, List<EffectPlayer>>();
+
+ public void Init(BattleField _battleField)
+ {
+ battleField = _battleField;
+ }
+
+ public void PauseGame()
+ {
+ foreach (KeyValuePair<int, List<EffectPlayer>> kvPair in effectDict)
+ {
+ foreach (EffectPlayer effectPlayer in kvPair.Value)
+ {
+ if (effectPlayer != null)
+ {
+ effectPlayer.Pause();
+ }
+ }
+ }
+ }
+
+ public void ResumeGame()
+ {
+ foreach (KeyValuePair<int, List<EffectPlayer>> kvPair in effectDict)
+ {
+ foreach (EffectPlayer effectPlayer in kvPair.Value)
+ {
+ if (effectPlayer != null)
+ {
+ effectPlayer.Resume();
+ }
+ }
+ }
+ }
+
+ public EffectPlayer PlayEffect(int ObjID, int effectId, Transform parent)
+ {
+ if (!effectDict.ContainsKey(effectId))
+ {
+ effectDict[effectId] = new List<EffectPlayer>();
+ }
+
+ EffectPlayer effectPlayer = EffectPlayer.Create(effectId, parent, true, false);
+ effectPlayer.onDestroy = OnEffectDestroy;
+ if (effectPlayer != null)
+ {
+ effectDict[effectId].Add(effectPlayer);
+ effectPlayer.Play();
+ }
+ return effectPlayer;
+ }
+
+ public void RemoveEffect(int effectId, EffectPlayer effectPlayer)
+ {
+ List<EffectPlayer> effectPlayers = null;
+
+ if (effectDict.TryGetValue(effectId, out effectPlayers))
+ {
+ effectPlayers.Remove(effectPlayer);
+ GameObject.DestroyImmediate(effectPlayer.gameObject);
+ effectPlayer = null;
+ }
+ else
+ {
+ Debug.LogError("could not find effect in list, effectid : " + effectId);
+ }
+ }
+
+ protected void OnEffectDestroy(EffectPlayer effectPlayer)
+ {
+ if (effectDict.ContainsKey(effectPlayer.effectId))
+ {
+ effectDict[effectPlayer.effectId].Remove(effectPlayer);
+ if (effectDict[effectPlayer.effectId].Count == 0)
+ {
+ effectDict.Remove(effectPlayer.effectId);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta b/Main/System/Battle/BattleEffectMgr.cs.meta
similarity index 83%
copy from Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta
copy to Main/System/Battle/BattleEffectMgr.cs.meta
index ee23e52..2452df0 100644
--- a/Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta
+++ b/Main/System/Battle/BattleEffectMgr.cs.meta
@@ -1,5 +1,5 @@
fileFormatVersion: 2
-guid: 0c39e10c6d11822409ee2e39b684f89d
+guid: 3b551bfee6a101744995645eecf86bb8
MonoImporter:
externalObjects: {}
serializedVersion: 2
diff --git a/Main/System/Battle/BattleField/BattleField.cs b/Main/System/Battle/BattleField/BattleField.cs
index 64174b8..44bdcd1 100644
--- a/Main/System/Battle/BattleField/BattleField.cs
+++ b/Main/System/Battle/BattleField/BattleField.cs
@@ -1,16 +1,30 @@
using System.Collections.Generic;
using UnityEngine;
using System;
+using LitJson;
+using DG.Tweening;
public class BattleField
{
public BattleObjMgr battleObjMgr;
+
+ public BattleEffectMgr battleEffectMgr;
+
+ public BattleTweenMgr battleTweenMgr;
public RecordPlayer recordPlayer;
public IOperationAgent operationAgent;
public int round = 0;
+
+ public string guid = string.Empty;
+
+ public int MapID = 0;
+
+ public int FuncLineID = 0;
+
+ public JsonData extendData;
public bool IsActive
{
@@ -63,15 +77,45 @@
public Action<bool> OnBattlePause;
- public virtual void Init(TeamBase _redTeam, TeamBase _blueTeam)
+ protected List<TeamBase> redTeamList = null;
+
+ protected List<TeamBase> blueTeamList = null;
+
+ protected int redTeamIndex = 0;
+
+ protected int blueTeamIndex = 0;
+
+ public BattleField(string _guid)
{
+ guid = _guid;
+ }
+
+ public virtual void Init(int _MapID, int _FuncLineID, JsonData _extendData,
+ List<TeamBase> _redTeamList, List<TeamBase> _blueTeamList)
+ {
+ MapID = _MapID;
+ redTeamList = _redTeamList;
+ blueTeamList = _blueTeamList;
+ FuncLineID = _FuncLineID;
+ extendData = _extendData;
+
+ redTeamIndex = 0;
+ blueTeamIndex = 0;
+
GameObject go = ResManager.Instance.LoadAsset<GameObject>("Battle/Prefabs", "BattleRootNode");
GameObject battleRootNodeGO = GameObject.Instantiate(go);
battleRootNode = battleRootNodeGO.GetComponent<BattleRootNode>();
battleRootNodeGO.name = this.GetType().Name;
battleObjMgr = new BattleObjMgr();
- battleObjMgr.Init(this, _redTeam, _blueTeam);
+ battleObjMgr.Init(this, redTeamList[redTeamIndex], blueTeamList[blueTeamIndex]);
+ battleEffectMgr = new BattleEffectMgr();
+ battleEffectMgr.Init(this);
+ battleTweenMgr = new BattleTweenMgr();
+ battleTweenMgr.Init(this);
+
+ // 杩欓噷鐨処nit浜ょ粰鍚勪釜瀛愮被鐨処nit閲屽幓瀹炵幇
+ // battleObjMgr.Init(this, _redTeam, _blueTeam);
recordPlayer = new RecordPlayer();
recordPlayer.Init(this);
@@ -148,6 +192,8 @@
{
battleObjMgr.ResumeGame();
recordPlayer.ResumeGame();
+ battleEffectMgr.ResumeGame();
+ battleTweenMgr.ResumeGame();
}
protected virtual void PauseGame()
@@ -156,8 +202,89 @@
battleObjMgr.PauseGame();
recordPlayer.PauseGame();
+ battleEffectMgr.PauseGame();
+ battleTweenMgr.PauseGame();
}
+ public virtual void TurnFightState(int TurnNum, int State,
+ uint FuncLineID, JsonData extendData)
+ {
+ round = TurnNum;
+ }
+
+ public virtual void OnTurnFightObjAction(int turnNum, int ObjID)
+ {
+
+ }
+
+ public virtual void OnTurnFightState(int turnNum, int State, int FuncLineID, JsonData extendData)
+ {
+
+ }
+
+ public void ObjInfoRefresh(H0418_tagObjInfoRefresh _refreshInfo)
+ {
+ BattleObject battleObj = battleObjMgr.GetBattleObject((int)_refreshInfo.ObjID);
+
+ if (null != battleObj)
+ {
+ battleObj.OnObjInfoRefresh(_refreshInfo);
+ }
+ }
+
+ public void ObjPropertyRefreshView(H0423_tagObjPropertyRefreshView vNetData)
+ {
+
+ }
+
+ public virtual void OnObjDead(int ObjID)
+ {
+ DeathRecordAction recordAction = new DeathRecordAction(this, battleObjMgr.GetBattleObject(ObjID));
+ recordPlayer.PlayRecord(recordAction);
+ }
+
+ public virtual void Destroy()
+ {
+ // 閿�姣佸叏閮ㄥ唴瀹�
+ }
+
+ public void FinishBattleInAdvance(uint[] ObjIDArr)
+ {
+ // 璁﹏pc闅愯棌鍚� 宸﹁竟鎾斁鐫¤鍔ㄤ綔
+
+
+ }
+
+ public virtual void ProcessUseSkillAttack(H0604_tagUseSkillAttack vNetData)
+ {
+ // H0604_tagUseSkillAttack
+ // public uint ObjID;
+ // public byte ObjType;
+ // public byte BattleType; //鐗╃悊/榄旀硶
+ // public ushort SkillID;
+ // public uint AttackID; //涓绘敾鍑荤洰鏍�
+ // public byte AttackObjType; //涓绘敾鍑荤洰鏍�
+ // public ushort HurtCount; //浼ゅ鏁扮洰
+ // public tagSkillHurtObj[] HurtList; //size = HurtCount
+
+ // ObjType绫诲瀷鐨凮bjID浣跨敤BattleType绫绘妧鑳絊killID鏀诲嚮浜咥ttackObjType绫诲瀷鐨凙ttackID 浼ゅ鏁板瓧鏄疕urtList
+ // SkillAction skillAction = new SkillAction();
+
+ }
+
+ public RectTransform GetTeamNode(BattleCamp battleCamp)
+ {
+ if (battleCamp == BattleCamp.Red)
+ {
+ return battleRootNode.redTeamNode;
+ }
+ else
+ {
+ return battleRootNode.blueTeamNode;
+ }
+ }
+
+
public bool IsRoundReachLimit()
{
// return round > xxx;
diff --git a/Main/System/Battle/BattleField/BattleRootNode.cs b/Main/System/Battle/BattleField/BattleRootNode.cs
index 22d5534..4f17cd1 100644
--- a/Main/System/Battle/BattleField/BattleRootNode.cs
+++ b/Main/System/Battle/BattleField/BattleRootNode.cs
@@ -4,11 +4,26 @@
public class BattleRootNode : MonoBehaviour
{
+ public RectTransform redTeamNode;
public List<GameObject> redTeamNodeList = new List<GameObject>();
+ public RectTransform blueTeamNode;
public List<GameObject> blueTeamNodeList = new List<GameObject>();
public RawImage imgBackground;
+ void Awake()
+ {
+ if (redTeamNodeList.Count != TeamConst.MaxTeamSlotCount)
+ {
+ Debug.LogError("redTeamNodeList count is not equal to MaxTeamSlotCount: " + redTeamNodeList.Count);
+ }
+
+ if (blueTeamNodeList.Count != TeamConst.MaxTeamSlotCount)
+ {
+ Debug.LogError("blueTeamNodeList count is not equal to MaxTeamSlotCount: " + blueTeamNodeList.Count);
+ }
+ DontDestroyOnLoad(gameObject);
+ }
}
\ No newline at end of file
diff --git a/Main/System/Battle/BattleField/RecordActions/DeathRecordAction.cs b/Main/System/Battle/BattleField/RecordActions/DeathRecordAction.cs
new file mode 100644
index 0000000..9e21eea
--- /dev/null
+++ b/Main/System/Battle/BattleField/RecordActions/DeathRecordAction.cs
@@ -0,0 +1,35 @@
+using UnityEngine;
+using System.Collections.Generic;
+
+public class DeathRecordAction : RecordAction
+{
+
+ public DeathRecordAction(BattleField _battleField, BattleObject _battleObj)
+ : base(RecordActionType.Death, _battleField, _battleObj)
+ {
+ isFinish = false;
+ isRunOnce = false;
+ }
+
+ public override bool IsFinished()
+ {
+ return isFinish;
+ }
+
+
+ public override void Run()
+ {
+ if (isRunOnce)
+ {
+ return;
+ }
+ base.Run();
+ isRunOnce = true;
+ battleObject.OnDeath(OnDeathAnimationEnd);
+ }
+
+ private void OnDeathAnimationEnd()
+ {
+ isFinish = true;
+ }
+}
\ No newline at end of file
diff --git a/Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta b/Main/System/Battle/BattleField/RecordActions/DeathRecordAction.cs.meta
similarity index 83%
copy from Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta
copy to Main/System/Battle/BattleField/RecordActions/DeathRecordAction.cs.meta
index ee23e52..894c8a3 100644
--- a/Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta
+++ b/Main/System/Battle/BattleField/RecordActions/DeathRecordAction.cs.meta
@@ -1,5 +1,5 @@
fileFormatVersion: 2
-guid: 0c39e10c6d11822409ee2e39b684f89d
+guid: 4db9e665fb4537244ad07b87755fbbc2
MonoImporter:
externalObjects: {}
serializedVersion: 2
diff --git a/Main/System/Battle/BattleField/RecordActions/EditorSkillRecordAction.cs b/Main/System/Battle/BattleField/RecordActions/EditorSkillRecordAction.cs
new file mode 100644
index 0000000..a5d1d07
--- /dev/null
+++ b/Main/System/Battle/BattleField/RecordActions/EditorSkillRecordAction.cs
@@ -0,0 +1,89 @@
+// #if UNITY_EDITOR
+// using UnityEngine;
+// using System.Collections.Generic;
+
+// public class EditorSkillRecordAction : RecordAction
+// {
+// public int SkillId;
+
+// public SkillConfig skillConfig;
+
+// protected SkillBase skillBase;
+
+// protected List<Dictionary<int, List<int>>> damageList = new List<Dictionary<int, List<int>>>();
+
+// private bool isCast = false;
+
+
+// public EditorSkillRecordAction(int _SkillId, BattleField _battleField, BattleObject _battleObj)
+// : base(RecordActionType.Skill, _battleField, _battleObj)
+// {
+// SkillId = _SkillId;
+
+// skillConfig = SkillConfig.Get(SkillId);
+
+// if (null == skillConfig)
+// {
+// Debug.LogError("鎵句笉鍒版妧鑳介厤缃� " + SkillId);
+// }
+
+// skillBase = SkillFactory.CreateSkill(skillConfig);
+
+// // _battleObj浣跨敤浜哠killId鐨勬妧鑳�
+// damageList = skillBase.GetDamageList(battleObject, battleField);
+// }
+
+// public EditorSkillRecordAction(int _SkillId, BattleField _battleField, BattleObject _battleObj, List<Dictionary<int, List<int>>> _damageList)
+// : base(RecordActionType.Skill, _battleField, _battleObj)
+// {
+// SkillId = _SkillId;
+
+// skillConfig = SkillConfig.Get(SkillId);
+
+// if (null == skillConfig)
+// {
+// Debug.LogError("鎵句笉鍒版妧鑳介厤缃� " + SkillId);
+// }
+
+// skillBase = SkillFactory.CreateSkill(skillConfig);
+
+// damageList = _damageList;
+// // _battleObj浣跨敤浜哠killId鐨勬妧鑳�
+// }
+
+// public override bool IsFinished()
+// {
+// return skillBase.IsFinished();
+// }
+
+
+// public override void Run()
+// {
+// base.Run();
+
+// if (null == skillBase)
+// {
+// return;
+// }
+
+// if (!skillBase.IsFinished())
+// {
+// skillBase.Run();
+// }
+
+// if (isCast)
+// return;
+
+// if (damageList.Count > 0)
+// {
+// skillBase.Cast(battleObject, battleField, damageList);
+// }
+// else
+// {
+// skillBase.ForceFinished();
+// }
+
+// isCast = true;
+// }
+// }
+// #endif
\ No newline at end of file
diff --git a/Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta b/Main/System/Battle/BattleField/RecordActions/EditorSkillRecordAction.cs.meta
similarity index 83%
copy from Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta
copy to Main/System/Battle/BattleField/RecordActions/EditorSkillRecordAction.cs.meta
index ee23e52..05a4dab 100644
--- a/Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta
+++ b/Main/System/Battle/BattleField/RecordActions/EditorSkillRecordAction.cs.meta
@@ -1,5 +1,5 @@
fileFormatVersion: 2
-guid: 0c39e10c6d11822409ee2e39b684f89d
+guid: eb0ee7684ec97d5479a7bf8d36a1673c
MonoImporter:
externalObjects: {}
serializedVersion: 2
diff --git a/Main/System/Battle/BattleField/RecordActions/SkillRecordAction.cs b/Main/System/Battle/BattleField/RecordActions/SkillRecordAction.cs
index 80e4092..74ba476 100644
--- a/Main/System/Battle/BattleField/RecordActions/SkillRecordAction.cs
+++ b/Main/System/Battle/BattleField/RecordActions/SkillRecordAction.cs
@@ -3,51 +3,14 @@
public class SkillRecordAction : RecordAction
{
- public int SkillId;
-
- public SkillConfig skillConfig;
-
protected SkillBase skillBase;
- protected List<Dictionary<int, List<int>>> damageList = new List<Dictionary<int, List<int>>>();
-
private bool isCast = false;
-
- public SkillRecordAction(int _SkillId, BattleField _battleField, BattleObject _battleObj)
- : base(RecordActionType.Skill, _battleField, _battleObj)
+ public SkillRecordAction(BattleField _battleField, BattleObject _caster, H0604_tagUseSkillAttack vNetData)
+ : base(RecordActionType.Skill, _battleField, _caster)
{
- SkillId = _SkillId;
-
- skillConfig = SkillConfig.Get(SkillId);
-
- if (null == skillConfig)
- {
- Debug.LogError("鎵句笉鍒版妧鑳介厤缃� " + SkillId);
- }
-
- skillBase = SkillFactory.CreateSkill(skillConfig);
-
- // _battleObj浣跨敤浜哠killId鐨勬妧鑳�
- damageList = skillBase.GetDamageList(battleObject, battleField);
- }
-
- public SkillRecordAction(int _SkillId, BattleField _battleField, BattleObject _battleObj, List<Dictionary<int, List<int>>> _damageList)
- : base(RecordActionType.Skill, _battleField, _battleObj)
- {
- SkillId = _SkillId;
-
- skillConfig = SkillConfig.Get(SkillId);
-
- if (null == skillConfig)
- {
- Debug.LogError("鎵句笉鍒版妧鑳介厤缃� " + SkillId);
- }
-
- skillBase = SkillFactory.CreateSkill(skillConfig);
-
- damageList = _damageList;
- // _battleObj浣跨敤浜哠killId鐨勬妧鑳�
+ skillBase = SkillFactory.CreateSkill(_caster, vNetData, _battleField);
}
public override bool IsFinished()
@@ -73,14 +36,7 @@
if (isCast)
return;
- if (damageList.Count > 0)
- {
- skillBase.Cast(battleObject, battleField, damageList);
- }
- else
- {
- skillBase.ForceFinished();
- }
+ skillBase.Cast();
isCast = true;
}
diff --git a/Main/System/Battle/BattleField/StoryBattleField.cs b/Main/System/Battle/BattleField/StoryBattleField.cs
index d65b54e..ec22f81 100644
--- a/Main/System/Battle/BattleField/StoryBattleField.cs
+++ b/Main/System/Battle/BattleField/StoryBattleField.cs
@@ -1,13 +1,43 @@
-
-
using System;
+using LitJson;
+using UnityEngine;
+using System.Collections.Generic;
public class StoryBattleField : BattleField
{
- public override void Init(TeamBase _redTeam, TeamBase _blueTeam)
- {
- base.Init(_redTeam, _blueTeam);
+ protected int chapter;// 绔犺妭
+ protected int wave;// 娉㈡暟
+ protected int level;// 鍏冲崱
+ protected JsonData extendData;
+ protected MainChapterConfig chapterConfig;
+
+ protected MainLevelConfig levelConfig;
+
+ public StoryBattleField() : base(string.Empty)
+ {
+
+ }
+
+ public override void Init(int MapID, int FuncLineID, JsonData _extendData,
+ List<TeamBase> _redTeamList, List<TeamBase> _blueTeamList)
+ {
+ base.Init(MapID, FuncLineID, extendData, _redTeamList, _blueTeamList);
+
+ LoadBattleMode();
+
+ chapter = FuncLineID / 10000;
+ wave = MapID == 1 ? FuncLineID % 100 : 1;//绗嚑娉㈡��
+ level = (FuncLineID % 10000) / 100;
+
+ extendData = _extendData;
+ chapterConfig = MainChapterConfig.Get(chapter);
+ levelConfig = MainLevelConfig.Get(level);
+
+ }
+
+ protected void LoadBattleMode()
+ {
string savedStr = LocalSave.GetString("StoryBattleFieldBattleMode");
if (string.IsNullOrEmpty(savedStr))
{
@@ -16,6 +46,43 @@
SetBattleMode((BattleMode)Enum.Parse(typeof(BattleMode), savedStr));
}
+ public override void TurnFightState(int TurnNum, int State,
+ uint FuncLineID, JsonData extendData)
+ {
+ base.TurnFightState(TurnNum, State, FuncLineID, extendData);
+
+ switch (State)
+ {
+ // 璧峰鐘舵�佹爣璁�
+ case 0:
+ break;
+ case 1://鍑嗗瀹屾瘯
+ break;
+ case 2://鎴樻枟涓�
+ break;
+ case 3://鎴樻枟缁撴潫
+ break;
+ case 4://缁撶畻濂栧姳
+ break;
+ case 5://缁撴潫鐘舵�佹爣璁�
+ break;
+ default:
+ Debug.LogError("recieve a unknown State");
+ break;
+ }
+ }
+
+ public override void OnTurnFightObjAction(int turnNum, int ObjID)
+ {
+ base.OnTurnFightObjAction(turnNum, ObjID);
+ }
+
+ public override void OnTurnFightState(int turnNum, int State, int FuncLineID, JsonData extendData)
+ {
+ base.OnTurnFightState(turnNum, State, FuncLineID, extendData);
+
+ }
+
// public override void Run()
// {
// // 涓�瀹氳璁颁綇杩欎釜
diff --git a/Main/System/Battle/BattleFieldFactory.cs b/Main/System/Battle/BattleFieldFactory.cs
new file mode 100644
index 0000000..e5ef680
--- /dev/null
+++ b/Main/System/Battle/BattleFieldFactory.cs
@@ -0,0 +1,29 @@
+using LitJson;
+using System;
+using System.Collections;
+using System.Collections.Generic;
+
+
+public static class BattleFieldFactory
+{
+
+ public static BattleField CreateBattleField(string guid, int MapID, int FuncLineID, JsonData extendData, List<TeamBase> redTeamList, List<TeamBase> blueTeamList)
+ {
+ BattleField battleField = null;
+
+
+ switch (MapID)
+ {
+ case 1:
+ case 2:
+ battleField = new StoryBattleField();
+ break;
+ default:
+ break;
+ }
+
+ return battleField;
+ }
+
+
+}
\ No newline at end of file
diff --git a/Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta b/Main/System/Battle/BattleFieldFactory.cs.meta
similarity index 83%
copy from Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta
copy to Main/System/Battle/BattleFieldFactory.cs.meta
index ee23e52..7cb2e9c 100644
--- a/Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta
+++ b/Main/System/Battle/BattleFieldFactory.cs.meta
@@ -1,5 +1,5 @@
fileFormatVersion: 2
-guid: 0c39e10c6d11822409ee2e39b684f89d
+guid: 04ec4d20225cf8e4a8e9abfccf38e154
MonoImporter:
externalObjects: {}
serializedVersion: 2
diff --git a/Main/System/Battle/BattleManager.cs b/Main/System/Battle/BattleManager.cs
index 054f5ae..5697047 100644
--- a/Main/System/Battle/BattleManager.cs
+++ b/Main/System/Battle/BattleManager.cs
@@ -1,57 +1,213 @@
using System.Collections.Generic;
using UnityEngine;
-
+using LitJson;
public class BattleManager : GameSystemManager<BattleManager>
{
public StoryBattleField storyBattleField = null;
- protected Dictionary<int, BattleField> battleFields = new Dictionary<int, BattleField>();
+ // 鍚屾椂鍙兘鏈変竴鍦烘垬鏂楀湪杩涜 guid, battlefield
+ protected Dictionary<string, BattleField> battleFields = new Dictionary<string, BattleField>();
protected LogicUpdate logicUpdate = new LogicUpdate();
public override void Init()
{
base.Init();
- StartStoryBattle();
+ // StartStoryBattle();
logicUpdate.Start(Run);
}
public override void Release()
{
- Debug.LogError("who release this one");
base.Release();
logicUpdate.Destroy();
}
- public void StartStoryBattle()
+ public void CreateStoryBattle(int MapID, int FuncLineID, JsonData extendData, List<TeamBase> redTeamList, List<TeamBase> blueTeamList)
{
if (null == storyBattleField)
{
storyBattleField = new StoryBattleField();
+ }
- TeamBase redTeam = GetStoryTeam();//TeamManager.Instance.GetTeam(TeamType.Story);
- TeamBase blueTeam = GetStoryTeam();
- storyBattleField.Init(/*杩欓噷瑕佸姞涓垱寤鸿儗鏅殑*/redTeam, blueTeam);
- // storyBattleField.Start();
- storyBattleField.battleRootNode.transform.SetParent(Launch.Instance.transform);
+ storyBattleField.Init(MapID, FuncLineID, extendData, redTeamList, blueTeamList);
+ }
+
+
+
+ public void OnBattleClose(BattleField _battleField)
+ {
+
+ }
+
+
+#region 鎴柇缃戠粶娲惧彂鍖� 鍙敹鍏ュ綋鍓嶅寘鐨勫悗缁�
+ private bool allow = true;
+
+ private Queue<GameNetPackBasic> packQueue = new Queue<GameNetPackBasic>();
+
+ public bool IsCanDistributePackage(GameNetPackBasic _package)
+ {
+ if (_package is HB425_tagSCTurnFightReportSign)
+ {
+ HB425_tagSCTurnFightReportSign pkg = _package as HB425_tagSCTurnFightReportSign;
+
+ // 0-鎴樻姤鐗囨寮�濮嬶紱1-鎴樻姤鐗囨缁撴潫锛�
+ if (pkg.Sign == 0)
+ {
+ allow = false;
+ }
+ else
+ {
+ allow = true;
+ }
+ }
+ else
+ {
+ if (!allow)
+ {
+ packQueue.Enqueue(_package);
+ }
+ }
+
+ return allow;
+ }
+
+ public bool DistributeNextPackage()
+ {
+ if (packQueue.Count > 0)
+ {
+ GameNetPackBasic pack = packQueue.Dequeue();
+ PackageRegedit.Distribute(pack);
+ return true;
+ }
+ else
+ {
+ return false;
}
}
- private TeamBase GetStoryTeam()
+ public void OnConnected()
{
- TeamBase teamBase = new TeamBase();
- #if UNITY_EDITOR
- teamBase.FillWithFakeData();
- #else
- // YYL TODO
- // 鏍规嵁閰嶈〃濉炶嫳闆� 鍚庨潰鍙兘杩樿濉炲叾浠栦笢瑗� 鍏堟斁鍦ㄨ繖閲屽弽姝� 鍋氫富绾夸簡鍐嶈浆绉�
- #endif
+ if (!allow)
+ {
+ allow = true;
+ packQueue.Clear();
- return teamBase;
+ // 閲嶆柊鍙戦�佽涓婁竴缁勬垬鏂楀寘鐨勮姹�
+ // TODO YYL
+ }
}
+#endregion
+
+#region 鎴樻姤閮ㄥ垎
+
+ protected Dictionary<string, Queue<GameNetPackBasic>> battleReportDict = new Dictionary<string, Queue<GameNetPackBasic>>();
+
+ protected Dictionary<string, List<ulong>> battlePackRelationList = new Dictionary<string, List<ulong>>();
+
+ public void PushPackage(string guid, GameNetPackBasic vNetPack)
+ {
+ Queue<GameNetPackBasic> queue = null;
+
+ if (!battleReportDict.TryGetValue(guid, out queue))
+ {
+ queue = new Queue<GameNetPackBasic>();
+ }
+
+ queue.Enqueue(vNetPack);
+
+ List<ulong> uidList = null;
+
+ if (!battlePackRelationList.TryGetValue(guid, out uidList))
+ {
+ uidList = new List<ulong>();
+ }
+
+ uidList.Add(vNetPack.packUID);
+ }
+
+ public BattleField GetBattleField(ulong packUID)
+ {
+ return GetBattleField(GetGUID(packUID));
+ }
+
+ public BattleField GetBattleField(string guid)
+ {
+ BattleField battleField = null;
+ battleFields.TryGetValue(guid, out battleField);
+ if (battleField == null)
+ {
+ battleField = storyBattleField;
+ }
+ return battleField;
+ }
+
+
+
+ public string GetGUID(ulong packUID)
+ {
+ foreach (var kv in battlePackRelationList)
+ {
+ if (kv.Value.Contains(packUID))
+ {
+ return kv.Key;
+ }
+ }
+ return string.Empty;
+ }
+
+
+ public void DistributeNextReportPackage(string guid)
+ {
+ Queue<GameNetPackBasic> queue = null;
+
+ if (!battleReportDict.TryGetValue(guid, out queue))
+ {
+ Debug.LogError("DistributeNextReportPackage could not find queue for guid : " + guid);
+ return;
+ }
+
+ PackageRegedit.Distribute(queue.Dequeue());
+
+ if (queue.Count <= 0)
+ {
+ battleReportDict.Remove(guid);
+ battlePackRelationList.Remove(guid);
+ }
+ }
+#endregion
+
+ public BattleField CreateBattleField(string guid, int MapID, int FuncLineID, JsonData extendData, List<TeamBase> redTeamList, List<TeamBase> blueTeamList)
+ {
+ BattleField battleField = null;
+
+ if (battleFields.TryGetValue(guid, out battleField))
+ {
+ Debug.LogError("鎴樺満宸插瓨鍦� 鍏堣繘琛岄攢姣�");
+ battleField.Destroy();
+ }
+
+
+ battleField = BattleFieldFactory.CreateBattleField(guid, MapID, FuncLineID, extendData, redTeamList, blueTeamList);
+
+ battleFields.Add(guid, battleField);
+
+ if (string.Empty == guid)
+ {
+ storyBattleField = battleField as StoryBattleField;
+ }
+
+ return battleField;
+ }
+
+
+ // public void OnTurnFightObjAction(battleType, vNetData.TurnNum, (int)vNetData.ObjID)
+
+
public void Run()
{
if (null != storyBattleField)
diff --git a/Main/System/Battle/BattleObject/BattleObjMgr.cs b/Main/System/Battle/BattleObject/BattleObjMgr.cs
index 2baac38..0141bdc 100644
--- a/Main/System/Battle/BattleObject/BattleObjMgr.cs
+++ b/Main/System/Battle/BattleObject/BattleObjMgr.cs
@@ -21,7 +21,8 @@
battleField = _battleField;
CreateTeam(battleField.battleRootNode.redTeamNodeList, redCampDict, _redTeam, BattleCamp.Red);
CreateTeam(battleField.battleRootNode.blueTeamNodeList, blueCampDict, _blueTeam, BattleCamp.Blue);
- }
+ }
+
protected void CreateTeam(List<GameObject> posNodeList, Dictionary<int, BattleObject> campDict, TeamBase teamBase, BattleCamp _Camp)
{
@@ -32,19 +33,34 @@
if (teamHero != null)
{
BattleObject battleObj = BattleObjectFactory.CreateBattleObject(battleField, posNodeList, teamHero, _Camp);
- allBattleObjDict.Add(battleObj.BattleObjectId, battleObj);
- campDict.Add(teamHero.heroIndex, battleObj);
+ allBattleObjDict.Add(battleObj.ObjID, battleObj);
+ campDict.Add(teamHero.positionNum, battleObj);
}
}
}
- public BattleObject GetBattleObject(int battleObjId)
+ public BattleObject GetBattleObject(int objId)
{
- if (allBattleObjDict.TryGetValue(battleObjId, out BattleObject battleObj))
+ if (allBattleObjDict.TryGetValue(objId, out BattleObject battleObj))
{
return battleObj;
}
return null;
+ }
+
+ public List<BattleObject> GetBattleObjList(H0604_tagUseSkillAttack tagUseSkillAttack)
+ {
+ List<BattleObject> retList = new List<BattleObject>();
+ foreach (var hurt in tagUseSkillAttack.HurtList)
+ {
+ BattleObject obj = GetBattleObject((int)hurt.ObjID);
+ if (null != obj)
+ {
+ retList.Add(obj);
+ }
+ }
+
+ return retList;
}
protected void DestroyTeam(Dictionary<int, BattleObject> campDict)
@@ -54,7 +70,7 @@
BattleObject battleObj = item.Value;
if (battleObj != null)
{
- allBattleObjDict.Remove(battleObj.BattleObjectId);
+ allBattleObjDict.Remove(battleObj.ObjID);
BattleObjectFactory.DestroyBattleObject(item.Key, battleObj);
}
}
@@ -127,7 +143,7 @@
return blueCampList;
}
-#if UNITY_EDITOR
+#if UNITY_EDITOR_STOP_USING
public void ReviveAll()
{
foreach (var kv in allBattleObjDict)
@@ -168,7 +184,7 @@
//鏆傛椂娌℃湁鍙敜鐗�
// 鏀惧湪绗�7鏍肩殑BOSS鍚庢帓鐨勩�傘�備綅缃斁鍦ㄦ涓棿
// a)鍓嶆帓,1銆�2銆�3鍙蜂负鍓嶆帓,鍓嶆帓鍏ㄩ儴闃典骸鍚�,4銆�5銆�6鍙峰嵆鏄墠鎺掍篃鏄悗鎺� 7鍏跺疄涔熸槸鍚庢帓
- List<BattleObject> frontList = new List<BattleObject>(from BO in returnList where BO.teamHero.heroIndex < 3 && !BO.IsDead() select BO);
+ List<BattleObject> frontList = new List<BattleObject>(from BO in returnList where BO.teamHero.positionNum < 3 && !BO.IsDead() select BO);
if (frontList.Count == 0)
{
frontList.AddRange(returnList);
@@ -176,7 +192,7 @@
returnList = frontList;
break;
case SkillTargetRangeType.Back:
- List<BattleObject> backList = new List<BattleObject>(from BO in returnList where BO.teamHero.heroIndex >= 3 && !BO.IsDead() select BO);
+ List<BattleObject> backList = new List<BattleObject>(from BO in returnList where BO.teamHero.positionNum >= 3 && !BO.IsDead() select BO);
if (backList.Count == 0)
{
backList.AddRange(returnList);
diff --git a/Main/System/Battle/BattleObject/BattleObject.cs b/Main/System/Battle/BattleObject/BattleObject.cs
index 6c28854..00862e4 100644
--- a/Main/System/Battle/BattleObject/BattleObject.cs
+++ b/Main/System/Battle/BattleObject/BattleObject.cs
@@ -30,7 +30,9 @@
{
public BattleField battleField;
- public int BattleObjectId { get; set; }
+ public BattleObjectBuffMgr buffMgr;
+
+ public int ObjID { get; set; }
public BattleCamp Camp { get; protected set; }
@@ -38,13 +40,19 @@
// public BuffMgr buffMgr;
- protected MotionBase motionBase;
+ public MotionBase motionBase;
public GameObject heroGo
{
get;
private set;
}
+
+ protected Action onDeathAnimationComplete;
+
+ protected Renderer[] renderers;
+
+ public Transform effectNode;
public BattleObject(BattleField _battleField)
{
@@ -58,6 +66,11 @@
Camp = _camp;
motionBase = new MotionBase();
motionBase.Init(heroGo.GetComponentInChildren<SkeletonGraphic>(true));
+ motionBase.onAnimationComplete += OnAnimationComplete;
+
+ buffMgr.Init(this);
+
+ renderers = heroGo.GetComponentsInChildren<Renderer>(true);
}
@@ -88,7 +101,27 @@
motionBase.Release();
motionBase = null;
teamHero = null;
- BattleObjectId = 0;
+ ObjID = 0;
+ motionBase.onAnimationComplete -= OnAnimationComplete;
+ }
+
+ public void OnObjInfoRefresh(H0418_tagObjInfoRefresh _refreshInfo)
+ {
+ switch ((PlayerDataType)_refreshInfo.RefreshType)
+ {
+ case PlayerDataType.HP:
+ teamHero.curHp = GeneralDefine.GetFactValue(_refreshInfo.Value, _refreshInfo.ValueEx);
+ break;
+ case PlayerDataType.MaxHP:
+ teamHero.maxHp = GeneralDefine.GetFactValue(_refreshInfo.Value, _refreshInfo.ValueEx);
+ break;
+ case PlayerDataType.XP:
+ teamHero.rage = (int)GeneralDefine.GetFactValue(_refreshInfo.Value, _refreshInfo.ValueEx);
+ break;
+ default:
+ Debug.LogError("BattleObject.ObjInfoRefresh 鍑虹幇鎰忓绫诲瀷 " + _refreshInfo.RefreshType.ToString());
+ break;
+ }
}
// 鐪╂檿
@@ -108,12 +141,6 @@
{
return teamHero.isStoned;
}
-
- // // 绂侀敘
- // public bool IsConfined()
- // {
- // return false;
- // }
// 琚矇榛�
public bool IsSlient()
@@ -180,32 +207,21 @@
return true;
}
- public virtual void TakeDamage(List<int> damageValues)
+ public virtual void Hurt(List<long> damageValues, int attackType)
{
- if (IsDead())
- return;
-
- PopDamage(damageValues);
+ PopDamage(teamHero.curHp, damageValues, attackType);
motionBase.PlayAnimation(MotionName.hit, false);
// 璁$畻浼ゅ
- int totalDamage = 0;
+ long totalDamage = 0;
foreach (var damage in damageValues)
{
totalDamage += damage;
}
-
// 鎵h
teamHero.curHp -= totalDamage;
-
- // 鍏跺疄杩欓噷搴旇鏄瓑鏈嶅姟鍣ㄥ彂death鐨刟ction
- // if (IsDead())
- // {
- // OnDeath();
- // }
-
}
// 闂伩寮�濮�
@@ -213,8 +229,10 @@
{
float pingpongTime = 0.2f;
RectTransform rectTrans = heroGo.GetComponent<RectTransform>();
- rectTrans.DOAnchorPos(new Vector3(-50, 50, 0), pingpongTime)
+ var tween = rectTrans.DOAnchorPos(new Vector3(-50, 50, 0), pingpongTime)
.SetEase(Ease.OutCubic);
+
+ battleField.battleTweenMgr.OnPlayTween(tween);
}
// 闂伩缁撴潫
@@ -222,21 +240,26 @@
{
float pingpongTime = 0.2f;
RectTransform rectTrans = heroGo.GetComponent<RectTransform>();
- rectTrans.DOAnchorPos(Vector3.zero, pingpongTime)
+
+ var tween = rectTrans.DOAnchorPos(Vector3.zero, pingpongTime)
.SetEase(Ease.OutCubic);
+
+ battleField.battleTweenMgr.OnPlayTween(tween);
}
- protected virtual void OnDeath()
+ public virtual void OnDeath(Action _onDeathAnimationComplete)
{
- motionBase.OnOtherAnimationComplete = OnOtherAnimationComplete;
+ onDeathAnimationComplete = _onDeathAnimationComplete;
motionBase.PlayAnimation(MotionName.dead, false);
}
- protected virtual void OnOtherAnimationComplete(MotionName motionName)
+ protected virtual void OnAnimationComplete(MotionName motionName)
{
if (motionName == MotionName.dead)
{
OnDeadAnimationComplete();
+ onDeathAnimationComplete?.Invoke();
+ onDeathAnimationComplete = null;
}
}
@@ -247,7 +270,7 @@
}
// 浼ゅ杩樿鐪� 鏄惁闂伩 鏆村嚮 and so on 闇�瑕佹湁涓�涓狣amageType 鏈嶅姟鍣ㄥ簲璇ヤ細缁�
- protected virtual void PopDamage(List<int> damageValues)
+ protected virtual void PopDamage(long curHp, List<long> damageValues, int attackType)
{
// 鍏跺疄搴旇閫氱煡鍑哄幓缁橴I鐣岄潰瑙h�� 璁︰I鐣岄潰鑷繁鏉ユ樉绀虹殑 YYL TODO
// 鎾斁浼ゅ鏁板瓧
@@ -258,121 +281,20 @@
Debug.Log($"Damage: {damage}");
}
- EventBroadcast.Instance.Broadcast<BattleObject, List<int>>(EventName.BATTLE_DAMAGE_TAKEN, this, damageValues);
+ EventBroadcast.Instance.Broadcast(EventName.BATTLE_DAMAGE_TAKEN, battleField.guid, this, damageValues);
}
- public void PlaySkill(SkillConfig skillConfig, List<Dictionary<int, List<int>>> damageList, Action _onComplete)
+ public RectTransform GetAliasTeamNode()
{
- bool moveToTarget = true;
-
- if (moveToTarget)
- {
- int targetId = damageList[0].First().Key;
- BattleObject _targetObj = battleField.battleObjMgr.GetBattleObject(targetId);
-
- RectTransform selfRect = heroGo.GetComponent<RectTransform>();
- RectTransform targetRect = _targetObj.heroGo.GetComponent<RectTransform>();
- Vector2 curAnchoredPos = selfRect.anchoredPosition;
-
- MoveToTargetUI(selfRect, targetRect, new Vector2(100f, 0f), () =>
- {
- PlaySkillAnimation(skillConfig, damageList, () =>
- {
- // 鍥炲埌鍘熶綅缃�
- selfRect.DOAnchorPos(curAnchoredPos, 0.2f)
- .SetEase(Ease.Linear)
- .OnComplete(() => {
- _onComplete?.Invoke();
- });
- });
- });
- }
- else
- {
- PlaySkillAnimation(skillConfig, damageList, _onComplete);
- }
+ return battleField.GetTeamNode(Camp);
}
- protected void MoveToTargetUI(RectTransform selfRect, RectTransform targetRect, Vector2 offset, Action _onComplete)
+ public RectTransform GetEnemyTeamNode()
{
- // 1. 鐩爣鐨勬湰鍦板潗鏍囪浆涓轰笘鐣屽潗鏍�
- Vector3 targetWorldPos = targetRect.TransformPoint(targetRect.anchoredPosition + offset);
-
- // 2. 涓栫晫鍧愭爣杞负鑷繁鐖惰妭鐐逛笅鐨勬湰鍦板潗鏍�
- RectTransform parentRect = selfRect.parent as RectTransform;
- Vector2 targetAnchoredPos;
- RectTransformUtility.ScreenPointToLocalPointInRectangle(
- parentRect,
- RectTransformUtility.WorldToScreenPoint(null, targetWorldPos),
- null,
- out targetAnchoredPos);
-
- // 3. DOTween 绉诲姩
- selfRect.DOAnchorPos(targetAnchoredPos, 0.2f)
- .SetEase(Ease.Linear)
- .OnComplete(() => _onComplete?.Invoke());
+ return battleField.GetTeamNode(Camp == BattleCamp.Red ? BattleCamp.Blue : BattleCamp.Red);
}
-
- protected void PlaySkillAnimation(SkillConfig skillConfig, List<Dictionary<int, List<int>>> damageList, Action _onComplete)
- {
-
- // 鍏抽敭甯у垪琛�
- List<int> keyFrameList = new List<int>() { 15 };
- motionBase.OnAttackHitEvent = (int _frame) =>
- {
- Dictionary<int, List<int>> oneRoundDamage = damageList[keyFrameList.IndexOf(_frame)];
-
- foreach (var kvp in oneRoundDamage)
- {
- int targetId = kvp.Key;
- List<int> damageValues = kvp.Value;
-
- BattleObject targetObj = battleField.battleObjMgr.GetBattleObject(targetId);
- if (targetObj != null && !targetObj.IsDead())
- {
- targetObj.TakeDamage(damageValues);
- }
- }
- };
-
- motionBase.OnAttackAnimationComplete = () =>
- {
- _onComplete?.Invoke();
-
- motionBase.OnAttackHitEvent = null;
- motionBase.OnAttackAnimationComplete = null;
-
- // 姝讳骸纭畾鍏跺疄涓嶅簲璇ュ湪杩欓噷杩涜瑙﹀彂 搴旇鐢辨湇鍔″櫒涓嬪彂 YYL TODO
-
-#if UNITY_EDITOR
- // 鏆傛椂鐨勫鐞�
- HashSet<int> hitTargets = new HashSet<int>();
-
- foreach (var dmgDict in damageList)
- {
- foreach (var kvp in dmgDict)
- {
- int targetId = kvp.Key;
- hitTargets.Add(targetId);
- }
- }
-
- foreach (int targetId in hitTargets)
- {
- BattleObject targetObj = battleField.battleObjMgr.GetBattleObject(targetId);
- if (targetObj != null && targetObj.IsDead())
- {
- targetObj.OnDeath();
- }
- }
-#endif
- };
-
- motionBase.PlayAnimationEx(MotionName.attack, false, keyFrameList);
- }
-
-#if UNITY_EDITOR
+#if UNITY_EDITOR_STOP_USING
public void EditorRevive()
{
teamHero.curHp = 100;
diff --git a/Main/System/Battle/BattleObject/BattleObjectFactory.cs b/Main/System/Battle/BattleObject/BattleObjectFactory.cs
index f7d9304..000fba5 100644
--- a/Main/System/Battle/BattleObject/BattleObjectFactory.cs
+++ b/Main/System/Battle/BattleObject/BattleObjectFactory.cs
@@ -2,20 +2,24 @@
using System.Collections.Generic;
using System;
using UnityEngine;
+using Spine.Unity;
public class BattleObjectFactory
{
// 鏈剰鏄鍦ㄨ繖閲屽仛姹犵殑鍐呭鐨� 浣嗘槸鎯充簡涓�涓� 鍒╃敤鏁堢巼鏈夌偣宸� 鏈�澶氬仛涓�涓嬬孩鑹叉柟鐨勭紦瀛� 钃濊壊鏂圭殑鍗虫椂鐢� 鍗虫椂鍒犻櫎 鎴栬�呯紦瀛樹笂涓�娆℃垬鏂楃殑灏辫
- private static int AutoIncrementID = 100000;
+ // private static int AutoIncrementID = 100000;
public static BattleObject CreateBattleObject(BattleField _battleField, List<GameObject> posNodeList, TeamHero teamHero, BattleCamp _Camp)
{
- HeroSkinConfig skinCfg = teamHero.heroInfo.skinConfig;
+ HeroSkinConfig skinCfg = teamHero.skinConfig;
GameObject battleGO = ResManager.Instance.LoadAsset<GameObject>("Hero/SpineRes", "Hero_001"/*skinCfg.SpineRes*/);
- GameObject goParent = posNodeList[teamHero.heroIndex];
+ SkeletonGraphic skeletonGraphic = battleGO.GetComponent<SkeletonGraphic>();
+ skeletonGraphic.skeletonDataAsset = ResManager.Instance.LoadAsset<SkeletonDataAsset>("Hero/SpineRes/", skinCfg.SpineRes);
+ skeletonGraphic.Initialize(true);
+ GameObject goParent = posNodeList[teamHero.positionNum];
BattleObject battleObject = new BattleObject(_battleField);
- battleObject.BattleObjectId = AutoIncrementID++;
- battleGO.name = battleObject.BattleObjectId.ToString();
+ battleObject.ObjID = teamHero.ObjID;
+ battleGO.name = battleObject.ObjID.ToString();
battleObject.Init(GameObject.Instantiate(battleGO, goParent.transform), teamHero, _Camp);
return battleObject;
}
diff --git a/Main/System/Battle/BattleTweenMgr.cs b/Main/System/Battle/BattleTweenMgr.cs
new file mode 100644
index 0000000..e36d309
--- /dev/null
+++ b/Main/System/Battle/BattleTweenMgr.cs
@@ -0,0 +1,54 @@
+using System;
+using System.Collections.Generic;
+using DG.Tweening;
+using UnityEngine;
+
+public class BattleTweenMgr
+{
+ private BattleField battleField;
+
+ private List<Tween> tweenList = new List<Tween>();
+
+ public void Init(BattleField _battleField)
+ {
+ battleField = _battleField;
+ }
+
+ public void PauseGame()
+ {
+ foreach (var tween in tweenList)
+ {
+ if (tween != null && !tween.IsComplete())
+ {
+ tween.Pause();
+ }
+ }
+ }
+
+ public void ResumeGame()
+ {
+ foreach (var tween in tweenList)
+ {
+ if (tween != null && !tween.IsComplete())
+ {
+ tween.Play();
+ }
+ }
+ }
+
+ public void OnPlayTween(Tween tween)
+ {
+ if (tween == null || tween.IsComplete())
+ {
+ return;
+ }
+
+ tweenList.Add(tween);
+ tween.OnComplete(() =>
+ {
+ tweenList.Remove(tween);
+ });
+
+ tween.Play();
+ }
+}
\ No newline at end of file
diff --git a/Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta b/Main/System/Battle/BattleTweenMgr.cs.meta
similarity index 83%
rename from Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta
rename to Main/System/Battle/BattleTweenMgr.cs.meta
index ee23e52..8892416 100644
--- a/Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta
+++ b/Main/System/Battle/BattleTweenMgr.cs.meta
@@ -1,5 +1,5 @@
fileFormatVersion: 2
-guid: 0c39e10c6d11822409ee2e39b684f89d
+guid: ee889e8a605a1904599601b289691889
MonoImporter:
externalObjects: {}
serializedVersion: 2
diff --git a/Main/System/Battle/BattleUtility.cs b/Main/System/Battle/BattleUtility.cs
new file mode 100644
index 0000000..5ac2287
--- /dev/null
+++ b/Main/System/Battle/BattleUtility.cs
@@ -0,0 +1,32 @@
+using System;
+using System.Collections.Generic;
+using UnityEngine;
+using UnityEngine.UI;
+using DG.Tweening;
+using DG.Tweening.Core;
+
+
+public static class BattleUtility
+{
+ // 鍏朵粬閫氱敤鐨勬垬鏂楀伐鍏锋柟娉曞彲浠ユ斁鍦ㄨ繖閲�
+
+ public static TweenerCore<Vector2, Vector2, DG.Tweening.Plugins.Options.VectorOptions> MoveToTarget(RectTransform transform, RectTransform target, Vector2 offset, float duration, Action onComplete = null)
+ {
+ Vector3 targetWorldPos = target.TransformPoint(target.anchoredPosition + offset);
+
+ RectTransform parentRect = transform.parent as RectTransform;
+
+ Vector2 targetAnchoredPos;
+ RectTransformUtility.ScreenPointToLocalPointInRectangle(
+ parentRect,
+ RectTransformUtility.WorldToScreenPoint(null, targetWorldPos),
+ null,
+ out targetAnchoredPos);
+
+ // 3. DOTween 绉诲姩
+ return transform.DOAnchorPos(targetAnchoredPos, duration)
+ .SetEase(Ease.Linear)
+ .OnComplete(() => onComplete?.Invoke());
+ }
+
+}
\ No newline at end of file
diff --git a/Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta b/Main/System/Battle/BattleUtility.cs.meta
similarity index 83%
copy from Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta
copy to Main/System/Battle/BattleUtility.cs.meta
index ee23e52..9a9c80e 100644
--- a/Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta
+++ b/Main/System/Battle/BattleUtility.cs.meta
@@ -1,5 +1,5 @@
fileFormatVersion: 2
-guid: 0c39e10c6d11822409ee2e39b684f89d
+guid: f2c6020c5feefa04e8a7975071123f79
MonoImporter:
externalObjects: {}
serializedVersion: 2
diff --git a/Main/System/Battle/Buff/BattleObjectBuffMgr.cs b/Main/System/Battle/Buff/BattleObjectBuffMgr.cs
new file mode 100644
index 0000000..7858db2
--- /dev/null
+++ b/Main/System/Battle/Buff/BattleObjectBuffMgr.cs
@@ -0,0 +1,39 @@
+using System.Collections.Generic;
+using UnityEngine;
+
+
+public class BattleObjectBuffMgr
+{
+ // private Dictionary<BuffBase, EffectPlayer> buffDict = new Dictionary<BuffBase, EffectPlayer>();
+
+ private BattleObject battleObject;
+
+ public void Init(BattleObject _battleObject)
+ {
+ battleObject = _battleObject;
+ }
+
+ public void Release()
+ {
+
+ }
+
+ // 澧炲姞buff
+ public void AddBuff(H0605_tagObjAddBuff vNetData)
+ {
+ // BuffBase buffBase = BuffFactory.CreateBuff(vNetData, battleObject);
+ // if (null == buffBase)
+ // {
+ // return;
+ // }
+
+ // buffBase.OnAdd();
+ }
+
+ // 鍒犻櫎buff
+ public void RemoveBuff(H0606_tagObjDelBuff vNetData)
+ {
+
+ // buffBase.OnRemove();
+ }
+}
\ No newline at end of file
diff --git a/Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta b/Main/System/Battle/Buff/BattleObjectBuffMgr.cs.meta
similarity index 83%
copy from Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta
copy to Main/System/Battle/Buff/BattleObjectBuffMgr.cs.meta
index ee23e52..933cd6c 100644
--- a/Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta
+++ b/Main/System/Battle/Buff/BattleObjectBuffMgr.cs.meta
@@ -1,5 +1,5 @@
fileFormatVersion: 2
-guid: 0c39e10c6d11822409ee2e39b684f89d
+guid: 1a6e63c004530d242982e4cdaddaa74d
MonoImporter:
externalObjects: {}
serializedVersion: 2
diff --git a/Main/System/Battle/Buff/BuffBase.cs b/Main/System/Battle/Buff/BuffBase.cs
new file mode 100644
index 0000000..d032c89
--- /dev/null
+++ b/Main/System/Battle/Buff/BuffBase.cs
@@ -0,0 +1,41 @@
+using UnityEngine;
+
+/// <summary>
+/// Buff鍩虹被锛屾墍鏈塀uff绫诲瀷缁ф壙鑷绫�
+/// </summary>
+public abstract class BuffBase
+{
+ // public int BuffId { get; protected set; }
+ // public BattleObject Owner { get; protected set; }
+ // public int DurationRound { get; protected set; } // 鎸佺画鍥炲悎鏁�
+ // public int ElapsedRound { get; protected set; } // 宸茬粡杩囩殑鍥炲悎鏁�
+
+ protected H0605_tagObjAddBuff h0605_TagObjAddBuff;
+
+ public BuffBase(H0605_tagObjAddBuff _h0605_TagObjAddBuff)
+ {
+ h0605_TagObjAddBuff = _h0605_TagObjAddBuff;
+ // BuffId = buffId;
+ // Owner = owner;
+ // DurationRound = durationRound;
+ // ElapsedRound = 0;
+
+
+ }
+
+ /// <summary>
+ /// Buff娣诲姞鏃惰皟鐢�
+ /// </summary>
+ public virtual void OnAdd()
+ {
+
+ }
+
+ /// <summary>
+ /// Buff绉婚櫎鏃惰皟鐢�
+ /// </summary>
+ public virtual void OnRemove()
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta b/Main/System/Battle/Buff/BuffBase.cs.meta
similarity index 83%
copy from Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta
copy to Main/System/Battle/Buff/BuffBase.cs.meta
index ee23e52..52b7fcc 100644
--- a/Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta
+++ b/Main/System/Battle/Buff/BuffBase.cs.meta
@@ -1,5 +1,5 @@
fileFormatVersion: 2
-guid: 0c39e10c6d11822409ee2e39b684f89d
+guid: 6afb02269964eb748bbe21d946a0ef7a
MonoImporter:
externalObjects: {}
serializedVersion: 2
diff --git a/Main/System/Battle/Buff/BuffFactory.cs b/Main/System/Battle/Buff/BuffFactory.cs
new file mode 100644
index 0000000..cda15e5
--- /dev/null
+++ b/Main/System/Battle/Buff/BuffFactory.cs
@@ -0,0 +1,24 @@
+using UnityEngine;
+
+/// <summary>
+/// Buff宸ュ巶锛屾牴鎹暟鎹垱寤哄搴旂殑Buff瀹炰緥
+/// </summary>
+public static class BuffFactory
+{
+ public static BuffBase CreateBuff(H0605_tagObjAddBuff vNetData, BattleObject owner)
+ {
+ // int buffId = vNetData.buffId;
+ // int durationRound = vNetData.durationRound;
+
+ // 绀轰緥锛氭牴鎹産uffId鍒涘缓涓嶅悓绫诲瀷Buff
+ // switch (buffId)
+ // {
+ // // case 1: return new StunBuff(buffId, owner, durationRound);
+ // // case 2: return new PoisonBuff(buffId, owner, durationRound);
+ // // 缁х画娣诲姞鍏跺畠鍏蜂綋Buff绫诲瀷
+ // default:
+ // return null; // 鏈煡buff涓嶅垱寤�
+ // }
+ return null;
+ }
+}
\ No newline at end of file
diff --git a/Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta b/Main/System/Battle/Buff/BuffFactory.cs.meta
similarity index 83%
copy from Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta
copy to Main/System/Battle/Buff/BuffFactory.cs.meta
index ee23e52..61aba00 100644
--- a/Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta
+++ b/Main/System/Battle/Buff/BuffFactory.cs.meta
@@ -1,5 +1,5 @@
fileFormatVersion: 2
-guid: 0c39e10c6d11822409ee2e39b684f89d
+guid: 6c080c000bb94344d94179aa6a0bfa3b
MonoImporter:
externalObjects: {}
serializedVersion: 2
diff --git a/Main/System/Battle/Bullet.meta b/Main/System/Battle/Bullet.meta
new file mode 100644
index 0000000..fb354f6
--- /dev/null
+++ b/Main/System/Battle/Bullet.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 115fa1b85e4a51a4d9869f53fca7c35c
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Main/System/Battle/Bullet/Bullet.cs b/Main/System/Battle/Bullet/Bullet.cs
new file mode 100644
index 0000000..e9f9529
--- /dev/null
+++ b/Main/System/Battle/Bullet/Bullet.cs
@@ -0,0 +1,95 @@
+
+
+using System;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class Bullet
+{
+ protected BattleObject caster;
+
+ protected SkillConfig skillConfig;
+
+ protected List<H0604_tagUseSkillAttack.tagSkillHurtObj> hurtList;
+
+ protected BattleField battleField;
+
+ protected Action onComplete;
+
+
+ protected int curFrame = 0;
+
+
+ public Bullet(BattleObject _caster, SkillConfig skillConfig,
+ List<H0604_tagUseSkillAttack.tagSkillHurtObj> hurtList, BattleField battleField, Action _onComplete)
+ {
+ this.caster = _caster;
+ this.skillConfig = skillConfig;
+ this.hurtList = hurtList;
+ this.battleField = battleField;
+ this.onComplete = _onComplete;
+
+ }
+
+ public virtual void Start()
+ {
+
+ }
+ public virtual void Run()
+ {
+
+ }
+
+ protected virtual void PlayEffect(int effectId, SkillEffectAnchor target)
+ {
+ // 杩橀渶瑕丼oAttackType鏉ュ垽鏂槸鎬庢牱鐨勭壒鏁�
+
+ switch (target)
+ {
+ // 鐗规晥鍏堜笉绠� TODO YYL 绛夌壒鏁堥噸鏂板啓杩囦竴閬嶅悗鍐嶅啓
+
+ case SkillEffectAnchor.Caster:
+ // caster.PlayEffect(effectId);
+ break;
+ case SkillEffectAnchor.Target:
+ // caster.teamHero.PlayEffectOnAllies(effectId);
+ break;
+ case SkillEffectAnchor.AlliesCenter:
+ // caster.teamHero.PlayEffectOnAlliesCenter(effectId);
+ break;
+ case SkillEffectAnchor.EnemiesCenter:
+ // caster.teamHero.PlayEffectOnEnemiesCenter(effectId);
+ break;
+ default:
+ Debug.LogWarning($"Unhandled effect target: {target}");
+ break;
+ }
+ }
+
+
+ protected virtual void PlayAudio(int audioId)
+ {
+ SoundPlayer.Instance.PlayUIAudio(audioId);
+ }
+
+ protected virtual void ShakeScreen(int intensity)
+ {
+ // Implement screen shaking logic here
+ Debug.Log($"Shaking screen with intensity: {intensity}");
+ }
+
+ protected virtual void PopDamage()
+ {
+
+ }
+
+ protected virtual void OnSkillComplete()
+ {
+ onComplete?.Invoke();
+ }
+
+ protected virtual void PlaySkill(int skillId)
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta b/Main/System/Battle/Bullet/Bullet.cs.meta
similarity index 83%
copy from Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta
copy to Main/System/Battle/Bullet/Bullet.cs.meta
index ee23e52..1765184 100644
--- a/Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta
+++ b/Main/System/Battle/Bullet/Bullet.cs.meta
@@ -1,5 +1,5 @@
fileFormatVersion: 2
-guid: 0c39e10c6d11822409ee2e39b684f89d
+guid: 8d4d5668dea0ef64da48bab26e795fac
MonoImporter:
externalObjects: {}
serializedVersion: 2
diff --git a/Main/System/Battle/Bullet/BulletFactory.cs b/Main/System/Battle/Bullet/BulletFactory.cs
new file mode 100644
index 0000000..a776873
--- /dev/null
+++ b/Main/System/Battle/Bullet/BulletFactory.cs
@@ -0,0 +1,12 @@
+
+using System;
+using System.Collections.Generic;
+using UnityEngine;
+
+public static class BulletFactory
+{
+ public static Bullet CreateBullet(BattleObject _caster, SkillConfig skillConfig, List<H0604_tagUseSkillAttack.tagSkillHurtObj> hurtList, BattleField battleField, Action _onComplete)
+ {
+ return null;
+ }
+}
\ No newline at end of file
diff --git a/Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta b/Main/System/Battle/Bullet/BulletFactory.cs.meta
similarity index 83%
copy from Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta
copy to Main/System/Battle/Bullet/BulletFactory.cs.meta
index ee23e52..8aa3b6e 100644
--- a/Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta
+++ b/Main/System/Battle/Bullet/BulletFactory.cs.meta
@@ -1,5 +1,5 @@
fileFormatVersion: 2
-guid: 0c39e10c6d11822409ee2e39b684f89d
+guid: b007b1040446daf4db9c2a14b6d25b1d
MonoImporter:
externalObjects: {}
serializedVersion: 2
diff --git a/Main/System/Battle/Bullet/CloseCombatBullet.cs b/Main/System/Battle/Bullet/CloseCombatBullet.cs
new file mode 100644
index 0000000..90467cd
--- /dev/null
+++ b/Main/System/Battle/Bullet/CloseCombatBullet.cs
@@ -0,0 +1,81 @@
+
+
+using System;
+using System.Collections.Generic;
+using UnityEngine;
+
+// 杩戞垬鏀诲嚮
+public class CloseCombatBullet : Bullet
+{
+
+ protected int keyFrameIndex = 0;
+
+ protected int frame = 0;
+
+ public CloseCombatBullet(BattleObject _caster, SkillConfig _skillConfig, List<H0604_tagUseSkillAttack.tagSkillHurtObj> _hurtList, BattleField _battleField, Action _onComplete)
+ : base(_caster, _skillConfig, _hurtList, _battleField, _onComplete)
+ {
+
+ }
+
+
+ public override void Start()
+ {
+ base.Start();
+
+ // 鐢╯killconfig.xp鏉ュ垽鏂笉淇濋櫓
+ MotionName motionName = GetMotionName(skillConfig.SkillMotionName);
+ caster.motionBase.PlayAnimation(motionName, false);
+ }
+
+ public MotionName GetMotionName(string strMotionName)
+ {
+ return Enum.Parse<MotionName>(strMotionName);
+ }
+
+
+ protected override void OnSkillComplete()
+ {
+ foreach (var hurtObj in hurtList)
+ {
+ BattleObject targetObj = battleField.battleObjMgr.GetBattleObject((int)hurtObj.ObjID);
+ if (targetObj != null)
+ {
+ long curHP = GeneralDefine.GetFactValue(hurtObj.CurHP, hurtObj.CurHPEx);
+ targetObj.teamHero.curHp = curHP;
+ }
+ }
+ base.OnSkillComplete();
+
+ }
+
+
+ protected override void PopDamage()
+ {
+ if (keyFrameIndex >= skillConfig.DamageDivide.Length)
+ {
+ Debug.LogError("CloseCombatBullet PopDamage keyFrameIndex out of range: " + keyFrameIndex);
+ return;
+ }
+
+ int[] tenKDamagePercentArray = skillConfig.DamageDivide[keyFrameIndex++];
+
+ foreach (var hurtObj in hurtList)
+ {
+ long factDamage = GeneralDefine.GetFactValue(hurtObj.HurtHP, hurtObj.HurtHPEx);
+ List<long> damageList = new List<long>();
+ for (int i = 0; i < tenKDamagePercentArray.Length; i++)
+ {
+ long damage = (long)(Mathf.Round(factDamage * tenKDamagePercentArray[i] / 10000.0f));
+ damageList.Add(damage);
+ }
+
+ BattleObject targetObj = battleField.battleObjMgr.GetBattleObject((int)hurtObj.ObjID);
+ if (targetObj != null)
+ {
+ // 鎾斁鍙楀嚮鍔ㄤ綔
+ targetObj.Hurt(damageList, hurtObj.AttackType);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta b/Main/System/Battle/Bullet/CloseCombatBullet.cs.meta
similarity index 83%
copy from Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta
copy to Main/System/Battle/Bullet/CloseCombatBullet.cs.meta
index ee23e52..12c6799 100644
--- a/Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta
+++ b/Main/System/Battle/Bullet/CloseCombatBullet.cs.meta
@@ -1,5 +1,5 @@
fileFormatVersion: 2
-guid: 0c39e10c6d11822409ee2e39b684f89d
+guid: a21315aaaa6e8f6448f864298b4516c0
MonoImporter:
externalObjects: {}
serializedVersion: 2
diff --git a/Main/System/Battle/Bullet/TrajectoryBullet.cs b/Main/System/Battle/Bullet/TrajectoryBullet.cs
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Main/System/Battle/Bullet/TrajectoryBullet.cs
diff --git a/Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta b/Main/System/Battle/Bullet/TrajectoryBullet.cs.meta
similarity index 83%
copy from Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta
copy to Main/System/Battle/Bullet/TrajectoryBullet.cs.meta
index ee23e52..9310e5e 100644
--- a/Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta
+++ b/Main/System/Battle/Bullet/TrajectoryBullet.cs.meta
@@ -1,5 +1,5 @@
fileFormatVersion: 2
-guid: 0c39e10c6d11822409ee2e39b684f89d
+guid: 3d40a22572b07c24e9eefb52db0bfd87
MonoImporter:
externalObjects: {}
serializedVersion: 2
diff --git a/Main/System/Battle/Define/BattleType.cs b/Main/System/Battle/Define/BattleType.cs
new file mode 100644
index 0000000..f1615ca
--- /dev/null
+++ b/Main/System/Battle/Define/BattleType.cs
@@ -0,0 +1,7 @@
+
+
+public enum BattleType
+{
+ MainLevelMobs = 1, //涓荤嚎灏忔��
+ MainLevelBoss = 2, //涓荤嚎boss
+}
\ No newline at end of file
diff --git a/Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta b/Main/System/Battle/Define/BattleType.cs.meta
similarity index 83%
copy from Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta
copy to Main/System/Battle/Define/BattleType.cs.meta
index ee23e52..412494e 100644
--- a/Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta
+++ b/Main/System/Battle/Define/BattleType.cs.meta
@@ -1,5 +1,5 @@
fileFormatVersion: 2
-guid: 0c39e10c6d11822409ee2e39b684f89d
+guid: ca8a7ce9d3982ee40bec8c3ea869a461
MonoImporter:
externalObjects: {}
serializedVersion: 2
diff --git a/Main/System/Battle/Define/PlayEffectType.cs b/Main/System/Battle/Define/PlayEffectType.cs
new file mode 100644
index 0000000..9f37d2a
--- /dev/null
+++ b/Main/System/Battle/Define/PlayEffectType.cs
@@ -0,0 +1,8 @@
+
+
+public enum PlayEffectType
+{
+ None = 0,
+ SkillStart, // 鎶�鑳藉紑濮�
+ AttackHit, // 鏀诲嚮鍛戒腑
+}
\ No newline at end of file
diff --git a/Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta b/Main/System/Battle/Define/PlayEffectType.cs.meta
similarity index 83%
copy from Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta
copy to Main/System/Battle/Define/PlayEffectType.cs.meta
index ee23e52..ca14887 100644
--- a/Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta
+++ b/Main/System/Battle/Define/PlayEffectType.cs.meta
@@ -1,5 +1,5 @@
fileFormatVersion: 2
-guid: 0c39e10c6d11822409ee2e39b684f89d
+guid: ae351bd17066a3040a5e423c69aa28eb
MonoImporter:
externalObjects: {}
serializedVersion: 2
diff --git a/Main/System/Battle/Motion/MotionBase.cs b/Main/System/Battle/Motion/MotionBase.cs
index e59f90a..e5dc60d 100644
--- a/Main/System/Battle/Motion/MotionBase.cs
+++ b/Main/System/Battle/Motion/MotionBase.cs
@@ -10,47 +10,19 @@
/// </summary>
public class MotionBase
{
- public class WaitingTask
+ public static List<string> AttackMotionList = new List<string>
{
- public List<int> triggerFrame;
- public MotionName motionName;
- public int currentFrame;
- public Action<MotionName, int> callback;
+ MotionName.attack.ToString(),
+ MotionName.angerSkill.ToString(),
+ MotionName.passiveSkill.ToString(),
+ };
- public WaitingTask(List<int> triggerFrame, MotionName motionName, Action<MotionName, int> _callback)
- {
- this.triggerFrame = new List<int>(triggerFrame);
- this.motionName = motionName;
- this.currentFrame = 0;
- this.callback = _callback;
- }
-
- public bool IsFinished()
- {
- return triggerFrame.Count <= 0;
- }
-
- public void Run()
- {
- if (triggerFrame.Count > 0)
- {
- currentFrame ++;
-
- if (currentFrame >= triggerFrame[0])
- {
- int frame = triggerFrame[0];
- triggerFrame.RemoveAt(0);
- callback?.Invoke(motionName, frame);
- }
- }
- }
- }
+ private Dictionary<Spine.TrackEntry, Action> trackEntryCompleteDict = new Dictionary<Spine.TrackEntry, Action>();
// 鍔ㄧ敾浜嬩欢
public Action OnAttackAnimationComplete;
public Action OnHitAnimationComplete;
- public Action<MotionName> OnOtherAnimationComplete;
- public Action<int> OnAttackHitEvent; //trigger index
+ public Action<MotionName> onAnimationComplete;
#region 缁勪欢寮曠敤
@@ -66,9 +38,6 @@
protected float defaultMixDuration = 0f;
#endregion
-
- protected List<WaitingTask> waitingTaskList = new List<WaitingTask>();
- protected List<WaitingTask> removeList = new List<WaitingTask>();
private Spine.TrackEntry currentTrackEntry;
@@ -117,11 +86,8 @@
skeletonGraphic = null;
skeleton = null;
currentTrackEntry = null;
-
- waitingTaskList.Clear();
- removeList.Clear();
}
-
+
#endregion
#region 鍔ㄧ敾鎺у埗
@@ -131,15 +97,35 @@
/// </summary>
/// <param name="motionName">鍔ㄧ敾鏋氫妇</param>
/// <param name="loop">鏄惁寰幆</param>
+ /// <param name="_onComplete">鍔ㄧ敾鎾斁瀹屾垚鍥炶皟</param>
/// <returns>鍔ㄧ敾杞ㄩ亾鏉$洰</returns>
- public virtual Spine.TrackEntry PlayAnimation(MotionName motionName, bool loop)
+ public virtual Spine.TrackEntry PlayAnimation(MotionName motionName, bool loop, Action _onComplete = null)
{
if (spineAnimationState == null) return null;
+ // 濡傛灉褰撳墠鍔ㄧ敾鏈畬鎴�
+ if (currentTrackEntry != null && !currentTrackEntry.IsComplete)
+ {
+ if (trackEntryCompleteDict.TryGetValue(currentTrackEntry, out var __onComplete))
+ {
+ __onComplete?.Invoke();
+ trackEntryCompleteDict.Remove(currentTrackEntry);
+ }
+ currentTrackEntry = null;
+ }
+
// 鐩存帴浣跨敤 ToString() 鑰屼笉鏄皟鐢� GetAnimationName
currentTrackEntry = spineAnimationState.SetAnimation(0, motionName.ToString(), loop);
+
+ // 缁戝畾鍥炶皟
+ if (_onComplete != null && currentTrackEntry != null)
+ {
+ trackEntryCompleteDict[currentTrackEntry] = _onComplete;
+ }
+
return currentTrackEntry;
}
+
/// <summary>
/// 璁剧疆鍔ㄧ敾浜嬩欢鐩戝惉
@@ -147,84 +133,44 @@
protected virtual void SetupAnimationHandlers()
{
if (spineAnimationState == null) return;
-
+
// 鐩戝惉鍔ㄧ敾瀹屾垚浜嬩欢
spineAnimationState.Complete += OnAnimationComplete;
}
-
+
/// <summary>
/// 鍔ㄧ敾瀹屾垚浜嬩欢澶勭悊
/// </summary>
protected virtual void OnAnimationComplete(Spine.TrackEntry trackEntry)
{
string animation = trackEntry.Animation.Name;
-
+
// 鏀诲嚮鍔ㄧ敾瀹屾垚鍚庢仮澶嶅埌寰呮満鐘舵��
- if (animation == MotionName.attack.ToString() ||
- animation == MotionName.angerSkill.ToString())
+ if (AttackMotionList.Contains(animation))
{
OnAttackAnimationComplete?.Invoke();
PlayAnimation(MotionName.idle, true);
}
- // 鍙椾激鍔ㄧ敾瀹屾垚鍚庢仮澶嶅埌寰呮満鐘舵��
+ // 鍙椾激鍔ㄧ敾瀹屾垚鍚庢仮澶嶅埌寰呮満鐘舵�� 鍙兘瑙﹀彂澶氭 鍥犱负鏈夊娈垫敾鍑荤殑瀛樺湪
else if (animation == MotionName.hit.ToString())
{
OnHitAnimationComplete?.Invoke();
PlayAnimation(MotionName.idle, true);
}
- else
+ onAnimationComplete?.Invoke((MotionName)Enum.Parse(typeof(MotionName), animation));
+
+ // 鍙皟鐢ㄦ湰娆rackEntry鐨勫洖璋�
+ if (trackEntryCompleteDict.TryGetValue(trackEntry, out var cb))
{
- OnOtherAnimationComplete?.Invoke((MotionName)Enum.Parse(typeof(MotionName), animation));
+ cb?.Invoke();
+ trackEntryCompleteDict.Remove(trackEntry);
}
}
- /// <summary>
- /// 鍔ㄧ敾浜嬩欢澶勭悊
- /// </summary>
- protected virtual void OnTriggerHitEvent(MotionName motionName, int hitIndex)
- {
- OnAttackHitEvent?.Invoke(hitIndex);
- }
-
- // 鎷撳睍浜嗘挱鏀惧姩鐢绘柟娉曪紝娣诲姞浜嗚Е鍙戝抚鐨勫姛鑳斤紝鍦ㄦ敾鍑诲姩鐢讳腑澶氭鏀诲嚮鐨勮Е鍙戝抚
- // 渚嬪锛氭敾鍑诲姩鐢绘湁涓夋锛岀涓�娈垫敾鍑诲湪绗�1甯цЕ鍙戯紝绗簩娈垫敾鍑诲湪绗�10甯цЕ鍙戯紝绗笁娈垫敾鍑诲湪绗�20甯цЕ鍙�
- // 閭d箞triggerFrame灏卞簲璇ユ槸[1, 10, 20]
- public virtual void PlayAnimationEx(MotionName motionName, bool loop, List<int> triggerFrame = null)
- {
- PlayAnimation(motionName, loop);
- if (triggerFrame != null && triggerFrame.Count >= 0)
- {
- AddWaitingTask(triggerFrame, motionName);
- }
- }
-
- protected void AddWaitingTask(List<int> triggerFrame, MotionName motionName)
- {
- if (triggerFrame != null && triggerFrame.Count > 0)
- {
- WaitingTask waitingTask = new WaitingTask(triggerFrame, motionName, OnTriggerHitEvent);
- waitingTaskList.Add(waitingTask);
- }
- }
public virtual void Run()
{
- foreach (WaitingTask waitingTask in waitingTaskList)
- {
- waitingTask.Run();
- if (waitingTask.IsFinished())
- {
- removeList.Add(waitingTask);
- }
- }
-
- foreach (WaitingTask waitingTask in removeList)
- {
- waitingTaskList.Remove(waitingTask);
- }
-
- removeList.Clear();
}
public virtual void Pause()
diff --git a/Main/System/Battle/Motion/MotionName.cs b/Main/System/Battle/Motion/MotionName.cs
index fa8796f..a87aa9b 100644
--- a/Main/System/Battle/Motion/MotionName.cs
+++ b/Main/System/Battle/Motion/MotionName.cs
@@ -16,4 +16,5 @@
dead,//姝讳骸
angerSkill,//鎬掓皵鎶�鑳�
attack,//鏅敾
+ passiveSkill,//琚姩鎶�鑳�
}
\ No newline at end of file
diff --git a/Main/System/Battle/RecordPlayer/RecordAction.cs b/Main/System/Battle/RecordPlayer/RecordAction.cs
index a7e4cfd..b34b071 100644
--- a/Main/System/Battle/RecordPlayer/RecordAction.cs
+++ b/Main/System/Battle/RecordPlayer/RecordAction.cs
@@ -7,8 +7,14 @@
{
protected BattleField battleField;
+ // 鏈Action鐨勪富瑙�
protected BattleObject battleObject;
+ // 缁欏瓙绫荤敤鐨� 骞朵笉浠h〃浜嬩欢鐨勭粨鏉熶笌鍚�
+ protected bool isFinish = false;
+
+ protected bool isRunOnce = false;
+
public RecordAction(RecordActionType _actionType, BattleField _battleField, BattleObject _battleObj)
{
actionType = _actionType;
diff --git a/Main/System/Battle/Skill/DirectlyDamageSkill.cs b/Main/System/Battle/Skill/DirectlyDamageSkill.cs
index d26c3e6..2b2bcdc 100644
--- a/Main/System/Battle/Skill/DirectlyDamageSkill.cs
+++ b/Main/System/Battle/Skill/DirectlyDamageSkill.cs
@@ -1,44 +1,93 @@
using System.Collections.Generic;
+using UnityEngine;
+using System;
+using System.Linq;
public class DirectlyDamageSkill : SkillBase
{
-
- public DirectlyDamageSkill(SkillConfig _skillCfg) : base(_skillCfg)
+
+ public DirectlyDamageSkill(BattleObject _caster, SkillConfig _skillCfg,
+ H0604_tagUseSkillAttack vNetData, BattleField _battleField) : base(_caster, _skillCfg, vNetData, _battleField)
{
-
+
}
public override void Run()
- {
+ {
base.Run();
+
}
- public override void Cast(BattleObject _caster, BattleField _battleField, List<Dictionary<int, List<int>>> damageList)
+ protected override void OnTriggerEvent(int triggerIndex, int triggerFrame)
+ {
+ if (0 == triggerIndex)
+ {
+ List<BattleObject> targetList = GetTargetList();
+ // 瀛愮被瀹炵幇鍏蜂綋鐨勬妧鑳介�昏緫
+ SkillEffect effect = SkillEffectFactory.CreateSkillEffect(caster, skillConfig, tagUseSkillAttack);
+ if (null != effect)
+ {
+ // 濡傛灉鏄瓙寮圭被鍨嬬殑
+ effect.Play((hitIndex, hurList) =>
+ {
+ for (int i = 0; i < hurList.Count; i++)
+ {
+ var hurt = hurList[i];
+ BattleObject target = caster.battleField.battleObjMgr.GetBattleObject((int)hurt.ObjID);
+
+ List<long> damageList = new List<long>();
+ // 璁$畻浼ゅ 鍒嗘鐨勮瘽
+ if (hitIndex >= skillConfig.DamageDivide.Length)
+ {
+ Debug.LogError("DamageDivide鏈夐棶棰� 闇�瑕佹鏌� 鍙樉绀轰竴娈典激瀹� 鍙杢riggerFrames鐨�");
+ long totalDamage = GeneralDefine.GetFactValue(hurt.HurtHP, hurt.HurtHPEx) / (skillConfig.TriggerFrames.Length == 0 ? 1 : skillConfig.TriggerFrames.Length);
+ damageList.Add(totalDamage);
+ }
+ else
+ {
+ long totalDamage = GeneralDefine.GetFactValue(hurt.HurtHP, hurt.HurtHPEx);
+
+ if (hitIndex >= skillConfig.DamageDivide.Length)
+ {
+ int[] tenKDamagePercentArray = skillConfig.DamageDivide[hitIndex];
+ long factDamage = totalDamage;
+ for (int j = 0; j < tenKDamagePercentArray.Length; j++)
+ {
+ long damage = (long)(Mathf.Round(factDamage * tenKDamagePercentArray[j] / 10000.0f));
+ damageList.Add(damage);
+ }
+ }
+ }
+ target.Hurt(damageList, hurt.AttackType);
+ }
+ });
+ }
+ }
+ }
+
+ protected override void DoSkillLogic(Action _onComplete = null)
{
- _caster.PlaySkill(skillConfig, damageList, OnSkillAnimationFinished);
+ // 寮�濮嬭褰曞抚鏁�
+ startCounting = true;
}
- protected void OnSkillAnimationFinished()
- {
- isFinished = true;
- }
-#if UNITY_EDITOR
+#if UNITY_EDITOR_STOP_USING
// 浼ゅ鍒楄〃鐞嗗簲鐢辨湇鍔″櫒鍙戠粰瀹㈡埛绔� 杩欒竟鍙仛绮楁祬妯℃嫙
- public override List<Dictionary<int, List<int>>> GetDamageList(BattleObject _caster, BattleField battleField)
+ public override List<Dictionary<int, List<int>>> GetDamageList(BattleField battleField)
{
List<Dictionary<int, List<int>>> damageList = new List<Dictionary<int, List<int>>>();
- List<BattleObject> affectList = GetTargetList(_caster, battleField);
+ List<BattleObject> affectList = GetTargetList(battleField);
Dictionary<int, List<int>> oneRoundDamage = new Dictionary<int, List<int>>();
for (int j = 0; j < affectList.Count; j++)
{
BattleObject obj = affectList[j];
- List<int> tryDmgList = _caster.TryAttack(obj, skillConfig);
- oneRoundDamage.Add(obj.BattleObjectId, tryDmgList);
+ List<int> tryDmgList = caster.TryAttack(obj, skillConfig);
+ oneRoundDamage.Add(obj.ObjID, tryDmgList);
}
damageList.Add(oneRoundDamage);
diff --git a/Main/System/Battle/Skill/SkillBase.cs b/Main/System/Battle/Skill/SkillBase.cs
index 6c8a691..71f78b2 100644
--- a/Main/System/Battle/Skill/SkillBase.cs
+++ b/Main/System/Battle/Skill/SkillBase.cs
@@ -1,26 +1,206 @@
using System.Collections.Generic;
using UnityEngine;
+using System;
+using DG.Tweening;
+using Spine;
public class SkillBase
{
+ protected H0604_tagUseSkillAttack tagUseSkillAttack;
+
protected SkillConfig skillConfig;
protected bool isFinished = false;
- public SkillBase(SkillConfig _skillCfg)
+ protected BattleField battleField = null; // 鎴樺満
+
+ protected RectTransform targetNode = null; // 鐩爣鑺傜偣
+
+ protected BattleObject caster = null; // 鏂芥硶鑰�
+
+ protected bool startCounting = false;
+
+ protected bool pauseState = false;
+
+ protected int curFrame = 0;
+
+ protected List<int> triggerFrames = new List<int>();
+
+ public SkillBase(BattleObject _caster, SkillConfig _skillCfg, H0604_tagUseSkillAttack vNetData, BattleField _battleField = null)
{
+ caster = _caster;
skillConfig = _skillCfg;
+ tagUseSkillAttack = vNetData;
+ battleField = _battleField;
+
+ triggerFrames.Clear();
+ triggerFrames.AddRange(skillConfig.TriggerFrames);
}
public virtual void Run()
{
-
+ if (startCounting)
+ {
+ curFrame++;
+
+ if (triggerFrames.Contains(curFrame))
+ {
+ OnTriggerEvent(triggerFrames.IndexOf(curFrame), curFrame);
+ }
+ }
}
- public virtual void Cast(BattleObject _caster, BattleField battleField, List<Dictionary<int, List<int>>> damageList)
+ protected virtual void OnTriggerEvent(int triggerIndex, int triggerFrame)
{
- Debug.LogError("SkillBase Cast should be overridden by derived class");
+
+ }
+
+ public void Pause()
+ {
+ pauseState = startCounting;
+ startCounting = false;
+ }
+
+ public void Resume()
+ {
+ startCounting = pauseState;
+ }
+
+ // 0路绉诲姩鍒拌窛绂荤洰鏍噉鐮侊紝鐨勮窛绂婚噴鏀撅紙鍙厤缃紝9999鍗冲師鍦伴噴鏀撅紝璐熸暟鍒欐槸绉诲姩鍒颁汉鐗╄儗闈紝浜虹墿瑕佽浆韬級
+ // 1路绉诲姩鍒拌窛绂婚樀瀹逛綅缃畁鐮佺殑璺濈锛堝2鍙蜂綅锛�5鍙蜂綅锛夐噴鏀撅紙鍗虫垬鍦轰腑澶绫伙級
+ public virtual void Cast()
+ {
+ // 楂樹寒鎵�鏈夋湰娆℃妧鑳界浉鍏崇殑鐩爣
+ HighLightAllTargets();
+
+ switch (skillConfig.castMode)
+ {
+ case SkillCastMode.StandCast:
+ PlayCastAnimation(() => DoSkillLogic(OnSkillFinished));
+ break;
+ case SkillCastMode.MoveToTarget:
+ MoveToTarget(_onComplete: () => TurnBack(() => PlayCastAnimation(() => DoSkillLogic(() => { BackToOrigin(OnSkillFinished); }))));
+ break;
+ case SkillCastMode.DashCast:
+ DashToTarget(() => BackToOrigin(OnSkillFinished));
+ break;
+ default:
+ Debug.LogError("鏆傛椂涓嶆敮鎸佸叾浠栫殑鏂瑰紡閲婃斁 鏈夐渶姹傝鑱旂郴绛栧垝");
+ break;
+ }
+ }
+
+ // 鍐插埡鐨勬妧鑳� 鍔ㄤ綔 璺熺Щ鍔� 鏄悓鏃惰繘琛岀殑 绉诲姩鍒扮洰鏍囩殑涓�鐬棿灏辫杩涜鎶�鑳介�昏緫
+ protected void DashToTarget(Action _onComplete)
+ {
+ TrackEntry entry = PlayCastAnimation();
+ // 鍋氫竴涓井寰殑鎻愬墠
+ MoveToTarget(entry.TrackTime - 0.05f, () => DoSkillLogic(_onComplete));
+ }
+
+ protected void GetTargetNode()
+ {
+ targetNode = null;
+
+ if (skillConfig.castMode == SkillCastMode.StandCast)
+ {
+ // 鍘熷湴鏂芥硶
+ targetNode = caster.heroGo.transform as RectTransform;
+ }
+ else if (skillConfig.castMode == SkillCastMode.MoveToTarget || skillConfig.castMode == SkillCastMode.DashCast)
+ {
+ if (tagUseSkillAttack.AttackID <= 0)
+ {
+ Debug.LogError("鎶�鑳芥病鏈夋寚瀹氱洰鏍�");
+ return;
+ }
+
+ // 绉诲姩鍒扮洰鏍囦綅缃柦娉�
+ BattleObject _mainTarget = battleField.battleObjMgr.GetBattleObject((int)tagUseSkillAttack.AttackID);
+ if (_mainTarget == null)
+ {
+ Debug.LogError("鎶�鑳芥寚瀹氱殑鐩爣涓嶅瓨鍦�");
+ return;
+ }
+
+ targetNode = _mainTarget.heroGo.transform as RectTransform;
+ }
+ else if (skillConfig.castMode == SkillCastMode.MoveToFormation)
+ {
+ // TODO YYL
+ targetNode = /*caster.GetEnemyTeamNode();*/ battleField.GetTeamNode(caster.Camp == BattleCamp.Blue ? BattleCamp.Red : BattleCamp.Blue);
+ }
+ else
+ {
+ Debug.LogError("鏈煡鐨勬柦娉曟柟寮� 鎶�鑳絠d锛�" + skillConfig.SkillID);
+ return;
+ }
+ }
+
+ protected List<BattleObject> GetTargetList()
+ {
+ return battleField.battleObjMgr.GetBattleObjList(tagUseSkillAttack);
+ }
+
+ protected virtual void DoSkillLogic(Action _onComplete = null)
+ {
+ // 瀛愮被瀹炵幇鍏蜂綋鐨勬妧鑳介�昏緫
+ }
+
+ protected TrackEntry PlayCastAnimation(Action onComplete = null)
+ {
+ // 鎾斁鏂芥硶鍔ㄤ綔
+ MotionName motionName = skillConfig.GetMotionName();
+ TrackEntry trackEntry = caster.motionBase.PlayAnimation(motionName, false, onComplete);
+ return trackEntry;
+ }
+
+ public void MoveToTarget(float duration = 0.2f, Action _onComplete = null)
+ {
+ GetTargetNode();
+ Vector2 offset = new Vector2(skillConfig.CastDistance, 0);
+ RectTransform selfRect = caster.heroGo.transform as RectTransform;
+ RectTransform targetRect = targetNode;
+
+ var tweener = BattleUtility.MoveToTarget(selfRect, targetRect, offset, duration, _onComplete);
+ battleField.battleTweenMgr.OnPlayTween(tweener);
+ }
+
+ public void TurnBack(Action _onComplete)
+ {
+ if (skillConfig.CastDistance < 0)
+ {
+ caster.heroGo.transform.localScale = new Vector3(-1, 1, 1);
+ }
+ _onComplete?.Invoke();
+ }
+
+ public void BackToOrigin(Action _onComplete = null)
+ {
+ RectTransform selfRect = caster.heroGo.transform as RectTransform;
+ Vector2 targetAnchoredPos = Vector2.zero;
+ var tween = selfRect.DOAnchorPos(targetAnchoredPos, 0.2f)
+ .SetEase(Ease.Linear)
+ .OnComplete(() =>
+ {
+ caster.heroGo.transform.localScale = Vector3.one;
+ _onComplete?.Invoke();
+ });
+
+ battleField.battleTweenMgr.OnPlayTween(tween);
+ }
+
+ protected void HighLightAllTargets()
+ {
+ // 楂樹寒鎵�鏈夌洰鏍�
+ HashSet<BattleObject> highlightList = new HashSet<BattleObject>(battleField.battleObjMgr.GetBattleObjList(tagUseSkillAttack));
+ highlightList.Add(caster);
+
+
+
+ // 鎶婅繖浜汢O鍏ㄩ珮浜� 鎴栬�呰鎶婇櫎浜嗚繖浜涚殑閮芥斁鍦ㄩ伄缃╁悗闈�
+ // YYL TODO
}
public virtual bool IsFinished()
@@ -33,17 +213,22 @@
isFinished = true;
}
-#if UNITY_EDITOR
- public virtual List<BattleObject> GetTargetList(BattleObject _caster, BattleField battleField)
+ public void OnSkillFinished()
+ {
+ isFinished = true;
+ }
+
+#if UNITY_EDITOR_STOP_USING
+ public virtual List<BattleObject> GetTargetList(BattleField _battleField)
{
SkillTargetType targetType = SkillTargetType.Enemy;
SkillTargetRangeType rangeType = SkillTargetRangeType.LowestHP;
- List<BattleObject> affectList = battleField.battleObjMgr.GetTargetList(_caster, targetType, rangeType);
+ List<BattleObject> affectList = _battleField.battleObjMgr.GetTargetList(caster, targetType, rangeType);
return affectList;
}
-
- public virtual List<Dictionary<int, List<int>>> GetDamageList(BattleObject _caster, BattleField battleField)
+
+ public virtual List<Dictionary<int, List<int>>> GetDamageList(BattleField _battleField)
{
Debug.LogError("SkillBase GetDamageList should be overridden by derived class");
return null;
diff --git a/Main/System/Battle/Skill/SkillCastMode.cs b/Main/System/Battle/Skill/SkillCastMode.cs
new file mode 100644
index 0000000..26c8615
--- /dev/null
+++ b/Main/System/Battle/Skill/SkillCastMode.cs
@@ -0,0 +1,9 @@
+
+
+public enum SkillCastMode
+{
+ StandCast, // 鍘熷湴閲婃斁
+ MoveToTarget, // 璺戝埌鐩爣闈㈠墠閲婃斁鍐嶅洖鏉�
+ DashCast, // 鍘熷湴鍔ㄤ綔浣嗚鑹蹭細鍐插埌鐩爣闈㈠墠
+ MoveToFormation, // 绉诲姩鍒伴樀瀹逛綅缃柦娉�
+}
\ No newline at end of file
diff --git a/Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta b/Main/System/Battle/Skill/SkillCastMode.cs.meta
similarity index 83%
copy from Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta
copy to Main/System/Battle/Skill/SkillCastMode.cs.meta
index ee23e52..52c8d49 100644
--- a/Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta
+++ b/Main/System/Battle/Skill/SkillCastMode.cs.meta
@@ -1,5 +1,5 @@
fileFormatVersion: 2
-guid: 0c39e10c6d11822409ee2e39b684f89d
+guid: f9281a48533a94f4ba2a84bc44bbe18d
MonoImporter:
externalObjects: {}
serializedVersion: 2
diff --git a/Main/System/Battle/Skill/SkillEffectAnchor.cs b/Main/System/Battle/Skill/SkillEffectAnchor.cs
new file mode 100644
index 0000000..b02a2a6
--- /dev/null
+++ b/Main/System/Battle/Skill/SkillEffectAnchor.cs
@@ -0,0 +1,7 @@
+public enum SkillEffectAnchor
+{
+ Caster, //鍦ㄦ柦娉曡�呬笂
+ Target, //鍦ㄧ洰鏍囦笂
+ AlliesCenter,// 鍦ㄥ弸鏂逛腑蹇�
+ EnemiesCenter,// 鍦ㄦ晫鏂逛腑蹇�
+}
\ No newline at end of file
diff --git a/Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta b/Main/System/Battle/Skill/SkillEffectAnchor.cs.meta
similarity index 83%
copy from Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta
copy to Main/System/Battle/Skill/SkillEffectAnchor.cs.meta
index ee23e52..7ab771c 100644
--- a/Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta
+++ b/Main/System/Battle/Skill/SkillEffectAnchor.cs.meta
@@ -1,5 +1,5 @@
fileFormatVersion: 2
-guid: 0c39e10c6d11822409ee2e39b684f89d
+guid: 8c9269b4bdb75f042b97225006214939
MonoImporter:
externalObjects: {}
serializedVersion: 2
diff --git a/Main/System/Battle/Skill/SkillEffectType.cs b/Main/System/Battle/Skill/SkillEffectType.cs
new file mode 100644
index 0000000..a1d4ce0
--- /dev/null
+++ b/Main/System/Battle/Skill/SkillEffectType.cs
@@ -0,0 +1,7 @@
+public enum SkillEffectType
+{
+ Bullet, // 瀛愬脊绫诲瀷
+ Direct, // 鐩存帴浼ゅ
+ BuffEffect, // Buff
+ StageEffect, // 鍦烘櫙鎶�
+}
\ No newline at end of file
diff --git a/Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta b/Main/System/Battle/Skill/SkillEffectType.cs.meta
similarity index 83%
copy from Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta
copy to Main/System/Battle/Skill/SkillEffectType.cs.meta
index ee23e52..d3332ba 100644
--- a/Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta
+++ b/Main/System/Battle/Skill/SkillEffectType.cs.meta
@@ -1,5 +1,5 @@
fileFormatVersion: 2
-guid: 0c39e10c6d11822409ee2e39b684f89d
+guid: 0e224e8034be71b4d8571bb3adba5ecf
MonoImporter:
externalObjects: {}
serializedVersion: 2
diff --git a/Main/System/Battle/Skill/SkillFactory.cs b/Main/System/Battle/Skill/SkillFactory.cs
index 9a6a009..c9d0fa4 100644
--- a/Main/System/Battle/Skill/SkillFactory.cs
+++ b/Main/System/Battle/Skill/SkillFactory.cs
@@ -40,13 +40,16 @@
- public static SkillBase CreateSkill(SkillConfig _skillConfig)
+ public static SkillBase CreateSkill(BattleObject _caster, H0604_tagUseSkillAttack vNetData, BattleField battleField)
{
+ SkillConfig skillConfig = SkillConfig.Get(vNetData.SkillID);
+
SkillBase skill = null;
- switch (_skillConfig.SkillType)
+ switch (skillConfig.SkillType)
{
case 1:
- skill = new DirectlyDamageSkill(_skillConfig);
+ // 鍏堝疄鐜颁竴涓敾鍑荤殑 鍚庣画鏈夊啀鎱㈡參澧炲姞
+ skill = new DirectlyDamageSkill(_caster, skillConfig, vNetData, battleField);
break;
case 2:
// skill = new DirectlyHealSkill(_skillConfig);
diff --git a/Main/System/Battle/Skill/SkillType.cs b/Main/System/Battle/Skill/SkillType.cs
new file mode 100644
index 0000000..b87d3ca
--- /dev/null
+++ b/Main/System/Battle/Skill/SkillType.cs
@@ -0,0 +1,17 @@
+
+// 鏀诲嚮鎶�鑳斤細鏈洖鍚堝鏁屼汉姝﹀皢閫犳垚浼ゅ
+// 娌荤枟鎶�鑳斤細鏈洖鍚堝宸叉柟姝﹀皢鍥炲鐢熷懡鍊�,鍥炲鐢熷懡鍊间笉鍙秴杩囩敓鍛戒笂闄�
+// 杈呭姪鎶�鑳斤細澧炲姞鎬掓皵銆佸彫鍞ゃ�佸厜鐜瓑
+// BUFF鎶�鑳斤細鎻愬崌宸叉柟灞炴�х殑澧炵泭BUFF(鍔犳敾銆佸姞琛�銆佸姞鐘舵�佺瓑),闄嶄綆鏁屾柟灞炴�х殑鍑忕泭BUFF(鍑忔敾銆佸噺琛�銆佹帶鍒剁瓑),鎸佺画澶氬洖鍚�
+// 澶嶆椿鎶�鑳斤細澶嶆椿宸叉柟宸叉姝﹀皢骞跺洖澶峏鐢熷懡鍊�,
+// 澶嶆椿锛氱户鎵挎浜″墠鐨勬墍鏈夌姸鎬�(鍚勭鐘舵�併�佸悇绉岯UFF銆佹�掓皵鍊肩瓑),澶嶆椿鍚庨敊杩囨湰鍥炲悎鏀诲嚮鏃舵満鍒欎笅涓�鍥炲悎鎵嶈兘鍑烘墜
+
+
+public enum SkillType
+{
+ Attack,
+ Heal,
+ Assist,
+ Buff,
+ Revive
+}
\ No newline at end of file
diff --git a/Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta b/Main/System/Battle/Skill/SkillType.cs.meta
similarity index 83%
copy from Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta
copy to Main/System/Battle/Skill/SkillType.cs.meta
index ee23e52..ec2a9c2 100644
--- a/Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta
+++ b/Main/System/Battle/Skill/SkillType.cs.meta
@@ -1,5 +1,5 @@
fileFormatVersion: 2
-guid: 0c39e10c6d11822409ee2e39b684f89d
+guid: caaeda374b158404196e766e25b9a3b3
MonoImporter:
externalObjects: {}
serializedVersion: 2
diff --git a/Main/System/Battle/SkillEffect.meta b/Main/System/Battle/SkillEffect.meta
new file mode 100644
index 0000000..8ece8c2
--- /dev/null
+++ b/Main/System/Battle/SkillEffect.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: dd67eeb1a237eb44cad753537ec81338
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Main/System/Battle/SkillEffect/BulletSkillEffect.cs b/Main/System/Battle/SkillEffect/BulletSkillEffect.cs
new file mode 100644
index 0000000..dd9b9c2
--- /dev/null
+++ b/Main/System/Battle/SkillEffect/BulletSkillEffect.cs
@@ -0,0 +1,101 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Cysharp.Threading.Tasks;
+using DG.Tweening;
+using UnityEngine;
+
+public class BulletSkillEffect : SkillEffect
+{
+ // protected SkillConfig skillConfig;
+ // protected BattleObject caster;
+ // protected List<BattleObject> targets; // 鐩爣鍒楄〃
+
+ public BulletSkillEffect(SkillConfig _skillConfig, BattleObject _caster, H0604_tagUseSkillAttack _tagUseSkillAttack)
+ : base(_skillConfig, _caster, _tagUseSkillAttack)
+ {
+
+ }
+
+
+
+ public override void Play(Action<int, List<H0604_tagUseSkillAttack.tagSkillHurtObj>> _onHit)
+ {
+ // Caster, //鍦ㄦ柦娉曡�呬笂
+ // Target, //鍦ㄧ洰鏍囦笂
+ // AlliesCenter,// 鍦ㄥ弸鏂逛腑蹇�
+ // EnemiesCenter,// 鍦ㄦ晫鏂逛腑蹇�
+
+ Action<int, List<H0604_tagUseSkillAttack.tagSkillHurtObj>> onHitFormation = (_hitIndex, _hurtList) =>
+ {
+ _onHit?.Invoke(_hitIndex, tagUseSkillAttack.HurtList.ToList());
+ };
+
+ if (skillConfig.effectAnchor == SkillEffectAnchor.Caster)
+ {
+ // 涓嶅彲鑳藉瓙寮瑰皠鍚戣嚜宸卞惂
+ Debug.LogError("瀛愬脊鎶�鑳界壒鏁堜笉鑳介敋瀹氬湪鏂芥硶鑰呬笂 skillConfig.effectAnchor");
+ _onHit?.Invoke(0, default);
+ }
+ else if (skillConfig.effectAnchor == SkillEffectAnchor.Target)
+ {
+ if (tagUseSkillAttack == null || tagUseSkillAttack.HurtList.Length <= 0)
+ {
+ Debug.LogError("瀛愬脊鎶�鑳界壒鏁堟病鏈夌洰鏍� tagUseSkillAttack.HurtList.Length <= 0");
+ _onHit?.Invoke(0, default);
+ return;
+ }
+
+ foreach (var hurt in tagUseSkillAttack.HurtList)
+ {
+ BattleObject target = caster.battleField.battleObjMgr.GetBattleObject((int)hurt.ObjID);
+ if (target == null)
+ {
+ Debug.LogError("瀛愬脊鎶�鑳界壒鏁堢洰鏍囦负绌� target == null ObjId : " + hurt.ObjID);
+ continue;
+ }
+
+ ShotToTarget(target.heroGo.transform as RectTransform, (index, list) => _onHit(0, new List<H0604_tagUseSkillAttack.tagSkillHurtObj>() { hurt }));
+ }
+ }
+ else if (skillConfig.effectAnchor == SkillEffectAnchor.AlliesCenter)
+ {
+ ShotToTarget(caster.battleField.GetTeamNode(caster.Camp), onHitFormation);
+ }
+ else if (skillConfig.effectAnchor == SkillEffectAnchor.EnemiesCenter)
+ {
+ ShotToTarget(caster.battleField.GetTeamNode(caster.Camp == BattleCamp.Blue ? BattleCamp.Red : BattleCamp.Blue), onHitFormation);
+ }
+ else
+ {
+ Debug.LogError("鏈煡鐨勬妧鑳界壒鏁堥敋鐐圭被鍨�: " + skillConfig.effectAnchor);
+ }
+ }
+
+ protected void ShotToTarget(RectTransform target, Action<int, List<H0604_tagUseSkillAttack.tagSkillHurtObj>> _onHit)
+ {
+ EffectPlayer effectPlayer = caster.battleField.battleEffectMgr.PlayEffect(caster.ObjID, skillConfig.EffectId, caster.effectNode);
+
+ effectPlayer.Play();
+
+ RectTransform effectTrans = effectPlayer.transform as RectTransform;
+
+ var tween = BattleUtility.MoveToTarget(effectTrans, target, Vector2.zero, skillConfig.FlyTime, () =>
+ {
+ // 琛ㄧ幇瀛愬脊椋炶鍒扮洰鏍囦綅缃�
+ _onHit?.Invoke(0, null);
+
+ // 鍑讳腑灏遍攢姣佸瓙寮�
+ caster.battleField.battleEffectMgr.RemoveEffect(skillConfig.EffectId, effectPlayer);
+ // 鎾斁瀛愬脊鐖嗙偢鐗规晥
+ caster.battleField.battleEffectMgr.PlayEffect(caster.ObjID, skillConfig.ExplotionEffectId, target).Play();
+ });
+
+ caster.battleField.battleTweenMgr.OnPlayTween(tween);
+ }
+
+ public override void Run()
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta b/Main/System/Battle/SkillEffect/BulletSkillEffect.cs.meta
similarity index 83%
copy from Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta
copy to Main/System/Battle/SkillEffect/BulletSkillEffect.cs.meta
index ee23e52..6c76a11 100644
--- a/Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta
+++ b/Main/System/Battle/SkillEffect/BulletSkillEffect.cs.meta
@@ -1,5 +1,5 @@
fileFormatVersion: 2
-guid: 0c39e10c6d11822409ee2e39b684f89d
+guid: 87730978d5481e24c9433f6cbe3bec78
MonoImporter:
externalObjects: {}
serializedVersion: 2
diff --git a/Main/System/Battle/SkillEffect/NormalSkillEffect.cs b/Main/System/Battle/SkillEffect/NormalSkillEffect.cs
new file mode 100644
index 0000000..91b98e9
--- /dev/null
+++ b/Main/System/Battle/SkillEffect/NormalSkillEffect.cs
@@ -0,0 +1,89 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Cysharp.Threading.Tasks;
+using DG.Tweening;
+using UnityEngine;
+
+public class NormalSkillEffect : SkillEffect
+{
+ // protected SkillConfig skillConfig;
+ // protected BattleObject caster;
+ // protected List<BattleObject> targets; // 鐩爣鍒楄〃
+
+ public NormalSkillEffect(SkillConfig _skillConfig, BattleObject _caster, H0604_tagUseSkillAttack _tagUseSkillAttack)
+ : base(_skillConfig, _caster, _tagUseSkillAttack)
+ {
+
+ }
+
+
+ public override void Play(Action<int, List<H0604_tagUseSkillAttack.tagSkillHurtObj>> _onHit)
+ {
+
+ Action<int, List<H0604_tagUseSkillAttack.tagSkillHurtObj>> onHitFormation = (_hitIndex, _hurtList) =>
+ {
+ _onHit?.Invoke(_hitIndex, tagUseSkillAttack.HurtList.ToList());
+ };
+
+ if (skillConfig.effectAnchor == SkillEffectAnchor.Caster)
+ {
+ CastInTarget(caster.heroGo.transform as RectTransform, onHitFormation);
+ }
+ else if (skillConfig.effectAnchor == SkillEffectAnchor.Target)
+ {
+ if (tagUseSkillAttack == null || tagUseSkillAttack.HurtList.Length <= 0)
+ {
+ Debug.LogError("娌℃湁鐩爣 tagUseSkillAttack.HurtList.Length <= 0");
+ _onHit?.Invoke(0, default);
+ return;
+ }
+
+ foreach (var hurt in tagUseSkillAttack.HurtList)
+ {
+ BattleObject target = caster.battleField.battleObjMgr.GetBattleObject((int)hurt.ObjID);
+ if (target == null)
+ {
+ Debug.LogError("鐗规晥鐩爣涓虹┖ target == null ObjId : " + hurt.ObjID);
+ continue;
+ }
+
+ CastInTarget(target.heroGo.transform as RectTransform, (index, list) => _onHit(0, new List<H0604_tagUseSkillAttack.tagSkillHurtObj>() { hurt }));
+ }
+ }
+ else if (skillConfig.effectAnchor == SkillEffectAnchor.AlliesCenter)
+ {
+ CastInTarget(caster.battleField.GetTeamNode(caster.Camp), onHitFormation);
+ }
+ else if (skillConfig.effectAnchor == SkillEffectAnchor.EnemiesCenter)
+ {
+ CastInTarget(caster.battleField.GetTeamNode(caster.Camp == BattleCamp.Blue ? BattleCamp.Red : BattleCamp.Blue), onHitFormation);
+ }
+ else
+ {
+ Debug.LogError("鏈煡鐨勬妧鑳界壒鏁堥敋鐐圭被鍨�: " + skillConfig.effectAnchor);
+ }
+ }
+
+ protected void CastInTarget(RectTransform target, Action<int, List<H0604_tagUseSkillAttack.tagSkillHurtObj>> _onHit)
+ {
+ EffectPlayer effectPlayer = caster.battleField.battleEffectMgr.PlayEffect(caster.ObjID, skillConfig.EffectId, caster.effectNode);
+
+ effectPlayer.Play();
+
+ RectTransform effectTrans = effectPlayer.transform as RectTransform;
+
+ _onHit?.Invoke(0, null);
+
+ // 閿�姣佽嚜韬笂鐨勭壒鏁堝簲璇ユ槸绛夌壒鏁堟挱鏀惧畬姣曚箣鍚�
+ // caster.battleField.battleEffectMgr.RemoveEffect(skillConfig.EffectId, effectPlayer);
+ // 鎾斁鍙楀嚮鐗规晥
+ caster.battleField.battleEffectMgr.PlayEffect(caster.ObjID, skillConfig.ExplotionEffectId, target).Play();
+
+ }
+
+ public override void Run()
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta b/Main/System/Battle/SkillEffect/NormalSkillEffect.cs.meta
similarity index 83%
copy from Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta
copy to Main/System/Battle/SkillEffect/NormalSkillEffect.cs.meta
index ee23e52..cf1e81e 100644
--- a/Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta
+++ b/Main/System/Battle/SkillEffect/NormalSkillEffect.cs.meta
@@ -1,5 +1,5 @@
fileFormatVersion: 2
-guid: 0c39e10c6d11822409ee2e39b684f89d
+guid: 532aa7a2a76cb1646ba7b5e9e6b5114a
MonoImporter:
externalObjects: {}
serializedVersion: 2
diff --git a/Main/System/Battle/SkillEffect/SkillEffect.cs b/Main/System/Battle/SkillEffect/SkillEffect.cs
new file mode 100644
index 0000000..9fb324f
--- /dev/null
+++ b/Main/System/Battle/SkillEffect/SkillEffect.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class SkillEffect
+{
+ protected SkillConfig skillConfig;
+ protected BattleObject caster;
+ protected H0604_tagUseSkillAttack tagUseSkillAttack;// 鐩爣鍒楄〃
+
+ public SkillEffect(SkillConfig _skillConfig, BattleObject _caster, H0604_tagUseSkillAttack _tagUseSkillAttack)
+ {
+ skillConfig = _skillConfig;
+ caster = _caster;
+ tagUseSkillAttack = _tagUseSkillAttack;
+ }
+
+ public Action OnHit; // 琛ㄧ幇鍒拌揪鐩爣鏃跺洖璋�
+
+ //
+ public virtual void Play(Action<int, List<H0604_tagUseSkillAttack.tagSkillHurtObj>> _onHit)
+ {
+ // OnHit = _onHit;
+ // switch (skillConfig.effectType)
+ // {
+ // case SkillEffectType.StageEffect:
+ // Debug.LogError("鎾斁鍦烘櫙鐗规晥");
+ // break;
+ // case SkillEffectType.Bullet:
+ // // 浼唬鐮侊細琛ㄧ幇瀛愬脊椋炶
+ // Debug.Log("鎾斁瀛愬脊鐗规晥");
+ // // 鍒拌揪鐩爣鏃�
+ // OnHit?.Invoke();
+ // break;
+ // case SkillEffectType.Direct:
+ // // 浼唬鐮侊細鐩存帴鍦ㄧ洰鏍囪韩涓婃挱鏀剧壒鏁�
+ // Debug.Log("鎾斁鐩存帴鐗规晥");
+ // OnHit?.Invoke();
+ // break;
+ // case SkillEffectType.BuffEffect:
+ // // 浼唬鐮侊細鎾斁鎸佺画鐗规晥
+ // Debug.Log("鎾斁Buff鐗规晥");
+ // break;
+ // default:
+ // break;
+ // }
+ }
+
+ public virtual void Run()
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta b/Main/System/Battle/SkillEffect/SkillEffect.cs.meta
similarity index 83%
copy from Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta
copy to Main/System/Battle/SkillEffect/SkillEffect.cs.meta
index ee23e52..68722eb 100644
--- a/Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta
+++ b/Main/System/Battle/SkillEffect/SkillEffect.cs.meta
@@ -1,5 +1,5 @@
fileFormatVersion: 2
-guid: 0c39e10c6d11822409ee2e39b684f89d
+guid: fac494539cf0a0b41b14681032f00cbf
MonoImporter:
externalObjects: {}
serializedVersion: 2
diff --git a/Main/System/Battle/SkillEffect/SkillEffectFactory.cs b/Main/System/Battle/SkillEffect/SkillEffectFactory.cs
new file mode 100644
index 0000000..ef959f3
--- /dev/null
+++ b/Main/System/Battle/SkillEffect/SkillEffectFactory.cs
@@ -0,0 +1,25 @@
+
+
+using System.Collections.Generic;
+
+public static class SkillEffectFactory
+{
+ public static SkillEffect CreateSkillEffect(BattleObject caster, SkillConfig skillConfig, H0604_tagUseSkillAttack tagUseSkillAttack)
+ {
+ switch (skillConfig.effectType)
+ {
+ case SkillEffectType.Bullet:
+ return new BulletSkillEffect(skillConfig, caster, tagUseSkillAttack);
+ case SkillEffectType.Direct:
+ return new NormalSkillEffect(skillConfig, caster, tagUseSkillAttack);
+ // case SkillEffectType.BuffEffect:
+ // return new BuffSkillEffect(skillConfig, caster, targets);
+ // case SkillEffectType.StageEffect:
+ // return new StageSkillEffect(skillConfig, caster, targets);
+ default:
+ UnityEngine.Debug.LogError("Unknown Skill Effect Type");
+ break;
+ }
+ return null;
+ }
+}
\ No newline at end of file
diff --git a/Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta b/Main/System/Battle/SkillEffect/SkillEffectFactory.cs.meta
similarity index 83%
copy from Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta
copy to Main/System/Battle/SkillEffect/SkillEffectFactory.cs.meta
index ee23e52..3a6a9ef 100644
--- a/Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta
+++ b/Main/System/Battle/SkillEffect/SkillEffectFactory.cs.meta
@@ -1,5 +1,5 @@
fileFormatVersion: 2
-guid: 0c39e10c6d11822409ee2e39b684f89d
+guid: 010772e03bcf658429d8aaf42b2483e4
MonoImporter:
externalObjects: {}
serializedVersion: 2
diff --git a/Main/System/Battle/UIComp/DamageContent.cs b/Main/System/Battle/UIComp/DamageContent.cs
index 155d39e..9963eb0 100644
--- a/Main/System/Battle/UIComp/DamageContent.cs
+++ b/Main/System/Battle/UIComp/DamageContent.cs
@@ -18,7 +18,7 @@
line.SetActive(false);
}
- public void SetDamage(List<int> damages, Action _onComplete)
+ public void SetDamage(List<long> damages, Action _onComplete)
{
for (int i = 0; i < damages.Count; i++)
{
diff --git a/Main/System/Battle/UIComp/DamageLine.cs b/Main/System/Battle/UIComp/DamageLine.cs
index 68ae28b..45edcab 100644
--- a/Main/System/Battle/UIComp/DamageLine.cs
+++ b/Main/System/Battle/UIComp/DamageLine.cs
@@ -9,13 +9,13 @@
public TextEx damageValueLabel;
- public void SetDamage(DamageType damageType, int damage)
+ public void SetDamage(DamageType damageType, long damage)
{
damageTypeLabel.SetActive(true);
damageValueLabel.text = damage.ToString();
}
- public void SetDamage(int damage)
+ public void SetDamage(long damage)
{
damageTypeLabel.SetActive(false);
damageValueLabel.text = damage.ToString();
diff --git a/Main/System/GeneralConfig/GeneralDefine.cs b/Main/System/GeneralConfig/GeneralDefine.cs
index 5c87124..7b2c547 100644
--- a/Main/System/GeneralConfig/GeneralDefine.cs
+++ b/Main/System/GeneralConfig/GeneralDefine.cs
@@ -1166,5 +1166,8 @@
return inputString;
}
-
+ public static long GetFactValue(uint value, uint valueEx)
+ {
+ return (long)valueEx * HundredMillion +(long)value;
+ }
}
diff --git a/Main/System/Hero/HeroFetterInfo.cs b/Main/System/Hero/HeroFetterInfo.cs
index a5bb622..32612c6 100644
--- a/Main/System/Hero/HeroFetterInfo.cs
+++ b/Main/System/Hero/HeroFetterInfo.cs
@@ -37,7 +37,7 @@
if (null == teamHero)
continue;
- if (Array.IndexOf(fetterConfig.HeroIDList, teamHero.heroInfo.heroId) >= 0)
+ if (Array.IndexOf(fetterConfig.HeroIDList, teamHero.heroId) >= 0)
{
count++;
}
diff --git a/Main/System/Hero/HeroInfo.Lineup.cs b/Main/System/Hero/HeroInfo.Lineup.cs
new file mode 100644
index 0000000..eac9cd5
--- /dev/null
+++ b/Main/System/Hero/HeroInfo.Lineup.cs
@@ -0,0 +1,35 @@
+
+using System.Collections.Generic;
+using UnityEngine;
+
+public partial class HeroInfo
+{
+ public Dictionary<TeamType, KeyValuePair<int, int>> GetTeamTypeShapeTypePositionDict()
+ {
+ // 鑻遍泟褰撳墠鎵�鏈夊湪鐨勯槦浼�
+ List<int> heroTeams = itemHero.GetUseData(81);
+
+ Dictionary<TeamType, KeyValuePair<int, int>> teamTypeShapeTypePositionDict = new Dictionary<TeamType, KeyValuePair<int, int>>();
+ foreach (var teamMsg in heroTeams)
+ {
+ // 鎵�鍦ㄩ樀瀹逛俊鎭垪琛� [闃靛绫诲瀷*10000+闃靛瀷绫诲瀷*100+浣嶇疆缂栧彿, ...]
+ int teamType = teamMsg / 10000;
+ int shapeType = (teamMsg % 10000) / 100;
+ int positionIndex = teamMsg % 100;
+
+ if (teamTypeShapeTypePositionDict.ContainsKey((TeamType)teamType))
+ {
+ // 闃熶紞绫诲瀷鐩稿悓锛屾洿鏂伴樀鍨嬪拰浣嶇疆
+ Debug.LogError("褰撳墠鑻遍泟鎷ユ湁涓や釜鐩稿悓鐨勯槦浼嶄俊鎭�: " + teamType + " " + shapeType + " " + positionIndex + ", hero guid is " + itemHero.guid);
+ }
+ else
+ {
+ // 闃熶紞绫诲瀷涓嶅悓锛屾坊鍔犳柊鐨�
+ KeyValuePair<int, int> shapeTypePosition = new KeyValuePair<int, int>(shapeType, positionIndex);
+ teamTypeShapeTypePositionDict.Add((TeamType)teamType, shapeTypePosition);
+ }
+ }
+
+ return teamTypeShapeTypePositionDict;
+ }
+}
diff --git a/Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta b/Main/System/Hero/HeroInfo.Lineup.cs.meta
similarity index 83%
copy from Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta
copy to Main/System/Hero/HeroInfo.Lineup.cs.meta
index ee23e52..f6e94cb 100644
--- a/Main/Core/NetworkPackage/ServerPack/H06_PlayerVsNPC/H0602_tagObjBaseAttack.cs.meta
+++ b/Main/System/Hero/HeroInfo.Lineup.cs.meta
@@ -1,5 +1,5 @@
fileFormatVersion: 2
-guid: 0c39e10c6d11822409ee2e39b684f89d
+guid: fe5defee75fe9b24c81fd8cb22c7d952
MonoImporter:
externalObjects: {}
serializedVersion: 2
diff --git a/Main/System/Hero/HeroInfo.cs b/Main/System/Hero/HeroInfo.cs
index f3bcba5..1839eac 100644
--- a/Main/System/Hero/HeroInfo.cs
+++ b/Main/System/Hero/HeroInfo.cs
@@ -61,16 +61,6 @@
UpdateHero(_itemHero);
}
- public HeroInfo(HB424_tagSCTurnFightInit.tagSCTurnFightObj fightObj)
- {
- // 鎴樻枟琛ㄧ幇闇�瑕佽繖浜涘熀鏈氨澶� 涓嶅杩橀渶瑕佹湇鍔″櫒鍔�
-
- heroId = (int)fightObj.HeroID;
- heroConfig = HeroConfig.Get(heroId);
- SkinID = (int)fightObj.SkinID;
- skinConfig = HeroSkinConfig.Get(SkinID);
- }
-
#if UNITY_EDITOR
public HeroInfo()
{
diff --git a/Main/System/Hero/HeroManager.cs b/Main/System/Hero/HeroManager.cs
index 27d2368..73cf424 100644
--- a/Main/System/Hero/HeroManager.cs
+++ b/Main/System/Hero/HeroManager.cs
@@ -20,6 +20,8 @@
public Action<HeroInfo> onHeroChangeEvent;
+ public Action<HeroInfo> onHeroDeleteEvent;
+
public override void Init()
{
base.Init();
@@ -67,6 +69,8 @@
{
heroInfo.UpdateHero(PackManager.Instance.GetItemByGuid(guid));
}
+
+ onHeroChangeEvent?.Invoke(heroInfo);
}
}
@@ -74,10 +78,13 @@
{
if (packType == PackType.Hero)
{
- if (heroInfoDict.ContainsKey(guid))
- {
- heroInfoDict.Remove(guid);
- }
+ HeroInfo heroInfo = null;
+ heroInfoDict.TryGetValue(guid, out heroInfo);
+
+ heroInfoDict.Remove(guid);
+
+ if (null != heroInfo)
+ onHeroDeleteEvent?.Invoke(heroInfo);
}
}
@@ -88,6 +95,10 @@
return heroInfoDict[guid];
}
+ public List<HeroInfo> GetHeroList()
+ {
+ return heroInfoDict.Values.ToList();
+ }
void InitHerosInfo()
diff --git a/Main/System/MainLevel.meta b/Main/System/MainLevel.meta
new file mode 100644
index 0000000..984e3ba
--- /dev/null
+++ b/Main/System/MainLevel.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: a02c6eff6ff37404ab5bdfb3357a7fa1
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Main/System/Team/TeamBase.Properties.cs b/Main/System/Team/TeamBase.Properties.cs
index 9eec33b..7dff15c 100644
--- a/Main/System/Team/TeamBase.Properties.cs
+++ b/Main/System/Team/TeamBase.Properties.cs
@@ -10,29 +10,30 @@
protected void UpdateProperties()
{
+ // YYL TODO
// 缇佺粖
- for (int i = 0; i < teamHeros.Length; i++)
- {
- TeamHero hero = teamHeros[i];
- if (null != hero)
- {
- for (int j = 0; j < hero.heroInfo.fetterInfoList.Count; j++)
- {
- hero.heroInfo.fetterInfoList[j].SetIsActiveFetter(this);
- }
- }
- }
+ // for (int i = 0; i < teamHeros.Length; i++)
+ // {
+ // TeamHero hero = teamHeros[i];
+ // if (null != hero)
+ // {
+ // for (int j = 0; j < hero.heroInfo.fetterInfoList.Count; j++)
+ // {
+ // hero.heroInfo.fetterInfoList[j].SetIsActiveFetter(this);
+ // }
+ // }
+ // }
// 闃靛瀷
// 灞炴�ц绠�
- for (int i = 0; i < teamHeros.Length; i++)
- {
- TeamHero hero = teamHeros[i];
- if (null != hero)
- hero.heroInfo.CalculateProperties();
- }
+ // for (int i = 0; i < teamHeros.Length; i++)
+ // {
+ // TeamHero hero = teamHeros[i];
+ // if (null != hero)
+ // hero.heroInfo.CalculateProperties();
+ // }
}
public void CalculatePower()
diff --git a/Main/System/Team/TeamBase.cs b/Main/System/Team/TeamBase.cs
index 6315779..e22edc8 100644
--- a/Main/System/Team/TeamBase.cs
+++ b/Main/System/Team/TeamBase.cs
@@ -1,78 +1,71 @@
using System;
using System.Collections.Generic;
+using UnityEngine;
// 闃靛瀷鍩虹
public partial class TeamBase
{
+ // 璇ラ樀瀹瑰湪鏈樀钀ョ殑缂栧彿锛屼笉鍚岄樀钀ョ殑闃靛缂栧彿鍙兘鐩稿悓锛岄兘鏄粠1寮�濮嬶紝涓�鑸�1V1鏃舵瘡涓樀钀ヤ负1涓樀瀹癸紝澶歏澶氭椂鍒欐瘡涓樀钀ヤ负澶氫釜闃靛
+ private int teamIndex = 0;
+ private uint playerId = 0;
- // 鍖哄垎涓�涓嬮樀钀ヨ窡闃靛 闃佃惀涓轰竴涓猅eamBase鍒楄〃 鍙兘鏄涓帺瀹剁粍鍚堣�屾垚
- // 闃靛涓轰竴涓猅eamBase 鏄帺瀹剁殑涓�涓槦浼�
- private int teamIndex = 0;//璇ラ樀钀ョ殑绗嚑涓槦浼�
-
- private uint playerId = 0; //璇ラ樀瀹圭殑鐜╁id
-
- private int ShapeType; //鏈樀瀹归樀鍨嬶紝0涓洪粯璁ら樀鍨嬶紝鍙墿灞曚笉鍚岀殑闃靛瀷锛屽boss鐗规畩鎴樻枟闃靛瀷锛屾垨鑰呭叾浠栦笉鍚岀珯浣嶇殑闃靛瀷
+ // 鏈湴鍙彉闃靛瀷
public bool IsPlayer
{
- get
- {
- return playerId == 0;
- }
+ get { return playerId == 0; }
}
- public TeamHero[] teamHeros = new TeamHero[TeamConst.MaxTeamSlotCount];
- public TeamBase()
+ // 鏈嶅姟鍣ㄤ笅鍙戠殑闃靛瀷鍜岄樀瀹癸紝鍙兘閫氳繃缃戠粶鍗忚璧嬪�硷紝澶栭儴鍙
+ public TeamType teamType
{
-
+ get;
+ private set;
}
+ private int ShapeType;
+ public int ServerShapeType { get; private set; }
+
+ public TeamHero[] teamHeros = new TeamHero[TeamConst.MaxTeamHeroCount];
+
+ public TeamHero[] serverData { get; private set; } = new TeamHero[TeamConst.MaxTeamHeroCount];
+
+ public TeamBase(TeamType _teamType)
+ {
+ teamType = _teamType;
+ teamIndex = 0;
+ playerId = PlayerDatas.Instance.baseData.PlayerID;
+ }
+
+ // 杩欒竟鏉ョ殑鍙互娌℃湁闃熶紞绫诲瀷
public TeamBase(HB424_tagSCTurnFightInit.tagSCTurnFightLineup lineUp)
{
teamIndex = lineUp.Num;
playerId = lineUp.OwnerID;
ShapeType = lineUp.ShapeType;
+ ServerShapeType = lineUp.ShapeType;
for (int i = 0; i < lineUp.ObjCnt; i++)
{
if (i < teamHeros.Length)
{
- TeamHero hero = new TeamHero(lineUp.ObjList[i], this);
- AddTeamHero(hero);
+ var fightObj = lineUp.ObjList[i];
+ TeamHero hero = new TeamHero(fightObj, this);
+ teamHeros[fightObj.PosNum] = hero;
+ serverData[fightObj.PosNum] = hero;
+ }
+ else
+ {
+ Debug.LogError("TeamBase: Too many heroes in lineup, exceeding MaxTeamHeroCount.");
}
}
- Update();
-
-
+ // 鍒锋柊鏈嶅姟鍣ㄦ暟鎹�
+ UpdateProperties();
}
- protected void Update()
- {
- // 妫�鏌ュ浗绫�
-
- // 妫�鏌ョ緛缁�
-
- // 妫�鏌ラ樀鍨�
-
- // 鏇存柊闃熶紞鑻遍泟灞炴��
- foreach (var teamHero in teamHeros)
- {
- teamHero.Update();
- }
-
- // 鏇存柊闃熶紞灞炴��
- // UpdateProperties();
-
- // CalculatePower();
- }
-
- public void SetShapeType(int shapeType)
- {
- ShapeType = shapeType;
- }
public int GetTeamHeroCount()
{
@@ -84,80 +77,9 @@
count++;
}
}
-
return count;
}
- public bool SwapTeamHero(int index1, int index2)
- {
- if (index1 < 0 || index1 >= teamHeros.Length || index2 < 0 || index2 >= teamHeros.Length)
- {
- return false;
- }
-
- TeamHero temp = teamHeros[index1];
- teamHeros[index1] = teamHeros[index2];
- teamHeros[index2] = temp;
- temp.heroIndex = index2;
- teamHeros[index1].heroIndex = index1;
-
- return true;
- }
-
- public void AddHeroInfos(List<HeroInfo> heroInfos)
- {
- for (int i = 0; i < heroInfos.Count; i++)
- {
- AddHeroInfo(heroInfos[i]);
- }
-
- UpdateProperties();
- }
-
-
- public bool AddHeroInfo(HeroInfo heroInfo)
- {
- if (heroInfo == null)
- {
- return false;
- }
-
- for (int i = 0; i < teamHeros.Length; i++)
- {
- if (teamHeros[i] == null)
- {
- teamHeros[i] = new TeamHero();
- teamHeros[i].heroInfo = heroInfo;
- teamHeros[i].heroIndex = i;
- UpdateProperties();
- return true;
- }
- }
- return false;
- }
-
-
- public void AddTeamHero(TeamHero teamHero)
- {
- if (null == teamHero)
- {
- return;
- }
-
- teamHeros[teamHero.heroIndex] = teamHero;
- }
-
-
- public bool RemoveTeamHero(int index)
- {
- if (index < 0 || index >= teamHeros.Length)
- {
- return false;
- }
-
- teamHeros[index] = null;
- return true;
- }
public bool IsFull()
{
@@ -170,18 +92,248 @@
}
-#if UNITY_EDITOR
- public void FillWithFakeData()
+ /// <summary>
+ /// 淇濆瓨闃靛锛堥鐣欐帴鍙o級
+ /// </summary>
+ public void SaveTeam()
{
- for (int i = 0; i < TeamConst.MaxTeamHeroCount; i++)
+ if (IsEmpty())
{
- TeamHero hero = new TeamHero();
- hero.curHp = 100;
- hero.heroInfo = new HeroInfo();
- hero.teamBase = this;
- hero.heroIndex = i;
- teamHeros[i] = hero;
+ Debug.LogError("Cannot save an empty team. You should at least have one hero in the team.");
+ return;
+ }
+
+ CB412_tagCSHeroLineupSave savePack = new CB412_tagCSHeroLineupSave();
+ savePack.LineupID = (byte)teamType;
+ savePack.ShapeType = (byte)ShapeType;
+ savePack.PosCnt = (byte)GetTeamHeroCount();
+ savePack.HeroPosList = new CB412_tagCSHeroLineupSave.tagCSHeroLineupPos[savePack.PosCnt];
+
+ foreach (var hero in teamHeros)
+ {
+ if (hero != null)
+ {
+ int posNum = hero.positionNum;
+ var heroInfo = HeroManager.Instance.GetHero(hero.guid);
+
+ if (heroInfo == null)
+ {
+ Debug.LogError($"Hero with GUID {hero.guid} not found in HeroManager.");
+ continue;
+ }
+
+ savePack.HeroPosList[posNum] = new CB412_tagCSHeroLineupSave.tagCSHeroLineupPos
+ {
+ ItemIndex = (ushort)heroInfo.itemHero.gridIndex,
+ PosNum = (byte)posNum
+ };
+ }
+ }
+
+ GameNetSystem.Instance.SendInfo(savePack);
+ }
+
+ public void OnChangeShapeType(int newShapeType)
+ {
+ ShapeType = newShapeType;
+ }
+
+ public void OnServerChangeShapeType(int newShapeType)
+ {
+ ServerShapeType = newShapeType;
+ ShapeType = newShapeType;
+ }
+
+ // hero info could be null if the hero is removed from the team
+ public void RefreshServerData(int shapeType, int positionIndex, HeroInfo heroInfo)
+ {
+ TeamHero teamHero = heroInfo == null ? null : new TeamHero(heroInfo, positionIndex, this);
+ SetServerTeamHero(positionIndex, teamHero);
+ OnServerChangeShapeType(shapeType);
+ }
+
+ public void CreateDefault(List<HeroInfo> heroInfos)
+ {
+ teamIndex = 0;
+ playerId = PlayerDatas.Instance.baseData.PlayerID;
+ OnServerChangeShapeType(0);
+
+ for (int i = 0; i < heroInfos.Count; i++)
+ {
+ if (i < teamHeros.Length)
+ {
+ var heroInfo = heroInfos[i];
+ TeamHero hero = new TeamHero(heroInfo, i, this);
+ SetServerTeamHero(i, hero);
+ }
+ else
+ {
+ Debug.LogError("TeamBase: Too many heroes in lineup");
+ }
}
}
-#endif
+
+ public TeamHero GetHero(string guid)
+ {
+ foreach (var hero in teamHeros)
+ {
+ if (hero != null && hero.guid == guid)
+ {
+ return hero;
+ }
+ }
+ return null;
+ }
+
+ public TeamHero GetServerHero(string guid)
+ {
+ foreach (var hero in serverData)
+ {
+ if (hero != null && hero.guid == guid)
+ {
+ return hero;
+ }
+ }
+ return null;
+ }
+
+ // 甯冮樀鎺ュ彛
+ public bool HasHero(string guid)
+ {
+ foreach (var hero in teamHeros)
+ {
+ if (hero != null && hero.guid == guid)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public int GetEmptyPosition()
+ {
+ for (int i = 0; i < teamHeros.Length; i++)
+ {
+ if (teamHeros[i] == null)
+ {
+ return i;
+ }
+ }
+ return -1; // No empty position
+ }
+
+ // 甯冮樀鎺ュ彛
+ public void SetTeamHero(int posNum, TeamHero hero)
+ {
+ teamHeros[posNum] = hero;
+ }
+
+ // 甯冮樀鎺ュ彛
+ public void SetServerTeamHero(int posNum, TeamHero hero)
+ {
+ serverData[posNum] = hero;
+ teamHeros[posNum] = hero;
+ }
+
+ public void AddHero(HeroInfo heroInfo, int targetPosition)
+ {
+ if (targetPosition < 0 || targetPosition >= teamHeros.Length)
+ {
+ Debug.LogError("Invalid target position for adding hero.");
+ return;
+ }
+
+ TeamHero targetHero = teamHeros[targetPosition];
+
+ if (null == targetHero)
+ {
+ TeamHero newHero = new TeamHero(heroInfo, targetPosition, this);
+ SetTeamHero(targetPosition, newHero);
+ }
+ else
+ {
+ SetTeamHero(targetPosition, new TeamHero(heroInfo, targetPosition, this));
+ }
+ }
+
+
+
+ // add鍙彲鑳芥槸鐐逛笅闈㈠崱鐗�
+ public bool AddHero(HeroInfo heroInfo)
+ {
+ if (heroInfo == null || heroInfo.itemHero == null) return false;
+
+
+ // 濡傛灉褰撳墠鑻遍泟宸茬粡鍦ㄩ槦浼嶉噷浜� 灏变笉澶勭悊浜�
+ if (GetHero(heroInfo.itemHero.guid) != null)
+ {
+ return false; // Hero already in team
+ }
+ else
+ {
+ int emptyPosition = GetEmptyPosition();
+
+ if (emptyPosition < 0)
+ {
+ Debug.LogError("No empty position available in the team.");
+ return false; // No empty position available
+ }
+
+ TeamHero teamHero = new TeamHero(heroInfo, GetEmptyPosition(), this);
+ SetTeamHero(teamHero.positionNum, teamHero);
+ return true;
+ }
+ }
+
+
+ public bool RemoveHero(HeroInfo heroInfo)
+ {
+ if (heroInfo == null || heroInfo.itemHero == null) return false;
+
+ TeamHero teamHero = GetHero(heroInfo.itemHero.guid);
+
+ if (teamHero != null)
+ {
+ // 浠庡綋鍓嶉槦浼嶉噷绉婚櫎璇ヨ嫳闆�
+ SetTeamHero(teamHero.positionNum, null);
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ public bool RemoveHero(TeamHero teamHero)
+ {
+ if (teamHero == null) return false;
+
+ for (int i = 0; i < teamHeros.Length; i++)
+ {
+ if (teamHeros[i] != null && teamHeros[i].guid == teamHero.guid)
+ {
+ SetTeamHero(i, null);
+ return true; // Hero removed successfully
+ }
+ }
+ return false; // Hero not found
+ }
+
+ public void SwapPosition(int index1, int index2)
+ {
+ if (index1 < 0 || index1 >= teamHeros.Length || index2 < 0 || index2 >= teamHeros.Length)
+ {
+ Debug.LogError("Invalid indices for swapping positions.");
+ return;
+ }
+
+ TeamHero temp = teamHeros[index1];
+ teamHeros[index1] = teamHeros[index2];
+ teamHeros[index2] = temp;
+
+ // 鏇存柊浣嶇疆缂栧彿
+ if (teamHeros[index1] != null) teamHeros[index1].positionNum = index1;
+ if (teamHeros[index2] != null) teamHeros[index2].positionNum = index2;
+ }
+
}
\ No newline at end of file
diff --git a/Main/System/Team/TeamConst.cs b/Main/System/Team/TeamConst.cs
index 19c59f8..15cd264 100644
--- a/Main/System/Team/TeamConst.cs
+++ b/Main/System/Team/TeamConst.cs
@@ -3,5 +3,5 @@
public class TeamConst
{
public const int MaxTeamHeroCount = 6;//鏈�澶у竷闃垫暟閲�
- public const int MaxTeamSlotCount = 7;//鏈�澶фЫ浣嶆暟閲�
+ public const int MaxTeamSlotCount = 7;//鏈�澶фЫ浣嶆暟閲� 鍖呭惈boss鐨勪腑闂翠綅缃� 甯冮樀鐨勬椂鍊欎笉鑳界敤杩欎釜
}
\ No newline at end of file
diff --git a/Main/System/Team/TeamHero.cs b/Main/System/Team/TeamHero.cs
index ad3dfe2..8117758 100644
--- a/Main/System/Team/TeamHero.cs
+++ b/Main/System/Team/TeamHero.cs
@@ -3,57 +3,100 @@
public partial class TeamHero
{
- public HeroInfo heroInfo;
- public TeamBase teamBase;
- public int heroIndex;
+ public int heroId;
+ public HeroConfig heroConfig;
+ public int SkinID;
+ public HeroSkinConfig skinConfig;
+ public string guid;
+
+
+ public TeamBase teamBase
+ {
+ get; private set;
+ }
+ public int positionNum;
// 鎴樺満鏁版嵁
- public uint ObjID = 0;// 鎴樻枟鍗曚綅鍞竴ID
+ public int ObjID = 0;// 鎴樻枟鍗曚綅鍞竴ID
- public uint NPCID = 0;// 鎴樻枟NPCID锛屼笉鍚岀殑瀹炰緥ID瀵瑰簲鐨凬PCID鍙兘涓�鏍�
+ public int NPCID = 0;// 鎴樻枟NPCID锛屼笉鍚岀殑瀹炰緥ID瀵瑰簲鐨凬PCID鍙兘涓�鏍�
- public TeamHero()
- {
-
- }
-
+ // 鏈嶅姟鍣ㄦ潵鐨勬瀯閫�
public TeamHero(HB424_tagSCTurnFightInit.tagSCTurnFightObj fightObj, TeamBase _teamBase)
{
- heroInfo = new HeroInfo(fightObj);
- teamBase = _teamBase;
- if (fightObj.PosNum < 0 || fightObj.PosNum >= TeamConst.MaxTeamSlotCount)
- {
- Debug.LogError("Invalid PosNum: " + fightObj.PosNum);
- }
- else
- {
- teamBase.teamHeros[fightObj.PosNum] = this; // 灏嗗綋鍓嶅璞℃坊鍔犲埌瀵瑰簲浣嶇疆
- }
+ heroId = (int)fightObj.HeroID;
+ heroConfig = HeroConfig.Get(heroId);
+ SkinID = (int)fightObj.SkinID;
+ skinConfig = HeroSkinConfig.Get(SkinID);
- ObjID = fightObj.ObjID;
- NPCID = fightObj.NPCID;
+ teamBase = _teamBase;
+
+ ObjID = (int)fightObj.ObjID;
+ NPCID = (int)fightObj.NPCID;
// HPEx * 1浜� + HP
- curHp = (long)fightObj.HPEx * GeneralDefine.HundredMillion +(long)fightObj.HP;
- maxHp = (long)fightObj.MaxHPEx * GeneralDefine.HundredMillion +(long)fightObj.MaxHP;
+ curHp = (long)fightObj.HPEx * GeneralDefine.HundredMillion + (long)fightObj.HP;
+ maxHp = (long)fightObj.MaxHPEx * GeneralDefine.HundredMillion + (long)fightObj.MaxHP;
rage = (int)fightObj.AngreXP;
- heroIndex = fightObj.PosNum;
+ positionNum = fightObj.PosNum;
+
+ // 銆愰噸瑕併�戞垬鏂楁瀯鎴愰噷娌℃湁鍗$墝鐨刧uid
+ guid = string.Empty;
+
+ Update();
+ }
+
+ // 甯冮樀鏃剁殑鏋勯��
+ public TeamHero(HeroInfo heroInfo, int posNum, TeamBase _teamBase)
+ {
+ heroId = heroInfo.itemHero.config.ID;
+ heroConfig = HeroConfig.Get(heroId);
+ SkinID = heroInfo.SkinID;
+ skinConfig = heroInfo.skinConfig;
+
+ teamBase = _teamBase;
+
+ ObjID = 0;
+ NPCID = 0;
+
+ curHp = heroInfo.hp;
+ maxHp = heroInfo.hp;
+ rage = 0;
+
+ positionNum = posNum;
+
+ // 銆愰噸瑕併�戝竷闃甸噷鐨勮guid
+ guid = heroInfo.itemHero.guid;
+
+ Update();
+ }
+
+ public void OnSwapPosition(TeamHero teamHero)
+ {
+ int tempPosNum = positionNum;
+ positionNum = teamHero.positionNum;
+ teamHero.positionNum = tempPosNum;
+
+ teamBase.teamHeros[positionNum] = this;
+ teamBase.teamHeros[teamHero.positionNum] = teamHero;
Update();
}
public void Update()
{
-
+
}
+
// 鏈�缁堝睘鎬� 褰撳墠灞炴�у簲璇ユ槸瑕佸湪杩欎竴灞傜殑
public int GetPower()
{
- return heroInfo.CalculatePower();
+ // 璁$畻鎴樻枟鍔沋YL TODO
+ return 0;
}
}
\ No newline at end of file
diff --git a/Main/System/Team/TeamManager.cs b/Main/System/Team/TeamManager.cs
index 980c7e9..c32a199 100644
--- a/Main/System/Team/TeamManager.cs
+++ b/Main/System/Team/TeamManager.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using System.Linq;
using UnityEngine;
@@ -7,15 +8,133 @@
{
protected Dictionary<TeamType, TeamBase> teamDict = new Dictionary<TeamType, TeamBase>();
- public override void Init()
- {
- base.Init();
+ public override void Init()
+ {
+ base.Init();
+
+ HeroManager.Instance.onHeroChangeEvent += onHeroChangeEvent;
+ HeroManager.Instance.onHeroDeleteEvent += onHeroDeleteEvent;
+ DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent += OnBeforePlayerDataInitialize;
}
- public override void Release()
- {
- base.Release();
+ public override void Release()
+ {
+ base.Release();
+ HeroManager.Instance.onHeroChangeEvent += onHeroChangeEvent;
+ HeroManager.Instance.onHeroDeleteEvent += onHeroDeleteEvent;
+ DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent += OnBeforePlayerDataInitialize;
}
+
+ protected void OnBeforePlayerDataInitialize()
+ {
+ teamDict.Clear();
+ }
+
+ protected void onHeroChangeEvent(HeroInfo heroInfo)
+ {
+ // 鑻遍泟褰撳墠鎵�鏈夊湪鐨勯槦浼�
+ List<int> heroTeams = heroInfo.itemHero.GetUseData(81);
+
+ Dictionary<TeamType, KeyValuePair<int, int>> teamTypeShapeTypePositionDict = new Dictionary<TeamType, KeyValuePair<int, int>>();
+ foreach (var teamMsg in heroTeams)
+ {
+ // 鎵�鍦ㄩ樀瀹逛俊鎭垪琛� [闃靛绫诲瀷*10000+闃靛瀷绫诲瀷*100+浣嶇疆缂栧彿, ...]
+ int teamType = teamMsg / 10000;
+ int shapeType = (teamMsg % 10000) / 100;
+ int positionIndex = teamMsg % 100;
+
+ if (teamTypeShapeTypePositionDict.ContainsKey((TeamType)teamType))
+ {
+ // 闃熶紞绫诲瀷鐩稿悓锛屾洿鏂伴樀鍨嬪拰浣嶇疆
+ Debug.LogError("褰撳墠鑻遍泟鎷ユ湁涓や釜鐩稿悓鐨勯槦浼嶄俊鎭�: " + teamType + " " + shapeType + " " + positionIndex + ", hero guid is " + heroInfo.itemHero.guid);
+ }
+ else
+ {
+ // 闃熶紞绫诲瀷涓嶅悓锛屾坊鍔犳柊鐨�
+ KeyValuePair<int, int> shapeTypePosition = new KeyValuePair<int, int>(shapeType, positionIndex);
+ teamTypeShapeTypePositionDict.Add((TeamType)teamType, shapeTypePosition);
+ }
+ }
+
+ // 閬嶅巻褰撳墠鎵�鏈夐槦浼� 鍒ゆ柇褰撳墠闃熶紞閲屾槸鍚︽湁璇ヨ嫳闆�
+ // 濡傛灉鏈夌殑璇� 璇诲彇涓�涓嬪綋鍓嶆槸鍚﹁鑻遍泟杩樺湪闃熶紞閲� 浣嶇疆鏄惁鍙戠敓鍙樺寲
+ // 鎴栬�呮槸闃靛瀷鍙戠敓鍙樺寲 鎴栬�呭崟绾殑鑻遍泟鍙戠敓鍙樺寲
+ // 濡傛灉娌℃湁鐨勮瘽 灏辫鏄庤鑻遍泟琚Щ鍑洪槦浼嶄簡
+ foreach (var team in teamDict.Values)
+ {
+ // 妫�鏌ヤ竴涓嬪綋鍓嶉槦浼嶆槸鍚︽湁璇ヨ嫳闆�
+ // 濡傛灉鏈夌殑璇� 璇诲彇涓�涓嬪綋鍓嶆槸鍚﹁鑻遍泟杩樺湪闃熶紞閲� 浣嶇疆鏄惁鍙戠敓鍙樺寲
+ TeamHero teamHero = team.GetHero(heroInfo.itemHero.guid);
+ if (teamHero != null)
+ {
+ if ((teamTypeShapeTypePositionDict.ContainsKey(team.teamType)))
+ {
+ KeyValuePair<int, int> shapeTypePosition = teamTypeShapeTypePositionDict[team.teamType];
+ // 鏇存柊闃熶紞淇℃伅
+ // 鍙互鍒ゆ柇teamHero鐨刾ositionNum鏄惁璺焥hapeTypePosition.Value涓�鑷� 鍒ゆ柇鏄惁鍙樹綅缃簡
+ // 鍙互鍒ゆ柇teamHero鐨凷erverShapeType鏄惁璺焥hapeTypePosition.Key涓�鑷� 鍒ゆ柇鏄惁鍙橀樀鍨嬩簡
+ team.RefreshServerData(shapeTypePosition.Key, shapeTypePosition.Value, heroInfo);
+ }
+ else
+ {
+ // 闃熶紞閲屾湁杩欎釜鑻遍泟锛屼絾鏄湪闃熶紞淇℃伅閲屾病鏈変簡 缃┖ 锛堣绉诲嚭闃熶紞锛�
+ team.SetTeamHero(teamHero.positionNum, null);
+ }
+ }
+ // 鍘熸潵闃熶紞閲屾病杩欎釜鑻遍泟
+ else
+ {
+ // 濡傛灉褰撳墠闃熶紞绫诲瀷鍦ㄨ嫳闆勭殑鎵�鍦ㄩ樀瀹逛俊鎭垪琛ㄩ噷鏈夌殑璇�
+ // 灏辫鏄庨槦浼嶉噷鏂板浜嗚繖涓嫳闆� 锛堟柊澧炶繘闃熶紞锛�
+ if (teamTypeShapeTypePositionDict.ContainsKey(team.teamType))
+ {
+ KeyValuePair<int, int> shapeTypePosition = teamTypeShapeTypePositionDict[team.teamType];
+ team.RefreshServerData(shapeTypePosition.Key, shapeTypePosition.Value, null);
+ }
+ }
+ }
+
+
+ // 閬嶅巻鑻遍泟鎵�鍦ㄧ殑闃熶紞淇℃伅鍒楄〃 鏂板涓�涓嬪綋鍓嶅偍瀛樼殑闃熶紞閲屾病鏈夌殑闃熶紞
+ foreach (var teamTypeShapeTypePosition in teamTypeShapeTypePositionDict)
+ {
+ // 濡傛灉褰撳墠闃熶紞绫诲瀷鍦ㄩ槦浼嶅瓧鍏搁噷娌℃湁鐨勮瘽
+ if (!teamDict.ContainsKey(teamTypeShapeTypePosition.Key))
+ {
+ // 鏂板缓涓�涓槦浼�
+ TeamBase team = new TeamBase(teamTypeShapeTypePosition.Key);
+ team.RefreshServerData(teamTypeShapeTypePosition.Value.Key, teamTypeShapeTypePosition.Value.Value, heroInfo);
+ teamDict.Add(teamTypeShapeTypePosition.Key, team);
+ }
+ }
+
+ }
+
+
+ protected void onHeroDeleteEvent(HeroInfo heroInfo)
+ {
+ List<int> heroTeams = heroInfo.itemHero.GetUseData(81);
+
+ foreach (int teamMsg in heroTeams)
+ {
+ // 鎵�鍦ㄩ樀瀹逛俊鎭垪琛� [闃靛绫诲瀷*10000+闃靛瀷绫诲瀷*100+浣嶇疆缂栧彿, ...]
+ int teamType = teamMsg / 10000;
+ int shapeType = (teamMsg % 10000) / 100;
+ int positionIndex = teamMsg % 100;
+
+ TeamBase team = GetTeam((TeamType)teamType);
+
+ if (team != null)
+ {
+ team.RefreshServerData(shapeType, positionIndex, null);
+ }
+ }
+ }
+
+ public bool HasTeam(TeamType teamType)
+ {
+ return teamDict.ContainsKey(teamType);
+ }
public TeamBase GetTeam(TeamType teamType)
{
@@ -23,8 +142,8 @@
if (!teamDict.TryGetValue(teamType, out team))
{
- team = new TeamBase();
- team.AddHeroInfos(HeroManager.Instance.GetPowerfulHeroList());
+ team = new TeamBase(teamType);
+ team.CreateDefault(HeroManager.Instance.GetPowerfulHeroList());
teamDict.Add(teamType, team);
}
diff --git a/Main/Utility/MathUtility.cs b/Main/Utility/MathUtility.cs
index 3982945..8f1c5d4 100644
--- a/Main/Utility/MathUtility.cs
+++ b/Main/Utility/MathUtility.cs
@@ -219,4 +219,6 @@
}
return 0f;
}
+
+
}
diff --git a/Main/Utility/UniTaskExtension.cs b/Main/Utility/UniTaskExtension.cs
index 58ff6bd..8ba915f 100644
--- a/Main/Utility/UniTaskExtension.cs
+++ b/Main/Utility/UniTaskExtension.cs
@@ -4,12 +4,12 @@
public static class UniTaskExtension
{
- public static void DelayFrame(this GameObject go, Action action)
+ public static void DelayFrame(this GameObject go, Action action)
{
DelayFrameInternal(1, action);
}
- public static void DelayFrame(this Component cmp, Action action)
+ public static void DelayFrame(this Component cmp, Action action)
{
DelayFrameInternal(1, action);
}
@@ -29,4 +29,9 @@
{
DelayFrameInternal(frames, action);
}
+
+ public static void DelayFrame(Action action)
+ {
+ DelayFrameInternal(1, action);
+ }
}
\ No newline at end of file
--
Gitblit v1.8.0