| | |
| | | /// <param name="damage"></param> |
| | | public void poisonAgent(float damage, int attid) |
| | | { |
| | | if (this.poisonTimes >= 1) return; |
| | | if (poisonTimes >= 1) return; |
| | | |
| | | if (!isPoison) |
| | | { |
| | |
| | | PoisonParticle.Play(); |
| | | } |
| | | |
| | | this.poisonTimes++; |
| | | this.poisonAttid = attid; |
| | | this.poisonHurt = (float)Math.Floor(this.configuration.maxHealth / 20.0f); |
| | | this.timeToPoisonHurt = 1.0f; |
| | | poisonTimes++; |
| | | poisonAttid = attid; |
| | | poisonHurt = (float)Math.Floor(configuration.maxHealth / 20.0f); |
| | | timeToPoisonHurt = 1.0f; |
| | | } |
| | | |
| | | public bool bInPoison { get { return this.poisonHurt > 0; } } |
| | | public bool bInPoison { get { return poisonHurt > 0; } } |
| | | |
| | | /// <summary> |
| | | /// 处理中毒相关的数据 |
| | |
| | | /// <param name="time"></param> |
| | | protected void updatePoison(float time) |
| | | { |
| | | this.timeToPoisonHurt -= time; |
| | | if (this.timeToPoisonHurt <= 0) |
| | | timeToPoisonHurt -= time; |
| | | if (timeToPoisonHurt <= 0) |
| | | { |
| | | Vector3 backPos = this.transform.position; |
| | | this.TakeDamage(poisonHurt, this.transform.position, null, poisonAttid); |
| | | Vector3 backPos = transform.position; |
| | | TakeDamage(poisonHurt, transform.position, null, poisonAttid); |
| | | // if ((poisonHurt > 0) && (!opponentAgent)) |
| | | // { |
| | | // if (GameUI.instanceExists) |
| | |
| | | |
| | | public bool bInDeathState |
| | | { |
| | | get { return this.bInDeathAct; } |
| | | get { return bInDeathAct; } |
| | | set { bInDeathAct = value; } |
| | | } |
| | | |
| | |
| | | |
| | | public NavMeshAgent navMeshAgent |
| | | { |
| | | get { return this.m_NavMeshAgent; } |
| | | get { return m_NavMeshAgent; } |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | |
| | | public float distanceToDest |
| | | { |
| | | get { return this.m_DisToDestination; } |
| | | get { return m_DisToDestination; } |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <param name="coinDrop"></param> 设置当前小怪的金币掉落数据 |
| | | public void SetAgentData(float health, float moveSpeed = -1, int coinDrop = 0) |
| | | { |
| | | this.configuration.maxHealth = health; |
| | | this.configuration.startingHealth = health; |
| | | this.configuration.SetMaxHealth(health); |
| | | this.configuration.Init(); |
| | | this.configuration.SetHealth(health); |
| | | configuration.maxHealth = health; |
| | | configuration.startingHealth = health; |
| | | configuration.SetMaxHealth(health); |
| | | configuration.Init(); |
| | | configuration.SetHealth(health); |
| | | |
| | | // 只有在速度大于零的情况下才会设置. |
| | | if (moveSpeed > 0) |
| | |
| | | mLootDrop.lootDropped = coinDrop; |
| | | |
| | | mAgentData.speed = fMoveSpeed; |
| | | mAgentData.hp = this.configuration.maxHealth; |
| | | mAgentData.hp = configuration.maxHealth; |
| | | |
| | | // |
| | | mStartYVal = this.transform.position.y; |
| | | mStartZVal = this.transform.position.z; |
| | | mStartYVal = transform.position.y; |
| | | mStartZVal = transform.position.z; |
| | | |
| | | speedSlowRate = 0.0f; |
| | | poisonHurt = 0; |
| | |
| | | // 需要设置移动的目标Node. |
| | | m_NextNode = m_CurrentNode.GetNextNode(); |
| | | |
| | | this.MoveToNode(); |
| | | MoveToNode(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | m_NavMeshAgent.enabled = false; |
| | | |
| | | // 必须要重置数据,不然会有一系列的小Bug. |
| | | this.m_CurrentNode = null; |
| | | m_CurrentNode = null; |
| | | m_NextNode = null; |
| | | |
| | | this.liveID = this.liveID + 1; |
| | | liveID = liveID + 1; |
| | | |
| | | speedSlowRate = 0.0f; |
| | | poisonHurt = 0; |
| | |
| | | if (WoodAimCount > 0) |
| | | WoodAimCount = 0; |
| | | StopWoodAimEffect(); |
| | | //this.SetTargetableMatColor(Color.white); |
| | | //SetTargetableMatColor(Color.white); |
| | | |
| | | // 删除当前停止特效和状态. |
| | | if (MoveStopTime > 0) |
| | |
| | | } |
| | | |
| | | // 停止DoTween动画. |
| | | this.transform.DOKill(); |
| | | transform.DOKill(); |
| | | |
| | | Poolable.TryPool(gameObject); |
| | | } |
| | |
| | | |
| | | // |
| | | // 设置一个DOTween队列,让场景内刷出来的Agent有一个变大淡出的效果,此时是无敌效果加持. |
| | | this.configuration.bInvincible = true; |
| | | mDefaultScale = this.transform.localScale; |
| | | configuration.bInvincible = true; |
| | | mDefaultScale = transform.localScale; |
| | | Sequence agentTweenSeq = DOTween.Sequence(); |
| | | var ss = mDefaultScale * 0.3f; |
| | | this.transform.localScale = this.transform.localScale * 0.3f; |
| | | Tweener agScale = this.transform.DOScale(mDefaultScale, 0.3f); |
| | | transform.localScale = transform.localScale * 0.3f; |
| | | Tweener agScale = transform.DOScale(mDefaultScale, 0.3f); |
| | | agentTweenSeq.Append(agScale); |
| | | agentTweenSeq.AppendCallback(beDamageStart); |
| | | |
| | | this.nodeMoveUpdate = false; |
| | | nodeMoveUpdate = false; |
| | | |
| | | // 获取移动速度 |
| | | fMoveSpeed = this.m_NavMeshAgent.speed / 2.0f; |
| | | fMoveSpeed = m_NavMeshAgent.speed / 2.0f; |
| | | } |
| | | |
| | | protected void beDamageStart() |
| | | { |
| | | this.configuration.bInvincible = false; |
| | | configuration.bInvincible = false; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | public void ResetAgentToInitialPos() |
| | | { |
| | | if (!this.initNode) return; |
| | | if (!initNode) return; |
| | | |
| | | Vector3 initPos = this.initNode.GetRandomPointInNodeArea(); |
| | | Vector3 initPos = initNode.GetRandomPointInNodeArea(); |
| | | transform.position = initPos; |
| | | ResetPositionData(); |
| | | |
| | | this.SetNode(initNode, -1); |
| | | SetNode(initNode, -1); |
| | | |
| | | // 更新AgentMgr,确保不再攻击回到原点的Agent. |
| | | AgentInsManager.instance.updateInsMgrPos(this.opponentAgent); |
| | | AgentInsManager.instance.updateInsMgrPos(opponentAgent); |
| | | |
| | | } |
| | | |
| | |
| | | if (configuration.bInvincible) return; |
| | | |
| | | // 只有处于非PosEffect状态才可以有这个状态. |
| | | var posResetEff = this.GetComponent<AgentResetPosEffect>(); |
| | | var posResetEff = GetComponent<AgentResetPosEffect>(); |
| | | if (posResetEff == null) |
| | | { |
| | | posResetEff = this.gameObject.AddComponent<AgentResetPosEffect>(); |
| | | posResetEff = gameObject.AddComponent<AgentResetPosEffect>(); |
| | | |
| | | // 初始化当前的PosResetEffect |
| | | posResetEff.Initialize(3, AgentInsManager.instance.posResetFx); |
| | |
| | | return; |
| | | } |
| | | |
| | | if (this.fMoveSpeed == 0) |
| | | if (fMoveSpeed == 0) |
| | | { |
| | | Debug.Log("当前的移动为零:" + fMoveSpeed); |
| | | return; |
| | |
| | | // 根据是否到达一个结点来进行不同的处理 |
| | | if (swithNode) |
| | | { |
| | | this.MoveToNextNode(m_NextNode); |
| | | MoveToNextNode(m_NextNode); |
| | | } |
| | | else |
| | | { |
| | | // Y值插值. |
| | | float lerpVal = (curPos.z - mStartZVal) / (m_Destination.transform.position.z - mStartZVal); |
| | | if (!this.opponentAgent) |
| | | if (!opponentAgent) |
| | | // curPos.y = mStartYVal + lerpVal * 60f; |
| | | curPos.y = mStartYVal; |
| | | m_NavMeshAgent.transform.position = curPos; |
| | |
| | | /// </summary> |
| | | protected virtual void LateUpdate() |
| | | { |
| | | this.UpdateAction(); |
| | | UpdateAction(); |
| | | HandleShieldWall(); |
| | | |
| | | // 处理死亡状态了,不必再移动: |
| | |
| | | updateAgentPos(Time.deltaTime); |
| | | |
| | | // 计算离目标的距离,非最终距离,只用于比较大小 |
| | | this.m_DisToDestination = this.GetDisToDestination(); |
| | | m_DisToDestination = GetDisToDestination(); |
| | | |
| | | // 计算中毒相关. |
| | | if ((poisonTimes > 0) && (poisonHurt > 0)) |
| | |
| | | { |
| | | /* // 设置最大的Z值,确保按路线移动 |
| | | Vector3 pos = m_NavMeshAgent.transform.position; |
| | | if (this.m_PositiveZ) |
| | | if (m_PositiveZ) |
| | | { |
| | | if (pos.z > m_ZMaxValue) |
| | | { |
| | |
| | | } |
| | | } |
| | | // 设置X值的限制,确保按路线移动 |
| | | if(this.m_PositiveX) |
| | | if(m_PositiveX) |
| | | { |
| | | if( pos.x > m_XMaxValue) |
| | | { |
| | |
| | | tmpDis += NODE_DIS; |
| | | tmpNode = tmpNode.GetNextNode(); |
| | | } |
| | | Vector3 tpos = this.position; |
| | | Vector3 tpos = position; |
| | | tpos.y = mStartYVal; |
| | | tmpDis += Vector3.Distance(tpos, this.m_Destination.transform.position); |
| | | tmpDis += Vector3.Distance(tpos, m_Destination.transform.position); |
| | | |
| | | return tmpDis; |
| | | } |