From 172d8ffbf5fe3bdd60b3d71a3a60feeed1cb1762 Mon Sep 17 00:00:00 2001 From: chenxin <chenxin6991@163.com> Date: Mon, 09 Nov 2020 16:37:47 +0800 Subject: [PATCH] Merge commit '894e974d944190fb2e10e14827f0d878626bd048' into master --- Assets/Scripts/TowerDefense/UI/EndlessBossSkillAI/EndlessBossSkillAI.cs | 2 Assets/Scripts/TowerDefense/Agents/Agent.cs | 23 + Assets/Scripts/TowerDefense/UI/EndlessBossSkill/BossSkillShieldWall.cs | 24 + Assets/Resources/UI/Endless/SkillTitle/3.png | 0 Assets/Resources/UI/Endless/SkillTitle/3.png.meta | 118 ++++++++ Assets/Scripts/TowerDefense/UI/EndlessBossSkill/EndlessBossSkillManager.cs | 2 Assets/Resources/UI/Endless/SkillTitle/2.png.meta | 0 Assets/Scripts/Core/Health/HealthChangeInfo.cs | 74 +++- Assets/Scripts/TowerDefense/Level/AgentInsManager.cs | 30 ++ Assets/Resources/UI/Endless/SkillTitle.meta | 8 Assets/Resources/UI/Endless/SkillTitle/2.png | 0 Assets/Scripts/Core/Health/DamageableBehaviour.cs | 1 Assets/Scripts/TowerDefense/UI/HUD/EndlessGameUI.cs | 2 Assets/Scripts/Core/Health/Damageable.cs | 532 ++++++++++++++++++++++--------------- Assets/Scripts/TowerDefense/UI/EndlessBossSkill/BossSkillBubbleBomb.cs | 2 Assets/Scripts/TowerDefense/UI/EndlessBossCtrl.cs | 7 Assets/Scripts/Core/Health/HealthVisualizer.cs | 7 17 files changed, 579 insertions(+), 253 deletions(-) diff --git a/Assets/Resources/UI/Endless/SkillTitle.meta b/Assets/Resources/UI/Endless/SkillTitle.meta new file mode 100644 index 0000000..3bfa733 --- /dev/null +++ b/Assets/Resources/UI/Endless/SkillTitle.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 83f03c8585bda6042b382981b1b95968 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/UI/Endless/bubbleBombTitle.png b/Assets/Resources/UI/Endless/SkillTitle/2.png similarity index 100% rename from Assets/Resources/UI/Endless/bubbleBombTitle.png rename to Assets/Resources/UI/Endless/SkillTitle/2.png Binary files differ diff --git a/Assets/Resources/UI/Endless/bubbleBombTitle.png.meta b/Assets/Resources/UI/Endless/SkillTitle/2.png.meta similarity index 100% rename from Assets/Resources/UI/Endless/bubbleBombTitle.png.meta rename to Assets/Resources/UI/Endless/SkillTitle/2.png.meta diff --git a/Assets/Resources/UI/Endless/SkillTitle/3.png b/Assets/Resources/UI/Endless/SkillTitle/3.png new file mode 100644 index 0000000..d27fc24 --- /dev/null +++ b/Assets/Resources/UI/Endless/SkillTitle/3.png Binary files differ diff --git a/Assets/Resources/UI/Endless/SkillTitle/3.png.meta b/Assets/Resources/UI/Endless/SkillTitle/3.png.meta new file mode 100644 index 0000000..0293c12 --- /dev/null +++ b/Assets/Resources/UI/Endless/SkillTitle/3.png.meta @@ -0,0 +1,118 @@ +fileFormatVersion: 2 +guid: af3089b3910c84646a24f960ecdd84dd +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 11 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -100 + wrapU: 1 + wrapV: 1 + wrapW: -1 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 8 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Android + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: 4 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 1 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: 5e97eb03825dee720800000000000000 + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Core/Health/Damageable.cs b/Assets/Scripts/Core/Health/Damageable.cs index 40a963d..59f64da 100644 --- a/Assets/Scripts/Core/Health/Damageable.cs +++ b/Assets/Scripts/Core/Health/Damageable.cs @@ -3,251 +3,347 @@ namespace Core.Health { - /// <summary> - /// Damageable class for handling health using events - /// Could be used on Players or enemies or even destructable world objects - /// </summary> - [Serializable] - public class Damageable - { - /// <summary> - /// The max health of this instance - /// </summary> - public float maxHealth; - - public float startingHealth; + /// <summary> + /// Damageable class for handling health using events + /// Could be used on Players or enemies or even destructable world objects + /// </summary> + [Serializable] + public class Damageable + { + /// <summary> + /// The max health of this instance + /// </summary> + public float maxHealth; - /// <summary> - /// The alignment of the damager - /// </summary> - public SerializableIAlignmentProvider alignment; + public float startingHealth; - // events - public event Action reachedMaxHealth; + /// <summary> + /// The alignment of the damager + /// </summary> + public SerializableIAlignmentProvider alignment; - // 当前的Entity用于响应各种血量相关的事件。 - public event Action<HealthChangeInfo> damaged, healed, died, healthChanged; + // events + public event Action reachedMaxHealth; + + // 当前的Entity用于响应各种血量相关的事件。 + public event Action<HealthChangeInfo> damaged, healed, died, healthChanged; + + /// <summary> + /// 魔法护盾值改变 + /// </summary> + public event Action<HealthChangeInfo> ShieldWallHealthChanged; + + /// <summary> + /// Gets the current health. + /// </summary> + public float currentHealth { protected set; get; } + + /// <summary> + /// 设置无敌状态. + /// </summary> + public bool bInvincible { get; set; } + + /// <summary> + /// 是否存在魔法护盾 + /// </summary> + public bool IsExistShieldWall { get; set; } + + /// <summary> + /// 0 -> 和agent的生命周期一致,直到死亡, > 0 (单位s)*时间内生效 + /// </summary> + public float ShieldWallEffectiveTime { get; set; } + + /// <summary> + /// 魔法护盾生效剩余时间,这个只针对 ShieldWallEffectTime > 0 才生效 + /// </summary> + public float ShieldWallRemainTime { get; set; } + + /// <summary> + /// 魔法护盾最大生命值,即初始生命值 + /// </summary> + public float ShieldWallMaxHealth { get; set; } + + /// <summary> + /// 魔法护盾当前生命值,当 <= 0时直接移除护盾效果 + /// </summary> + public float ShieldWallCurrentHealth { get; set; } + + /// <summary> + /// Gets the normalised health. + /// </summary> + public float normalisedHealth + { + get + { + if (Math.Abs(maxHealth) <= Mathf.Epsilon) + { + Debug.LogError("Max Health is 0"); + maxHealth = 1f; + } + return currentHealth / maxHealth; + } + } + + /// <summary> + /// 清理魔法护盾 + /// </summary> + public void ClearShieldWall() + { + IsExistShieldWall = false; + ShieldWallMaxHealth = 0; + ShieldWallCurrentHealth = 0; + ShieldWallRemainTime = 0; + ShieldWallEffectiveTime = 0; + } + + /// <summary> + /// Gets the <see cref="IAlignmentProvider"/> of this instance + /// </summary> + public IAlignmentProvider alignmentProvider + { + get + { + return alignment != null ? alignment.GetInterface() : null; + } + } + + /// <summary> + /// Gets whether this instance is dead. + /// </summary> + public bool isDead + { + get { return currentHealth < 1.0f; } + } + + /// <summary> + /// Gets whether this instance is at max health. + /// </summary> + public bool isAtMaxHealth + { + get { return Mathf.Approximately(currentHealth, maxHealth); } + } - /// <summary> - /// Gets the current health. - /// </summary> - public float currentHealth { protected set; get; } + /// <summary> + /// Init this instance + /// </summary> + public virtual void Init() + { + currentHealth = startingHealth; + } - /// <summary> - /// 设置无敌状态. - /// </summary> - public bool bInvincible { get; set; } + /// <summary> + /// Sets the max health and starting health to the same value + /// </summary> + public void SetMaxHealth(float health) + { + if (health <= 0) + { + return; + } + maxHealth = startingHealth = health; + } - /// <summary> - /// Gets the normalised health. - /// </summary> - public float normalisedHealth - { - get - { - if (Math.Abs(maxHealth) <= Mathf.Epsilon) - { - Debug.LogError("Max Health is 0"); - maxHealth = 1f; - } - return currentHealth / maxHealth; - } - } + /// <summary> + /// Sets the max health and starting health separately + /// </summary> + public void SetMaxHealth(float health, float startingHealth) + { + if (health <= 0) + { + return; + } + maxHealth = health; + this.startingHealth = startingHealth; + } - /// <summary> - /// Gets the <see cref="IAlignmentProvider"/> of this instance - /// </summary> - public IAlignmentProvider alignmentProvider - { - get - { - return alignment != null ? alignment.GetInterface() : null; - } - } + /// <summary> + /// Sets this instance's health directly. + /// </summary> + /// <param name="health"> + /// The value to set <see cref="currentHealth"/> to + /// </param> + public void SetHealth(float health) + { + var info = new HealthChangeInfo + { + damageable = this, + newHealth = health, + oldHealth = currentHealth + }; - /// <summary> - /// Gets whether this instance is dead. - /// </summary> - public bool isDead - { - get { return currentHealth < 1.0f; } - } + currentHealth = health; + info.oldHealth = health; - /// <summary> - /// Gets whether this instance is at max health. - /// </summary> - public bool isAtMaxHealth - { - get { return Mathf.Approximately(currentHealth, maxHealth); } - } + if (healthChanged != null) + { + healthChanged(info); + } + } + /// <summary> + /// 获得一个魔法护盾 + /// </summary> + /// <param name="maxHealth">护盾的最大生命值</param> + /// <param name="effectiveTime">生效时间 0 -> 和Agent生命周期一致,> 0 *(单位ms)时间内生效</param> + public void AddShieldWall(float maxHealth, float effectiveTime) + { + // 如果重复获得护盾,直接全部重置数据,移除之前的护盾效果,重新获得一个护盾 + IsExistShieldWall = true; + ShieldWallEffectiveTime = effectiveTime; - /// <summary> - /// Init this instance - /// </summary> - public virtual void Init() - { - currentHealth = startingHealth; - } + if (effectiveTime > 0) + ShieldWallRemainTime = effectiveTime / 1000f; - /// <summary> - /// Sets the max health and starting health to the same value - /// </summary> - public void SetMaxHealth(float health) - { - if (health <= 0) - { - return; - } - maxHealth = startingHealth = health; - } + ShieldWallMaxHealth = ShieldWallCurrentHealth = maxHealth; - /// <summary> - /// Sets the max health and starting health separately - /// </summary> - public void SetMaxHealth(float health, float startingHealth) - { - if (health <= 0) - { - return; - } - maxHealth = health; - this.startingHealth = startingHealth; - } + HealthChangeInfo info = new HealthChangeInfo + { + damageable = this, + ShieldWallMaxHealth = maxHealth, + ShieldWallCurrentHealth = maxHealth, + IsExistShieldWall = true + }; - /// <summary> - /// Sets this instance's health directly. - /// </summary> - /// <param name="health"> - /// The value to set <see cref="currentHealth"/> to - /// </param> - public void SetHealth(float health) - { - var info = new HealthChangeInfo - { - damageable = this, - newHealth = health, - oldHealth = currentHealth - }; - - currentHealth = health; - info.oldHealth = health; + if (ShieldWallHealthChanged != null) + { + ShieldWallHealthChanged(info); + } + } - if (healthChanged != null) - { - healthChanged(info); - } - } + /// <summary> + /// Use the alignment to see if taking damage is a valid action + /// </summary> + /// <param name="damage"> + /// The damage to take + /// </param> + /// <param name="damageAlignment"> + /// The alignment of the other combatant + /// </param> + /// <param name="output"> + /// The output data if there is damage taken + /// </param> + /// <returns> + /// <value>true if this instance took damage</value> + /// <value>false if this instance was already dead, or the alignment did not allow the damage</value> + /// </returns> + public bool TakeDamage(float damage, IAlignmentProvider damageAlignment, ref HealthChangeInfo output) + { - /// <summary> - /// Use the alignment to see if taking damage is a valid action - /// </summary> - /// <param name="damage"> - /// The damage to take - /// </param> - /// <param name="damageAlignment"> - /// The alignment of the other combatant - /// </param> - /// <param name="output"> - /// The output data if there is damage taken - /// </param> - /// <returns> - /// <value>true if this instance took damage</value> - /// <value>false if this instance was already dead, or the alignment did not allow the damage</value> - /// </returns> - public bool TakeDamage(float damage, IAlignmentProvider damageAlignment, ref HealthChangeInfo output) - { - - /*output = new HealthChangeInfo + /*output = new HealthChangeInfo { damageAlignment = damageAlignment, damageable = this, newHealth = currentHealth, oldHealth = currentHealth };*/ - output.damageAlignment = damageAlignment; - output.damageable = this; - output.newHealth = currentHealth; - output.oldHealth = currentHealth; + output.damageAlignment = damageAlignment; + output.damageable = this; + output.newHealth = currentHealth; + output.oldHealth = currentHealth; - // 无敌状态下,不可伤害. - if (this.bInvincible) - return false; + // 无敌状态下,不可伤害. + if (this.bInvincible) + return false; - bool canDamage = damageAlignment == null || alignmentProvider == null || - damageAlignment.CanHarm(alignmentProvider); - - if (isDead || !canDamage) - { - return false; - } + bool canDamage = damageAlignment == null || alignmentProvider == null || + damageAlignment.CanHarm(alignmentProvider); - ChangeHealth(-damage, ref output); - SafelyDoAction(damaged, output); - if (isDead) - { - SafelyDoAction(died, output); - } - return true; - } + if (isDead || !canDamage) + { + return false; + } - /// <summary> - /// Logic for increasing the health. - /// </summary> - /// <param name="health">Health.</param> - public HealthChangeInfo IncreaseHealth(float health) - { - var info = new HealthChangeInfo {damageable = this}; - ChangeHealth(health, ref info); - SafelyDoAction(healed, info); - if (isAtMaxHealth) - { - SafelyDoAction(reachedMaxHealth); - } + ChangeHealth(-damage, ref output); + SafelyDoAction(damaged, output); + if (isDead) + { + SafelyDoAction(died, output); + } + return true; + } - return info; - } + /// <summary> + /// Logic for increasing the health. + /// </summary> + /// <param name="health">Health.</param> + public HealthChangeInfo IncreaseHealth(float health) + { + var info = new HealthChangeInfo { damageable = this }; + ChangeHealth(health, ref info); + SafelyDoAction(healed, info); + if (isAtMaxHealth) + { + SafelyDoAction(reachedMaxHealth); + } - /// <summary> - /// Changes the health. - /// </summary> - /// <param name="healthIncrement">Health increment.</param> - /// <param name="info">HealthChangeInfo for this change</param> - protected void ChangeHealth(float healthIncrement, ref HealthChangeInfo info) - { - info.oldHealth = currentHealth; - currentHealth += healthIncrement; - currentHealth = Mathf.Clamp(currentHealth, 0f, maxHealth); - info.newHealth = currentHealth; - - if (healthChanged != null) - { - healthChanged(info); - } - } + return info; + } - /// <summary> - /// A helper method for null checking actions - /// </summary> - /// <param name="action">Action to be done</param> - protected void SafelyDoAction(Action action) - { - if (action != null) - { - action(); - } - } + /// <summary> + /// Changes the health. + /// </summary> + /// <param name="healthIncrement">Health increment.</param> + /// <param name="info">HealthChangeInfo for this change</param> + protected void ChangeHealth(float healthIncrement, ref HealthChangeInfo info) + { + bool changeHealth = false; + float increment = healthIncrement; - /// <summary> - /// A helper method for null checking actions - /// </summary> - /// <param name="action">Action to be done</param> - /// <param name="info">The HealthChangeInfo to be passed to the Action</param> - protected void SafelyDoAction(Action<HealthChangeInfo> action, HealthChangeInfo info) - { - if (action != null) - { - action(info); - } - } - } + if (IsExistShieldWall) + { + info.ShieldWallOldHealth = ShieldWallCurrentHealth; + ShieldWallCurrentHealth += healthIncrement; + + if (ShieldWallCurrentHealth == 0) + info.IsExistShieldWall = IsExistShieldWall = false; + else if (ShieldWallCurrentHealth < 0) + { + changeHealth = true; + info.IsExistShieldWall = IsExistShieldWall = false; + // 护盾血量不够减 + increment = ShieldWallCurrentHealth; + info.ShieldWallCurrentHealth = ShieldWallCurrentHealth = 0; + } + } + else + changeHealth = true; + + if (changeHealth) + { + info.oldHealth = currentHealth; + currentHealth += increment; + currentHealth = Mathf.Clamp(currentHealth, 0f, maxHealth); + info.newHealth = currentHealth; + + if (healthChanged != null) + { + healthChanged(info); + } + } + } + + /// <summary> + /// A helper method for null checking actions + /// </summary> + /// <param name="action">Action to be done</param> + protected void SafelyDoAction(Action action) + { + if (action != null) + { + action(); + } + } + + /// <summary> + /// A helper method for null checking actions + /// </summary> + /// <param name="action">Action to be done</param> + /// <param name="info">The HealthChangeInfo to be passed to the Action</param> + protected void SafelyDoAction(Action<HealthChangeInfo> action, HealthChangeInfo info) + { + if (action != null) + { + action(info); + } + } + } } \ No newline at end of file diff --git a/Assets/Scripts/Core/Health/DamageableBehaviour.cs b/Assets/Scripts/Core/Health/DamageableBehaviour.cs index 9f754ef..02f73a4 100644 --- a/Assets/Scripts/Core/Health/DamageableBehaviour.cs +++ b/Assets/Scripts/Core/Health/DamageableBehaviour.cs @@ -54,7 +54,6 @@ /// </summary> public event Action<DamageableBehaviour> died; - /// <summary> /// Takes the damage and also provides a position for the damage being dealt /// </summary> diff --git a/Assets/Scripts/Core/Health/HealthChangeInfo.cs b/Assets/Scripts/Core/Health/HealthChangeInfo.cs index ae969ed..00c7917 100644 --- a/Assets/Scripts/Core/Health/HealthChangeInfo.cs +++ b/Assets/Scripts/Core/Health/HealthChangeInfo.cs @@ -2,32 +2,62 @@ namespace Core.Health { - /// <summary> - /// Health change info - stores information about the health change - /// </summary> - public struct HealthChangeInfo - { - public Damageable damageable; + /// <summary> + /// Health change info - stores information about the health change + /// </summary> + public struct HealthChangeInfo + { + public Damageable damageable; - public float oldHealth; + public float oldHealth; - public float newHealth; + public float newHealth; - /// <summary> - /// 用于标注是由哪个种类的Tower造成的伤害. - /// </summary> - public int attributeId; + /// <summary> + /// 是否存在魔法护盾 + /// </summary> + public bool IsExistShieldWall { get; set; } - public IAlignmentProvider damageAlignment; + /// <summary> + /// 魔法护盾最大生命值 + /// </summary> + public float ShieldWallMaxHealth; - public float healthDifference - { - get { return newHealth - oldHealth; } - } + /// <summary> + /// 魔法护盾当前生命值 + /// </summary> + public float ShieldWallCurrentHealth; - public float absHealthDifference - { - get { return Mathf.Abs(healthDifference); } - } - } + /// <summary> + /// 上一次的魔法护盾生命值 + /// </summary> + public float ShieldWallOldHealth; + + /// <summary> + /// 用于标注是由哪个种类的Tower造成的伤害. + /// </summary> + public int attributeId; + + public IAlignmentProvider damageAlignment; + + public float healthDifference + { + get { return newHealth - oldHealth; } + } + + public float absHealthDifference + { + get { return Mathf.Abs(healthDifference); } + } + + public float ShieldWallHealthDifference + { + get { return ShieldWallCurrentHealth - ShieldWallOldHealth; } + } + + public float AbsShieldWallHealthDifference + { + get { return Mathf.Abs(ShieldWallHealthDifference); } + } + } } \ No newline at end of file diff --git a/Assets/Scripts/Core/Health/HealthVisualizer.cs b/Assets/Scripts/Core/Health/HealthVisualizer.cs index e3273ee..56a4bde 100644 --- a/Assets/Scripts/Core/Health/HealthVisualizer.cs +++ b/Assets/Scripts/Core/Health/HealthVisualizer.cs @@ -108,9 +108,11 @@ if (m_Damageable != null) { m_Damageable.healthChanged -= OnHealthChanged; + m_Damageable.ShieldWallHealthChanged -= OnShieldWallHealthChanged; } m_Damageable = damageable; m_Damageable.healthChanged += OnHealthChanged; + m_Damageable.ShieldWallHealthChanged += OnShieldWallHealthChanged; } /// <summary> @@ -167,5 +169,10 @@ { UpdateHealth(m_Damageable.normalisedHealth); } + + private void OnShieldWallHealthChanged(HealthChangeInfo healthChangeInfo) + { + Debug.Log("--------------------- 获得魔法护盾 ---------------------"); + } } } \ No newline at end of file diff --git a/Assets/Scripts/TowerDefense/Agents/Agent.cs b/Assets/Scripts/TowerDefense/Agents/Agent.cs index 2fceb1c..19c9003 100644 --- a/Assets/Scripts/TowerDefense/Agents/Agent.cs +++ b/Assets/Scripts/TowerDefense/Agents/Agent.cs @@ -296,6 +296,7 @@ { this.configuration.maxHealth = health; this.configuration.startingHealth = health; + this.configuration.SetMaxHealth(health); this.configuration.Init(); this.configuration.SetHealth(health); @@ -468,6 +469,8 @@ timeToPoisonHurt = 0; bShieldBreak = false; bInDeathAct = false; + + configuration.ClearShieldWall(); StopFrostParticle(); //this.SetTargetableMatColor(Color.white); @@ -875,6 +878,7 @@ protected virtual void Update() { this.UpdateAction(); + HandleShieldWall(); // 处理死亡状态了,不必再移动: if (bInDeathAct || !CanMove) return; @@ -891,6 +895,25 @@ } /// <summary> + /// 处理魔法护盾血量值 + /// </summary> + protected void HandleShieldWall() + { + if (configuration.IsExistShieldWall) + { + if (configuration.ShieldWallCurrentHealth <= 0.00001f) + configuration.IsExistShieldWall = false; + else if (configuration.ShieldWallEffectiveTime > 0.00001f) + { + if (configuration.ShieldWallRemainTime <= 0.00001f) + configuration.IsExistShieldWall = false; + else + configuration.ShieldWallRemainTime -= Time.deltaTime; + } + } + } + + /// <summary> /// 限制当前Agent的移动位置,让Agent的移动看起来更帅一些 /// </summary> protected void restrictAgentPos() diff --git a/Assets/Scripts/TowerDefense/Level/AgentInsManager.cs b/Assets/Scripts/TowerDefense/Level/AgentInsManager.cs index dfe2c74..14de1c6 100644 --- a/Assets/Scripts/TowerDefense/Level/AgentInsManager.cs +++ b/Assets/Scripts/TowerDefense/Level/AgentInsManager.cs @@ -252,10 +252,40 @@ { list[j].CanMove = canMove; } + + break; } } } + /// <summary> + /// 根据赛道获得该赛道的所有敌人 + /// </summary> + /// <param name="tunel">赛道id (1~5)</param> + /// <param name="isOppo">是否是对手的赛道</param> + /// <returns></returns> + public List<Agent> GetAgentsByTunel(int tunel, bool isOppo = false) + { + WaveLineAgentInsMgr[] waveLineAgents = isOppo ? getOppoWaveLineList() : GetWaveLineList(); + List<Agent> ret = new List<Agent>(); + + for (int i = 0; i < waveLineAgents.Length; ++i) + { + if (i == tunel - 1) + { + for (int j = 0; j < waveLineAgents[i].listAgent.Count; ++j) + { + if (waveLineAgents[i].listAgent[j].AgentType == SpawnAgentType.Normal) + ret.Add(waveLineAgents[i].listAgent[j]); + } + + return ret; + } + } + + return null; + } + public List<Agent> agentList { get { return this.agentInsList; } diff --git a/Assets/Scripts/TowerDefense/UI/EndlessBossCtrl.cs b/Assets/Scripts/TowerDefense/UI/EndlessBossCtrl.cs index 8b0bfcb..61e32c0 100644 --- a/Assets/Scripts/TowerDefense/UI/EndlessBossCtrl.cs +++ b/Assets/Scripts/TowerDefense/UI/EndlessBossCtrl.cs @@ -26,11 +26,13 @@ public Image Title; + private string titlePath = "UI/Endless/SkillTitle/"; + // Start is called before the first frame update private void Start() { ColorVal = 0; - EventCenter.Ins.Add((int)KTGMGemClient.EventType.EndlessBossSkillGlintTitle, Glint); + EventCenter.Ins.Add<int>((int)KTGMGemClient.EventType.EndlessBossSkillGlintTitle, Glint); } // Update is called once per frame @@ -39,8 +41,9 @@ } - private void Glint() + private void Glint(int skillType) { + Title.sprite = Resources.Load<Sprite>($"{titlePath}{skillType}"); //设置一个DOTween队列 Sequence flashSeq = DOTween.Sequence(); Color c = Title.color; diff --git a/Assets/Scripts/TowerDefense/UI/EndlessBossSkill/BossSkillBubbleBomb.cs b/Assets/Scripts/TowerDefense/UI/EndlessBossSkill/BossSkillBubbleBomb.cs index bf9d957..66839b8 100644 --- a/Assets/Scripts/TowerDefense/UI/EndlessBossSkill/BossSkillBubbleBomb.cs +++ b/Assets/Scripts/TowerDefense/UI/EndlessBossSkill/BossSkillBubbleBomb.cs @@ -1,5 +1,3 @@ -using TowerDefense.UI.HUD; -using Core.Utilities; using System.Collections.Generic; using UnityEngine; using TowerDefense.Agents; diff --git a/Assets/Scripts/TowerDefense/UI/EndlessBossSkill/BossSkillShieldWall.cs b/Assets/Scripts/TowerDefense/UI/EndlessBossSkill/BossSkillShieldWall.cs index a9b2850..7c10315 100644 --- a/Assets/Scripts/TowerDefense/UI/EndlessBossSkill/BossSkillShieldWall.cs +++ b/Assets/Scripts/TowerDefense/UI/EndlessBossSkill/BossSkillShieldWall.cs @@ -1,4 +1,6 @@ +using System.Collections.Generic; using UnityEngine; +using TowerDefense.Agents; /** * 魔法护盾 @@ -16,18 +18,30 @@ /// </summary> public override void ReleaseSkill() { + base.ReleaseSkill(); + List<int> tunelIdList = GetTunelList(); + + if (tunelIdList.Count > 0) + { + for (int i = 0; i < tunelIdList.Count; ++i) + { + List<Agent> agents = AgentInsManager.instance.GetAgentsByTunel(tunelIdList[i]); + if (agents == null) continue; + + for (int j = 0; j < agents.Count; ++j) + { + float shieldValue = agents[j].configuration.currentHealth * SkillData.effect[0]; + agents[j].configuration.AddShieldWall(shieldValue, SkillData.effect[1]); + } + } + } } public override void Init() { base.Init(); Debug.Log("--------------------- 魔法护盾技能初始化 ---------------------"); - } - - public override void Update(float deltaTime) - { - IsCDCompleted = false; } } } \ No newline at end of file diff --git a/Assets/Scripts/TowerDefense/UI/EndlessBossSkill/EndlessBossSkillManager.cs b/Assets/Scripts/TowerDefense/UI/EndlessBossSkill/EndlessBossSkillManager.cs index 83117e5..b4ac36b 100644 --- a/Assets/Scripts/TowerDefense/UI/EndlessBossSkill/EndlessBossSkillManager.cs +++ b/Assets/Scripts/TowerDefense/UI/EndlessBossSkill/EndlessBossSkillManager.cs @@ -131,7 +131,7 @@ { currentSkill = cdList[i]; EventCenter.Ins.Add((int)KTGMGemClient.EventType.EndlessBossSkillGlintTitleCompleted, OnGlintTitleCompleted); - EventCenter.Ins.BroadCast((int)KTGMGemClient.EventType.EndlessBossSkillGlintTitle); + EventCenter.Ins.BroadCast((int)KTGMGemClient.EventType.EndlessBossSkillGlintTitle, (int)cdList[i].SkillType); isFloatWordCompleted = false; ChangeState(EndlessBossSkillState.FloatWord); break; diff --git a/Assets/Scripts/TowerDefense/UI/EndlessBossSkillAI/EndlessBossSkillAI.cs b/Assets/Scripts/TowerDefense/UI/EndlessBossSkillAI/EndlessBossSkillAI.cs index cc9a5ea..4b3b7dd 100644 --- a/Assets/Scripts/TowerDefense/UI/EndlessBossSkillAI/EndlessBossSkillAI.cs +++ b/Assets/Scripts/TowerDefense/UI/EndlessBossSkillAI/EndlessBossSkillAI.cs @@ -12,7 +12,7 @@ public EndlessBossSkillAI(boss_skill param) { SkillData = param; - // cx test 现在表里面没有配AI类型,所以默认全部是Normal + // 现在表里面没有配AI类型,所以默认全部是Normal AIType = EndlessBossSkillAIType.Normal; } diff --git a/Assets/Scripts/TowerDefense/UI/HUD/EndlessGameUI.cs b/Assets/Scripts/TowerDefense/UI/HUD/EndlessGameUI.cs index 81fec58..d1b2dae 100644 --- a/Assets/Scripts/TowerDefense/UI/HUD/EndlessGameUI.cs +++ b/Assets/Scripts/TowerDefense/UI/HUD/EndlessGameUI.cs @@ -737,7 +737,7 @@ /// <param name="opponent"></param> public void DestroyTowerGrid(int xidx) { - // cx test 这里的逻辑已经不走了 + // 这里的逻辑已经不走了 for (int i = 0; i < AttackRowNumbers; ++i) { if (TowerDestroyArr[xidx, i]) continue; -- Gitblit v1.9.1