using Snxxz.UI;
|
using TableConfig;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.Events;
|
using System.Collections;
|
|
public abstract class GActorPlayerBase : GActorFight
|
{
|
public static UnityAction<bool> onShowEffect;
|
private bool m_LoadDefaultHorse;
|
protected struct EquipInfo
|
{
|
public uint itemID;
|
public int suitID;
|
public int suitLevel;
|
}
|
|
protected Material m_WingMaterial;
|
protected Material m_HorseMaterial;
|
protected Material m_WeaponMaterial;
|
protected Material m_SecondaryMaterial;
|
|
public int EquipSuitID { get; private set; }
|
|
private E_MovingState m_MovingState;
|
public E_MovingState MovingState
|
{
|
get { return m_MovingState; }
|
private set
|
{
|
m_MovingState = value;
|
// Debug.LogFormat("设置 {0} 的移动状态为 {1}", ServerInstID, value);
|
}
|
}
|
|
private ActorShadowCaster m_ShadowCaster = null;
|
private SFXController m_Shadow;
|
protected HeadUpName m_HeadUpName = null;
|
|
private int m_HorseActionType = 0;
|
|
public JobSetupConfig JobSetup { get; protected set; }
|
|
public override int NextAction
|
{
|
get
|
{
|
if (!m_ClothesAnimator)
|
{
|
return -1;
|
}
|
return m_ClothesAnimator.GetInteger(GAStaticDefine.Param_Action);
|
}
|
|
set
|
{
|
if (m_ClothesAnimator)
|
{
|
m_ClothesAnimator.SetInteger(GAStaticDefine.Param_Action, value);
|
}
|
}
|
}
|
|
public int nextComAtkIndex = -1;
|
|
public void SwitchHeadNameBindNode(bool castingSkill)
|
{
|
// 角色被隐藏状态下不执行头顶名称切换逻辑
|
if (!ShowOrHide)
|
{
|
return;
|
}
|
|
if (m_HeadUpName)
|
{
|
if (castingSkill)
|
{
|
m_HeadUpName.target = MP_Name1;
|
}
|
else
|
{
|
m_HeadUpName.target = MP_Name;
|
}
|
}
|
}
|
|
protected override void OnInit(GameNetPackBasic package)
|
{
|
ActorType = GameObjType.gotPlayer;
|
ClothesItemID = uint.MaxValue;
|
HorseID = uint.MaxValue;
|
WeaponItemID = uint.MaxValue;
|
SecondaryID = uint.MaxValue;
|
WingItemID = uint.MaxValue;
|
m_SuitLevel = 0;
|
MovingState = E_MovingState.Normal;
|
|
SystemSetting.Instance.qualityLevelChangeEvent += OnGameQualityChange;
|
base.OnInit(package);
|
}
|
|
protected override void OnUnit()
|
{
|
ShowOrHideModel(true);
|
|
GameObject _prefab = null;
|
|
if (m_HorseModel)
|
{
|
HorseConfig _horseConfig = ConfigManager.Instance.GetTemplate<HorseConfig>((int)HorseID);
|
_prefab = InstanceResourcesLoader.LoadModelRes(_horseConfig.Model);
|
GameObjectPoolManager.Instance.ReleaseGameObject(_prefab, m_HorseModel);
|
m_HorseModel = null;
|
|
if (m_HorseAnimator)
|
{
|
m_HorseAnimator.SetInteger(GAStaticDefine.Param_Action, 0);
|
m_HorseAnimator.enabled = false;
|
m_HorseAnimator = null;
|
}
|
|
m_HorseBindNode = null;
|
}
|
|
if (null != m_Guard)
|
{
|
m_Guard.UnInit();
|
m_Guard = null;
|
}
|
|
int _resID = 0;
|
ItemConfig _itemConfig = null;
|
|
if (m_ClothesModel)
|
{
|
_resID = JobSetup.BaseEquip[0];
|
if (ClothesItemID != 0)
|
{
|
_itemConfig = ConfigManager.Instance.GetTemplate<ItemConfig>((int)ClothesItemID);
|
_resID = _itemConfig.ChangeOrd;
|
}
|
|
if (TryRelease(_resID, m_ClothesModel))
|
{
|
m_ClothesModel = null;
|
|
if (m_ClothesAnimator)
|
{
|
m_ClothesAnimator.SetInteger(GAStaticDefine.Param_MoveState, (int)E_MovingState.Normal);
|
m_ClothesAnimator.enabled = false;
|
m_ClothesAnimator = null;
|
}
|
}
|
}
|
|
if (m_WeaponModel)
|
{
|
_resID = JobSetup.BaseEquip[1];
|
if (WeaponItemID != 0)
|
{
|
_itemConfig = ConfigManager.Instance.GetTemplate<ItemConfig>((int)WeaponItemID);
|
_resID = _itemConfig.ChangeOrd;
|
}
|
|
if (TryRelease(_resID, m_WeaponModel))
|
{
|
m_WeaponModel = null;
|
}
|
}
|
|
if (m_SecondaryModel)
|
{
|
_resID = JobSetup.BaseEquip[2];
|
if (SecondaryID != 0)
|
{
|
_itemConfig = ConfigManager.Instance.GetTemplate<ItemConfig>((int)SecondaryID);
|
_resID = _itemConfig.ChangeOrd;
|
}
|
|
if (TryRelease(_resID, m_SecondaryModel))
|
{
|
m_SecondaryModel = null;
|
}
|
}
|
|
if (m_WingModel)
|
{
|
if (WingItemID != 0)
|
{
|
_itemConfig = ConfigManager.Instance.GetTemplate<ItemConfig>((int)WingItemID);
|
_resID = _itemConfig.ChangeOrd;
|
}
|
|
if (TryRelease(_resID, m_WingModel))
|
{
|
m_WingModel = null;
|
|
if (m_WingAnimator)
|
{
|
m_WingAnimator.enabled = false;
|
m_WingAnimator = null;
|
}
|
|
}
|
}
|
|
UnloadSuitSFX();
|
ReleaseLifeBar();
|
ReleaseName();
|
ReleaseShadow();
|
m_IsRushing = false;
|
if (m_RushEffect)
|
{
|
SFXPlayUtility.Instance.Release(m_RushEffect);
|
m_RushEffect = null;
|
}
|
JobSetup = null;
|
|
SystemSetting.Instance.qualityLevelChangeEvent -= OnGameQualityChange;
|
|
base.OnUnit();
|
}
|
|
public abstract override void Destroy();
|
|
protected override void OnLateUpdate()
|
{
|
UpdateRush();
|
}
|
|
#region 装备穿戴相关
|
|
private GameObject m_ClothesModel;
|
private GameObject m_WeaponModel;
|
private GameObject m_SecondaryModel;
|
private GameObject m_WingModel;
|
private GameObject m_HorseModel;
|
private GA_Guard m_Guard;
|
|
private List<SFXController> m_SuitEffect = new List<SFXController>();
|
|
private Transform m_HorseBindNode;
|
|
protected uint ClothesItemID { get; private set; }
|
protected uint HorseID { get; private set; }
|
protected uint WeaponItemID { get; private set; }
|
protected uint SecondaryID { get; private set; }
|
protected uint WingItemID { get; private set; }
|
protected uint GuardID { get; private set; }
|
|
protected byte m_SuitLevel;// 套装等级
|
|
private Animator m_ClothesAnimator;
|
private Animator m_WingAnimator;
|
private Animator m_HorseAnimator;
|
|
public void SwitchRealm(int _realm)
|
{
|
if (m_HeadUpName == null)
|
{
|
return;
|
}
|
|
m_HeadUpName.SetPlayerRealm(_realm);
|
}
|
|
public void SwitchTitle(uint titleID)
|
{
|
if (m_HeadUpName == null)
|
{
|
return;
|
}
|
|
m_HeadUpName.SetTitle(titleID);
|
}
|
|
public void SwitchAlliance(string allianceName)
|
{
|
if (m_HeadUpName == null)
|
{
|
return;
|
}
|
|
m_HeadUpName.SetAlliance(allianceName);
|
}
|
|
public void SwitchBossBelong(bool belong)
|
{
|
if (m_HeadUpName == null)
|
{
|
return;
|
}
|
|
m_HeadUpName.SetBossDropout(belong);
|
}
|
|
public virtual void SwitchRedName(bool on)
|
{
|
if (m_HeadUpName == null)
|
{
|
return;
|
}
|
|
m_HeadUpName.SetRedName(on);
|
}
|
|
public void SetFairyLeagueHeadUp(bool on)
|
{
|
if (m_HeadUpName == null)
|
{
|
return;
|
}
|
|
m_HeadUpName.SetFairyLeague(on, ActorInfo.faction);
|
}
|
|
public virtual void SwitchYellowName(bool on)
|
{
|
if (m_HeadUpName == null)
|
{
|
return;
|
}
|
|
m_HeadUpName.SetYellowName(on);
|
}
|
|
public virtual void SwitchGrayName(bool on)
|
{
|
if (m_HeadUpName == null)
|
{
|
return;
|
}
|
|
m_HeadUpName.SetGrayName(on);
|
}
|
|
public void SwitchWeapon(uint itemID)
|
{
|
// 相同的装备, 不做处理
|
if (itemID == WeaponItemID)
|
{
|
return;
|
}
|
|
int _resID = JobSetup.BaseEquip[1];
|
|
ItemConfig _itemConfig = null;
|
|
// > 0, 默认判断为穿上
|
if (itemID > 0)
|
{
|
_itemConfig = ConfigManager.Instance.GetTemplate<ItemConfig>((int)itemID);
|
|
if (_itemConfig == null || _itemConfig.ChangeOrd == 0)
|
{
|
Debug.LogWarningFormat("SwitchWeapon() => 需要换装的道具ID: {0} 不存在或者没有正确的换装ID, 请 <color=red>@吕超</color>", itemID);
|
return;
|
}
|
|
_resID = _itemConfig.ChangeOrd;
|
}
|
|
// 判断是否之前已经穿了
|
// 穿了就先脱掉
|
if (m_WeaponModel)
|
{
|
if (WeaponItemID == 0)
|
{
|
if (!TryRelease(JobSetup.BaseEquip[1], m_WeaponModel))
|
{
|
return;
|
}
|
}
|
else
|
{
|
|
if (!TryRelease(WeaponItemID, m_WeaponModel))
|
{
|
return;
|
}
|
}
|
|
m_WeaponModel = null;
|
}
|
|
// 穿上新的
|
if (itemID > 0 && _itemConfig != null)
|
{
|
GameObject _prefab = InstanceResourcesLoader.LoadModelRes(_itemConfig.ChangeOrd);
|
|
if (!_prefab)
|
{
|
itemID = 0;
|
if (!TryRequest(JobSetup.BaseEquip[1], ref m_WeaponModel))
|
{
|
return;
|
}
|
}
|
else
|
{
|
if (!TryRequest(itemID, ref m_WeaponModel))
|
{
|
return;
|
}
|
}
|
}
|
else
|
{
|
if (!TryRequest(_resID, ref m_WeaponModel))
|
{
|
return;
|
}
|
}
|
|
// 替换当前衣服上的武器
|
Transform _weaponNode = m_ClothesModel.transform.GetChildTransformDeeply(GAStaticDefine.WeaponBindBoneName);
|
m_WeaponModel.transform.SetParent(_weaponNode);
|
m_WeaponModel.transform.localPosition = Vector3.zero;
|
m_WeaponModel.transform.localRotation = Quaternion.identity;
|
|
WeaponItemID = itemID;
|
|
OnPutonWeapon(WeaponItemID, m_WeaponModel);
|
|
MP_Weapon = m_WeaponModel.transform;
|
|
RequestShadow();
|
}
|
|
public void SwitchSecondary(uint itemID)
|
{
|
// 相同的装备, 不做处理
|
if (itemID == SecondaryID)
|
{
|
return;
|
}
|
|
int _resID = JobSetup.BaseEquip[2];
|
|
ItemConfig _itemConfig = null;
|
|
// > 0, 默认判断为穿上
|
if (itemID > 0)
|
{
|
_itemConfig = ConfigManager.Instance.GetTemplate<ItemConfig>((int)itemID);
|
|
if (_itemConfig == null || _itemConfig.ChangeOrd == 0)
|
{
|
Debug.LogWarningFormat("SwitchSecondary() => 需要换装的道具ID: {0} 不存在或者没有正确的换装ID, 请 <color=red>@吕超</color>", itemID);
|
return;
|
}
|
|
_resID = _itemConfig.ChangeOrd;
|
}
|
|
|
// 判断是否之前已经穿了
|
// 穿了就先脱掉
|
if (m_SecondaryModel)
|
{
|
if (SecondaryID == 0)
|
{
|
if (!TryRelease(JobSetup.BaseEquip[2], m_SecondaryModel))
|
{
|
return;
|
}
|
}
|
else
|
{
|
if (!TryRelease(SecondaryID, m_SecondaryModel))
|
{
|
return;
|
}
|
}
|
m_SecondaryModel = null;
|
}
|
|
// 穿上新的
|
if (itemID > 0 && _itemConfig != null)
|
{
|
var _prefab = InstanceResourcesLoader.LoadModelRes(_itemConfig.ChangeOrd);
|
if (!_prefab)
|
{
|
itemID = 0;
|
if (!TryRequest(JobSetup.BaseEquip[2], ref m_SecondaryModel))
|
{
|
return;
|
}
|
}
|
else
|
{
|
if (!TryRequest(itemID, ref m_SecondaryModel))
|
{
|
return;
|
}
|
}
|
}
|
else
|
{
|
if (!TryRequest(_resID, ref m_SecondaryModel))
|
{
|
return;
|
}
|
}
|
|
// 替换当前衣服上的武器
|
Transform _secondaryNode = m_ClothesModel.transform.GetChildTransformDeeply(GAStaticDefine.SecondaryBindBoneName[JobSetup.Job - 1]);
|
m_SecondaryModel.transform.SetParent(_secondaryNode);
|
m_SecondaryModel.transform.localPosition = Vector3.zero;
|
m_SecondaryModel.transform.localRotation = Quaternion.identity;
|
|
SecondaryID = itemID;
|
|
OnPutonSecondary(SecondaryID, m_SecondaryModel);
|
|
RequestShadow();
|
}
|
|
public void SwitchWing(uint itemID)
|
{ // 相同的装备, 不做处理
|
if (itemID == WingItemID)
|
{
|
return;
|
}
|
|
// > 0, 默认判断为穿上
|
if (itemID > 0)
|
{
|
ItemConfig _itemConfig;
|
|
_itemConfig = ConfigManager.Instance.GetTemplate<ItemConfig>((int)itemID);
|
|
if (_itemConfig == null || _itemConfig.ChangeOrd == 0)
|
{
|
Debug.LogWarningFormat("PutonWing() => 需要换装的道具ID: {0} 不存在或者没有正确的换装ID, 请 <color=red>@吕超</color>", itemID);
|
return;
|
}
|
|
// 判断是否之前已经穿了
|
// 穿了就先脱掉
|
if (m_WingModel)
|
{
|
if (!TryRelease(WingItemID, m_WingModel))
|
{
|
return;
|
}
|
|
m_WingModel = null;
|
m_WingAnimator = null;
|
}
|
|
// 穿上新的
|
if (!TryRequest(itemID, ref m_WingModel))
|
{
|
return;
|
}
|
|
// 替换当前衣服上的翅膀
|
Transform _wingNode = m_ClothesModel.transform.GetChildTransformDeeply(GAStaticDefine.WingBindBoneName);
|
m_WingModel.transform.SetParent(_wingNode);
|
m_WingModel.transform.localPosition = Vector3.zero;
|
m_WingModel.transform.localRotation = Quaternion.identity;
|
|
OnPutonWing(itemID, m_WingModel);
|
|
// 处理动画相关
|
m_WingAnimator = m_WingModel.GetComponent<Animator>();
|
m_WingAnimator.enabled = true;
|
m_WingAnimator.Play(GAStaticDefine.State_IdleHash);
|
// 如果当前没有骑马
|
if (MovingState == E_MovingState.Normal)
|
{
|
MovingState = E_MovingState.Fly;
|
m_ClothesAnimator.SetInteger(GAStaticDefine.Param_MoveState, (int)E_MovingState.Fly);
|
}
|
}
|
else
|
{
|
// 这里是脱下逻辑
|
if (m_WingModel)
|
{
|
if (!TryRelease(WingItemID, m_WingModel))
|
{
|
return;
|
}
|
|
m_WingModel = null;
|
if (m_WingAnimator)
|
{
|
m_WingAnimator.enabled = false;
|
m_WingAnimator = null;
|
}
|
}
|
|
if (MovingState == E_MovingState.Fly)
|
{
|
MovingState = E_MovingState.Normal;
|
m_ClothesAnimator.SetInteger(GAStaticDefine.Param_MoveState, (int)E_MovingState.Normal);
|
}
|
}
|
|
if (IsRun())
|
{
|
Run();
|
}
|
else
|
{
|
Idle();
|
}
|
|
// 重新申请影子
|
RequestShadow();
|
|
WingItemID = itemID;
|
}
|
|
public void SwitchClothes(uint itemID)
|
{
|
// 相同的装备, 不做处理
|
if (itemID == ClothesItemID)
|
{
|
return;
|
}
|
|
// 换装ID
|
int _resID = JobSetup.BaseEquip[0];
|
|
ItemConfig _itemConfig = null;
|
|
// > 0, 默认判断为穿上
|
if (itemID > 0)
|
{
|
_itemConfig = ConfigManager.Instance.GetTemplate<ItemConfig>((int)itemID);
|
|
if (_itemConfig == null || _itemConfig.ChangeOrd == 0)
|
{
|
Debug.LogWarningFormat("SwitchClothes() => 需要换装的道具ID: {0} 不存在或者没有正确的换装ID, 请 <color=red>@吕超</color>", itemID);
|
return;
|
}
|
|
_resID = _itemConfig.ChangeOrd;
|
}
|
|
// 存在旧的先卸载
|
if (m_ClothesModel)
|
{
|
if (!ShowOrHide)
|
{
|
m_ClothesModel.transform.localPosition = Vector3.zero;
|
// 改变层级
|
ChangeBinderToClothes();
|
}
|
|
if (ClothesItemID == 0)
|
{
|
if (!TryRelease(JobSetup.BaseEquip[0], m_ClothesModel))
|
{
|
return;
|
}
|
}
|
else
|
{
|
if (!TryRelease(ClothesItemID, m_ClothesModel))
|
{
|
return;
|
}
|
}
|
|
m_ClothesModel = null;
|
if (m_ClothesAnimator)
|
{
|
m_ClothesAnimator.Play(GAStaticDefine.State_IdleHash);
|
m_ClothesAnimator.Update(0);
|
m_ClothesAnimator.enabled = false;
|
m_ClothesAnimator = null;
|
}
|
}
|
|
GameObject _prefab = null;
|
// 穿上新的
|
if (itemID > 0 && _itemConfig != null)
|
{
|
_prefab = InstanceResourcesLoader.LoadModelRes(_itemConfig.ChangeOrd);
|
|
if (!_prefab)
|
{
|
itemID = 0;
|
if (!TryRequest(JobSetup.BaseEquip[0], ref m_ClothesModel))
|
{
|
return;
|
}
|
}
|
else if (!TryRequest(itemID, ref m_ClothesModel))
|
{
|
return;
|
}
|
}
|
else
|
{
|
if (!TryRequest(_resID, ref m_ClothesModel))
|
{
|
return;
|
}
|
}
|
|
if (_prefab)
|
{
|
MP_Name = _prefab.transform.GetChildTransformDeeply("A_Name");
|
if (MP_Name_Pos == Vector3.zero && MP_Name)
|
{
|
MP_Name_Pos = MP_Name.localPosition;
|
}
|
}
|
|
m_SMRenderer = m_ClothesModel.GetComponentInChildren<SkinnedMeshRenderer>();
|
if (m_SMRenderer)
|
{
|
m_Material = m_SMRenderer.material;
|
}
|
|
m_ClothesAnimator = m_ClothesModel.GetComponent<Animator>();
|
m_ClothesAnimator.enabled = true;
|
m_ClothesAnimator.SetInteger(GAStaticDefine.Param_ActorInstID, (int)ClientInstID);
|
|
if (SkillMgr.CurCastSkill != null)
|
{
|
SkillMgr.CurCastSkill.SkillCompelete = true;
|
}
|
|
// 开始同步身上装备
|
Transform _parentNode = null;
|
|
if (m_WeaponModel)
|
{
|
_parentNode = m_ClothesModel.transform.GetChildTransformDeeply(GAStaticDefine.WeaponBindBoneName);
|
m_WeaponModel.transform.SetParent(_parentNode);
|
m_WeaponModel.transform.localPosition = Vector3.zero;
|
m_WeaponModel.transform.localRotation = Quaternion.identity;
|
}
|
|
if (m_WingModel)
|
{
|
_parentNode = m_ClothesModel.transform.GetChildTransformDeeply(GAStaticDefine.WingBindBoneName);
|
m_WingModel.transform.SetParent(_parentNode);
|
m_WingModel.transform.localPosition = Vector3.zero;
|
m_WingModel.transform.localRotation = Quaternion.identity;
|
}
|
|
if (m_SecondaryModel)
|
{
|
_parentNode = m_ClothesModel.transform.GetChildTransformDeeply(GAStaticDefine.SecondaryBindBoneName[JobSetup.Job - 1]);
|
m_SecondaryModel.transform.SetParent(_parentNode);
|
m_SecondaryModel.transform.localPosition = Vector3.zero;
|
m_SecondaryModel.transform.localRotation = Quaternion.identity;
|
}
|
|
// 重新确定当前状态
|
if (m_HorseModel)
|
{
|
m_ClothesAnimator.SetInteger(GAStaticDefine.Param_MoveState, (int)E_MovingState.Ride);
|
MovingState = E_MovingState.Ride;
|
}
|
else if (m_WingModel)
|
{
|
m_ClothesAnimator.SetInteger(GAStaticDefine.Param_MoveState, (int)E_MovingState.Fly);
|
MovingState = E_MovingState.Fly;
|
}
|
else
|
{
|
m_ClothesAnimator.SetInteger(GAStaticDefine.Param_MoveState, (int)E_MovingState.Normal);
|
MovingState = E_MovingState.Normal;
|
}
|
|
// 切换衣服后重新设置绑点
|
SetupBindNode(m_ClothesModel.transform);
|
|
if (MovingState == E_MovingState.Ride)
|
{
|
m_ClothesModel.transform.SetParent(m_HorseBindNode);
|
m_ClothesModel.transform.localPosition = Vector3.zero;
|
m_ClothesModel.transform.localEulerAngles = new Vector3(90, 0, 0);
|
}
|
else
|
{
|
m_ClothesModel.transform.SetParent(m_Root);
|
|
if (ShowOrHide)
|
{
|
m_ClothesModel.transform.localPosition = Vector3.zero;
|
}
|
else
|
{
|
m_ClothesModel.transform.localPosition = Vector3.zero;
|
// 改变层级
|
ChangeBinderToRoot();
|
|
m_ClothesModel.transform.localPosition = Constants.Special_Hide_Position;
|
}
|
|
m_ClothesModel.transform.localRotation = Quaternion.identity;
|
}
|
|
if (State == E_ActorState.AutoRun ||
|
State == E_ActorState.CtrlRun)
|
{
|
Run();
|
}
|
else
|
{
|
Idle();
|
}
|
|
if (MovingState == E_MovingState.Ride)
|
{
|
if (State == E_ActorState.AutoRun ||
|
State == E_ActorState.CtrlRun)
|
{
|
if (m_ClothesAnimator)
|
{
|
m_ClothesAnimator.Play(GAStaticDefine.State_HorseRunHash);
|
}
|
}
|
else
|
{
|
if (m_ClothesAnimator)
|
{
|
m_ClothesAnimator.Play(GAStaticDefine.State_HorseIdleHash);
|
}
|
}
|
}
|
|
ClothesItemID = itemID;
|
|
OnPutonClothes(ClothesItemID, m_ClothesModel);
|
|
// 重新申请影子
|
RequestShadow();
|
// 重新设置名字
|
RequestName();
|
|
// 判断是否有boss归属
|
if (StatusMgr.Instance.IsExistBossBelong(ServerInstID))
|
{
|
SetBossBelong(true);
|
}
|
|
// 技能是与状态机有关系的, 这里需要强制停止当前释放的技能
|
// 避免换了衣服以后其他技能无法释放
|
if (SkillMgr.CurCastSkill != null)
|
{
|
SkillMgr.CurCastSkill.SkillCompelete = true;
|
}
|
SkillMgr.DoingPrepareSkill = false;
|
|
}
|
|
public void SwitchGuard(uint guardID)
|
{
|
// 获得配置
|
FuncConfigConfig _item = null;
|
int shActorId = -1;
|
|
GameObject _prefab = null;
|
uint _guardSID = ServerInstID * 100 + 1;
|
if (guardID > 0)
|
{
|
if (null != m_Guard)
|
{
|
_item = ConfigManager.Instance.GetTemplate<FuncConfigConfig>(StringUtility.Contact("SH", GuardID));
|
if (int.TryParse(_item.Numerical2, out shActorId))
|
{
|
if (m_Guard.guardPrefabModel)
|
{
|
_prefab = InstanceResourcesLoader.LoadNpc(shActorId);
|
GameObjectPoolManager.Instance.ReleaseGameObject(_prefab, m_Guard.guardPrefabModel);
|
}
|
}
|
m_Guard.UnInit();
|
m_Guard = null;
|
}
|
_item = ConfigManager.Instance.GetTemplate<FuncConfigConfig>(StringUtility.Contact("SH", guardID));
|
if (_item == null)
|
{
|
return;
|
}
|
if (!int.TryParse(_item.Numerical2, out shActorId))
|
{
|
return;
|
}
|
GA_Guard _guard = GAMgr.Instance.GetBySID(_guardSID) as GA_Guard;
|
if (_guard != null)
|
{
|
GAMgr.Instance.ServerDie(_guardSID);
|
GAMgr.Instance.Release(_guard);
|
}
|
|
if (ShowOrHide)
|
{
|
m_Guard = GAMgr.Instance.RequestNpcNoFight<GA_Guard>(ServerInstID * 100 + 1, (uint)shActorId, Group, null);
|
m_Guard.itemID = (int)guardID;
|
m_Guard.InitBase();
|
m_Guard.IsStateActive = true;
|
var bornpos = m_Root.position + m_Root.right * 0.6f - Forward * 0.3f;
|
bornpos.y = m_Root.position.y + m_Guard.GuardianHeight;
|
m_Guard.Pos = bornpos;
|
}
|
}
|
else
|
{
|
if (null != m_Guard)
|
{
|
GA_Guard _guard = GAMgr.Instance.GetBySID(_guardSID) as GA_Guard;
|
if (_guard != null)
|
{
|
GAMgr.Instance.ServerDie(_guardSID);
|
GAMgr.Instance.Release(_guard);
|
}
|
m_Guard = null;
|
}
|
}
|
|
GuardID = guardID;
|
}
|
|
public void SwitchHorse(uint horseItemID)
|
{
|
if (horseItemID != 0
|
&& !GAStaticDefine.HorseItemID2ConfigID.ContainsKey(horseItemID))
|
{
|
var _horseConfigs = ConfigManager.Instance.GetAllValues<HorseConfig>();
|
foreach (var _horseConfig in _horseConfigs)
|
{
|
if (_horseConfig.ItemID == horseItemID)
|
{
|
GAStaticDefine.HorseItemID2ConfigID[horseItemID] = (uint)_horseConfig.HorseID;
|
}
|
}
|
}
|
|
var _newHorseID = horseItemID == 0 ? 0 : GAStaticDefine.HorseItemID2ConfigID[horseItemID];
|
|
GameObject _prefab = null;
|
|
if (_newHorseID <= 0)
|
{
|
if (MovingState != E_MovingState.Ride)
|
{
|
return;
|
}
|
|
HorseConfig _horseConfig = ConfigManager.Instance.GetTemplate<HorseConfig>((int)HorseID);
|
_prefab = InstanceResourcesLoader.LoadModelRes(_horseConfig.Model);
|
if (m_LoadDefaultHorse)
|
{
|
GameObjectPoolManager.Instance.ReleaseDefaultHorse(m_HorseModel);
|
}
|
else
|
{
|
GameObjectPoolManager.Instance.ReleaseGameObject(_prefab, m_HorseModel);
|
}
|
m_HorseModel = null;
|
if (m_HorseAnimator)
|
{
|
m_HorseAnimator.enabled = false;
|
m_HorseAnimator = null;
|
}
|
|
// 衣服重置父节点
|
m_ClothesModel.transform.SetParent(m_Root);
|
if (MP_Name && MP_Name_Pos != Vector3.zero)
|
{
|
MP_Name.localPosition = MP_Name_Pos;
|
}
|
if (ShowOrHide)
|
{
|
m_ClothesModel.transform.localPosition = Vector3.zero;
|
m_ClothesModel.transform.localRotation = Quaternion.identity;
|
}
|
else
|
{
|
m_ClothesModel.transform.localPosition = Constants.Special_Hide_Position;
|
m_ClothesModel.transform.localRotation = Quaternion.identity;
|
}
|
|
// 判断是否佩戴翅膀
|
if (m_WingModel)
|
{
|
MovingState = E_MovingState.Fly;
|
m_ClothesAnimator.SetInteger(GAStaticDefine.Param_MoveState, (int)E_MovingState.Fly);
|
}
|
else
|
{
|
MovingState = E_MovingState.Normal;
|
m_ClothesAnimator.SetInteger(GAStaticDefine.Param_MoveState, (int)E_MovingState.Normal);
|
}
|
|
SwitchHeadNameBindNode(false);
|
}
|
else
|
{
|
// 已经上马并且要骑的马相同, 不做处理
|
if (MovingState == E_MovingState.Ride
|
&& HorseID == _newHorseID)
|
{
|
return;
|
}
|
|
HorseConfig _horseConfig = ConfigManager.Instance.GetTemplate<HorseConfig>((int)_newHorseID);
|
if (_horseConfig == null)
|
{
|
return;
|
}
|
|
m_HorseActionType = _horseConfig.ActionType;
|
|
ModelResConfig _modelResConfig = ConfigManager.Instance.GetTemplate<ModelResConfig>(_horseConfig.Model);
|
if (_modelResConfig == null)
|
{
|
return;
|
}
|
|
MovingState = E_MovingState.Ride;
|
m_ClothesAnimator.SetInteger(GAStaticDefine.Param_MoveState, (int)E_MovingState.Ride);
|
|
// 卸下旧的
|
if (m_HorseModel)
|
{
|
_horseConfig = ConfigManager.Instance.GetTemplate<HorseConfig>((int)HorseID);
|
if (m_LoadDefaultHorse)
|
{
|
GameObjectPoolManager.Instance.ReleaseDefaultHorse(m_HorseModel);
|
}
|
else
|
{
|
_prefab = InstanceResourcesLoader.LoadModelRes(_horseConfig.Model);
|
GameObjectPoolManager.Instance.ReleaseGameObject(_prefab, m_HorseModel);
|
}
|
if (m_HorseMaterial)
|
{
|
MaterialUtility.SwitchXrayShader(m_HorseMaterial, false);
|
}
|
m_HorseModel = null;
|
if (m_HorseAnimator)
|
{
|
m_HorseAnimator.enabled = false;
|
m_HorseAnimator = null;
|
}
|
}
|
|
// 骑上新的
|
_prefab = InstanceResourcesLoader.LoadModelRes(_modelResConfig.ID);
|
if (_prefab == null)
|
{
|
_prefab = InstanceResourcesLoader.LoadDefaultHorse();
|
if (_prefab == null)
|
{
|
return;
|
}
|
else
|
{
|
m_LoadDefaultHorse = true;
|
}
|
}
|
else
|
{
|
m_LoadDefaultHorse = false;
|
}
|
|
m_HorseModel = GameObjectPoolManager.Instance.RequestGameObject(_prefab);
|
m_HorseAnimator = m_HorseModel.GetComponent<Animator>();
|
m_HorseAnimator.enabled = true;
|
|
// 先设置根节点
|
m_HorseModel.transform.SetParent(m_Root);
|
if (ShowOrHide)
|
{
|
m_HorseModel.transform.localPosition = Vector3.zero;
|
m_HorseModel.transform.localRotation = Quaternion.identity;
|
}
|
else
|
{
|
m_HorseModel.transform.localPosition = Constants.Special_Hide_Position;
|
m_HorseModel.transform.localRotation = Quaternion.identity;
|
}
|
|
OnSwitchHorse(_newHorseID, m_HorseModel);
|
|
m_HorseBindNode = m_HorseModel.transform.GetChildTransformDeeply(_modelResConfig.BindPoint);
|
|
if (m_HorseBindNode)
|
{
|
m_ClothesModel.transform.SetParent(m_HorseBindNode);
|
m_ClothesModel.transform.localPosition = Vector3.zero;
|
m_ClothesModel.transform.localEulerAngles = new Vector3(90, 0, 0);
|
|
if (State == E_ActorState.AutoRun
|
|| State == E_ActorState.CtrlRun)
|
{
|
switch (m_HorseActionType)
|
{
|
case 0:
|
m_ClothesAnimator.Play(GAStaticDefine.State_HorseRunHash);
|
break;
|
case 1:
|
m_ClothesAnimator.Play(GAStaticDefine.State_HorseRun1Hash);
|
break;
|
case 2:
|
m_ClothesAnimator.Play(GAStaticDefine.State_HorseRun2Hash);
|
break;
|
case 3:
|
m_ClothesAnimator.Play(GAStaticDefine.State_HorseRun3Hash);
|
break;
|
case 4:
|
m_ClothesAnimator.Play(GAStaticDefine.State_HorseRun4Hash);
|
break;
|
}
|
}
|
else
|
{
|
switch (m_HorseActionType)
|
{
|
case 0:
|
m_ClothesAnimator.Play(GAStaticDefine.State_HorseIdleHash);
|
break;
|
case 1:
|
m_ClothesAnimator.Play(GAStaticDefine.State_HorseIdle1Hash);
|
break;
|
case 2:
|
m_ClothesAnimator.Play(GAStaticDefine.State_HorseIdle2Hash);
|
break;
|
case 3:
|
m_ClothesAnimator.Play(GAStaticDefine.State_HorseIdle3Hash);
|
break;
|
case 4:
|
m_ClothesAnimator.Play(GAStaticDefine.State_HorseIdle4Hash);
|
break;
|
}
|
}
|
}
|
|
SwitchHeadNameBindNode(true);
|
}
|
|
RequestShadow();
|
|
if (State == E_ActorState.AutoRun ||
|
State == E_ActorState.CtrlRun)
|
{
|
Run();
|
}
|
else
|
{
|
Idle();
|
}
|
|
HorseID = _newHorseID;
|
}
|
|
private void SyncSuitSFX(int suitEffectID)
|
{
|
if (!m_ClothesModel)
|
{
|
return;
|
}
|
|
UnloadSuitSFX();
|
|
if (suitEffectID <= 0)
|
{
|
return;
|
}
|
|
SuitEffectConfig _suitEffect = ConfigManager.Instance.GetTemplate<SuitEffectConfig>(suitEffectID);
|
|
// 上特效
|
if (_suitEffect != null)
|
{
|
Transform _parent = null;
|
SFXController _sfx = null;
|
for (int i = 0; _suitEffect.bindbones != null && i < _suitEffect.bindbones.Length; ++i)
|
{
|
if (string.IsNullOrEmpty(_suitEffect.bindbones[i])
|
|| _suitEffect.effectIds[i] == 0)
|
{
|
continue;
|
}
|
|
_parent = m_ClothesModel.transform.GetChildTransformDeeply(_suitEffect.bindbones[i]);
|
|
if (_parent == null)
|
{
|
Debug.LogErrorFormat("套装: {0} 配置的骨骼节点: {1} 不存在", suitEffectID, _suitEffect.bindbones[i]);
|
continue;
|
}
|
|
_sfx = SFXPlayUtility.Instance.PlayBattleEffect(_suitEffect.effectIds[i], _parent);
|
m_SuitEffect.Add(_sfx);
|
}
|
}
|
}
|
|
private PlayerSuitModel _suitModel;
|
private PlayerSuitModel SuitModel
|
{
|
get { return _suitModel ?? (_suitModel = ModelCenter.Instance.GetModel<PlayerSuitModel>()); }
|
}
|
|
private PlayerPackModel m_PlayerBackModel;
|
private PlayerPackModel PlayerBackModel
|
{
|
get
|
{
|
return m_PlayerBackModel ?? (m_PlayerBackModel = ModelCenter.Instance.GetModel<PlayerPackModel>());
|
}
|
}
|
|
public void ChangeEquip(int place, uint itemID, int suitLevel)
|
{
|
if (PlayerDatas.Instance.PlayerId != ServerInstID)
|
{
|
return;
|
}
|
|
var _equipModel = PlayerBackModel.GetSinglePackModel(PackType.rptEquip);
|
|
int _suitCount = 0;
|
|
int _start = (int)RoleEquipType.retHat;
|
int _end = (int)RoleEquipType.retShoes;
|
int _rank = 0;
|
|
ItemModel _itemModel = null;
|
|
// 先取得衣服的阶数
|
_itemModel = _equipModel.GetItemModelByIndex((int)RoleEquipType.retClothes);
|
if (_itemModel == null)
|
{
|
return;
|
}
|
|
_rank = _itemModel.chinItemModel.LV;
|
|
for (int i = _start; i <= _end; ++i)
|
{
|
_itemModel = _equipModel.GetItemModelByIndex(i);
|
|
if (_itemModel == null)
|
{
|
continue;
|
}
|
|
if (_itemModel.chinItemModel.SuiteiD <= 0)
|
{
|
continue;
|
}
|
|
if (SuitModel.suitModelDict.ContainsKey(i))
|
{
|
if (SuitModel.suitModelDict[i].ContainsKey(1)
|
|| SuitModel.suitModelDict[i].ContainsKey(2))
|
{
|
if (_itemModel.chinItemModel.LV >= _rank)
|
{
|
_suitCount += 1;
|
}
|
}
|
}
|
}
|
|
if (_suitCount == 5)
|
{
|
int _type = 1;
|
EquipSuitID = _type * 1000 + JobSetup.Job * 100 + _rank;
|
SyncSuitSFX(EquipSuitID);
|
if (onShowEffect != null)
|
{
|
onShowEffect(true);
|
}
|
}
|
else
|
{
|
EquipSuitID = 0;
|
UnloadSuitSFX();
|
if (onShowEffect != null)
|
{
|
onShowEffect(false);
|
}
|
}
|
}
|
|
public void UnloadSuitSFX()
|
{
|
for (int i = 0; i < m_SuitEffect.Count; ++i)
|
{
|
SFXPlayUtility.Instance.Release(m_SuitEffect[i]);
|
}
|
m_SuitEffect.Clear();
|
}
|
|
private bool TryRequest(uint itemID, ref GameObject model)
|
{
|
ItemConfig _itemConfig = ConfigManager.Instance.GetTemplate<ItemConfig>((int)itemID);
|
|
if (_itemConfig == null)
|
{
|
model = null;
|
return false;
|
}
|
|
return TryRequest(_itemConfig.ChangeOrd, ref model);
|
}
|
|
private bool TryRequest(int resID, ref GameObject model)
|
{
|
GameObject _prefab = InstanceResourcesLoader.LoadModelRes(resID);
|
|
if (!_prefab)
|
{
|
model = null;
|
return false;
|
}
|
|
model = GameObjectPoolManager.Instance.RequestGameObject(_prefab);
|
|
return true;
|
}
|
|
private bool TryRelease(uint itemID, GameObject go)
|
{
|
if (itemID == 0)
|
{
|
return TryRelease(itemID, go);
|
}
|
else
|
{
|
ItemConfig _itemConfig = ConfigManager.Instance.GetTemplate<ItemConfig>((int)itemID);
|
|
if (_itemConfig == null)
|
{
|
return false;
|
}
|
|
return TryRelease(_itemConfig.ChangeOrd, go);
|
}
|
}
|
|
private bool TryRelease(int resID, GameObject go)
|
{
|
GameObject _prefab = InstanceResourcesLoader.LoadModelRes(resID);
|
|
if (!_prefab)
|
{
|
return false;
|
}
|
|
GameObjectPoolManager.Instance.ReleaseGameObject(_prefab, go);
|
|
return true;
|
}
|
|
// 上下马与派生类的装备有关, 此类不进行决策层的实现, 只做基础实现
|
public abstract void OnHorse(byte upOrDown);
|
protected abstract void OnPutonClothes(uint clothesItemID, GameObject clothed);
|
protected abstract void OnPutonWeapon(uint weaponItemID, GameObject weapon);
|
protected abstract void OnPutonWing(uint wingItemID, GameObject wing);
|
protected abstract void OnPutonSecondary(uint secondaryItemID, GameObject secondary);
|
protected abstract void OnSwitchHorse(uint horseID, GameObject horse);
|
|
#endregion
|
|
#region 动画接口, 动画状态判断相关
|
|
public sealed override void SetAnimatorSpeed(float speed)
|
{
|
if (m_ClothesAnimator)
|
{
|
m_ClothesAnimator.speed = speed;
|
}
|
}
|
|
public sealed override void Play(int stateNameHash, float normalizeTime = 0)
|
{
|
if (m_ClothesAnimator)
|
{
|
m_ClothesAnimator.Play(stateNameHash, 0, normalizeTime);
|
}
|
}
|
|
public sealed override bool IsIdle()
|
{
|
if (!m_ClothesAnimator)
|
{
|
return false;
|
}
|
|
AnimatorStateInfo _stateInfo = m_ClothesAnimator.GetCurrentAnimatorStateInfo(0);
|
|
return _stateInfo.shortNameHash == GAStaticDefine.State_AirIdleHash
|
|| _stateInfo.shortNameHash == GAStaticDefine.State_IdleHash
|
|| _stateInfo.shortNameHash == GAStaticDefine.State_HorseIdleHash
|
|| _stateInfo.shortNameHash == GAStaticDefine.State_HorseIdle1Hash
|
|| _stateInfo.shortNameHash == GAStaticDefine.State_HorseIdle2Hash
|
|| _stateInfo.shortNameHash == GAStaticDefine.State_HorseIdle3Hash
|
|| _stateInfo.shortNameHash == GAStaticDefine.State_HorseIdle4Hash;
|
}
|
|
public bool IsDaZuo()
|
{
|
if (m_ClothesAnimator)
|
{
|
AnimatorStateInfo _stateInfo = m_ClothesAnimator.GetCurrentAnimatorStateInfo(0);
|
return _stateInfo.shortNameHash == GAStaticDefine.State_SitDown;
|
}
|
|
return false;
|
}
|
|
public bool IsCollect()
|
{
|
if (m_ClothesAnimator)
|
{
|
AnimatorStateInfo _stateInfo = m_ClothesAnimator.GetCurrentAnimatorStateInfo(0);
|
return _stateInfo.shortNameHash == GAStaticDefine.State_CollectHash;
|
}
|
|
return false;
|
}
|
|
public sealed override bool IsRun()
|
{
|
if (!m_ClothesAnimator)
|
{
|
return false;
|
}
|
|
AnimatorStateInfo _stateInfo = m_ClothesAnimator.GetCurrentAnimatorStateInfo(0);
|
|
return _stateInfo.shortNameHash == GAStaticDefine.State_AirRunHash
|
|| _stateInfo.shortNameHash == GAStaticDefine.State_RunHash
|
|| _stateInfo.shortNameHash == GAStaticDefine.State_HorseRunHash
|
|| _stateInfo.shortNameHash == GAStaticDefine.State_HorseRun1Hash
|
|| _stateInfo.shortNameHash == GAStaticDefine.State_HorseRun2Hash
|
|| _stateInfo.shortNameHash == GAStaticDefine.State_HorseRun3Hash
|
|| _stateInfo.shortNameHash == GAStaticDefine.State_HorseRun4Hash;
|
}
|
|
public sealed override bool IsHurt()
|
{
|
if (!m_ClothesAnimator)
|
{
|
return false;
|
}
|
|
AnimatorStateInfo _stateInfo = m_ClothesAnimator.GetCurrentAnimatorStateInfo(0);
|
|
return _stateInfo.shortNameHash == GAStaticDefine.State_HurtHash
|
|| _stateInfo.shortNameHash == GAStaticDefine.State_HurtDown1Hash
|
|| _stateInfo.shortNameHash == GAStaticDefine.State_HurtDown2Hash;
|
}
|
|
public sealed override bool IsStun()
|
{
|
if (!m_ClothesAnimator)
|
{
|
return false;
|
}
|
|
AnimatorStateInfo _stateInfo = m_ClothesAnimator.GetCurrentAnimatorStateInfo(0);
|
|
return _stateInfo.shortNameHash == GAStaticDefine.State_StunHash;
|
}
|
|
public bool IsCollecting()
|
{
|
if (!m_ClothesAnimator)
|
{
|
return false;
|
}
|
|
AnimatorStateInfo _stateInfo = m_ClothesAnimator.GetCurrentAnimatorStateInfo(0);
|
|
return _stateInfo.shortNameHash == GAStaticDefine.State_CollectHash;
|
}
|
|
public sealed override void Hurt()
|
{
|
if (NextAction == GAStaticDefine.Act_Dead)
|
{
|
return;
|
}
|
|
m_ClothesAnimator.Play(GAStaticDefine.State_HurtHash);
|
}
|
|
public override void Die()
|
{
|
// 死亡的时候如果处于骑马状态就下马死
|
if (MovingState == E_MovingState.Ride)
|
{
|
DTC0428_tagPlayerRideHorse.Send_tagPlayerRideHorse(false);
|
SwitchHorse(0);
|
}
|
|
if (m_ClothesAnimator == null)
|
{
|
return;
|
}
|
|
if (NextAction == GAStaticDefine.Act_Dead)
|
{
|
return;
|
}
|
|
if (OnDie != null)
|
{
|
OnDie();
|
}
|
|
NextAction = GAStaticDefine.Act_Dead;
|
Play(GAStaticDefine.State_DeadHash);
|
|
if (ServerInstID == PlayerDatas.Instance.PlayerId)
|
{
|
SoundUtility.PlayDeadAudio(m_AudioSource, PlayerDatas.Instance.baseData.Job);
|
}
|
|
#if UNITY_EDITOR
|
string _content = string.Format("调用了 SID: {0}, CID: {1} 的Die方法 ", ServerInstID, ClientInstID);
|
RuntimeLogUtility.AddLog_Red(_content, ServerInstID);
|
#endif
|
|
}
|
|
public sealed override void HurtDown()
|
{
|
if (NextAction == GAStaticDefine.Act_Dead)
|
{
|
return;
|
}
|
|
NextAction = GAStaticDefine.Act_HurtDown;
|
m_ClothesAnimator.Play(GAStaticDefine.State_HurtDown1Hash);
|
}
|
|
public sealed override void Idle()
|
{
|
if (ActorInfo.serverDie)
|
{
|
return;
|
}
|
// 是否在骑马状态
|
if (MovingState == E_MovingState.Ride)
|
{
|
if (m_HorseAnimator)
|
{
|
m_HorseAnimator.SetInteger(GAStaticDefine.Param_Action,
|
GAStaticDefine.Act_Idle);
|
m_HorseAnimator.CrossFade(GAStaticDefine.State_IdleHash,
|
.2f);// 是否因为切换不及时 ???
|
}
|
|
if (m_WingAnimator)
|
{
|
m_WingAnimator.SetInteger(GAStaticDefine.Param_Action,
|
GAStaticDefine.Act_HorseIdle);
|
}
|
|
if (m_ClothesAnimator)
|
{
|
switch (m_HorseActionType)
|
{
|
case 0:
|
NextAction = GAStaticDefine.Act_HorseIdle;
|
break;
|
case 1:
|
NextAction = GAStaticDefine.Act_HorseIdle1;
|
break;
|
case 2:
|
NextAction = GAStaticDefine.Act_HorseIdle2;
|
break;
|
case 3:
|
NextAction = GAStaticDefine.Act_HorseIdle3;
|
break;
|
case 4:
|
NextAction = GAStaticDefine.Act_HorseIdle4;
|
break;
|
}
|
}
|
}
|
else if (MovingState == E_MovingState.Fly)
|
{
|
if (m_WingAnimator)
|
{
|
m_WingAnimator.SetInteger(GAStaticDefine.Param_Action,
|
GAStaticDefine.Act_Idle);
|
}
|
if (m_ClothesAnimator)
|
{
|
NextAction = GAStaticDefine.Act_AirIdle;
|
}
|
}
|
else if (MovingState == E_MovingState.Normal)
|
{
|
if (m_ClothesAnimator)
|
{
|
NextAction = GAStaticDefine.Act_Idle;
|
}
|
}
|
|
ShowOrHideWeapon(true);
|
}
|
|
public sealed override void IdleImmediate()
|
{
|
if (ActorInfo.serverDie)
|
{
|
return;
|
}
|
|
// 是否在骑马状态
|
if (MovingState == E_MovingState.Ride)
|
{
|
if (m_HorseAnimator)
|
{
|
m_HorseAnimator.SetInteger(GAStaticDefine.Param_Action,
|
GAStaticDefine.Act_Idle);
|
m_HorseAnimator.Play(GAStaticDefine.State_IdleHash);
|
}
|
|
if (m_WingAnimator)
|
{
|
m_WingAnimator.SetInteger(GAStaticDefine.Param_Action,
|
GAStaticDefine.Act_HorseIdle);
|
m_WingAnimator.Play(GAStaticDefine.State_HorseIdleHash);
|
}
|
|
if (m_ClothesAnimator)
|
{
|
switch (m_HorseActionType)
|
{
|
case 0:
|
NextAction = GAStaticDefine.Act_HorseIdle;
|
Play(GAStaticDefine.State_HorseIdleHash);
|
break;
|
case 1:
|
NextAction = GAStaticDefine.Act_HorseIdle1;
|
Play(GAStaticDefine.State_HorseIdle1Hash);
|
break;
|
case 2:
|
NextAction = GAStaticDefine.Act_HorseIdle2;
|
Play(GAStaticDefine.State_HorseIdle2Hash);
|
break;
|
case 3:
|
NextAction = GAStaticDefine.Act_HorseIdle3;
|
Play(GAStaticDefine.State_HorseIdle3Hash);
|
break;
|
case 4:
|
NextAction = GAStaticDefine.Act_HorseIdle4;
|
Play(GAStaticDefine.State_HorseIdle4Hash);
|
break;
|
}
|
}
|
}
|
else if (MovingState == E_MovingState.Fly)
|
{
|
if (m_WingAnimator)
|
{
|
m_WingAnimator.SetInteger(GAStaticDefine.Param_Action,
|
GAStaticDefine.Act_Idle);
|
m_WingAnimator.Play(GAStaticDefine.State_IdleHash);
|
}
|
if (m_ClothesAnimator)
|
{
|
NextAction = GAStaticDefine.Act_AirIdle;
|
Play(GAStaticDefine.State_AirIdleHash);
|
}
|
}
|
else if (MovingState == E_MovingState.Normal)
|
{
|
if (m_ClothesAnimator)
|
{
|
NextAction = GAStaticDefine.Act_Idle;
|
Play(GAStaticDefine.State_IdleHash);
|
}
|
}
|
|
ShowOrHideWeapon(true);
|
}
|
|
public sealed override void Run()
|
{
|
if (ActorInfo.serverDie)
|
{
|
return;
|
}
|
|
// 是否在骑马状态
|
if (MovingState == E_MovingState.Ride)
|
{
|
if (m_HorseAnimator)
|
{
|
m_HorseAnimator.SetInteger(GAStaticDefine.Param_Action,
|
GAStaticDefine.Act_Run);
|
}
|
|
if (m_WingAnimator)
|
{
|
m_WingAnimator.SetInteger(GAStaticDefine.Param_Action,
|
GAStaticDefine.Act_HorseRun);
|
}
|
|
switch (m_HorseActionType)
|
{
|
case 0:
|
NextAction = GAStaticDefine.Act_HorseRun;
|
break;
|
case 1:
|
NextAction = GAStaticDefine.Act_HorseRun1;
|
break;
|
case 2:
|
NextAction = GAStaticDefine.Act_HorseRun2;
|
break;
|
case 3:
|
NextAction = GAStaticDefine.Act_HorseRun3;
|
break;
|
case 4:
|
NextAction = GAStaticDefine.Act_HorseRun4;
|
break;
|
}
|
|
|
}
|
else if (MovingState == E_MovingState.Fly)
|
{
|
if (m_WingAnimator)
|
{
|
m_WingAnimator.SetInteger(GAStaticDefine.Param_Action,
|
GAStaticDefine.Act_Run);
|
}
|
|
NextAction = GAStaticDefine.Act_AirRun;
|
|
}
|
else if (MovingState == E_MovingState.Normal)
|
{
|
NextAction = GAStaticDefine.Act_Run;
|
}
|
}
|
|
public sealed override void RunImmediate()
|
{
|
if (ActorInfo.serverDie)
|
{
|
return;
|
}
|
|
// 是否在骑马状态
|
if (MovingState == E_MovingState.Ride)
|
{
|
if (m_HorseAnimator)
|
{
|
m_HorseAnimator.SetInteger(GAStaticDefine.Param_Action,
|
GAStaticDefine.Act_Run);
|
m_HorseAnimator.Play(GAStaticDefine.State_RunHash);
|
}
|
|
if (m_WingAnimator)
|
{
|
m_WingAnimator.SetInteger(GAStaticDefine.Param_Action,
|
GAStaticDefine.Act_HorseRun);
|
m_WingAnimator.Play(GAStaticDefine.State_HorseRunHash);
|
}
|
|
if (m_ClothesAnimator)
|
{
|
switch (m_HorseActionType)
|
{
|
case 0:
|
NextAction = GAStaticDefine.Act_HorseRun;
|
m_ClothesAnimator.Play(GAStaticDefine.State_HorseRunHash);
|
break;
|
case 1:
|
NextAction = GAStaticDefine.Act_HorseRun1;
|
m_ClothesAnimator.Play(GAStaticDefine.State_HorseRun1Hash);
|
break;
|
case 2:
|
NextAction = GAStaticDefine.Act_HorseRun2;
|
m_ClothesAnimator.Play(GAStaticDefine.State_HorseRun2Hash);
|
break;
|
case 3:
|
NextAction = GAStaticDefine.Act_HorseRun3;
|
m_ClothesAnimator.Play(GAStaticDefine.State_HorseRun3Hash);
|
break;
|
case 4:
|
NextAction = GAStaticDefine.Act_HorseRun4;
|
m_ClothesAnimator.Play(GAStaticDefine.State_HorseRun4Hash);
|
break;
|
}
|
}
|
}
|
else if (MovingState == E_MovingState.Fly)
|
{
|
if (m_WingAnimator)
|
{
|
m_WingAnimator.SetInteger(GAStaticDefine.Param_Action,
|
GAStaticDefine.Act_Run);
|
m_WingAnimator.Play(GAStaticDefine.State_RunHash);
|
}
|
|
if (m_ClothesAnimator)
|
{
|
NextAction = GAStaticDefine.Act_AirRun;
|
m_ClothesAnimator.Play(GAStaticDefine.State_AirRunHash);
|
}
|
}
|
else if (MovingState == E_MovingState.Normal)
|
{
|
if (m_ClothesAnimator)
|
{
|
NextAction = GAStaticDefine.Act_HorseRun;
|
m_ClothesAnimator.Play(GAStaticDefine.State_RunHash);
|
}
|
}
|
}
|
|
public void Dazuo()
|
{
|
if (State == E_ActorState.AutoRun)
|
{
|
StopPathFind();
|
}
|
|
if (MovingState == E_MovingState.Ride)
|
{
|
DTC0428_tagPlayerRideHorse.Send_tagPlayerRideHorse(false);
|
OnHorse(0);
|
}
|
|
NextAction = GAStaticDefine.Act_Dazuo;
|
|
if (m_ClothesAnimator)
|
{
|
m_ClothesAnimator.Play(GAStaticDefine.State_SitDown);
|
}
|
|
GameObject _prefab = Resources.Load<GameObject>("Prefabs/PT_FS");
|
|
ShowOrHideWeapon(false);
|
}
|
|
public virtual void Collect()
|
{
|
if (State == E_ActorState.AutoRun)
|
{
|
StopPathFind();
|
}
|
|
if (MovingState == E_MovingState.Ride)
|
{
|
DTC0428_tagPlayerRideHorse.Send_tagPlayerRideHorse(false);
|
}
|
|
SnxxzGame.Instance.StartCoroutine(DelayCollect());
|
}
|
|
public sealed override bool HasState(int stateHash)
|
{
|
if (m_ClothesAnimator)
|
{
|
return m_ClothesAnimator.HasState(0, stateHash);
|
}
|
return false;
|
}
|
IEnumerator DelayCollect()
|
{
|
while (MovingState == E_MovingState.Ride)
|
{
|
yield return null;
|
}
|
|
NextAction = GAStaticDefine.Act_Collect;
|
|
if (m_ClothesAnimator)
|
{
|
m_ClothesAnimator.Play(GAStaticDefine.State_CollectHash);
|
}
|
}
|
|
#endregion
|
|
public void CalculateMoveSpeed(ushort speedValue)
|
{
|
FuncConfigConfig _funcConfig = ConfigManager.Instance.GetTemplate<FuncConfigConfig>("MoveSpeedClient");
|
Equation.Instance.Clear();
|
Equation.Instance.AddKeyValue("speed", speedValue);
|
float _speed = Equation.Instance.Eval<float>(_funcConfig.Numerical1);
|
ActorInfo.moveSpeed = _speed;
|
}
|
|
public void CalculateAtkSpeed(float speedValue)
|
{
|
FuncConfigConfig _funcConfig = ConfigManager.Instance.GetTemplate<FuncConfigConfig>("AtkInterval");
|
Equation.Instance.Clear();
|
Equation.Instance.AddKeyValue("atkSpeed", speedValue);
|
float _speed = Equation.Instance.Eval<float>(_funcConfig.Numerical1);
|
ActorInfo.atkSpeed = Mathf.Clamp(1f / (_speed * Constants.F_GAMMA), 1f, 2f);
|
}
|
|
public void SetBossBelong(bool belong)
|
{
|
if (m_HeadUpName != null)
|
{
|
m_HeadUpName.SetBossDropout(belong);
|
}
|
}
|
|
public sealed override void RequestShadow()
|
{
|
ReleaseShadow();
|
|
switch (SystemSetting.Instance.GetCurrentQualityLevel())
|
{
|
case GameQuality.Low:
|
m_Shadow = SFXPlayUtility.Instance.PlayBattleEffect(999999, m_Root);
|
m_Shadow.duration = 0;
|
m_Shadow.transform.localScale = new Vector3(1 / Root.transform.localScale.x, 1, 1 / Root.transform.localScale.z);
|
break;
|
case GameQuality.Medium:
|
case GameQuality.High:
|
if (MovingState == E_MovingState.Ride)
|
{
|
m_ShadowCaster = ActorShadowCaster.Cast(MP_Name, m_HorseModel.transform);
|
}
|
else
|
{
|
if (m_ClothesModel)
|
{
|
m_ShadowCaster = ActorShadowCaster.Cast(MP_Name, m_ClothesModel.transform);
|
}
|
}
|
break;
|
}
|
|
}
|
|
public sealed override void RequestLifeBar()
|
{
|
// 此类型, 不做处理
|
}
|
|
public sealed override void ReleaseLifeBar()
|
{
|
// 此类型, 不做处理
|
}
|
|
public sealed override void ReleaseName()
|
{
|
if (m_HeadUpName != null)
|
{
|
m_HeadUpName.SetRedName(false);
|
m_HeadUpName.SetGrayName(false);
|
m_HeadUpName.SetYellowName(false);
|
m_HeadUpName.SetBossDropout(false);
|
m_HeadUpName.target = null;
|
HeadUpName.Recycle(m_HeadUpName);
|
m_HeadUpName = null;
|
}
|
}
|
|
public sealed override void ReleaseShadow()
|
{
|
if (m_ShadowCaster != null)
|
{
|
m_ShadowCaster.Stop();
|
m_ShadowCaster = null;
|
}
|
|
if (m_Shadow)
|
{
|
SFXPlayUtility.Instance.Release(m_Shadow);
|
m_Shadow = null;
|
}
|
}
|
|
private void OnGameQualityChange()
|
{
|
RequestShadow();
|
}
|
|
/// <summary>
|
/// 显示或者隐藏表现层
|
/// </summary>
|
/// <param name="showOrHide">显示: true, 隐藏: false</param>
|
public sealed override void ShowOrHideModel(bool showOrHide)
|
{
|
if (ShowOrHide == showOrHide)
|
{
|
return;
|
}
|
|
if (showOrHide)
|
{
|
if (MovingState == E_MovingState.Ride)
|
{
|
if (m_HorseModel)
|
{
|
m_HorseModel.transform.localPosition = Vector3.zero;
|
m_HorseModel.transform.localRotation = Quaternion.identity;
|
|
// 设置头顶名称空间的目标
|
if (m_HeadUpName)
|
{
|
m_HeadUpName.target = MP_Name1;
|
}
|
}
|
}
|
else
|
{
|
if (m_ClothesModel)
|
{
|
m_ClothesModel.transform.localPosition = Vector3.zero;
|
m_ClothesModel.transform.localRotation = Quaternion.identity;
|
|
// 设置头顶名称空间的目标
|
if (m_HeadUpName)
|
{
|
m_HeadUpName.target = MP_Name;
|
}
|
}
|
}
|
|
// 改变层级
|
ChangeBinderToClothes();
|
|
RequestShadow();
|
}
|
else
|
{
|
// 改变层级
|
ChangeBinderToRoot();
|
|
if (MovingState == E_MovingState.Ride)
|
{
|
if (m_HorseModel)
|
{
|
m_HorseModel.transform.localPosition = Constants.Special_Hide_Position;
|
}
|
}
|
else
|
{
|
if (m_ClothesModel)
|
{
|
m_ClothesModel.transform.localPosition = Constants.Special_Hide_Position;
|
}
|
}
|
|
// 设置头顶名称空间的目标
|
if (m_HeadUpName)
|
{
|
m_HeadUpName.target = MP_Name;
|
}
|
|
SwitchGuard(0);
|
|
ReleaseShadow();
|
}
|
|
GA_Pet _pet = GAMgr.Instance.GetBySID(ServerInstID * 10 + 1) as GA_Pet;
|
if (_pet != null)
|
{
|
_pet.ShowOrHideModel(showOrHide);
|
}
|
|
ShowOrHide = showOrHide;
|
|
if (this is GA_Player)
|
{
|
var _player = this as GA_Player;
|
|
if (ShowOrHide)
|
{
|
if (_player.serverGuardId != 0)
|
{
|
SwitchGuard((uint)_player.serverGuardId);
|
}
|
}
|
}
|
|
}
|
|
private void ChangeBinderToClothes()
|
{
|
if (MP_Name != m_ClothesModel.transform)
|
{
|
MP_Name.SetParent(m_ClothesModel.transform);
|
}
|
|
if (MP_Hit != m_ClothesModel.transform)
|
{
|
MP_Hit.SetParent(m_ClothesModel.transform);
|
}
|
|
if (MP_Stun != m_ClothesModel.transform)
|
{
|
MP_Stun.SetParent(m_ClothesModel.transform);
|
}
|
}
|
|
private void ChangeBinderToRoot()
|
{
|
if (MP_Name != m_ClothesModel.transform)
|
{
|
MP_Name.SetParent(Root);
|
}
|
|
if (MP_Hit != m_ClothesModel.transform)
|
{
|
MP_Hit.SetParent(Root);
|
}
|
|
if (MP_Stun != m_ClothesModel.transform)
|
{
|
MP_Stun.SetParent(Root);
|
}
|
}
|
|
|
/// <summary>
|
/// 判断技能是否可以被打断
|
/// </summary>
|
public bool CanSkillInterrupt(int skillID)
|
{
|
if (JobSetup == null)
|
{
|
return false;
|
}
|
|
for (int i = 0; i < JobSetup.StopAction.Length; ++i)
|
{
|
if (JobSetup.StopAction[i] == skillID)
|
{
|
return true;
|
}
|
}
|
|
return false;
|
}
|
|
public override bool CanAtked()
|
{
|
return true;
|
}
|
|
public override bool CanAtkedRotate()
|
{
|
return false;
|
}
|
|
public override bool CanPushedBack()
|
{
|
return State != E_ActorState.Roll && MovingState != E_MovingState.Ride;
|
}
|
|
public override bool CanHurted()
|
{
|
return State != E_ActorState.Roll && MovingState != E_MovingState.Ride;
|
}
|
|
public override bool CanDieFly()
|
{
|
return false;
|
}
|
|
public int GetCommonSkillID(int index)
|
{
|
if (index >= 0 && index < JobSetup.ComAtkIdList.Length)
|
{
|
return JobSetup.ComAtkIdList[index];
|
}
|
return -1;
|
}
|
|
#region 战前冲锋
|
|
private bool m_IsRushing = false;
|
public bool IsRushing
|
{
|
get
|
{
|
return m_IsRushing;
|
}
|
}
|
protected float m_LastRushTime;
|
private SFXController m_RushEffect;
|
private float m_GhostCreateInterval;
|
|
public void StartRush()
|
{
|
if (m_IsRushing)
|
{
|
return;
|
}
|
|
m_IsRushing = true;
|
|
if (m_HorseModel)
|
{
|
DTC0428_tagPlayerRideHorse.Send_tagPlayerRideHorse(false);
|
}
|
|
ActorInfo.moveSpeed = JobSetup.RushSpeed * Constants.F_DELTA;
|
SetAnimatorSpeed(JobSetup.RushAnimatorSpeed * Constants.F_DELTA);
|
m_LastRushTime = Time.time;
|
|
if (m_RushEffect == null)
|
{
|
m_RushEffect = SFXPlayUtility.Instance.PlayBattleEffect(50401, this);
|
m_RushEffect.duration = 0;
|
}
|
}
|
|
public void StopRush()
|
{
|
if (m_IsRushing == false)
|
{
|
return;
|
}
|
m_IsRushing = false;
|
|
// 重置速度, 冲锋时提高了移动速度, 这里降回来
|
CalculateMoveSpeed((ushort)PlayerDatas.Instance.extersion.SpeedValue);
|
SetAnimatorSpeed(1);
|
|
if (m_RushEffect != null)
|
{
|
SFXPlayUtility.Instance.Release(m_RushEffect);
|
m_RushEffect = null;
|
}
|
|
if (this is GA_Hero)
|
{
|
if (PreFightMission.Instance.IsFinished())
|
{
|
// 发送冲锋包
|
CB404_tagCMRush _b404 = new CB404_tagCMRush();
|
// 防止乱冲
|
if (SelectTarget != null)
|
{
|
_b404.ObjID = (uint)SelectTarget.ServerInstID;
|
}
|
_b404.PosX = (ushort)(Pos.x * 2 + GA_Hero.MapOffset.x);
|
_b404.PosY = (ushort)(Pos.z * 2 + GA_Hero.MapOffset.z);
|
GameNetSystem.Instance.SendInfo(_b404);
|
}
|
PrevPos = Pos;
|
}
|
}
|
|
private void UpdateRush()
|
{
|
if (m_IsRushing)
|
{
|
if (Time.time - m_GhostCreateInterval > JobSetup.ShadowCreateInterval * Constants.F_DELTA)
|
{
|
XRayShadow.Request(m_SMRenderer, JobSetup.ShadowLastTime * Constants.F_DELTA);
|
m_GhostCreateInterval = Time.time;
|
}
|
}
|
}
|
|
#endregion
|
|
public void PlayFootAudio()
|
{
|
if (MovingState == E_MovingState.Normal)
|
{
|
SoundUtility.PlayFootAudio(m_AudioSource, FootAudioType.Walk);
|
}
|
else if (MovingState == E_MovingState.Ride)
|
{
|
SoundUtility.PlayFootAudio(m_AudioSource, FootAudioType.Ride, (int)HorseID);
|
}
|
else if (MovingState == E_MovingState.Fly)
|
{
|
SoundUtility.PlayFootAudio(m_AudioSource, FootAudioType.Fly);
|
}
|
}
|
|
public void ShowOrHideWeapon(bool showOrHide)
|
{
|
if (m_WeaponModel)
|
{
|
if (showOrHide)
|
{
|
m_WeaponModel.transform.localPosition = Vector3.zero;
|
}
|
else
|
{
|
m_WeaponModel.transform.localPosition = Constants.Special_Hide_Position;
|
}
|
}
|
}
|
}
|