| | |
| | | protected bool bInDeathAct = false; |
| | | |
| | | /// <summary> |
| | | /// 原地罚站 |
| | | /// </summary> |
| | | /// <param name="can"></param> |
| | | public bool CanMove { get; set; } = true; |
| | | |
| | | /// <summary> |
| | | /// Gets the attached nav mesh agent velocity |
| | | /// </summary> |
| | | public override Vector3 velocity |
| | |
| | | public bool bInDeathState |
| | | { |
| | | get { return this.bInDeathAct; } |
| | | set { bInDeathAct = value; } |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | protected bool nodeMoveUpdate = false; |
| | | |
| | | /// <summary> |
| | | /// 代理的类型 |
| | | /// </summary> |
| | | public SpawnAgentType AgentType { get; set; } = SpawnAgentType.Normal; |
| | | |
| | | |
| | | /// <summary> |
| | | /// 无尽模式小怪对应 endless_enemy表中数据 |
| | | /// </summary> |
| | | public endless_enemy EnemyData { get; set; } |
| | | |
| | | /// <summary> |
| | | /// Accessor to <see cref="m_NavMeshAgent"/> |
| | |
| | | { |
| | | this.configuration.maxHealth = health; |
| | | this.configuration.startingHealth = health; |
| | | this.configuration.SetMaxHealth(health); |
| | | this.configuration.Init(); |
| | | this.configuration.SetHealth(health); |
| | | |
| | |
| | | poisonTimes = 0; |
| | | timeToPoisonHurt = 0; |
| | | bShieldBreak = false; |
| | | CanMove = true; |
| | | |
| | | /*// 如果对应的粒子不为空,则播放 |
| | | if( spawnParticle) |
| | |
| | | /// 处理Agent的锁定Buf,播放特效,设置速度为零,并时间到达后重设数据。 |
| | | /// </summary> |
| | | /// <param name="binfo"></param> |
| | | protected void SetAgentStopBuff(buffinfo binfo) |
| | | protected virtual void SetAgentStopBuff(buffinfo binfo) |
| | | { |
| | | MoveStopTime = binfo.last / 1000; |
| | | |
| | | if (WaveLineSelMgr.instanceExists) |
| | | if (!isFrost) |
| | | { |
| | | // 播放特效: |
| | | if (WaveLineSelMgr.instance.bufStopMovePrefab == null) return; |
| | | isFrost = true; |
| | | |
| | | // 正在播放的话,直接返回. |
| | | if (MoveStopEffect) |
| | | return; |
| | | |
| | | MoveStopEffect = Instantiate(WaveLineSelMgr.instance.bufStopMovePrefab); |
| | | MoveStopEffect.transform.position = this.position; |
| | | MoveStopEffect.Play(); |
| | | } |
| | | else if (EndlessWaveLineManager.instanceExists) |
| | | { |
| | | // 播放特效: |
| | | if (EndlessWaveLineManager.instance.bufStopMovePrefab == null) return; |
| | | |
| | | // 正在播放的话,直接返回. |
| | | if (MoveStopEffect) |
| | | return; |
| | | |
| | | MoveStopEffect = Instantiate(EndlessWaveLineManager.instance.bufStopMovePrefab); |
| | | MoveStopEffect.transform.position = this.position; |
| | | MoveStopEffect.Play(); |
| | | if (FrostParticle != null) |
| | | FrostParticle.Play(); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | // 统一管理器内删除当前的Agent: |
| | | AgentInsManager.instance.removeAgent(this); |
| | | |
| | | EventCenter.Ins.BroadCast((int)KTGMGemClient.EventType.EndlessAgentDead, this); |
| | | base.Remove(); |
| | | |
| | | if (m_LevelManager) m_LevelManager.DecrementNumberOfEnemies(); |
| | |
| | | timeToPoisonHurt = 0; |
| | | bShieldBreak = false; |
| | | bInDeathAct = false; |
| | | |
| | | configuration.ClearShieldWall(); |
| | | |
| | | StopFrostParticle(); |
| | | //this.SetTargetableMatColor(Color.white); |
| | | |
| | | // 删除当前停止特效和状态. |
| | | if (MoveStopTime > 0) |
| | | { |
| | | if (MoveStopEffect) |
| | | { |
| | | MoveStopEffect.Stop(); |
| | | Destroy(MoveStopEffect); |
| | | MoveStopEffect = null; |
| | | } |
| | | |
| | | MoveStopTime = 0.0f; |
| | | } |
| | | |
| | | |
| | | // 停止DoTween动画. |
| | | this.transform.DOKill(); |
| | | |
| | | Poolable.TryPool(gameObject); |
| | | } |
| | | |
| | | private void StopFrostParticle() |
| | | { |
| | | if (isFrost) |
| | | { |
| | | isFrost = false; |
| | | |
| | | if (FrostParticle != null) |
| | | FrostParticle.Stop(); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | protected override void Awake() |
| | | { |
| | | //Debug.Log("哪里生成的?"); |
| | | base.Awake(); |
| | | LazyLoad(); |
| | | m_NavMeshAgent.enabled = false; |
| | |
| | | MoveStopTime -= Time.deltaTime; |
| | | if (MoveStopTime <= 0) |
| | | { |
| | | if (MoveStopEffect) |
| | | { |
| | | MoveStopEffect.Stop(); |
| | | Destroy(MoveStopEffect); |
| | | MoveStopEffect = null; |
| | | } |
| | | StopFrostParticle(); |
| | | MoveStopTime = 0; |
| | | } |
| | | else |
| | |
| | | } |
| | | |
| | | float finalSpeed = fMoveSpeed * (1 - speedSlowRate); |
| | | |
| | | if (speedSlowRate > 0 && !isSlowDown) |
| | | { |
| | | isSlowDown = true; |
| | | |
| | | if (SlowDownParticle != null) |
| | | SlowDownParticle.Play(); |
| | | } |
| | | else if (speedSlowRate == 0 && isSlowDown) |
| | | { |
| | | isSlowDown = false; |
| | | |
| | | if (SlowDownParticle != null) |
| | | { |
| | | SlowDownParticle.Stop(); |
| | | SlowDownParticle.Clear(); |
| | | } |
| | | } |
| | | |
| | | Vector3 curPos = m_NavMeshAgent.transform.position; |
| | | bool swithNode = false; |
| | |
| | | /// <returns></returns> |
| | | protected void UpdateAction() |
| | | { |
| | | if (!mAnim) return; |
| | | if (mAnim) |
| | | { |
| | | AnimatorStateInfo stateinfo = mAnim.GetCurrentAnimatorStateInfo(0); |
| | | |
| | | AnimatorStateInfo stateinfo = mAnim.GetCurrentAnimatorStateInfo(0); |
| | | |
| | | if (stateinfo.IsName("Die") && (stateinfo.normalizedTime >= 0.7f)) |
| | | { |
| | | this.Remove(); |
| | | return; |
| | | } |
| | | else if (stateinfo.IsName("GetHit") && (stateinfo.normalizedTime >= 0.7f)) |
| | | { |
| | | mAnim.SetBool("GetHit", false); |
| | | } |
| | | else if (stateinfo.IsName("Attack") && (stateinfo.normalizedTime >= 0.9f)) |
| | | { |
| | | if (this.healthVal <= 0.1) |
| | | if (stateinfo.IsName("Die") && (stateinfo.normalizedTime >= 0.7f)) |
| | | { |
| | | // 统一管理器内删除当前的Agent: |
| | | AgentInsManager.instance.removeAgent(this); |
| | | this.Remove(); |
| | | Debug.Log("删除多余的攻击Agent."); |
| | | return; |
| | | } |
| | | else if (stateinfo.IsName("GetHit") && (stateinfo.normalizedTime >= 0.7f)) |
| | | { |
| | | mAnim.SetBool("GetHit", false); |
| | | } |
| | | else if (stateinfo.IsName("Attack") && (stateinfo.normalizedTime >= 0.9f)) |
| | | { |
| | | if (this.healthVal <= 0.1) |
| | | { |
| | | // 统一管理器内删除当前的Agent: |
| | | AgentInsManager.instance.removeAgent(this); |
| | | this.Remove(); |
| | | } |
| | | } |
| | | } |
| | | else if (changeMat) |
| | | { |
| | | |
| | | return; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 检查自身血量 |
| | | /// </summary> |
| | | private void CheckHealth() |
| | | { |
| | | if (this.healthVal <= 0.1) |
| | | { |
| | | Die(); |
| | | |
| | | //Debug.Log("删除多余的攻击Agent."); |
| | | } |
| | | } |
| | | |
| | | private void Die() |
| | | { |
| | | // 统一管理器内删除当前的Agent: |
| | | AgentInsManager.instance.removeAgent(this); |
| | | this.Remove(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | protected virtual void Update() |
| | | { |
| | | this.UpdateAction(); |
| | | HandleShieldWall(); |
| | | |
| | | // 处理死亡状态了,不必再移动: |
| | | if (bInDeathAct) return; |
| | | if (bInDeathAct || !CanMove) return; |
| | | |
| | | m_Destination = initNode.GetNextNode(); |
| | | updateAgentPos(Time.deltaTime); |
| | |
| | | // 计算中毒相关. |
| | | if ((poisonTimes > 0) && (poisonHurt > 0)) |
| | | updatePoison(Time.deltaTime); |
| | | } |
| | | |
| | | /// <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> |
| | |
| | | return tmpDis; |
| | | } |
| | | |
| | | protected ChangeMat changeMat; |
| | | /// <summary> |
| | | /// This is a lazy way of caching several components utilised by the Agent |
| | | /// </summary> |
| | |
| | | mAnim = t.GetComponent<Animator>(); |
| | | } |
| | | } |
| | | |
| | | //使用三渲二的方式 |
| | | if (mAnim == null) |
| | | { |
| | | changeMat = GetComponent<ChangeMat>(); |
| | | changeMat?.SetSelf(this.opponentAgent, CheckHealth, Die); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | { |
| | | if (mAnim) |
| | | mAnim.SetBool("GetHit", true); |
| | | else if (changeMat) |
| | | { |
| | | changeMat.SetGetHit(); |
| | | } |
| | | } |
| | | |
| | | public void PlayAttack() |
| | | { |
| | | AudioSourceManager.Ins.Play(AudioEnum.AttackTower); |
| | | if (mAnim) |
| | | mAnim.SetBool("Attack", true); |
| | | else if (changeMat) |
| | | { |
| | | changeMat.SetAttack(); |
| | | } |
| | | } |
| | | |
| | | public override void PlayDeath() |
| | |
| | | if (PoisonParticle != null) |
| | | { |
| | | PoisonParticle.Stop(); |
| | | PoisonParticle.Clear(); |
| | | if (PoisonEndParticle != null) |
| | | PoisonEndParticle.Play(); |
| | | } |
| | | } |
| | | |
| | | if (isSlowDown) |
| | | { |
| | | isSlowDown = false; |
| | | |
| | | if (SlowDownParticle != null) |
| | | { |
| | | SlowDownParticle.Stop(); |
| | | SlowDownParticle.Clear(); |
| | | } |
| | | } |
| | | |
| | | mAnim.SetBool("Die", true); |
| | | // 统一管理器内删除当前的Agent: |
| | | AgentInsManager.instance.removeAgent(this); |
| | | bInDeathAct = true; |
| | | } |
| | | else if (changeMat) |
| | | { |
| | | if (isPoison) |
| | | { |
| | | isPoison = false; |
| | | // 移除Agent身上的中毒特效,并播放一个中毒效果消失的特效 |
| | | if (PoisonParticle != null) |
| | | { |
| | | PoisonParticle.Stop(); |
| | | PoisonParticle.Clear(); |
| | | if (PoisonEndParticle != null) |
| | | PoisonEndParticle.Play(); |
| | | } |
| | | } |
| | | |
| | | if (isSlowDown) |
| | | { |
| | | isSlowDown = false; |
| | | |
| | | if (SlowDownParticle != null) |
| | | { |
| | | SlowDownParticle.Stop(); |
| | | SlowDownParticle.Clear(); |
| | | } |
| | | } |
| | | changeMat.SetDie(); |
| | | // 统一管理器内删除当前的Agent: |
| | | AgentInsManager.instance.removeAgent(this); |
| | | bInDeathAct = true; |
| | | } |
| | | else |
| | | { |
| | | this.Remove(); |