using vnxbqy.UI; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Events; public class GA_Hero : GActorPlayerBase, ICtrlGA { public static Vector3 recordServerPos; public static Vector3 MapOffset; public static bool s_MapSwitching = false; public static bool s_Flying = false; //public static bool s_MapSwitching //{ // get // { // return _s_MapSwitching; // } // set // { // _s_MapSwitching = value; // Debug.Log("---------- MapSwitching: " + value); // } //} public static event UnityAction OnStartBeAttacked; public static event UnityAction OnStopBeAttacked; public static void CallOnStartBeAttacked(uint sid) { if (OnStartBeAttacked != null) { OnStartBeAttacked(sid); } } public static void CallOnStopBeAttacked(uint sid) { if (OnStopBeAttacked != null) { OnStopBeAttacked(sid); } } public static event UnityAction OnStateEnter; public static event UnityAction OnStateEnd; public static void CallOnStateEnter(float length) { if (OnStateEnter != null) { OnStateEnter(length); } } public static void CallOnStateEnd() { if (OnStateEnd != null) { OnStateEnd(); } } /// /// 当切换锁定目标的时候, 为空的时候id=0 /// public static event UnityAction OnLockTargetChanged; public static void CallLockTargetChanged(uint sid) { if (OnLockTargetChanged != null) { OnLockTargetChanged(sid); #if UNITY_EDITOR Debug.LogFormat("执行了切换锁定目标的逻辑: {0}", sid); #endif } } public static event UnityAction OnKillPlayer; private GameObject m_Light; public static bool forceAutoFight; /// /// 锁定目标对象 /// 用户点击锁定, 被攻击锁定攻击者... /// private GActor m_LockTarget; public GActor LockTarget { get { return m_LockTarget; } set { if (m_LockTarget == value) { return; } #if UNITY_EDITOR // if (m_LockTarget is GA_Player && value != null && !(value is GA_Player)) // { // if (value != null) // { // Debug.LogFormat("更换了锁定目标: {0} ", value.ServerInstID); // } // else // { // Debug.LogFormat("清空了锁定目标: null"); // } // } #endif m_LockTarget = value; } } public MapArea currentBossArea; private uint _atkBossID; public uint atkBossID { get { return _atkBossID; } set { if (_atkBossID != value) { _atkBossID = value; //if (_atkBossID != 0) //{ // Debug.LogFormat("设置攻击的bossID: {0}", atkBossID); //} //else //{ // Debug.LogFormat("清空bossID"); //} } } } public sealed override int NextAction { get { return base.NextAction; } set { base.NextAction = value; } } public sealed override GActor SelectTarget { get { return base.SelectTarget; } set { if (base.SelectTarget == value) { return; } IOtherSelectable _selectable = base.SelectTarget as IOtherSelectable; if (_selectable != null) { _selectable.OnUnSelect(); } _selectable = value as IOtherSelectable; if (_selectable != null) { _selectable.OnSelect(); } base.SelectTarget = value; if (PlayerDatas.Instance.baseData.AttackMode == (byte)E_AttackMode.Contest) { var _pkg = new CA202_tagCMSelectObj(); if (value == null) { _pkg.isSelect = 0; } else { _pkg.isSelect = 1; _pkg.ID = value.ServerInstID; _pkg.Type = (byte)value.ActorType; } if (CrossServerUtility.IsCrossServer()) { GameNetSystem.Instance.SendToCrossServer(_pkg); } else { GameNetSystem.Instance.SendInfo(_pkg); } } } } public HeroBehaviour Behaviour; public HeroAIHandler aiHandler; private Bhv_FindEnemy m_BhvFindEnemy; private float m_LastSyncTickTime = 0; protected sealed override void OnInit(GameNetPackBasic package) { CharacterController _charCtrl = Root.AddMissingComponent(); _charCtrl.height = 1.2f; _charCtrl.center = new Vector3(0, .6f, 0); _charCtrl.radius = .4f; Root.gameObject.layer = LayerUtility.Hero; m_BhvFindEnemy = Root.AddMissingComponent(); JobSetup = JobSetupConfig.Get(PlayerDatas.Instance.baseData.Job); Behaviour = new HeroBehaviour(this); aiHandler = new HeroAIHandler(); base.OnInit(package); ActorInfo.familyID = PlayerDatas.Instance.baseData.FamilyId; OnPathFinding += MapTransferUtility.Instance.OnHeroPathFinding; UserInputHandler.OnCirclePanelTouched += OnCirclePanelTouched; UserInputHandler.OnClickedFloor += OnClickedFloor; HeroBehaviour.OnStopHandupAI += OnStopHandupAI; FuncOpen.Instance.OnFuncStateChangeEvent += OnFunctionOpen; ModelCenter.Instance.GetModel().appearanceChangeEvent += SwitchSuit; m_CalculAutoFightTime = Time.realtimeSinceStartup; m_LastSyncTickTime = Time.realtimeSinceStartup; ModelCenter.Instance.GetModel().onReikiRootEffectRefresh += OnReikiEffectRefresh; } private void OnReikiEffectRefresh() { ReqLingGenEffect((int)(PlayerDatas.Instance.baseData.equipShowSwitch / 10 % 100), (int)(PlayerDatas.Instance.baseData.equipShowSwitch / 1000 % 1000)); } private List m_SuitEffectList = new List(); public override void SyncSuitEffect(bool onOrOff = true) { RlsSuitEffect(); onOrOff = (PlayerDatas.Instance.baseData.equipShowSwitch % 10) > 0; var _itemConfig = ItemConfig.Get((int)ClothesItemID); if (_itemConfig != null) { Material _replaceMat = null; if (onOrOff) { _replaceMat = MaterialLoader.LoadClothesMaterial(_itemConfig.ChangeOrd, false, true); } else { _replaceMat = MaterialLoader.LoadClothesMaterial(_itemConfig.ChangeOrd, false, false); } if (_replaceMat) { MaterialLoader.Release(m_SMRenderer.material); m_SMRenderer.material = m_Material = _replaceMat; MaterialUtility.SwitchXrayShader(m_SMRenderer.material, true); } if (onOrOff) { var _modelResConfig = ModelResConfig.Get(_itemConfig.ChangeOrd); if (_modelResConfig != null) { var _boneList = ModelResConfig.GetBoneList(_modelResConfig.ResourcesName); var _effectList = ModelResConfig.GetEffectList(_modelResConfig.ResourcesName); if (_boneList != null) { Transform _node = null; SFXController _sfx = null; for (int i = 0; i < _boneList.Count; ++i) { _node = Root.GetChildTransformDeeply(_boneList[i]); if (_node) { _sfx = SFXPlayUtility.Instance.PlayEffectAsync(_effectList[i], _node); if (_sfx) { m_SuitEffectList.Add(_sfx); } } } } } } } m_SuitEffectShow = onOrOff; } private void RlsSuitEffect() { foreach (var _sfx in m_SuitEffectList) { if (_sfx != null) { SFXPlayUtility.Instance.Release(_sfx); } } m_SuitEffectList.Clear(); } protected sealed override void OnUnit() { UnityEngine.Object.Destroy(m_BhvFindEnemy); m_BhvFindEnemy = null; RlsSuitEffect(); OnPathFinding -= MapTransferUtility.Instance.OnHeroPathFinding; OnPathFindStop -= MapTransferUtility.Instance.OnHeroStopPathFind; ModelCenter.Instance.GetModel().appearanceChangeEvent -= SwitchSuit; FuncOpen.Instance.OnFuncStateChangeEvent -= OnFunctionOpen; Behaviour = null; m_LockTarget = null; MaterialUtility.SwitchXrayShader(m_Material, false); MaterialUtility.SwitchXrayShader(m_WingMaterial, false); MaterialUtility.SwitchXrayShader(m_HorseMaterial, false); MaterialUtility.SwitchXrayShader(m_WeaponMaterial, false); MaterialUtility.SwitchXrayShader(m_SecondaryMaterial, false); m_WingMaterial = null; m_HorseMaterial = null; m_WeaponMaterial = null; m_SecondaryMaterial = null; ReleaseLight(); base.OnUnit(); } public sealed override void Destroy() { } public float forceAutoFightTime; private float m_ChkOpenAutoEscapeTime; private DungeonModel m_DungeonModel; public DungeonModel dungeonModel { get { return m_DungeonModel ?? (m_DungeonModel = ModelCenter.Instance.GetModel()); } } protected sealed override void OnUpdate() { base.OnUpdate(); if (!forceAutoFight) { if (Time.realtimeSinceStartup - m_ChkOpenAutoEscapeTime > 2f) { int _dgDataID = dungeonModel.GetDataMapIdByMapId(PlayerDatas.Instance.baseData.MapID); if (DungeonOpenTimeConfig.Has(_dgDataID)) { var dungeonOpen = DungeonOpenTimeConfig.Get(_dgDataID); if (dungeonOpen.DoFight == 1) { forceAutoFight = true; } } m_ChkOpenAutoEscapeTime = Time.realtimeSinceStartup; } } if (forceAutoFight #if UNITY_EDITOR && RuntimeLogUtility.s_forceAutoFight #endif && !CrossServerUtility.IsCrossServerOneVsOne()) { if (!aiHandler.IsAuto() && !BossShowModel.Instance.BossShowing) { if (IsIdle()) { if (Time.realtimeSinceStartup - forceAutoFightTime > 2) { Behaviour.StartHandupAI(); } } else { forceAutoFightTime = Time.realtimeSinceStartup; } } } aiHandler.Update(); bool _isCastSkill = false; if (SkillMgr.CurCastSkill != null) { _isCastSkill = !SkillMgr.CurCastSkill.SkillCompelete; } // 每隔1分钟同步一次tick if (Time.realtimeSinceStartup - m_LastSyncTickTime > 60) { PlayerDatas.Instance.RequestWorldTick(); m_LastSyncTickTime = Time.realtimeSinceStartup; } if ((IsRun() || IsIdle() || UserInputHandler.isTouched) && UserInputHandler.IsMoveValid()) { float _distance = MathUtility.DistanceSqrtXZ(PrevPos, Pos); if (_distance > 0.25f) { PrevPos = Pos; UserInputHandler.Send_CB409_tagCMPyMove(); } } HandleBossAttack(); if (CrossServerUtility.IsCrossServerOneVsOne() || ArenaManager.isArenaClient) { if (LockTarget is GActorNpcFight || LockTarget == null) { var _list = GAMgr.Instance.GetTypeList(E_ActorClassType.Player); if (_list != null && _list.Count > 0) { LockTarget = _list[0]; } } } } private static bool m_StartAutoHazyRegion = false; public static bool startAutoHazyRegion { get { return m_StartAutoHazyRegion; } set { m_StartAutoHazyRegion = false; // if (m_StartAutoHazyRegion != value) // { // if (ModelCenter.Instance.GetModel().auto) // { // if (value) // { // SysNotifyMgr.Instance.ShowTip("Automatic_PMXY"); // } // else // { // SysNotifyMgr.Instance.ShowTip("Automatic_PMXY1"); // } // } //#if UNITY_EDITOR // Debug.Log("自动开始飘渺仙域: " + value); //#endif // } // m_StartAutoHazyRegion = value; // if (m_StartAutoHazyRegion == false) // ModelCenter.Instance.GetModel().auto = false; } } private float m_CalcAutoHazyRegionTime = 0; public float LastChkCanAutoHazyRegionTime = 0; public float hazyAutoWaitTime = 3; HazyRegionModel m_HazyRegionModel; HazyRegionModel hazyRegionModel { get { return m_HazyRegionModel ?? (m_HazyRegionModel = ModelCenter.Instance.GetModel()); } } DailyQuestModel m_DailyQuestModel; DailyQuestModel dailyQuestModel { get { return m_DailyQuestModel ?? (m_DailyQuestModel = ModelCenter.Instance.GetModel()); } } #if UNITY_EDITOR private int m_CalcTime; private int m_CalcTime2; #endif private void HandleAutoHazyRegion() { if (!hazyRegionModel.auto) { return; } if (!startAutoHazyRegion) { if (hazyRegionModel.IsIncidentDungeon() || AdventureStage.Instance.IsInAdventureStage) { m_CalcAutoHazyRegionTime += Time.deltaTime; #if UNITY_EDITOR int _t2 = Mathf.FloorToInt(m_CalcAutoHazyRegionTime); if (_t2 != m_CalcTime2) { Debug.LogFormat("处于前端副本内,开始倒计时开始自动飘渺仙域时间 {0} / 5", _t2); m_CalcTime2 = _t2; } #endif } if (m_CalcAutoHazyRegionTime > 3) { startAutoHazyRegion = true; } return; } m_CalcAutoHazyRegionTime = 0; if (ActorInfo.serverDie) { return; } //if (WindowCenter.Instance.ExistAnyFullScreenOrMaskWin() // && (!WindowCenter.Instance.IsOpen() && !WindowCenter.Instance.IsOpen())) //{ // startAutoHazyRegion = false; // return; //} if (AdventureStage.Instance.IsInAdventureStage || ClientDungeonStageUtility.isClientDungeon || CrossServerUtility.IsCrossServer()) { return; } if (PlayerDatas.Instance.extersion.bossState == 1) { return; } if (PlayerDatas.Instance.extersion.pkState == 1) { return; } var _mapConfig = MapConfig.Get(PlayerDatas.Instance.baseData.MapID); if (_mapConfig.MapFBType != (int)MapType.OpenCountry) { return; } if (taskmodel.IsTaskMove()) { return; } LastChkCanAutoHazyRegionTime += Time.deltaTime; #if UNITY_EDITOR int _tmpTime = Mathf.FloorToInt(LastChkCanAutoHazyRegionTime); if (_tmpTime != m_CalcTime) { m_CalcTime = _tmpTime; Debug.LogFormat("自动执行缥缈仙玉倒计时: {0} / {1}", m_CalcTime, hazyAutoWaitTime); } #endif if (LastChkCanAutoHazyRegionTime < hazyAutoWaitTime) { return; } var _list = new List(hazyRegionModel.GetAllIncidents()); // 是否已经存在可前往的事件 if (_list.Count > 0) { HazyRegionModel.Incident _incident; int _eventID = -1; foreach (var _id in _list) { if (hazyRegionModel.TryGetIncident(_id, out _incident)) { if (_incident.state != HazyRegionModel.IncidentState.Complete) { _eventID = _id; break; } } } if (_eventID == -1) { hazyRegionModel.SendBackHazyRegion(); hazyAutoWaitTime = 2; #if UNITY_EDITOR Debug.LogFormat("所有寻访都已经结束了, 这里结束寻访, 设置下次等待时间 2"); #endif } else { hazyRegionModel.SendGotoIncident(_eventID); hazyAutoWaitTime = 2; #if UNITY_EDITOR Debug.LogFormat("进行 {0} 寻访, 设置下次等待时间 2", _eventID); #endif } } else { if (dailyQuestModel.usableActivePoint > hazyRegionModel.openActviePoint) { hazyRegionModel.SendOpenHazyRegion(); hazyAutoWaitTime = 2; #if UNITY_EDITOR Debug.LogFormat("开启寻访, 设置等待时间为 2"); #endif } } LastChkCanAutoHazyRegionTime = 0; } private void HandleBossAttack() { if (PlayerDatas.Instance.extersion.bossState != 1) { return; } if (LockTarget != null) { return; } GA_Player _player = SelectTarget as GA_Player; if (_player == null) { return; } foreach (var _key in DungeonStage.s_MapAreaDict.Keys) { if ((int)_key < 3000) { continue; } var _areaList = DungeonStage.s_MapAreaDict[_key]; if (_areaList == null) { continue; } MapArea _area = null; for (int i = 0; i < _areaList.Count; ++i) { _area = _areaList[i]; if (_area != currentBossArea) { continue; } if (_area.IsPosOut(_player.Pos)) { SelectTarget = null; if (atkBossID != 0) { MapTransferUtility.Instance.MoveToNPC((int)atkBossID); } } } } } protected sealed override void OnFixedUpdate() { base.OnFixedUpdate(); if (IsRushing) { m_RushTime += Time.deltaTime; if (m_RushTime > 2) { StopRush(); } } if (PlayerDatas.Instance.baseData.MapID == 31340) { if (State == E_ActorState.AutoRun || State == E_ActorState.CtrlRun) { var _collect = GAMgr.Instance.GetCloserCollectNpc(Pos) as GA_NpcCollect; if (_collect != null) { var _dist = MathUtility.DistanceSqrtXZ(_collect.Pos, Pos); if (_dist < 6) { if ((SelectTarget == null || SelectTarget is GA_NpcCollect) && SelectTarget != _collect) { SelectTarget = _collect; PrepareHandler.Instance.Arrive(_collect); } } } } else if (State == E_ActorState.Idle) { if (SelectTarget == null) { var _collect = GAMgr.Instance.GetCloserCollectNpc(Pos) as GA_NpcCollect; if (_collect != null) { var _dist = MathUtility.DistanceSqrtXZ(_collect.Pos, Pos); if (_dist < 6) { SelectTarget = _collect; PrepareHandler.Instance.Arrive(_collect); } } } } } } protected sealed override void OnLateUpdate() { base.OnLateUpdate(); UpdateAutoStartFight(); HandleAutoHazyRegion(); } protected sealed override void OnPutonClothes(uint clothesItemID, GameObject clothed) { clothed.layer = LayerUtility.Hero; SkinnedMeshRenderer _renderer = clothed.GetComponentInChildren(); _renderer.gameObject.SetLayer(LayerUtility.Hero, false); MaterialUtility.SwitchXrayShader(m_Material, true); GameObjectPoolManager.Instance.AddDontDestroyGoInstID(clothed.GetInstanceID()); StopRush(); Behaviour.StopKillUntilDieAI(); ReqLingGenEffect((int)(PlayerDatas.Instance.baseData.equipShowSwitch / 10 % 100), (int)(PlayerDatas.Instance.baseData.equipShowSwitch / 1000 % 1000)); } protected sealed override void OnPutonSecondary(uint secondaryItemID, GameObject secondary) { if (secondary) { Renderer _renderer = secondary.GetComponent(); if (_renderer) { _renderer.gameObject.SetLayer(LayerUtility.Hero, false); m_SecondaryMaterial = _renderer.material; MaterialUtility.SwitchXrayShader(m_SecondaryMaterial, true); } GameObjectPoolManager.Instance.AddDontDestroyGoInstID(secondary.GetInstanceID()); } } protected sealed override void OnPutonWeapon(uint weaponItemID, GameObject weapon) { Renderer _renderer = weapon.GetComponent(); if (_renderer) { _renderer.gameObject.SetLayer(LayerUtility.Hero, false); m_WeaponMaterial = _renderer.material; MaterialUtility.SwitchXrayShader(m_WeaponMaterial, true); } GameObjectPoolManager.Instance.AddDontDestroyGoInstID(weapon.GetInstanceID()); } protected sealed override void OnPutonWing(uint wingItemID, GameObject wing) { wing.gameObject.layer = LayerUtility.Hero; SkinnedMeshRenderer _renderer = wing.GetComponentInChildren(); _renderer.gameObject.SetLayer(LayerUtility.Hero, false); m_WingMaterial = _renderer.material; MaterialUtility.SwitchXrayShader(m_WingMaterial, true); GameObjectPoolManager.Instance.AddDontDestroyGoInstID(wing.GetInstanceID()); } protected sealed override void OnSwitchHorse(uint horseID, GameObject horse) { horse.layer = LayerUtility.Hero; SkinnedMeshRenderer _renderer = horse.GetComponentInChildren(); _renderer.gameObject.SetLayer(LayerUtility.Hero, false); m_HorseMaterial = _renderer.material; MaterialUtility.SwitchXrayShader(m_HorseMaterial, true); GameObjectPoolManager.Instance.AddDontDestroyGoInstID(horse.GetInstanceID()); } public override void OnHorse(byte upOrDown) { if (upOrDown == 1) { var _packModel = ModelCenter.Instance.GetModel(); var _horseItem = _packModel.GetItemByIndex(PackType.Equip, 5); if (_horseItem != null) { SwitchHorse((uint)_horseItem.itemId); } } else { SwitchHorse(0); } } public sealed override void RefreshLifeBar(ulong value) { } public override void RequestName() { ReleaseName(); if (MovingState == E_MovingState.Ride) { m_HeadUpName = HeadUpName.RequireHeadUpName(HeadUpName.Pattern.Hero, MP_Name1, 0, CameraController.Instance.CameraObject); } else { m_HeadUpName = HeadUpName.RequireHeadUpName(HeadUpName.Pattern.Hero, MP_Name, 0, CameraController.Instance.CameraObject); } // 称号 var titleModel = ModelCenter.Instance.GetModel(); var _title = titleModel.GetTitleEquip(); uint _titleID = 0; if (_title != null && titleModel.IsTitleGain(_title.id) && PlayerDatas.Instance.baseData.MapID != 31160)//上古战场不显示称号 { _titleID = (uint)_title.id; } var _familyName = string.Empty; // 仙盟 if (PlayerDatas.Instance.baseData.FamilyId != 0) { _familyName = PlayerDatas.Instance.baseData.FamilyName; } m_HeadUpName.SetPlayerInfo( new HeadUpName.PlayerInfo() { realm = PlayerDatas.Instance.baseData.realmLevel, title = _titleID, name = PlayerDatas.Instance.baseData.PlayerName, alliance = _familyName, faction = (int)PlayerDatas.Instance.baseData.faction, } ); RefreshShediaoEffect(_titleID); if (StatusMgr.Instance.IsExist(ServerInstID, StatusMgr.Instance.bossBelongBuffID)) { m_HeadUpName.SetBossDropout(true); } if (StatusMgr.Instance.IsExist(ServerInstID, StatusMgr.Instance.crossKingBuffID)) { m_HeadUpName.SetCrossKing(true); } base.SetFairyLeagueHeadUp(PlayerDatas.Instance.baseData.MapID == FairyLeagueModel.FAIRY_LEAGUE_DUNGEON); CheckAncientHeadUp(); } public sealed override void SwitchRedName(bool on) { if (PlayerDatas.Instance.baseData.MapID == FairyLeagueModel.FAIRY_LEAGUE_DUNGEON) { return; } base.SwitchRedName(on); } public sealed override void SwitchYellowName(bool on) { if (PlayerDatas.Instance.baseData.MapID == FairyLeagueModel.FAIRY_LEAGUE_DUNGEON) { return; } base.SwitchYellowName(on); } public override void SwitchRealm(int _realm) { if (m_HeadUpName == null) { return; } m_HeadUpName.SetPlayerRealm(_realm); } private void OnFunctionOpen(int functionId) { if (functionId == 12) { SwitchRealm(PlayerDatas.Instance.baseData.realmLevel); } } public sealed override void Die() { LockTarget = null; SelectTarget = null; base.Die(); } public sealed override void Collect() { if (ActorInfo.serverDie) { return; } base.Collect(); Behaviour.StopKillUntilDieAI(); Behaviour.StopHandupAI(); } public bool CanMove() { if (IsHurt() || IsRushing || ActorInfo.serverDie || State == E_ActorState.Mocked || IsDaZuo() || BossShowModel.Instance.BossShowing || heavenBattleModel.IsBattlePrepare || BeBeating) { return false; } if (StatusMgr.IsValid() && !StatusMgr.Instance.CanMove(ServerInstID)) { return false; } if (State == E_ActorState.Idle || State == E_ActorState.AutoRun || State == E_ActorState.CtrlRun) { return true; } return false; } public bool CanRotate() { return State != E_ActorState.Mocked && !IsDaZuo(); } private HeavenBattleModel m_HeavenBattleModel = null; public HeavenBattleModel heavenBattleModel { get { return m_HeavenBattleModel ?? (m_HeavenBattleModel = ModelCenter.Instance.GetModel()); } } public bool CanCommonAtk() { return !MapArea.IsInMapArea(CurMapArea, MapArea.E_Type.Safe) && !MapArea.IsInMapArea(CurMapArea, MapArea.E_Type.RebornSafe) && !IsStun() && !IsHurt() && !IsDaZuo() && State != E_ActorState.Roll && !s_MapSwitching && !heavenBattleModel.IsBattlePrepare && !BeBeating; } public bool CanCastSkill() { return !MapArea.IsInMapArea(CurMapArea, MapArea.E_Type.Safe) && !MapArea.IsInMapArea(CurMapArea, MapArea.E_Type.RebornSafe) && !IsHurt() && !IsDaZuo() && State != E_ActorState.Roll && State != E_ActorState.Mocked && !s_MapSwitching && !heavenBattleModel.IsBattlePrepare && !BeBeating; } public void StopAll() { MapTransferUtility.Instance.Clear(); StopRush(); Behaviour.StopHandupAI(true); Behaviour.StopKillUntilDieAI(); if (State == E_ActorState.AutoRun || PathFindStatus == E_PathFindStatus.Moving) { StopPathFind(); } if (!ActorInfo.serverDie) { IdleImmediate(); } } public void SwitchTarget() { if (m_BhvFindEnemy) { m_BhvFindEnemy.SwitchTarget(); } } public void RequestLight() { ReleaseLight(); if (PlayerDatas.Instance.baseData.MapID == 31160) { m_Light = UnityEngine.Object.Instantiate(BuiltInLoader.LoadPrefab("Zhujiao_Pointlight")); m_Light.transform.SetParent(MP_Name); m_Light.transform.localPosition = Vector3.zero; m_Light.transform.localScale = Vector3.one; m_Light.transform.localRotation = Quaternion.identity; } } public void ReleaseLight() { if (m_Light) { UnityEngine.Object.Destroy(m_Light); m_Light = null; } } public void KillPlayer(uint sid, string name) { #if UNITY_EDITOR Debug.LogFormat("杀死了玩家: {0}, {1}", sid, name); #endif if (OnKillPlayer != null) { OnKillPlayer(sid, name); } } #region 地图区域相关处理 private int m_CurMapArea = 1 << (int)MapArea.E_Type.Normal; public int CurMapArea { get { return m_CurMapArea; } set { m_CurMapArea = value; } } public static UnityAction OnEnterOrExitArea; public void EnterArea(int type) { if (type < 3000) { CurMapArea |= type; if (OnEnterOrExitArea != null) { OnEnterOrExitArea((MapArea.E_Type)type, true); } if (type == (int)MapArea.E_Type.RebornSafe || type == (int)MapArea.E_Type.Safe) { if (aiHandler.IsAuto()) { Behaviour.StopKillUntilDieAI(); Behaviour.StopHandupAI(); } } } } public void ExitArea(int type) { if (type < 3000) { CurMapArea &= ~type; if (OnEnterOrExitArea != null) { OnEnterOrExitArea((MapArea.E_Type)type, false); } } } #endregion #region 站前冲锋相关逻辑 public bool IsNeedRush(float distanceSqrt) { if (IsRushing) { return false; } if (PreFightMission.Instance.IsFinished()) { if (Time.time - m_LastRushTime <= JobSetup.RushInterval * Constants.F_DELTA) { return false; } } if (JobSetup.RushTargetType == 0 || (JobSetup.RushTargetType == 2 && SelectTarget is GActorNpcFight) || (JobSetup.RushTargetType == 1 && SelectTarget is GA_Player)) { float _minDistSqrt = JobSetup.RushMinDist * Constants.F_DELTA; _minDistSqrt *= _minDistSqrt; float _maxDistSqrt = JobSetup.RushMaxDist * Constants.F_DELTA; _maxDistSqrt *= _maxDistSqrt; if (PreFightMission.Instance.IsFinished() == false) { _minDistSqrt = 1f; _maxDistSqrt = 100f; } if (distanceSqrt > _minDistSqrt && distanceSqrt < _maxDistSqrt) { return true; } } return false; } #endregion #region 攻击相关逻辑 public void ComAtk() { if (MapArea.IsInMapArea(CurMapArea, MapArea.E_Type.Safe) || MapArea.IsInMapArea(CurMapArea, MapArea.E_Type.RebornSafe)) { SysNotifyMgr.Instance.ShowTip("NoFighting"); return; } if (!CanCommonAtk()) { return; } if (!PreFightMission.Instance.IsFinished()) { if (SelectTarget != null) { if (!PathFinder.WalkAble(Pos, SelectTarget.Pos)) { SelectTarget = GAMgr.Instance.FindAtkTarget(Pos, 10, 360); } } } if (UserInputHandler.isTouched) { int _index = nextComAtkIndex == -1 ? 0 : nextComAtkIndex; int _skillID = GetCommonSkillID(_index); Skill _skill = SkillMgr.Get(_skillID); float _skillDist = _skill.skillInfo.config.AtkDist * .5f; GActor _dirTarget = GAMgr.Instance.FindAtkTarget(Pos, _skillDist, 90); if (_dirTarget != null) { LockTarget = _dirTarget; SelectTarget = _dirTarget; } } Behaviour.StartKillUntilDieAI(); } public void CastSkill(int skillID) { if (!PreFightMission.Instance.IsFinished()) { if (SelectTarget != null) { destForward = -SelectTarget.Forward; Forward = destForward; } } if (MapArea.IsInMapArea(CurMapArea, MapArea.E_Type.Safe) || MapArea.IsInMapArea(CurMapArea, MapArea.E_Type.RebornSafe)) { SysNotifyMgr.Instance.ShowTip("NoFighting"); return; } if (!PreFightMission.Instance.IsFinished() && skillID == 190) { } else { if (!CanCastSkill()) { return; } } Skill _skill = SkillMgr.Get(skillID); if (!_skill.IsValid()) { return; } if (SelectTarget != null) { E_SkillCastTarget _targetType = (E_SkillCastTarget)(_skill.skillInfo.config.Tag / 10); E_SkillCastType _castType = (E_SkillCastType)(_skill.skillInfo.config.Tag % 10); if (_castType == E_SkillCastType.NeedTarget) { if (!AttackHandler.CanAttack(_targetType, this, SelectTarget as GActorFight)) { SysNotifyMgr.Instance.ShowTip("SkillSelectedTarget"); return; } } } if (skillID == 190) { if (State != E_ActorState.Roll) { if (SkillMgr.CurCastSkill != null) { int _id = SkillMgr.CurCastSkill.id; bool _canBreak = false; foreach (var _skillID in JobSetup.RollBreakSkillList) { if (_id == _skillID) { _canBreak = true; break; } } if (_canBreak) { SkillMgr.CurCastSkill.SkillCompelete = true; Behaviour.DoAttack(_skill); return; } } } } if (MapArea.IsInMapArea(CurMapArea, MapArea.E_Type.Safe) || MapArea.IsInMapArea(CurMapArea, MapArea.E_Type.RebornSafe)) { SysNotifyMgr.Instance.ShowTip("NoFighting"); return; } Behaviour.StartKillUntilDieAI(skillID); } #endregion #region 自动开启自动战斗逻辑 private float m_CalculAutoFightTime; public float calculAutoFightTime { get { return m_CalculAutoFightTime; } } TaskModel m_TaskModel; TaskModel taskmodel { get { return m_TaskModel ?? (m_TaskModel = ModelCenter.Instance.GetModel()); } } PlayerMainDate m_MainModel; PlayerMainDate onMainModel { get { return m_MainModel ?? (m_MainModel = ModelCenter.Instance.GetModel()); } } public float Second = 2.5f; private float timeType = 0f; private bool isbool = true; private void UpdateAutoStartFight() { timeType += Time.deltaTime; if (timeType > Second && !isbool) { timeType = 0f; isbool = true; } if (timeType > Second && isbool) { timeType = 0f; } if (DTCB105_tagMCPlayerWallow.forceOffLine) { return; } if (ActorInfo.serverDie) { return; } if (taskmodel.IsTaskMove()) { if (Time.realtimeSinceStartup - m_CalculAutoFightTime > taskmodel.TaskAutoTime && !NewBieCenter.Instance.inGuiding && TaskModel.IsOPenAutoResolve()) { if (PlayerDatas.Instance.hero != null && PlayerDatas.Instance.hero.State == E_ActorState.AutoRun && onMainModel.MoveBool) { } else { SnxxzGame.Instance.StartCoroutine(Wait()); } } } if (MapArea.IsInMapArea(CurMapArea, MapArea.E_Type.Safe) || MapArea.IsInMapArea(CurMapArea, MapArea.E_Type.RebornSafe)) { return; } // 打坐状态下不自动开始战斗 if (IsDaZuo()) { return; } if (!aiHandler.IsAuto()) { if (HangUpSetModel.Instance.GetBool(HangUpAutoBoolType.isAutoHangUp) && !(AdventureStage.Instance.IsInAdventureStage || ClientDungeonStageUtility.isClientDungeon)) { if (Time.realtimeSinceStartup - m_CalculAutoFightTime > 60 && !NewBieCenter.Instance.inGuiding && TaskModel.IsOPenAutoResolve()) { MapTransferUtility.Instance.Clear(); Behaviour.StartHandupAI(); } } } } private IEnumerator Wait() { if (WindowCenter.Instance.IsOpen("VipExperienceWin") || !WindowCenter.Instance.IsOpen("MainInterfaceWin")) { yield break; } yield return WaitingForSecondConst.WaitMS1500; if (PlayerDatas.Instance.extersion.bossState == 1) { yield break; } var IsAuto = PlayerDatas.Instance.hero.aiHandler.IsAuto(); var inDungeon = IsDungeon();//是否在副本中 if (inDungeon || IsAuto) { yield break; } if (PlayerDatas.Instance.hero != null && PlayerDatas.Instance.hero.State == E_ActorState.AutoRun && onMainModel.MoveBool) { yield break; } if (isbool) { isbool = false; taskmodel.TaskMove(taskmodel.currentMission); } } private bool IsDungeon()//判断是否在副本中 { var mapId = PlayerDatas.Instance.baseData.MapID; var mapConfig = MapConfig.Get(mapId); return mapConfig != null && mapConfig.MapFBType != 0; } private SFXController m_ArrowEffect; public void ShowArrow(bool showOrHide) { if (showOrHide) { if (!m_ArrowEffect) { m_ArrowEffect = SFXPlayUtility.Instance.PlayBattleEffect(1052, this); if (PlayerDatas.Instance.baseData.MapID == 31230) { FaceTargetXZ _f = m_ArrowEffect.gameObject.AddComponent(); _f.targetPos = new Vector3(5.877f, 7.73f, 20.243f); } } } else { if (m_ArrowEffect) { FaceTargetXZ _f = m_ArrowEffect.GetComponent(); UnityEngine.Object.Destroy(_f); SFXPlayUtility.Instance.Release(m_ArrowEffect); m_ArrowEffect = null; } } } private void OnClickedFloor(Vector3 dest) { m_CalculAutoFightTime = Time.realtimeSinceStartup; } private void OnCirclePanelTouched() { m_CalculAutoFightTime = Time.realtimeSinceStartup; } private void OnStopHandupAI() { m_CalculAutoFightTime = Time.realtimeSinceStartup; } #endregion }