using System.Collections.Generic;
|
using vnxbqy.UI;
|
|
using UnityEngine;
|
|
public abstract class HeroAI_Data { }
|
|
public abstract class HeroAI_Base
|
{
|
public static byte stopReason = 0;
|
|
private SkillModel m_SkillModel;
|
private SkillModel skillModel
|
{
|
get { return m_SkillModel ?? (m_SkillModel = ModelCenter.Instance.GetModel<SkillModel>()); }
|
}
|
|
public abstract bool Condition();
|
public abstract void Enter();
|
public abstract void Update();
|
public abstract void Exit();
|
public abstract bool IsOver();
|
|
protected int xpSkillID = 0;
|
|
protected Skill DecideUserSkill(int[] skillList = null, int priorSkillId = -1)
|
{
|
GA_Hero _hero = PlayerDatas.Instance.hero;
|
if (_hero == null || !_hero.CanCastSkill())
|
{
|
return null;
|
}
|
|
Skill _skill = null;
|
|
if (priorSkillId >= 0)
|
{
|
if (CanCast(priorSkillId, true))
|
{
|
_skill = _hero.SkillMgr.Get(priorSkillId);
|
if (_skill != null)
|
{
|
return _skill;
|
}
|
}
|
}
|
|
if (skillList != null)
|
{
|
// 判断是否需要使用哪个攻击技能
|
_skill = CanCast(skillList);
|
}
|
|
if (_skill != null)
|
{
|
return _skill;
|
}
|
|
if (_hero.CanCommonAtk())
|
{
|
int _index = _hero.nextComAtkIndex;
|
if (_index == -1)
|
{
|
_index = 0;
|
}
|
int _comSkillID = _hero.GetCommonSkillID(_index);
|
|
return _hero.SkillMgr.Get(_comSkillID);
|
}
|
|
return null;
|
}
|
|
protected Skill CanCast(int[] skillList)
|
{
|
GA_Hero _hero = PlayerDatas.Instance.hero;
|
|
int _chkSkillID = -1;
|
for (int i = 0; i < skillList.Length; ++i)
|
{
|
_chkSkillID = SkillHelper.Instance.GetSkillID(skillList[i]);
|
|
if (CanCast(_chkSkillID))
|
{
|
if(ArenaManager.IsArenaClientNotMirrorFight)
|
{
|
bool bWork = true;
|
for(int j = 0;j < GeneralDefine.WorkNotSkills.Length;j++)
|
{
|
if (_chkSkillID == GeneralDefine.WorkNotSkills[j])
|
bWork = false;
|
}
|
if(bWork)
|
return _hero.SkillMgr.Get(_chkSkillID);
|
}
|
else
|
{
|
return _hero.SkillMgr.Get(_chkSkillID);
|
}
|
|
}
|
}
|
|
return null;
|
}
|
|
protected bool CanCastActiveUse(int skillID)
|
{
|
GA_Hero _hero = PlayerDatas.Instance.hero;
|
var _skill = _hero.SkillMgr.Get(skillID);
|
|
// 获取英雄真实拥有的技能
|
Dictionary<int, PlayerSkillData> _heroSkills = PlayerDatas.Instance.skill.GetAllSkill();
|
|
bool _has = false;
|
foreach (var _skillData in _heroSkills.Values)
|
{
|
if (_skillData.skillCfg.SkillTypeID == _skill.skillInfo.config.SkillTypeID)
|
{
|
_has = true;
|
break;
|
}
|
}
|
|
if (!_has)
|
{
|
return false;
|
}
|
|
if (StatusMgr.Instance.IsExist(_hero.ServerInstID, skillID))
|
{
|
return false;
|
}
|
|
if (!_skill.IsValid())
|
{
|
return false;
|
}
|
|
return true;
|
}
|
|
protected bool CanCast(int skillID, bool userClick = false)
|
{
|
if (!CanCastActiveUse(skillID))
|
{
|
return false;
|
}
|
|
bool _canCast = true;
|
|
bool _forceCast = false;
|
|
SkillHelper.EffectValue _effectValue;
|
if (SkillHelper.Instance.TryGetExpertSkillEvByMainSkillID(skillID, 4093, out _effectValue))
|
{
|
_forceCast = true;
|
}
|
var _skillConfig = SkillConfig.Get(skillID);
|
// 判断是否是被封禁的技能
|
if (!StatusMgr.Instance.CanAttack(PlayerDatas.Instance.PlayerId, _skillConfig) && !_forceCast)
|
{
|
_canCast = false;
|
}
|
|
if (skillID == xpSkillID)
|
{
|
GA_Hero _hero = PlayerDatas.Instance.hero;
|
|
if ((!skillModel.AutoUseXp()
|
|| GeneralDefine.NoXpDungeons.Contains(PlayerDatas.Instance.baseData.MapID)
|
|| (_hero.SelectTarget != null && _hero.SelectTarget is GActorPlayerBase)) && !userClick)
|
{
|
_canCast = false;
|
}
|
}
|
|
return _canCast;
|
}
|
|
protected GActorFight DecideAttackTarget(Vector3 searchCenter, float range, int lockNpcID = -1)
|
{
|
GA_Hero _hero = PlayerDatas.Instance.hero;
|
GActorFight _target = _hero.SelectTarget as GActorFight;
|
|
if (_target == null || !_target.CanAtked() || _target.ActorInfo.serverDie)
|
{
|
_target = GAMgr.Instance.FindAtkTarget(searchCenter, range, 360, lockNpcID);
|
}
|
|
if (_target != null && lockNpcID != -1)
|
{
|
var _npcFight = _target as GActorNpcFight;
|
if (_npcFight != null)
|
{
|
if (_npcFight.NpcConfig.NPCID != lockNpcID)
|
{
|
_target = GAMgr.Instance.FindAtkTarget(searchCenter, range, 360, lockNpcID);
|
}
|
}
|
}
|
|
return _target;
|
}
|
|
private PackModel m_PlayerBackModel;
|
private PackModel PlayerBackModel
|
{
|
get
|
{
|
return m_PlayerBackModel ?? (m_PlayerBackModel = ModelCenter.Instance.GetModel<PackModel>());
|
}
|
}
|
|
protected bool WaitForPickup()
|
{
|
GA_Hero _hero = PlayerDatas.Instance.hero;
|
DropItemManager.DropObject _obj = null;
|
bool _needPickupSelf = true;
|
Vector3 _destPosition = _hero.Pos;
|
|
DropItem _item = null;
|
if (_needPickupSelf = ClientDropItemUtility.Instance.TryGetDropItem(out _item))
|
{
|
if (_needPickupSelf)
|
{
|
_destPosition = _item.transform.position;
|
}
|
}
|
|
if (!_needPickupSelf)
|
{
|
if (_needPickupSelf = DropItemManager.HandupTryGetHeroItem(out _obj))
|
{
|
// 有掉落物
|
// 是否是强制守护不能拾取的
|
if (_obj.ownerType != 7)
|
{
|
if (DungeonOpenTimeConfig.Has(PlayerDatas.Instance.baseData.MapID)) // 是副本
|
{
|
var _dungeonOpenTime = DungeonOpenTimeConfig.Get(PlayerDatas.Instance.baseData.MapID);
|
if (_dungeonOpenTime.GuardPick == 1)// 守护可以拾取
|
{
|
var _singleModel = PlayerBackModel.GetSinglePack(PackType.Equip);
|
if (_singleModel != null)
|
{
|
// 如果有守护
|
var _equipIndex = EquipSet.ClientPlaceToServerPlace(new Int2(0, (int)RoleEquipType.Guard));
|
var _guard = PlayerBackModel.GetItemByIndex(PackType.Equip, _equipIndex);
|
if (_guard != null // 有守护
|
&& GeneralDefine.GuardianPickUpID.Contains(_guard.itemId))// 守护有拾取功能
|
{
|
_needPickupSelf = false;
|
}
|
}
|
}
|
}
|
else
|
{
|
var _singleModel = PlayerBackModel.GetSinglePack(PackType.Equip);
|
if (_singleModel != null)
|
{
|
// 如果有守护
|
var _equipIndex = EquipSet.ClientPlaceToServerPlace(new Int2(0, (int)RoleEquipType.Guard));
|
var _guard = PlayerBackModel.GetItemByIndex(PackType.Equip, _equipIndex);
|
if (_guard != null // 有守护
|
&& GeneralDefine.GuardianPickUpID.Contains(_guard.itemId))// 守护有拾取功能
|
{
|
_needPickupSelf = false;
|
}
|
}
|
}
|
}
|
|
if (_needPickupSelf)
|
{
|
_destPosition = _obj.dropItem.transform.position;
|
}
|
}
|
}
|
|
if (_needPickupSelf)
|
{
|
_hero.StopRush();
|
float _chkDistSqrt = MathUtility.DistanceSqrtXZ(_hero.Pos, _destPosition);
|
if (_chkDistSqrt > 0.5f)
|
{
|
_hero.MoveToPosition(_destPosition);
|
}
|
return true;
|
}
|
return false;
|
}
|
|
public static bool IsSkillNeedMove(int tag, E_SkillType skillType)
|
{
|
E_SkillCastTarget _targetType = (E_SkillCastTarget)(tag / 10);
|
E_SkillCastType _castType = (E_SkillCastType)(tag % 10);
|
|
if ((_targetType == E_SkillCastTarget.None
|
|| _targetType == E_SkillCastTarget.Self
|
|| _targetType == E_SkillCastTarget.SelfAndFriend
|
|| _castType == E_SkillCastType.None)
|
&& (skillType != E_SkillType.Attack))
|
{
|
return false;
|
}
|
else
|
{
|
return true;
|
}
|
}
|
}
|