using Snxxz.UI; using System.Collections.Generic; using UnityEngine; using UnityEngine.Events; using System.Collections; public abstract class GActorPlayerBase : GActorFight { public class PlayerInfo { public Vector3 pos; public byte job; public uint playerID; public string FamilyName; public uint FamilyID; public string name; public ushort level; public uint hp; public uint maxHp; public CEquipInfo[] itemDatas; } public struct CEquipInfo { public int id; public int place; public int isSuit; public int suitLevel; } private GameObject m_EmptyJY; public static UnityAction onShowEffect; private bool m_LoadDefaultHorse; public struct EquipInfo { public int place; public uint itemID; public int suitLV_1; public int suitLV_2; } protected int m_SuitCount; 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); } } protected Dictionary m_EquipDict = new Dictionary(); private ActorShadowCaster m_ShadowCaster = null; private SFXController m_Shadow; protected HeadUpName m_HeadUpName = null; private int m_HorseActionType = 0; public int nextComAtkIndex = -1; public JobSetupConfig JobSetup { get; protected set; } DungeonModel dungeonModel { get { return ModelCenter.Instance.GetModel(); } } 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 void SwitchHeadNameBindNode(bool castingSkill) { // 角色被隐藏状态下不执行头顶名称切换逻辑 if (!ShowOrHide) { return; } if (m_HeadUpName) { if (castingSkill) { m_HeadUpName.target = MP_Name1; } else { m_HeadUpName.target = MP_Name; } } } public sealed override void Polymorph(bool doOrNo, int npcID) { IsPolyMorph = doOrNo; if (IsPolyMorph) { ChangeBinderToRoot(); // 正在骑乘状态下 if (MovingState == E_MovingState.Ride) { m_HorseModel.transform.position = Constants.Special_Hide_Position; SwitchHorse(0); DTC0428_tagPlayerRideHorse.Send_tagPlayerRideHorse(false); } else { m_ClothesModel.transform.position = Constants.Special_Hide_Position; } m_SheepIsDefaultNpc = false; var _p = InstanceResourcesLoader.LoadNpc(npcID); if (_p == null) { _p = InstanceResourcesLoader.LoadDefaultFightNPC(); m_SheepIsDefaultNpc = true; } m_SheepModel = GameObjectPoolManager.Instance.RequestGameObject(_p); m_SheepModel.transform.SetParent(m_Root); var _a = m_SheepModel.GetComponent(); if (_a) { _a.enabled = true; _a.SetInteger(GAStaticDefine.Param_ActorInstID, (int)ClientInstID); m_ClothesAnimator.enabled = false; m_ClothesAnimator = _a; } if (ShowOrHide) { m_SheepModel.transform.localPosition = Vector3.zero; } else { m_SheepModel.transform.localPosition = Constants.Special_Hide_Position; } m_SheepModel.transform.localRotation = Quaternion.identity; } else { if (m_SheepModel) { var _a = m_SheepModel.GetComponent(); if (_a) { _a.enabled = false; } if (m_SheepIsDefaultNpc) { GameObjectPoolManager.Instance.ReleaseDefaultFightNPC(m_SheepModel); } else { var _prefab = InstanceResourcesLoader.LoadNpc(npcID); GameObjectPoolManager.Instance.ReleaseGameObject(_prefab, m_SheepModel); } } m_SheepModel = null; m_ClothesModel.transform.localPosition = Vector3.zero; ChangeBinderToClothes(); m_ClothesAnimator = m_ClothesModel.GetComponent(); m_ClothesAnimator.enabled = true; m_ClothesAnimator.SetInteger(GAStaticDefine.Param_ActorInstID, (int)ClientInstID); m_ClothesAnimator.SetInteger(GAStaticDefine.Param_MoveState, (int)E_MovingState.Normal); } } protected sealed override 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); } } protected sealed override 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); } } protected override void OnInit(GameNetPackBasic package) { ActorType = GameObjType.gotPlayer; ClothesItemID = uint.MaxValue; HorseID = uint.MaxValue; WeaponItemID = uint.MaxValue; SecondaryID = uint.MaxValue; WingItemID = uint.MaxValue; MovingState = E_MovingState.Normal; SystemSetting.Instance.qualityLevelChangeEvent += OnGameQualityChange; dungeonModel.updateMissionEvent += CheckAncientHeadUp; base.OnInit(package); } protected override void OnUnit() { ShowOrHideModel(true); GameObject _prefab = null; HideWeaponEffect(); HideSecondaryEffect(); HideHorseEffect(); int _resID = 0; ItemConfig _itemConfig = null; m_EquipDict.Clear(); if (m_WeaponModel) { _resID = JobSetup.BaseEquip[1]; if (WeaponItemID != 0) { _itemConfig = ItemConfig.Get((int)WeaponItemID); _resID = _itemConfig.ChangeOrd; } if (TryRelease(_resID, m_WeaponModel)) { m_WeaponModel = null; } } if (m_SecondaryModel) { _resID = JobSetup.BaseEquip[2]; if (SecondaryID != 0) { _itemConfig = ItemConfig.Get((int)SecondaryID); _resID = _itemConfig.ChangeOrd; } if (TryRelease(_resID, m_SecondaryModel)) { m_SecondaryModel = null; } } if (m_WingModel) { if (WingItemID != 0) { _itemConfig = ItemConfig.Get((int)WingItemID); _resID = _itemConfig.ChangeOrd; } if (TryRelease(_resID, m_WingModel)) { m_WingModel = null; if (m_WingAnimator) { m_WingAnimator.enabled = false; m_WingAnimator = null; } } } if (m_HorseModel) { HorseConfig _horseConfig = HorseConfig.Get((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; } if (m_ClothesModel) { SFXController[] _ctrls = m_ClothesModel.GetComponentsInChildren(); if (_ctrls != null && _ctrls.Length > 0) { for (int i = 0; i < _ctrls.Length; ++i) { SFXPlayUtility.Instance.Release(_ctrls[i]); } } _resID = JobSetup.BaseEquip[0]; if (ClothesItemID != 0) { _itemConfig = ItemConfig.Get((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_SMRenderer) { MaterialLoader.Release(m_SMRenderer.material); m_SMRenderer.material = null; m_SMRenderer.materials = m_SMRenderer.sharedMaterials = new Material[0]; } m_Material = null; SwitchHand(false); foreach (var _effect in m_GodWeaponEffectDict.Values) { SFXPlayUtility.Instance.Release(_effect); } m_GodWeaponEffectDict.Clear(); ReleaseLifeBar(); ReleaseName(); ReleaseShadow(); m_IsRushing = false; if (m_RushEffect) { SFXPlayUtility.Instance.Release(m_RushEffect); m_RushEffect = null; } JobSetup = null; SystemSetting.Instance.qualityLevelChangeEvent -= OnGameQualityChange; dungeonModel.updateMissionEvent -= CheckAncientHeadUp; base.OnUnit(); } public abstract override void Destroy(); protected override void OnLateUpdate() { UpdateRush(); } public void CheckAncientHeadUp() { if (PlayerDatas.Instance.baseData.MapID == 31160) { var help = dungeonModel.mission; SwitchAncientKing(help.topPlayerID == ServerInstID); SwitchAncientEnemy(help.enemyID == ServerInstID && ServerInstID != PlayerDatas.Instance.baseData.PlayerID); } else { SwitchAncientKing(false); SwitchAncientEnemy(false); } } #region 装备穿戴相关 private GameObject m_ClothesModel; private GameObject m_WeaponModel; private GameObject m_SecondaryModel; private GameObject m_WingModel; private GameObject m_HorseModel; private GameObject m_HandModel; private GA_Guard m_Guard; private Transform m_HorseBindNode; protected uint ClothesItemID { get; private set; } protected int HandResID { 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; } 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 void SwitchAncientKing(bool on) { if (m_HeadUpName == null) { return; } m_HeadUpName.SetAncientKing(on); } public void SwitchAncientEnemy(bool on) { if (m_HeadUpName == null) { return; } m_HeadUpName.SetAncientEnemy(on); } 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, int index = (int)RoleEquipType.Weapon) { // 相同的装备, 不做处理 if (itemID == WeaponItemID) { return; } int _resID = JobSetup.BaseEquip[1]; EquipInfo _equipInfo; // 如果是套装位置 if (index == (int)RoleEquipType.FashionWeapon) { // 脱下套装 if (itemID == 0) { // 寻找原身上装备, 如果有的话就重置此次要换装的道具id if (m_EquipDict.TryGetValue((int)RoleEquipType.Weapon, out _equipInfo)) { itemID = _equipInfo.itemID; } } } else if (index == (int)RoleEquipType.Weapon) { if (m_EquipDict.ContainsKey((int)RoleEquipType.FashionWeapon)) { return; } } ItemConfig _itemConfig = null; // > 0, 默认判断为穿上 if (itemID > 0) { _itemConfig = ItemConfig.Get((int)itemID); if (_itemConfig == null || _itemConfig.ChangeOrd == 0) { Debug.LogWarningFormat("SwitchWeapon() => 需要换装的道具ID: {0} 不存在或者没有正确的换装ID, 请 @吕超", 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(); ShowWeaponEffect(); } public void SwitchSecondary(uint itemID, int index = (int)RoleEquipType.Weapon2) { // 相同的装备, 不做处理 if (itemID == SecondaryID) { return; } int _baseHandResID = ModelResConfig.GetHandByClothesID((int)ClothesItemID); int _resID = _baseHandResID; if (JobSetup.Job == 2) { _resID = JobSetup.BaseEquip[2]; } EquipInfo _equipInfo; // 如果是套装位置 if (index == (int)RoleEquipType.FashionWeapon2) { // 脱下套装 if (itemID == 0) { // 寻找原身上装备, 如果有的话就重置此次要换装的道具id if (m_EquipDict.TryGetValue((int)RoleEquipType.Weapon2, out _equipInfo)) { itemID = _equipInfo.itemID; } } } else if (index == (int)RoleEquipType.Weapon2) { if (m_EquipDict.ContainsKey((int)RoleEquipType.FashionWeapon2)) { return; } } ItemConfig _itemConfig = null; // > 0, 默认判断为穿上 if (itemID > 0) { _itemConfig = ItemConfig.Get((int)itemID); if (_itemConfig == null || _itemConfig.ChangeOrd == 0) { Debug.LogWarningFormat("SwitchSecondary() => 需要换装的道具ID: {0} 不存在或者没有正确的换装ID, 请 @吕超", itemID); return; } _resID = _itemConfig.ChangeOrd; } // 判断是否之前已经穿了 // 穿了就先脱掉 if (m_SecondaryModel) { if (SecondaryID == 0) { if (!TryRelease(_baseHandResID, 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; } } if (m_EquipDict.ContainsKey((int)RoleEquipType.FashionWeapon2)) { SwitchHand(true); } else { SwitchHand(false); } // 替换当前衣服上的武器 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; OnPutonSecondary(SecondaryID, m_SecondaryModel); } else { if (JobSetup.Job == 2) { 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; OnPutonSecondary(SecondaryID, m_SecondaryModel); } else if (JobSetup.Job == 1) { SwitchHand(true); OnPutonSecondary(SecondaryID, m_HandModel); } } SecondaryID = itemID; ShowSecondaryEffect(); RequestShadow(); } public void SwitchWing(uint itemID) { // 相同的装备, 不做处理 if (itemID == WingItemID) { return; } // > 0, 默认判断为穿上 if (itemID > 0) { ItemConfig _itemConfig; _itemConfig = ItemConfig.Get((int)itemID); if (_itemConfig == null || _itemConfig.ChangeOrd == 0) { Debug.LogWarningFormat("PutonWing() => 需要换装的道具ID: {0} 不存在或者没有正确的换装ID, 请 @吕超", 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; ModelResConfig _resConfig = ModelResConfig.Get(_itemConfig.ChangeOrd); m_WingModel.transform.localScale = _resConfig.Scale; OnPutonWing(itemID, m_WingModel); // 处理动画相关 m_WingAnimator = m_WingModel.GetComponent(); 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, int index = (int)RoleEquipType.Clothes) { // 相同的装备, 不做处理 if (itemID == ClothesItemID) { return; } EquipInfo _equipInfo; // 换装ID int _resID = JobSetup.BaseEquip[0]; // 如果是套装位置 if (index == (int)RoleEquipType.FashionClothes) { // 脱下套装 if (itemID == 0) { // 寻找原身上装备, 如果有的话就重置此次要换装的道具id if (m_EquipDict.TryGetValue((int)RoleEquipType.Clothes, out _equipInfo)) { itemID = _equipInfo.itemID; } } } else if (index == (int)RoleEquipType.Clothes) { if (m_EquipDict.ContainsKey((int)RoleEquipType.FashionClothes)) { return; } } ItemConfig _itemConfig = null; // > 0, 默认判断为穿上 if (itemID > 0) { _itemConfig = ItemConfig.Get((int)itemID); if (_itemConfig == null || _itemConfig.ChangeOrd == 0) { Debug.LogWarningFormat("SwitchClothes() => 需要换装的道具ID: {0} 不存在或者没有正确的换装ID, 请 @吕超", 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(); if (m_SMRenderer) { MaterialLoader.Release(m_SMRenderer.material); var _material = MaterialLoader.LoadClothesMaterial(_resID, false, false); if (!_material) { _material = MaterialLoader.LoadClothesMaterial(JobSetup.BaseEquip[0], false, false); } m_Material = m_SMRenderer.material = _material; } m_ClothesAnimator = m_ClothesModel.GetComponent(); var _modelName = string.Empty; RuntimeAnimatorController _controller = null; if (JobSetup.Job == 1) { _controller = AnimatorControllerLoader.LoadMobController(AnimatorControllerLoader.controllerSuffix, "A_Zs"); } else if (JobSetup.Job == 2) { _controller = AnimatorControllerLoader.LoadMobController(AnimatorControllerLoader.controllerSuffix, "A_Fs"); } else { Debug.LogError("..................职业异常................."); } if (_controller) { m_ClothesAnimator.runtimeAnimatorController = _controller; } 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_EquipDict.ContainsKey((int)RoleEquipType.FashionWeapon2)) { SwitchHand(true); } else { if (!m_EquipDict.ContainsKey((int)RoleEquipType.Weapon2)) { SwitchHand(true); } } // 重新确定当前状态 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) { // 获得配置 uint _guardSID = ServerInstID * 100 + 1; if (guardID > 0) { if (null != m_Guard) { m_Guard.UnInit(); m_Guard = null; } var config = GuardConfig.Get((int)guardID); if (config == null) { 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(ServerInstID * 100 + 1, (uint)config.npcId, Group, null); m_Guard.ActorInfo.ownerSID = ServerInstID; m_Guard.itemID = (int)guardID; m_Guard.InitBase(); m_Guard.IsStateActive = true; } } 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; } protected void SwitchHand(bool onOrOff) { if (JobSetup == null || JobSetup.Job != 1) { return; } if (onOrOff) { EquipInfo _equipInfo; int _itemID = 7000; if (!m_EquipDict.TryGetValue((int)RoleEquipType.FashionClothes, out _equipInfo)) { if (!m_EquipDict.TryGetValue((int)RoleEquipType.Clothes, out _equipInfo)) { _itemID = 7000; } } if (_equipInfo.itemID != 0) { _itemID = (int)_equipInfo.itemID; } int _resID = 7000; if (_itemID != 7000) { var _itemConfig = ItemConfig.Get(_itemID); _resID = ModelResConfig.GetHandByClothesID(_itemConfig.ChangeOrd); } if (m_HandModel) { if (!TryRelease(HandResID, m_HandModel)) { return; } } if (TryRequest(_resID, ref m_HandModel)) { // 替换当前衣服上的武器 if (m_ClothesModel) { Transform _secondaryNode = m_ClothesModel.transform.GetChildTransformDeeply(GAStaticDefine.SecondaryBindBoneName[JobSetup.Job - 1]); m_HandModel.transform.SetParent(_secondaryNode); m_HandModel.transform.localPosition = Vector3.zero; m_HandModel.transform.localRotation = Quaternion.identity; HandResID = _resID; } } } else { if (m_HandModel) { if (!TryRelease(HandResID, m_HandModel)) { return; } m_HandModel = null; HandResID = 0; } } } public void SwitchHorse(uint horseItemID) { if (horseItemID != 0 && !GAStaticDefine.HorseItemID2ConfigID.ContainsKey(horseItemID)) { var _horseConfigs = HorseConfig.GetValues(); 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) { HideHorseEffect(); if (MovingState != E_MovingState.Ride) { return; } HorseConfig _horseConfig = HorseConfig.Get((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.runtimeAnimatorController = null; 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) { if (!IsPolyMorph) { 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; if (!IsPolyMorph) { m_ClothesAnimator.SetInteger(GAStaticDefine.Param_MoveState, (int)E_MovingState.Fly); } } else { MovingState = E_MovingState.Normal; if (!IsPolyMorph) { m_ClothesAnimator.SetInteger(GAStaticDefine.Param_MoveState, (int)E_MovingState.Normal); } } SwitchHeadNameBindNode(false); } else { // 已经上马并且要骑的马相同, 不做处理 if (MovingState == E_MovingState.Ride && HorseID == _newHorseID) { return; } HorseConfig _horseConfig = HorseConfig.Get((int)_newHorseID); if (_horseConfig == null) { return; } m_HorseActionType = _horseConfig.ActionType; ModelResConfig _modelResConfig = ModelResConfig.Get(_horseConfig.Model); if (_modelResConfig == null) { return; } MovingState = E_MovingState.Ride; m_ClothesAnimator.SetInteger(GAStaticDefine.Param_MoveState, (int)E_MovingState.Ride); // 卸下旧的 if (m_HorseModel) { _horseConfig = HorseConfig.Get((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.runtimeAnimatorController = null; 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(); RuntimeAnimatorController _controller = null; if (m_LoadDefaultHorse) { _controller = InstanceResourcesLoader.LoadDefaultMobAnimatorController_Horse(); } else { _controller = AnimatorControllerLoader.LoadMobController(AnimatorControllerLoader.controllerSuffix, _modelResConfig.ResourcesName); } if (_controller) { m_HorseAnimator.runtimeAnimatorController = _controller; } 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; if (m_HorseModel && ShowOrHide) { ShowHorseEffect(); } } private List m_HorseEffectList = new List(); private List m_WeaponEffectList = new List(); private List m_SecondaryEffectList = new List(); public void HideSecondaryEffect() { foreach (var _ctrl in m_SecondaryEffectList) { SFXPlayUtility.Instance.Release(_ctrl); } m_SecondaryEffectList.Clear(); } public void HideWeaponEffect() { foreach (var _ctrl in m_WeaponEffectList) { SFXPlayUtility.Instance.Release(_ctrl); } m_WeaponEffectList.Clear(); } public void HideHorseEffect() { foreach (var _ctrl in m_HorseEffectList) { SFXPlayUtility.Instance.Release(_ctrl); } m_HorseEffectList.Clear(); } public void ShowSecondaryEffect() { HideSecondaryEffect(); if (SecondaryID <= 0 || !m_SecondaryModel) { return; } var _itemConfig = ItemConfig.Get((int)SecondaryID); if (_itemConfig == null) { return; } var _config = ModelResConfig.Get(_itemConfig.ChangeOrd); if (_config == null) { Debug.LogError("找不到配置ModelResConfig: " + _itemConfig.ChangeOrd); return; } var _boneList = ModelResConfig.GetBoneList(_config.ResourcesName); var _effectlist = ModelResConfig.GetEffectList(_config.ResourcesName); if (_boneList != null && _effectlist != null) { for (int i = 0; i < _boneList.Count; ++i) { if (_boneList[i].Equals("null")) { var _ctrl = SFXPlayUtility.Instance.PlayBattleEffect(_effectlist[i], m_SecondaryModel.transform); m_SecondaryEffectList.Add(_ctrl); } else { var _ctrl = SFXPlayUtility.Instance.PlayBattleEffect(_effectlist[i], m_SecondaryModel.transform.GetChildTransformDeeply(_boneList[i])); m_SecondaryEffectList.Add(_ctrl); } } } } public void ShowWeaponEffect() { HideWeaponEffect(); if (WeaponItemID <= 0) { return; } var _itemConfig = ItemConfig.Get((int)WeaponItemID); if (_itemConfig == null) { return; } var _config = ModelResConfig.Get(_itemConfig.ChangeOrd); if (_config == null) { Debug.LogError("找不到配置ModelResConfig: " + _itemConfig.ChangeOrd); return; } var _boneList = ModelResConfig.GetBoneList(_config.ResourcesName); var _effectlist = ModelResConfig.GetEffectList(_config.ResourcesName); if (_boneList != null && _effectlist != null) { for (int i = 0; i < _boneList.Count; ++i) { if (_boneList[i].Equals("null")) { var _ctrl = SFXPlayUtility.Instance.PlayBattleEffect(_effectlist[i], m_WeaponModel.transform); m_WeaponEffectList.Add(_ctrl); } else { var _ctrl = SFXPlayUtility.Instance.PlayBattleEffect(_effectlist[i], m_WeaponModel.transform.GetChildTransformDeeply(_boneList[i])); m_WeaponEffectList.Add(_ctrl); } } } } public void ShowHorseEffect() { HideHorseEffect(); if (HorseID <= 0) { return; } var _horseConfig = HorseConfig.Get((int)HorseID); if (_horseConfig == null) { Debug.LogError("找不到配置HorseConfig: " + HorseID); return; } var _config = ModelResConfig.Get(_horseConfig.Model); if (_config == null) { Debug.LogError("找不到配置ModelResConfig: " + _horseConfig.Model); return; } var _boneList = ModelResConfig.GetBoneList(_config.ResourcesName); var _effectlist = ModelResConfig.GetEffectList(_config.ResourcesName); if (_boneList != null && _effectlist != null) { for (int i = 0; i < _boneList.Count; ++i) { if (_boneList[i].Equals("null")) { var _ctrl = SFXPlayUtility.Instance.PlayBattleEffect(_effectlist[i], m_HorseModel.transform); m_HorseEffectList.Add(_ctrl); } else { var _ctrl = SFXPlayUtility.Instance.PlayBattleEffect(_effectlist[i], m_HorseModel.transform.GetChildTransformDeeply(_boneList[i])); m_HorseEffectList.Add(_ctrl); } } } } public void ChangeEquip(EquipInfo equipInfo) { // 传入ID为0代表脱下了装备 if (equipInfo.itemID == 0 && equipInfo.place != 0) { if (m_EquipDict.ContainsKey(equipInfo.place)) { m_EquipDict.Remove(equipInfo.place); } } else { m_EquipDict[equipInfo.place] = equipInfo; } } public abstract void SyncSuitEffect(); private bool TryRequest(uint itemID, ref GameObject model) { ItemConfig _itemConfig = ItemConfig.Get((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 = ItemConfig.Get((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 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); } 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 = FuncConfigConfig.Get("MoveSpeedClient"); Equation.Instance.Clear(); Equation.Instance.AddKeyValue("speed", speedValue); float _speed = Equation.Instance.Eval(_funcConfig.Numerical1); ActorInfo.moveSpeed = _speed; } public void CalculateAtkSpeed(float speedValue) { FuncConfigConfig _funcConfig = FuncConfigConfig.Get("AtkInterval"); Equation.Instance.Clear(); Equation.Instance.AddKeyValue("atkSpeed", speedValue); float _speed = Equation.Instance.Eval(_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 ReleaseShadow() { if (m_ShadowCaster != null) { m_ShadowCaster.Stop(); m_ShadowCaster = null; } if (m_Shadow) { SFXPlayUtility.Instance.Release(m_Shadow); m_Shadow = null; } } 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; } } private void OnGameQualityChange() { RequestShadow(); } /// /// 显示或者隐藏表现层 /// /// 显示: true, 隐藏: false 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_Player _player = this as GA_Player; if (_player != null) { if (m_EmptyJY) { GameObjectPoolManager.Instance.ReleaseEmptyJY(m_EmptyJY); m_EmptyJY = null; } if (!showOrHide) { m_EmptyJY = GameObjectPoolManager.Instance.RequestEmptyJY(); m_EmptyJY.transform.SetParent(Root); m_EmptyJY.transform.localPosition = Vector3.zero; m_EmptyJY.transform.localScale = Vector3.one; m_EmptyJY.AddMissingComponent(); 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); } GA_Pet _pet = GAMgr.Instance.GetBySID(ServerInstID * 10 + 1) as GA_Pet; var _index = BattleEffectPlayRule.Instance.GetIndex(ServerInstID); if (_index != -1 && _index < BattleEffectPlayRule.Instance.petLimit) { if (_pet != null) { _pet.ShowOrHideModel(true); } if (m_Guard == null) { SwitchGuard((uint)_player.serverGuardId); } } else { if (_pet != null) { _pet.ShowOrHideModel(false); } if (m_Guard != null) { SwitchGuard(0); } } } ShowOrHide = showOrHide; } /// /// 判断技能是否可以被打断 /// 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) { if (this is GA_NpcFightZZPlayer) { switch (JobSetup.Job) { case 1: return 12500 + index; case 2: return 12600 + index; } } else if (this is GA_NpcFightSgzcZZ) { switch (JobSetup.Job) { case 1: return 12000 + index; case 2: return 12100 + index; } } else { 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; protected float m_RushTime; public void StartRush() { if (m_IsRushing) { return; } m_RushTime = 0; 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 (this is GA_Hero || BattleEffectPlayRule.Instance.CanPlay(ServerInstID)) { if (m_RushEffect == null) { m_RushEffect = SFXPlayUtility.Instance.PlayEffectAsync(50401, this); if (m_RushEffect) { 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); if (!CrossServerUtility.IsCrossServer()) { GameNetSystem.Instance.SendInfo(_b404); } else { GameNetSystem.Instance.SendToCrossServer(_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; } } } private Dictionary m_GodWeaponEffectDict = new Dictionary(); public virtual void ShowGodWeaponEffect() { } public void HideGodWeaponEffect() { SwitchGodWeapon(1, 0); SwitchGodWeapon(2, 0); SwitchGodWeapon(4, 0); } public void SwitchGodWeapon(int type, int level) { bool _showOrHide = true; GodWeaponEffectConfig _config = null; if (level <= 0) { _showOrHide = false; } else { _config = GodWeaponEffectConfig.Get(type, level); if (_config == null) { _showOrHide = false; } } SFXController _effect = null; if (m_GodWeaponEffectDict.TryGetValue(type, out _effect)) { if (_effect) { SFXPlayUtility.Instance.Release(_effect); m_GodWeaponEffectDict.Remove(type); } } if (_showOrHide) { Transform _bindBone = null; if (m_ClothesModel != null) { switch (type) { case 1: _bindBone = m_ClothesModel.transform.GetChildTransformDeeply(GAStaticDefine.SecondaryBindBoneName[JobSetup.Job - 1]); break; case 2: _bindBone = m_ClothesModel.transform.GetChildTransformDeeply(GAStaticDefine.WeaponBindBoneName); break; case 4: _bindBone = m_ClothesModel.transform.GetChildTransformDeeply("Bip001 Neck"); break; } } if (_bindBone) { var _effectJson = LitJson.JsonMapper.ToObject(_config.effect); var _effectID = int.Parse(_effectJson[JobSetup.Job.ToString()].ToString()); _effect = SFXPlayUtility.Instance.PlayBattleEffect(_effectID, _bindBone); m_GodWeaponEffectDict[type] = _effect; } } } }