/// <summary> /// 变速倒计时,计时完毕恢复初始速度 /// </summary> /// <param name="_totaltime">倒计时总时间</param> /// <param name="_objTeam">队伍</param> /// <returns></returns> IEnumerator TeamSpeedCountDownRestore(float _totaltime, TeamObj _objTeam) { yield return(new WaitForSeconds(_totaltime)); if (_objTeam) { _objTeam.UpdateTeamNAVSpeed(_objTeam.teamspeed); } }
/// <summary> /// 英雄使用英雄技 /// </summary> /// <param name="_objTeam">目标队伍</param> public void HeroUseSkill(TeamObj _objTeam) { if (!clickSkill) { return; } clickSkill = false; //如果本队伍是工兵,则不适用英雄技 if (teamObj.soldiertype == WorldObj.SoldierType.Worker || teamObj.soldiertype == WorldObj.SoldierType.Tank) { return; } //判断目标队伍距离 if (Vector3.Distance(_objTeam.transform.position, teamObj.transform.position) > WorldObj.SkillDistance) { return; } switch (WorldObj.MatchHero(teamObj.hero).heroskill) { case WorldObj.HeroSkill.none: break; case WorldObj.HeroSkill.IncreaseOwnSpeed: if (_objTeam.nationality == countryObj.nationality) { //急行军倒计时,计时完毕恢复初始速度 _objTeam.UpdateTeamNAVSpeed(WorldObj.IncreaseOwnSpeedCoefficient * _objTeam.GetComponent <NavMeshAgent>().speed); StartCoroutine(TeamSpeedCountDownRestore(WorldObj.IncreaseOwnSpeedTime, _objTeam)); // 英雄技能进入冷却 HeroSkillCoolDown(); } break; case WorldObj.HeroSkill.ReduceEnemySpeed: if (_objTeam.nationality != countryObj.nationality) { //缓慢倒计时,计时完毕恢复初始速度 _objTeam.UpdateTeamNAVSpeed(WorldObj.ReduceEnemySpeedCoefficient * _objTeam.GetComponent <NavMeshAgent>().speed); StartCoroutine(TeamSpeedCountDownRestore(WorldObj.ReduceEnemySpeedTime, _objTeam)); // 英雄技能进入冷却 HeroSkillCoolDown(); } break; case WorldObj.HeroSkill.Disorient: if (_objTeam.nationality != countryObj.nationality) { //迷惑减低军心 _objTeam.UpdateTeamMorale(Mathf.RoundToInt(WorldObj.DisorientCoefficient * _objTeam.GetComponent <TeamObj>().teammorale)); // 英雄技能进入冷却 HeroSkillCoolDown(); } break; case WorldObj.HeroSkill.Encourage: if (_objTeam.nationality == countryObj.nationality) { //鼓舞提升军心 _objTeam.UpdateTeamMorale(Mathf.RoundToInt(WorldObj.EncourageCoefficient * _objTeam.GetComponent <TeamObj>().teammorale)); // 英雄技能进入冷却 HeroSkillCoolDown(); } break; case WorldObj.HeroSkill.Silence: if (_objTeam.nationality != countryObj.nationality) { //保存原技能 HeroObj objHero = WorldObj.MatchHero(_objTeam.hero); WorldObj.HeroSkill originalSkill = objHero.heroskill; //沉默对手 objHero.GiveHeroSkill(WorldObj.HeroSkill.none); //计时结束后恢复对手 StartCoroutine(HeroSkillSilenceCountDownRestore(WorldObj.SilenceTime, objHero, originalSkill)); // 英雄技能进入冷却 HeroSkillCoolDown(); } break; case WorldObj.HeroSkill.Disease: if (_objTeam.nationality != countryObj.nationality) { //瘟疫降低敌方队伍人数 _objTeam.UpdateSoldierNumber(Mathf.RoundToInt(WorldObj.DiseaseCoefficient * _objTeam.GetComponent <TeamObj>().soldiernumber)); // 英雄技能进入冷却 HeroSkillCoolDown(); } break; default: break; } }