6 files renamed
7 files modified
| | |
| | | using Core.Health; |
| | | using System; |
| | | using System.Dynamic; |
| | | using TowerDefense.UI.HUD; |
| | | using UnityEngine; |
| | | |
| | | namespace ActionGameFramework.Health |
| | |
| | | public Transform targetTransform; |
| | | |
| | | /// <summary> |
| | | /// 是否精英怪 |
| | | /// </summary> |
| | | public bool bElit = false; |
| | | |
| | | /// <summary> |
| | | /// 是否Boss怪. |
| | | /// </summary> |
| | | public bool bBoss = false; |
| | | |
| | | /// <summary> |
| | | /// 分别对应三种不同的纹理. |
| | | /// </summary> |
| | | public Texture poisonTex; |
| | | public Texture frozenTex; |
| | | public Texture commonTex; |
| | | |
| | | /// <summary> |
| | | /// The position of the object |
| | | /// </summary> |
| | | protected Vector3 m_CurrentPosition, m_PreviousPosition; |
| | | |
| | | |
| | | /// <summary> |
| | | /// 速度降低值. |
| | | /// </summary> |
| | | protected float speedSlowRate = 0.0f; |
| | | |
| | | // 中毒相关的数据 |
| | | protected int poisonTimes = 0; |
| | | protected float poisonHurt = 0.0f; |
| | | protected int poisonAttid = 0; |
| | | protected float timeToPoisonHurt = 0.0f; |
| | | |
| | | /// <summary> |
| | | /// 是否处于 中毒状态 |
| | | /// </summary> |
| | | protected bool isPoison; |
| | | |
| | | /// <summary> |
| | | /// 是否处于减速状态 |
| | | /// </summary> |
| | | protected bool isSlowDown; |
| | | |
| | | /// <summary> |
| | | /// 是否处于冰冻状态 |
| | | /// </summary> |
| | | protected bool isFrost; |
| | | |
| | | /// <summary> |
| | | /// 中毒粒子特效 |
| | | /// </summary> |
| | | public ParticleSystem PoisonParticle; |
| | | |
| | | /// <summary> |
| | | /// 中毒结束播放的粒子特效 |
| | | /// </summary> |
| | | public ParticleSystem PoisonEndParticle; |
| | | |
| | | /// <summary> |
| | | /// 减速粒子特效 |
| | | /// </summary> |
| | | public ParticleSystem SlowDownParticle; |
| | | |
| | | /// <summary> |
| | | /// 冰冻特效 |
| | | /// </summary> |
| | | public ParticleSystem FrostParticle; |
| | | |
| | | /// <summary> |
| | | /// 被火技能攻击特效 |
| | | /// </summary> |
| | | public ParticleSystem FireSkillParticle; |
| | | |
| | | protected Color mMatColor; |
| | | |
| | | /// <summary> |
| | | /// 是否处于破甲状态. |
| | | /// </summary> |
| | | public bool bShieldBreak { get; set; } |
| | | |
| | | /// <summary> |
| | | /// The velocity of the rigidbody |
| | |
| | | return targetTransform == null ? transform : targetTransform; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 设置当前目标的颜色数据 |
| | | /// </summary> |
| | | /// <param name="color"></param> |
| | | public void SetTargetableMatColor(Color color, bool force = false) |
| | | { |
| | | |
| | | if (!force) |
| | | { |
| | | if (color == mMatColor) return; |
| | | // 无敌状态,只接受白色原贴图: |
| | | if (this.configuration.bInvincible && (color != Color.white)) return; |
| | | } |
| | | |
| | | foreach (Transform t in transform.GetComponentsInChildren<Transform>()) |
| | | { |
| | | if (t.name == "Cube") |
| | | { |
| | | Material tMat = t.GetComponent<MeshRenderer>().material; |
| | | if ((color == Color.green) && (poisonTex != null)) |
| | | { |
| | | tMat.mainTexture = poisonTex; |
| | | } |
| | | if ((color == Color.blue) && (frozenTex != null)) |
| | | { |
| | | tMat.mainTexture = frozenTex; |
| | | } |
| | | if ((color == Color.white) && (commonTex != null)) |
| | | { |
| | | tMat.mainTexture = commonTex; |
| | | } |
| | | mMatColor = color; |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 降低移动速度. |
| | | /// </summary> |
| | | /// <param name="rate"></param> |
| | | public void addSpeedSlowRate(float rate) |
| | | { |
| | | speedSlowRate += rate; |
| | | if (speedSlowRate >= 0.5f) |
| | | speedSlowRate = 0.5f; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 怪物中毒. |
| | | /// </summary> |
| | | /// <param name="damage"></param> |
| | | public void poisonAgent(float damage, int attid) |
| | | { |
| | | if (this.poisonTimes >= 1) return; |
| | | |
| | | if (!isPoison) |
| | | { |
| | | isPoison = true; |
| | | |
| | | if (PoisonParticle != null) |
| | | PoisonParticle.Play(); |
| | | } |
| | | |
| | | this.poisonTimes++; |
| | | this.poisonAttid = attid; |
| | | this.poisonHurt = (float)Math.Floor(this.configuration.maxHealth / 20.0f); |
| | | this.timeToPoisonHurt = 1.0f; |
| | | } |
| | | |
| | | public bool bInPoison { get { return this.poisonHurt > 0; } } |
| | | |
| | | /// <summary> |
| | | /// 处理中毒相关的数据 |
| | | /// </summary> |
| | | /// <param name="time"></param> |
| | | protected void updatePoison(float time) |
| | | { |
| | | this.timeToPoisonHurt -= time; |
| | | if (this.timeToPoisonHurt <= 0) |
| | | { |
| | | Vector3 backPos = this.transform.position; |
| | | this.TakeDamage(poisonHurt, this.transform.position, null, poisonAttid); |
| | | if ((poisonHurt > 0) && (!opponentAgent)) |
| | | { |
| | | if (GameUI.instanceExists) |
| | | GameUI.instance.generateBloodText(backPos, poisonHurt, false, false, true); |
| | | else if (EndlessGameUI.instanceExists) |
| | | EndlessGameUI.instance.generateBloodText(backPos, poisonHurt, false, false, true); |
| | | } |
| | | |
| | | if (poisonHurt > 0) |
| | | timeToPoisonHurt = 1.0f; |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// Returns our targetable's transform position |
| | |
| | | { |
| | | base.Awake(); |
| | | ResetPositionData(); |
| | | bShieldBreak = false; |
| | | mMatColor = Color.white; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | using System; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using System.ComponentModel; |
| | | using ActionGameFramework.Health; |
| | | using Core.Health; |
| | | using Core.Utilities; |
| | | using DG.Tweening; |
| | | using KTGMGemClient; |
| | | using TMPro.Examples; |
| | | using TowerDefense.Affectors; |
| | | using TowerDefense.Agents.Data; |
| | | using TowerDefense.Economy; |
| | | using TowerDefense.Level; |
| | | using TowerDefense.Nodes; |
| | |
| | | |
| | | public AgentSetData mAgentData; |
| | | |
| | | |
| | | |
| | | //public Textur |
| | | |
| | | |
| | | /// <summary> |
| | | /// The NavMeshAgent component attached to this |
| | | /// 这个,Unity内比较核心的类 |
| | |
| | | /// </summary> |
| | | /// <param name="can"></param> |
| | | public bool CanMove { get; set; } = true; |
| | | |
| | | /// <summary> |
| | | /// 分别对应三种不同的纹理. |
| | | /// </summary> |
| | | public Texture poisonTex; |
| | | |
| | | public Texture frozenTex; |
| | | |
| | | public Texture commonTex; |
| | | |
| | | /// <summary> |
| | | /// 速度降低值. |
| | | /// </summary> |
| | | protected float speedSlowRate = 0.0f; |
| | | |
| | | // 中毒相关的数据 |
| | | protected int poisonTimes = 0; |
| | | protected float poisonHurt = 0.0f; |
| | | protected int poisonAttid = 0; |
| | | protected float timeToPoisonHurt = 0.0f; |
| | | |
| | | /// <summary> |
| | | /// 是否处于 中毒状态 |
| | | /// </summary> |
| | | protected bool isPoison; |
| | | |
| | | /// <summary> |
| | | /// 是否处于减速状态 |
| | | /// </summary> |
| | | protected bool isSlowDown; |
| | | |
| | | /// <summary> |
| | | /// 是否处于冰冻状态 |
| | | /// </summary> |
| | | protected bool isFrost; |
| | | |
| | | /// <summary> |
| | | /// 中毒粒子特效 |
| | | /// </summary> |
| | | public ParticleSystem PoisonParticle; |
| | | |
| | | /// <summary> |
| | | /// 中毒结束播放的粒子特效 |
| | | /// </summary> |
| | | public ParticleSystem PoisonEndParticle; |
| | | |
| | | /// <summary> |
| | | /// 减速粒子特效 |
| | | /// </summary> |
| | | public ParticleSystem SlowDownParticle; |
| | | |
| | | /// <summary> |
| | | /// 冰冻特效 |
| | | /// </summary> |
| | | public ParticleSystem FrostParticle; |
| | | |
| | | /// <summary> |
| | | /// 被火技能攻击特效 |
| | | /// </summary> |
| | | public ParticleSystem FireSkillParticle; |
| | | |
| | | |
| | | /// <summary> |
| | | /// 降低移动速度. |
| | | /// </summary> |
| | | /// <param name="rate"></param> |
| | | public void addSpeedSlowRate(float rate) |
| | | { |
| | | speedSlowRate += rate; |
| | | if (speedSlowRate >= 0.5f) |
| | | speedSlowRate = 0.5f; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 怪物中毒. |
| | | /// </summary> |
| | | /// <param name="damage"></param> |
| | | public void poisonAgent(float damage, int attid) |
| | | { |
| | | if (this.poisonTimes >= 1) return; |
| | | |
| | | if (!isPoison) |
| | | { |
| | | isPoison = true; |
| | | |
| | | if (PoisonParticle != null) |
| | | PoisonParticle.Play(); |
| | | } |
| | | |
| | | this.poisonTimes++; |
| | | this.poisonAttid = attid; |
| | | this.poisonHurt = (float)Math.Floor(this.configuration.maxHealth / 20.0f); |
| | | this.timeToPoisonHurt = 1.0f; |
| | | } |
| | | |
| | | public bool bInPoison { get { return this.poisonHurt > 0; } } |
| | | |
| | | /// <summary> |
| | | /// 处理中毒相关的数据 |
| | | /// </summary> |
| | | /// <param name="time"></param> |
| | | protected void updatePoison(float time) |
| | | { |
| | | this.timeToPoisonHurt -= time; |
| | | if (this.timeToPoisonHurt <= 0) |
| | | { |
| | | Vector3 backPos = this.transform.position; |
| | | this.TakeDamage(poisonHurt, this.transform.position, null, poisonAttid); |
| | | if ((poisonHurt > 0) && (!opponentAgent)) |
| | | { |
| | | if (GameUI.instanceExists) |
| | | GameUI.instance.generateBloodText(backPos, poisonHurt, false, true); |
| | | else if (EndlessGameUI.instanceExists) |
| | | EndlessGameUI.instance.generateBloodText(backPos, poisonHurt, false, true); |
| | | } |
| | | |
| | | if (poisonHurt > 0) |
| | | timeToPoisonHurt = 1.0f; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Gets the attached nav mesh agent velocity |
| | |
| | | mStartYVal = this.transform.position.y; |
| | | mStartZVal = this.transform.position.z; |
| | | |
| | | // 确保设置成默认白色纹理: |
| | | this.SetTargetableMatColor(Color.white, true); |
| | | |
| | | speedSlowRate = 0.0f; |
| | | poisonHurt = 0; |
| | | poisonAttid = 0; |
| | | poisonTimes = 0; |
| | | timeToPoisonHurt = 0; |
| | | bShieldBreak = false; |
| | | CanMove = true; |
| | | |
| | | /*// 如果对应的粒子不为空,则播放 |
| | |
| | | poisonTimes = 0; |
| | | timeToPoisonHurt = 0; |
| | | isFrost = false; |
| | | bShieldBreak = false; |
| | | bInDeathAct = false; |
| | | ChangeState(AgentActionState.Move); |
| | | configuration.ClearShieldWall(); |
| | |
| | | return; |
| | | } |
| | | |
| | | |
| | | |
| | | protected void releaseAllCenterAgent() |
| | | { |
| | | int cnt = this.agentInsList.Count; |
| | | for (int ti = cnt - 1; ti >= 0; ti--) |
| | | { |
| | | if (agentInsList[ti].bBoss) |
| | | continue; |
| | | agentInsList[ti].Remove(); |
| | | } |
| | | |
| | | cnt = this.oppoAgentInsList.Count; |
| | | for (int ti = cnt - 1; ti >= 0; ti--) |
| | | { |
| | | if (oppoAgentInsList[ti].bBoss) |
| | | continue; |
| | | oppoAgentInsList[ti].Remove(); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取WaveManager相关的中心点 |
| | | /// </summary> |
| | |
| | | Vector3 cpos = Vector3.zero; |
| | | return cpos; |
| | | } |
| | | |
| | | |
| | | protected void updateOpponentAgent() |
| | | { |
| | |
| | | if (!eag.opponentAgent) |
| | | { |
| | | if (GameUI.instanceExists) |
| | | GameUI.instance.generateBloodText(fpos, damage, false, false); |
| | | GameUI.instance.generateBloodText(fpos, damage); |
| | | else if (EndlessGameUI.instanceExists) |
| | | EndlessGameUI.instance.generateBloodText(fpos, damage, false, false); |
| | | EndlessGameUI.instance.generateBloodText(fpos, damage); |
| | | } |
| | | |
| | | if (!isDeath && eag.isDead) |
| | |
| | | if (!eag.opponentAgent) |
| | | { |
| | | if (GameUI.instanceExists) |
| | | GameUI.instance.generateBloodText(fpos, damage, false, false); |
| | | GameUI.instance.generateBloodText(fpos, damage); |
| | | else if (EndlessGameUI.instanceExists) |
| | | EndlessGameUI.instance.generateBloodText(fpos, damage, false, false); |
| | | EndlessGameUI.instance.generateBloodText(fpos, damage); |
| | | } |
| | | |
| | | eag.PlayFireSkillHit(); |
| | |
| | | if (!eag.opponentAgent) |
| | | { |
| | | if (GameUI.instanceExists) |
| | | GameUI.instance.generateBloodText(fpos, damage, false, false); |
| | | GameUI.instance.generateBloodText(fpos, damage); |
| | | else if (EndlessGameUI.instanceExists) |
| | | EndlessGameUI.instance.generateBloodText(fpos, damage, false, false); |
| | | EndlessGameUI.instance.generateBloodText(fpos, damage); |
| | | } |
| | | |
| | | eag.PlayFireSkillHit(); |
| | |
| | | if (!eag.opponentAgent) |
| | | { |
| | | if (GameUI.instanceExists) |
| | | GameUI.instance.generateBloodText(fpos, damage, false, false); |
| | | GameUI.instance.generateBloodText(fpos, damage); |
| | | else if (EndlessGameUI.instanceExists) |
| | | EndlessGameUI.instance.generateBloodText(fpos, damage, false, false); |
| | | EndlessGameUI.instance.generateBloodText(fpos, damage); |
| | | } |
| | | if (eag.isDead) |
| | | ++deathCount; |
| | |
| | | if ((ag.liveID == tid) && (!ag.opponentAgent)) |
| | | { |
| | | if (GameUI.instanceExists) |
| | | GameUI.instance.generateBloodText(ag.position, chainAttackHurt, false, false); |
| | | GameUI.instance.generateBloodText(ag.position, chainAttackHurt); |
| | | else if (EndlessGameUI.instanceExists) |
| | | EndlessGameUI.instance.generateBloodText(ag.position, chainAttackHurt, false, false); |
| | | EndlessGameUI.instance.generateBloodText(ag.position, chainAttackHurt); |
| | | } |
| | | } |
| | | listBlood.Clear(); |
| | |
| | | { |
| | | case 2: // 减速. |
| | | SlowDown slowDown = (SlowDown)EndlessBuffManager.instance.GetBuffInstanceByType(EndlessBuffEffectType.SlowDown); |
| | | enemy.addSpeedSlowRate(0.15f + (slowDown != null ? slowDown.GetSlowDownAdd(TowerPtr.attributeId) : 0)); |
| | | enemy.SetTargetableMatColor(Color.blue); |
| | | (enemy as Agent).addSpeedSlowRate(0.15f + (slowDown != null ? slowDown.GetSlowDownAdd(TowerPtr.attributeId) : 0)); |
| | | break; |
| | | case 3: // 中毒 |
| | | // enemy.poisonAgent(damage, attid); |
| | | // enemy.SetTargetableMatColor(Color.green); |
| | | break; |
| | | case 5: // 破甲 |
| | | enemy.bShieldBreak = true; |
| | | break; |
| | | } |
| | | return; |
| | |
| | | using ActionGameFramework.Health; |
| | | using Core.Utilities; |
| | | using DG.Tweening; |
| | | using System; |
| | | using System.Net.Http.Headers; |
| | | using TowerDefense.Agents; |
| | | using TowerDefense.UI.HUD; |
| | | using UnityEngine; |
| | | using System.Collections; |
| | | |
| | | namespace TowerDefense.Towers.Projectiles |
| | | { |
| | |
| | | switch (id) |
| | | { |
| | | case 2: // 减速. |
| | | enemy.addSpeedSlowRate(0.15f); |
| | | enemy.SetTargetableMatColor(Color.blue); |
| | | (enemy as Agent).addSpeedSlowRate(0.15f); |
| | | break; |
| | | case 3: // 中毒 |
| | | enemy.poisonAgent(damage, attid); |
| | | enemy.SetTargetableMatColor(Color.green); |
| | | break; |
| | | case 5: // 破甲 |
| | | enemy.bShieldBreak = true; |
| | | (enemy as Agent).poisonAgent(damage, attid); |
| | | break; |
| | | } |
| | | return; |
| | |
| | | // 攻击目标已经经历过了Pool了,不能再攻击了。 |
| | | if (mLiveID != m_Enemy.liveID) return; |
| | | |
| | | // effects |
| | | // ParticleSystem pfxPrefab = m_Damager.collisionParticles; |
| | | // var attackEffect = Poolable.TryGetPoolable<ParticleSystem>(pfxPrefab.gameObject); |
| | | // attackEffect.transform.position = m_Enemy.position; |
| | | // attackEffect.Play(); |
| | | |
| | | // GameObject hitObj = Poolable.TryGetPoolable(m_Damager.collisionObj); |
| | | // ParticleSystem ps = hitObj.GetComponent<ParticleSystem>(); |
| | | // if (ps == null) |
| | | // ps = hitObj.transform.GetChild(0).GetComponent<ParticleSystem>(); |
| | | // ps.Play(); |
| | | // // StartCoroutine(RecycleParticle(hitObj, ps.main.duration)); |
| | | |
| | | // var hitVFX = Instantiate(m_Damager.collisionObj, m_Enemy.position, Quaternion.identity); |
| | | // var ps = hitVFX.GetComponent<ParticleSystem>(); |
| | | // if (ps == null) |
| | | // { |
| | | // var psChild = hitVFX.transform.GetChild(0).GetComponent<ParticleSystem>(); |
| | | // psChild.Play(); |
| | | // Destroy(hitVFX, psChild.main.duration); |
| | | // } |
| | | // else |
| | | // { |
| | | // ps.Play(); |
| | | // Destroy(hitVFX, ps.main.duration); |
| | | // } |
| | | |
| | | float finalDamage = m_Damager.finalDamage; |
| | | bool crit = m_Damager.isCrit; |
| | | if (crit) |
| | | { |
| | | finalDamage += finalDamage; |
| | | |
| | | // 暂时去掉这个ShakePosition的功能: |
| | | //m_Enemy.transform.DOShakePosition(0.5f); |
| | | } |
| | | // 精英怪和Boss双倍攻击. |
| | | bool doubleHit = m_Damager.doubleHit && m_Enemy.bElit; |
| | | if (doubleHit) |
| | | { |
| | | finalDamage *= 2; |
| | | } |
| | | |
| | | // |
| | | // 处理光塔对应的攻击增加: |
| | | if (attackRise > 0) |
| | | finalDamage += (finalDamage * attackRise); |
| | | // 破甲状态 |
| | | if (m_Enemy.bShieldBreak) |
| | | finalDamage += (finalDamage * 0.1f); |
| | | |
| | | // |
| | | // 提前处理非当前Enemy的爆炸攻击: |
| | | if (chainAttackRate > 0) |
| | | AgentInsManager.instance.StartExplodeAttack(m_Enemy as Agent, finalDamage); |
| | |
| | | ProcessTowerAttributeAttack(m_Enemy, finalDamage, attributeId); |
| | | |
| | | if (!m_Enemy.opponentAgent) |
| | | GameUI.instance.generateBloodText(backPos, finalDamage, crit, doubleHit); |
| | | GameUI.instance.generateBloodText(backPos, finalDamage, crit); |
| | | |
| | | // 播放受击动画: |
| | | if ((!m_Enemy.isDead) && (m_Enemy.liveID == tid)) |
| | | (m_Enemy as Agent).PlayOnHit(); |
| | | |
| | | // 重设到开始位置的处理. liveID必须要等于tid. |
| | | /*if( (resetStartPosRate > 0)&&(!m_Enemy.isDead)&& (m_Enemy.liveID == tid)) |
| | | { |
| | | if (mRand.NextDouble() < resetStartPosRate) |
| | | { |
| | | Agent ag = m_Enemy as Agent; |
| | | if( ag.bBoss) |
| | | { |
| | | // 如果是Boss,更低的概率重设位置. |
| | | if (mRand.NextDouble() < resetStartPosRate / 20.0f) |
| | | ag.execAgentPosResetAction(); |
| | | } |
| | | else |
| | | ag.execAgentPosResetAction(); |
| | | } |
| | | |
| | | }*/ |
| | | |
| | | /*// 链式攻击的测试处理: 需要确保是同一个敌人,ID相同. |
| | | if( (chainAttackRate > 0)&& (!m_Enemy.isDead) && (m_Enemy.liveID == tid) ) |
| | | { |
| | | if (mRand.NextDouble() < chainAttackRate) |
| | | AgentInsManager.instance.StartChainAttack(m_Enemy as Agent,m_Damager.alignmentProvider,(float)Math.Floor(finalDamage/2.0f )); |
| | | |
| | | }*/ |
| | | |
| | | m_PauseTimer = true; |
| | | } |
| | |
| | | /// </summary> |
| | | public class Tower : Targetable |
| | | { |
| | | public readonly float INSCENE_TU_DAMAGE = 30f; |
| | | |
| | | public static readonly int MAX_LEVEL = 4; |
| | | |
| | | /// <summary> |
| | |
| | | { |
| | | inSceneTowerLevel++; |
| | | |
| | | // cx test |
| | | // 设置攻击数据的加强,暂时是测试数据,后面需要读取表格数据处理: |
| | | float damageAdd = inSceneTowerLevel * INSCENE_TU_DAMAGE; |
| | | float damageAdd = inSceneTowerLevel; |
| | | |
| | | Debug.Log("Upgrade Tower name is:" + name); |
| | | |
| | |
| | | /// <param name="x"></param> |
| | | /// <param name="y"></param> |
| | | /// <param name="val"></param> |
| | | public void generateBloodText(Vector3 wpos, float val, bool crit = false, bool doubleHit = false, bool poison = false) |
| | | public void generateBloodText(Vector3 wpos, float val, bool crit = false, bool poison = false) |
| | | { |
| | | if (Mathf.FloorToInt(val) == 0) return; |
| | | |
| | |
| | | { |
| | | tm.GetComponent<Transform>().SetParent(GameObject.Find("BattleMainUI").GetComponent<Transform>(), true); |
| | | string bloodStr = ""; |
| | | if (doubleHit) |
| | | bloodStr += "Dble!"; |
| | | if (crit) |
| | | bloodStr += "Crt!"; |
| | | bloodStr += "-"; |