示例#1
0
        /// <summary>
        /// 锁住和解锁被建造的队伍模型
        /// </summary>
        /// <param name="_teamObj">队伍模型</param>
        /// <param name="_lock">锁住,解锁</param>
        void LockUnLockBuildingTeam(TeamObj _teamObj, bool _lock)
        {
            _teamObj.locking = _lock;
            if (_teamObj.teamHealthCanvas)
            {
                //隐藏或恢复血条
                _teamObj.teamHealthCanvas.gameObject.SetActive(!_lock);
            }

            //空军在解锁时禁用导航组件
            if (_teamObj.GetComponent <NavMeshAgent>() && _teamObj.features.Contains(WorldObj.TeamFeature.AirForce))
            {
                _teamObj.GetComponent <NavMeshAgent>().enabled = _lock;
            }
            //暂停或启动所有动画
            Animator[] modelAnimators = _teamObj.GetComponentsInChildren <Animator>();
            foreach (var item in modelAnimators)
            {
                item.enabled = !_lock;
            }
            Animation[] modelAnimations = _teamObj.GetComponentsInChildren <Animation>();
            foreach (var item in modelAnimations)
            {
                item.enabled = !_lock;
            }
        }
示例#2
0
 /// <summary>
 /// 锁住和解锁队伍
 /// </summary>
 /// <param name="_lock"></param>
 void LockUnLockTeam(TeamObj _teamObj, bool _lock)
 {
     _teamObj.GetComponent <NavMeshAgent>().SetDestination(_teamObj.transform.position);
     _teamObj.PlayAnimator(WorldObj.AnimatorAction.Victory, !_lock);
     _teamObj.PlayAnimator(WorldObj.AnimatorAction.Work, _lock);
     _teamObj.GetComponent <NavMeshAgent>().isStopped = _lock;
 }
示例#3
0
        /// <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;
            }
        }