using Thousandto.Cfg.Data; using Thousandto.Code.Center; using Thousandto.Code.Global; using Thousandto.Code.Logic.LocalPlayerBT; using Thousandto.Core.Asset; using Thousandto.Core.Base; using Thousandto.Plugins.Common; using System; using System.Collections.Generic; using UnityEngine; using EventManager = UnityEngine.Gonbest.MagicCube.EventManager; using EventSystemHandler = UnityEngine.Gonbest.MagicCube.EventSystemHandler; using CoreEventDefine = UnityEngine.Gonbest.MagicCube.CoreEventDefine; using EventConstDefine = UnityEngine.Gonbest.MagicCube.EventConstDefine; namespace Thousandto.Code.Logic { /// /// 本地玩家 /// public class LocalPlayer : Player, IPlayerInputer { #region//私有变量 //反击列表 private Dictionary _strikeBackTable = new Dictionary(); //改变战斗力 private long _changeFightPower = 0; //安全区检测时间 private float _safeTileCheckTimer = 0f; private bool _frontSafeTile = false; private bool _firstCheckSafe = true; //玩家属性信息 private LocalPlayerProperty _propMoudleEx = null; //是否正在抓宠 private bool _isCatching = false; //存储玩家位置信息的内存块 private float[] _posBlock = null; //当前选中的boss,用以展示目标头像 private ulong _curSelectBoss = 0; private bool _showFightPower = true; private bool _showPropChange = true; #endregion #region//属性信息 public new LocalPlayerProperty PropMoudle { get { if (_propMoudleEx == null) { _propMoudleEx = base.PropMoudle as LocalPlayerProperty; } return _propMoudleEx; } } //仇恨列表 public Dictionary StrikeBackTable { get { return _strikeBackTable; } } //是否正在跳跃 public bool IsJumped { get { return Fsm.CurrentState.StateID == EntityStateID.Jump; } } //是否有效 -- 判断模型是否为null public bool IsValid { get { return ModelTransform != null; } } //获取战斗力 public override long FightPower { get { return _fightPower; } set { if (_fightPower != value) { if (_fightPower != 0) { long differ = value - _fightPower; _changeFightPower += differ; } _fightPower = value; GameCenter.PushFixEvent(LogicEventDefine.EID_EVENT_FIGHT_POWER_CHANGED, _fightPower); } } } //是否正在抓宠 public bool IsCatching { get { return _isCatching; } set { _isCatching = value; } } //当前经验值 public ulong CurExp { get { return PropMoudle.Exp; } } public PKMode PkMode { get { return PropMoudle.PkModel; } } //是否正在渡劫 public bool IsDuJieing { get;set; } //锁定当前装备 public bool LockEquip { get;set; } //当前称号 public override DeclareTitle CurPictureTitle { get { return DeclareTitle.Get(GameCenter.LuaSystem.Adaptor.GetCurrTitleID()); } } //展示战力变化 public bool ShowFightPower { get { return _showFightPower; } set { if(_showFightPower != value) { _showFightPower = value; if(!_showFightPower) { GameCenter.PushFixEvent(UIEventDefine.UIFightPowerChangeForm_CLOSE); } } } } //展示属性变化 public bool ShowPropChange { get { return _showPropChange; } set { if(_showPropChange != value) { _showPropChange = value; if(!_showPropChange) { GameCenter.PushFixEvent(UIEventDefine.UIPropertyChangeForm_CLOSE); } } } } #endregion #region//初始化以及卸载处理:加载Skin,初始化组件,初始化数据,反初始化 //加载Skin处理 protected override FSkinBase OnSetupSkin() { FSkinModel skin = GameCenter.LuaSystem.Adaptor.CreateFSkinModel(FSkinTypeCode.LocalPlayer); skin.SetLayer(LayerUtils.LocalPlayer); skin.SetActiveChangedCallBack(OnActiveChanged); skin.SetOnSkinPartChangedHandler((x, y) => { if (y == FSkinPartCode.Mount) { GameCenter.CameraControlUtil.FollowToCharacter(this, true); GameCenter.PushFixEvent(LogicEventDefine.EID_EVENT_UPDATMOUNTRIDE_STATE); if (IsXState(EntityStateID.Idle) || IsXState(EntityStateID.DirMove) || IsXState(EntityStateID.PathMove)) { x.StopAnim(); } var cfgId = Skin.GetSkinPartCfgID(FSkinPartCode.Mount); var cfg = DeclareHuaxingHorse.Get(cfgId); if (cfg != null) { RotBySceneHeight = cfg.RotBySceneHeight != 0; MountAnimSpeed = cfg.AnimSpeed / 100f; MountAnimSpeed /= 2;//fix yy } else //fix yy 当前狐狸40100坐骑不在配置表里 { RotBySceneHeight = true; //MountAnimSpeed = 1f; MountAnimSpeed = 0.5f; } var mPart = x.GetSkinPart(FSkinPartCode.Mount); if(cfgId > 0 && mPart != null) { var radious = mPart.GetRadious(); if(radious > 0) { SetRotationSpeed(FGameObjectRotater.CN_ROTATE_SPEED_DEFAULT * radious); } else { SetRotationSpeed(); } } else { SetRotationSpeed(); } } else if (y == FSkinPartCode.Body) { //重新挂载buff特效 GameCenter.BuffSystem.ReAddAllBuffVfx(this); var body = Skin.GetSkinPart(FSkinPartCode.Body); if (body != null) { FlySwordHeightTrans = body.FindTransform(SlotNameDefine.RightWeaponReceive); } } if (y == FSkinPartCode.GodWeaponHead) { var weaponModelID = Skin.GetSkinPartCfgID(FSkinPartCode.GodWeaponHead); var scaleCfg = DeclareWeaponScale.Get(weaponModelID); if (scaleCfg != null) { _receiveWeaponScale = new Vector3(scaleCfg.ReceiveScale / 100f, scaleCfg.ReceiveScale / 100f, scaleCfg.ReceiveScale / 100f); _brightWeaponScale = new Vector3(scaleCfg.BrightScale / 100f, scaleCfg.BrightScale / 100f, scaleCfg.BrightScale / 100f); } else { _receiveWeaponScale = Vector3.one; _brightWeaponScale = Vector3.one; } } if(y == FSkinPartCode.GodWeaponHead || y == FSkinPartCode.Body) { //SlotUtils.SetSlotLocalScale(Skin.RealTransform, SlotNameDefine.LeftWeapon, _brightWeaponScale); SlotUtils.SetSlotLocalScale(Skin.RealTransform, SlotNameDefine.RightWeapon, _brightWeaponScale); //SlotUtils.SetSlotLocalScale(Skin.RealTransform, SlotNameDefine.LeftWeaponReceive, _receiveWeaponScale); SlotUtils.SetSlotLocalScale(Skin.RealTransform, SlotNameDefine.RightWeaponReceive, _receiveWeaponScale); } }); return skin; } //初始化定制数据 protected override bool OnInitializeAfter(EntityInitInfo baseInfo) { base.OnInitializeAfter(baseInfo); //blackboard.Initialize(this); PlayerBT.InitializeBD(this); if (baseInfo != null) { var initInfo = baseInfo as LocalPlayerInitInfo; SyncInfo(initInfo); } ShowHUD(); _firstCheckSafe = true; ShowFightPower = true; ShowPropChange = true; GameCenter.RegFixEventHandle(CoreEventDefine.EID_EVENT_CAMERAFOLLOWDIS_CHANGED, OnCameraFollowDisChanged); return true; } //初始化属性数据 private void InitProps(LocalPlayerInitInfo initInfo) { _propMoudle = _propMoudlePlayer = _propMoudleEx = new LocalPlayerProperty(); _propMoudleEx.Owner = this; _propMoudleEx.ID = ID; _propMoudleEx.Occ =initInfo.Occ; _propMoudleEx.Name = initInfo.Name; _propMoudleEx.SceneCampID = initInfo.Camp; _propMoudleEx.PkModel = (PKMode)initInfo.PkMode; _propMoudleEx.XiSuiLevel = initInfo.XiSuiLevel; _propMoudleEx.Level = (uint)initInfo.Level; _propMoudleEx.VipLevel = (uint)initInfo.VipLevel; _propMoudleEx.VipExp = initInfo.VipExp; _propMoudleEx.GuildId = initInfo.Guild; _propMoudleEx.GuildRank = initInfo.GuildRank; _propMoudleEx.GuildName = initInfo.GuildName; _propMoudleEx.CurHP = (ulong)initInfo.CurHP; _propMoudleEx.CurLinLi = (ulong)initInfo.CurLingLi; _propMoudleEx.Exp = initInfo.Exp; _propMoudleEx.AccountId = initInfo.AccountId; _propMoudleEx.StateLevel = initInfo.StateLevel; _propMoudleEx.ShiHaiID = initInfo.ShiHaiID; _propMoudleEx.ServerID = initInfo.ServerID; _propMoudleEx.SetBattleProp(AllBattleProp.MoveSpeed, 500); _propMoudleEx.SetBattleProp(AllBattleProp.AttackSpeed, 100); _propMoudleEx.BattlePropertyChanged += BattlePropertyChange; } //数据信息同步 public void SyncInfo(LocalPlayerInitInfo initInfo) { //_spouseName = GameCenter.MarrySystem.SpouseName; if (initInfo != null) { InitProps(initInfo); _visualInfo = initInfo.VisualInfo; _propMoudleEx.FaBaoCfgID = initInfo.FaBaoCfgID; _propMoudleEx.FaBaoUID = initInfo.FaBaoUID; _propMoudleEx.FaBaoSprite1ID = initInfo.FaBaoSprite1ID; _propMoudleEx.FaBaoSprite2ID = initInfo.FaBaoSprite2ID; _propMoudleEx.FaBaoSprite3ID = initInfo.FaBaoSprite3ID; _propMoudleEx.FlySwordCfgID = initInfo.FlySwordCfgID; _propMoudleEx.FlySwordUID = initInfo.FlySwordUID; _propMoudleEx.FlySwordSkillId = initInfo.FlySwordSkillId; _propMoudleEx.ChangeJobLevel = initInfo.ChangeJobLevel; _propMoudleEx.MarryChildID = initInfo.MarryChildID; _propMoudleEx.MarryChildName = initInfo.MarryChildName; _fightPower = initInfo.FightPower; GameCenter.LuaSystem.Adaptor.RefreshPlayerModel(this, VisualInfo); EquipWithType(FSkinPartCode.Mount, initInfo.Mount); RayCastToGroundXOZ(new Vector2(initInfo.X, initInfo.Z)); //护送 FightPower = initInfo.FightPower; FashionHeadId = initInfo.FashionHeadId; FashionFrameId = initInfo.FashionFrameId; TexHeadPicID = initInfo.TexHeadPicID; IsShowHeadPic = initInfo.IsShowHeadPic; } } //卸载处理 protected override void OnUninitializeBefore() { _skillManager.Clear(); HideHUD(); _propMoudleEx.BattlePropertyChanged -= BattlePropertyChange; _propMoudle = _propMoudleEx = null; ClearStrikeBackCharacter(); GameCenter.SkillSelectFiledManager.DestoryFiled(); GameCenter.UnRegFixEventHandle(CoreEventDefine.EID_EVENT_CAMERAFOLLOWDIS_CHANGED, OnCameraFollowDisChanged); base.OnUninitializeBefore(); } // public override void EquipWithType(int type, int equipId, bool bClearVfx = true) { //锁定当前装备时不能改变外观 if (LockEquip) return; equipId = CheckEquipID(type, equipId); Skin.SetSkinPartFromCfgID(type, equipId, null, true, null, bClearVfx); GameCenter.PushFixEvent(LogicEventDefine.EID_EVENT_EQUIPMENTFORM_MODELUPDATE); } #endregion #region//心跳处理 update protected override void OnUpdate(float dt) { base.OnUpdate(dt); UpdateSafeTile(dt); GameCenter.SkillSelectFiledManager.UpdatePos(Position); if (_changeFightPower != 0 && ShowFightPower) { if (_changeFightPower > 5 || _changeFightPower < -5) { GameCenter.PushFixEvent((int)UIEventDefine.UIFightPowerChangeForm_OPEN, _changeFightPower); } _changeFightPower = 0; } if (_posBlock == null) { _posBlock = GonbestGMemoryAccessor.AllocFloatBlock("PlayerPos", 3); } if (_posBlock != null) { _posBlock[0] = Position.x; _posBlock[1] = Position.y; _posBlock[2] = Position.z; } } private void UpdateSafeTile(float dt) { _safeTileCheckTimer += dt; if (_safeTileCheckTimer < 0.5f) return; _safeTileCheckTimer = 0f; bool nonceState = InSafeTile; if (nonceState != _frontSafeTile || _firstCheckSafe) { _frontSafeTile = nonceState; if (!_firstCheckSafe) { if (nonceState) { GameCenter.ChatSystem.AddChat(ChatChanelType.SYSTEM, Thousandto.Cfg.Data.DeclareMessageString.Get(Thousandto.Cfg.Data.DeclareMessageString.C_LP_ENTER_SAFE_TILE)); } else { GameCenter.ChatSystem.AddChat(ChatChanelType.SYSTEM, Thousandto.Cfg.Data.DeclareMessageString.Get(Thousandto.Cfg.Data.DeclareMessageString.C_LP_LEAVE_SAFE_TILE)); } } _firstCheckSafe = false; //更新挂机按钮 //GameCenter.PushFixEvent(LogicEventDefine.EID_EVENT_MANDATE_STATE_CHANGED); } } #endregion #region //仇恨列表处理 //添加反击的角色 public void AddStrikeBackCharacter(ulong id) { int value = 0; if (!_strikeBackTable.TryGetValue(id, out value)) { _strikeBackTable[id] = 1; var player = GameCenter.GameSceneSystem.FindEntity(id); if (player != null) player.UpdateNameColor(); } } //删除反击角色 public void DeleteStrikeBackCharacter(ulong id) { if (_strikeBackTable.ContainsKey(id)) { _strikeBackTable.Remove(id); var player = GameCenter.GameSceneSystem.FindEntity(id); if (player != null) player.UpdateNameColor(); } } //清除反击角色 public void ClearStrikeBackCharacter() { var tmp = _strikeBackTable; _strikeBackTable = new Dictionary(); var ptr = tmp.GetEnumerator(); try { while (ptr.MoveNext()) { var player = GameCenter.GameSceneSystem.FindEntity(ptr.Current.Key); if (player != null) player.UpdateNameColor(); } } finally { ptr.Dispose(); } tmp.Clear(); } //判断是否可以反击 public bool IsStrikeBack(ulong id) { return _strikeBackTable.ContainsKey(id); } #endregion #region //状态切换 public override void OnAddState(RoleState type) { switch (type) { case RoleState.SkillFreeze: GameCenter.PushFixEvent(LogicEventDefine.EID_EVENT_SKILLSTIFFSTATE_CHANGED); break; case RoleState.SuperArmor: break; } base.OnAddState(type); } public override void OnRemoveState(RoleState type) { switch (type) { case RoleState.SkillFreeze: GameCenter.PushFixEvent(LogicEventDefine.EID_EVENT_SKILLSTIFFSTATE_CHANGED); break; case RoleState.SuperArmor: break; } base.OnRemoveState(type); } #endregion #region//场景切换 //角色切换场景 public void ChangeToScene(GameScene scene, Vector2? position) { Scene = scene; FightState = false; if (position.HasValue) RayCastToGroundXOZ(position.Value); if (IsDead()) { DeadDetail.IsReborn = true; } IdleData data = StateDateCache.Get(EntityStateID.Idle); data.SendStopMoveMsg = false; Fsm.TransTo(EntityStateID.Idle); Fsm.Update(0f); //DropAscription = false; ClearStrikeBackCharacter(); GameCenter.LuaSystem.Adaptor.RefreshPlayerModel(this, VisualInfo); _firstCheckSafe = true; GameCenter.SkillSelectFiledManager.DestoryFiled(); //重置根节点位置,防止万妖卷出来之后高度不对 var bodyPart = Skin.GetSkinPart(FSkinPartCode.Body); if (bodyPart != null) { bodyPart.RootTransform.localPosition = Vector3.zero; } //刷新buff列表,删除切换场景清除的buff GameCenter.BuffSystem.OnChangeScene(); //刷新主角名字 GameCenter.PushFixEvent(LogicEventDefine.EID_EVENT_HUD_UPDATE_HEADINFO, this); } #endregion #region//其他公共接口 //是否被本地 protected override bool OnIsLocal() { return true; } //是否为本地玩家 public override bool IsLocalPlayer() { return true; } //死亡后的回调 public override void OnDead() { base.OnDead(); PlayerBT.ChangeState(PlayerBDState.Default); ClearStrikeBackCharacter(); } public void DoChangeLine() { if(!PlayerBT.IsState(PlayerBDState.CrossMap)) PlayerBT.ChangeState(PlayerBDState.Default); Stop_Action(); skillManager.Clear(); ClearStrikeBackCharacter(); SetCurSelectedTargetId(0); } //开始引导,结束所有动作 public void DoStartGuide() { if (PlayerBT.IsInitPlayerBD) PlayerBT.ChangeState(PlayerBDState.Default); Stop_Action(); if (skillManager != null) skillManager.Clear(); SetCurSelectedTargetId(0); } //判断是否能够移动 public bool CanMove() { if (IsDead() || //死亡 !skillManager.CanMove() || //正在使用的技能不能移动 _stateManager.InState(RoleState.SkillFreeze)) //技能僵直 return false; if (_isCatching) return false; return true; } //判断是否能够跳跃 public bool CanJump() { //由于没有动作,暂时屏蔽跳跃 //return false; if (FightState) //战斗状态不能跳跃 return false; if (IsDead() || //死亡 IsBeHitAway() || //击退 _stateManager.InState(RoleState.SkillFreeze)) //技能僵直 return false; //当前有正在使用的技能 if (_skillManager.IsSkillUseing()) return false; //变身状态下不能跳跃 if (IsChangeModel) return false; return true; } //判断是否能够使用技能 public bool CanUseSkill(int skillId, bool checkMove = false) { var skillCfg = DeclareSkill.Get(skillId); if (skillCfg == null) return false; var visInfo = GameCenter.SkillVisualManager.Find(skillCfg.VisualDef); if (visInfo == null) return false; if (IsDead() || //死亡状态不能使用技能 _stateManager.InState(RoleState.SkillFreeze) || //技能僵直状态不能使用技能 IsBeHitAway() || //击退状态不能使用技能 IsXState(EntityStateID.Fly) || //飞行状态不能使用技能 IsXState(EntityStateID.Jump) ||//跳跃状态不能使用技能 IsXState(EntityStateID.RollDodge) || //翻滚状态不能使用技能 IsXState(EntityStateID.FlyTeleport) //飞行传送时不能使用技能 ) { return false; } if(!GameCenter.LuaSystem.Adaptor.CanUseSkill(skillCfg.Id)) { return false; } if (checkMove) { //如果是在站立状态直接可以使用技能 if (IsXState(EntityStateID.Idle)) { return true; } //如果在移动状态并且技能是可移动技能,可以使用 if (IsMoving() && SkillSystem.CanMove(visInfo)) { return true; } } else { return true; } return false; } //判断是否能够传送 public bool CanTeleport() { //死亡 if (IsDead()) return false; if (_strikeBackTable.Count > 0) return false; if (!IsXState(EntityStateID.DirMove) && !IsXState(EntityStateID.PathMove) && !IsXState(EntityStateID.Idle)) return false; //变身状态下不能传送 if (IsChangeModel) return false; return true; } //判断是否能够采集 public bool CanCollect() { if (IsDead() || //死亡 IsBeHitAway() || //被击退 skillManager.IsSkillUseing() || //使用技能中 IsXState(EntityStateID.Collect) || //正在采集 _stateManager.InState(RoleState.SkillFreeze))//技能僵直 return false; //变身状态下不能采集 if (IsChangeModel) return false; return true; } //判断是否能够打坐 public bool CanSitDown() { if (!IsXState(EntityStateID.Idle) || //不是idle skillManager.IsSkillUseing() || //使用技能中 _stateManager.InState(RoleState.SkillFreeze) ||//技能僵直 FightState || //战斗状态 Scene.Cfg.MapExp != 0 ||//只有当前地图是非经验地图 IsChuanDaoing //传道时不能打坐 ) return false; return true; } //判断能否上马 public bool CanUpMount() { if (IsDead() || //死亡 skillManager.IsSkillUseing() || //使用技能中 _stateManager.InState(RoleState.SkillFreeze) ||//技能僵直 IsXState(EntityStateID.Jump) || //跳跃 IsXState(EntityStateID.Fly) || //飞行 IsXState(EntityStateID.FlyTeleport) || //飞行 IsXState(EntityStateID.Collect) || //采集 FightState) //战斗状态 return false; //地图配置不能骑马 if (!GameCenter.MapLogicSwitch.CanRide) return false; if (Scene.Cfg.CanRiding == 0) return false; //变身状态下不能骑马 if (IsChangeModel) return false; //打坐 if (IsSitDown) { var cfg = DeclareHuaxingHorse.Get(LocalPlayerRoot.CurMountId); if(cfg != null && cfg.CanSitDown == 0) { return false; } } //判断是否有马 if (!IsOnMount && LocalPlayerRoot.CurMountId > 0) return true; return false; } //判断能否翻滚闪避 public bool CanRollDodge() { //由于没有动作,暂时屏蔽 if (IsDead()) //死亡 return false; //正在坐骑上 if (IsOnMount) { return false; } if (!IsTransAble(EntityStateID.RollDodge)) { return false; } //是否被定身 if(_stateManager.InState(RoleState.SkillFreeze)) //技能僵直 { return false; } return true; } //判断是否能够使用小飞鞋传送 public bool CanItemTeleport() { //死亡 if (IsDead()) return false; //PK的时候不能传送 if (_strikeBackTable.Count > 0) return false; //副本的时候不能传送 if (!GameCenter.MapLogicSwitch.CanTeleport) return false; if (!IsXState(EntityStateID.DirMove) && !IsXState(EntityStateID.PathMove) && !IsXState(EntityStateID.Idle)) return false; //变身状态下不能传送 if (IsChangeModel) return false; return true; } //检测血量 public void CheckLifeHint() { //float curHP = HpPercent; //if (curHP <= 0.2f) //{ // GameCenter.PushFixEvent(UIEventDefine.UILifeHintForm_OPEN); //} //else //{ // GameCenter.PushFixEvent(UIEventDefine.UILifeHintForm_CLOSE); //} } #endregion #region 关系判断 //是否是好友 public bool IsFriend(Character p) { if ( p != null && p is RemotePlayer) return GameCenter.LuaSystem.Adaptor.IsFriend(p.ID); return false; } //是否是好友 public bool IsFriend(ulong ID) { return GameCenter.LuaSystem.Adaptor.IsFriend(ID); } //是否是仇人 public bool IsEnemy(Character p) { return GameCenter.LuaSystem.Adaptor.IsEnemy(p.ID); } //是否是仇人 public bool IsEnemy(ulong ID) { return GameCenter.LuaSystem.Adaptor.IsEnemy(ID); } //是否在黑名单 public bool IsBlackRoster(Character p) { if ( p != null && p is RemotePlayer) return GameCenter.LuaSystem.Adaptor.IsShield(p.ID); return false; } //是否在黑名单 public bool IsBlackRoster(ulong ID) { return GameCenter.LuaSystem.Adaptor.IsShield(ID); } #endregion #region 坐骑 //发送上马消息 public void MountUP() { if (!IsOnMount && LocalPlayerRoot.CurMountId > 0) { MSG_Horse.ReqChangeRideState msg = new MSG_Horse.ReqChangeRideState(); msg.rideState = 1; msg.Send(); } } //先下马再发送下马消息 public bool MountDown(bool showPrompt = false) { if (IsXState(EntityStateID.FlyTeleport)) return false; if (IsOnMount) { MSG_Horse.ReqChangeRideState msg = new MSG_Horse.ReqChangeRideState(); msg.rideState = 0; msg.Send(); EquipWithType(FSkinPartCode.Mount, 0); } return true; ; } #endregion #region 摄像机处理 private void OnCameraFollowDisChanged(object o, object sender = null) { //if (o == null) // return; //var camera = Scene.SceneCamera; //if (camera == null) // return; //float nowDis = (float)o; //if (nowDis <= 1f) //{ // camera.cullingMask = camera.cullingMask & (~LayerUtils.LayerToMask(LayerUtils.LocalPlayer)); //} //else //{ // camera.cullingMask = camera.cullingMask | LayerUtils.LayerToMask(LayerUtils.LocalPlayer); //} } #endregion #region 战斗状态 public override void OnFightStateChangated(bool state) { GameCenter.PushFixEvent(LogicEventDefine.EID_EVENT_FIGHT_STATE_CHANGED, state); base.OnFightStateChangated(state); } #endregion #region 受击处理 public override void OnBeAttackedResponse(Character attacker, HitEffectInfo hitInfo, SkillHitType hitType, MSG_Fight.HitEffectInfo msgInfo) { if (hitType != SkillHitType.None) { MountDown(); } //玩家正在传送的时候,如果被其他玩家攻击,打断传送 if (IsXState(EntityStateID.CrossMapTran)) { if (attacker is RemotePlayer || attacker is Pet) { Stop_Action(); } } base.OnBeAttackedResponse(attacker, hitInfo, hitType, msgInfo); } #endregion public void ShowPlayer(bool state) { ModelTransform.gameObject.SetActive(state); } //跨地图传送 public bool Action_CrossMapTran(int desMapId, Action callBack = null, long cloneMapId = 0, int vfxId = 0) { if (IsXState(EntityStateID.Collect)) { GameCenter.MsgPromptSystem.ShowPrompt(Thousandto.Cfg.Data.DeclareMessageString.Get(Thousandto.Cfg.Data.DeclareMessageString.CANNOT_TRANS_BY_COLLECT)); return false; } GameCenter.LuaSystem.Adaptor.EndMandate(); Stop_Action(); if(!PlayerBT.IsState(PlayerBDState.CrossMap)) PlayerBT.ChangeState(PlayerBDState.Default); if (!IsTransAble(EntityStateID.CrossMapTran)) return false; CrossMapTranData data = StateDateCache.Get(EntityStateID.CrossMapTran); data.vfxId = vfxId; data.DesMapId = desMapId; data.CloneMapId = cloneMapId; data.CrossCallBack = callBack; bool ret = Fsm.TryTransTo(EntityStateID.CrossMapTran, data); if (ret) { Fsm.Update(0); } return ret; } //寻路到指定目标点 public void Action_FindPos(int mapId, Vector3 pos, CrossMapReason reson = CrossMapReason.Chat) { PlayerBT.crossBD.Write(mapId, pos, 0, reson); } #region//属性改变提示 public void BattlePropertyChange(BaseProperty pro, AllBattleProp type, long value, long changeValue) { if (!ShowPropChange) return; switch (type) { case AllBattleProp.Attack: case AllBattleProp.MaxHP: case AllBattleProp.SunderArmor: case AllBattleProp.Defense: case AllBattleProp.Precise: case AllBattleProp.Deflect: case AllBattleProp.Luck: case AllBattleProp.IgnoreDefense: case AllBattleProp.Critical: case AllBattleProp.Toughness: { if (changeValue > 0 && MainFunctionSystem.MainFormIsCreated) { GameCenter.PushFixEvent(UIEventDefine.UIPropertyChangeForm_OPEN, new object[] { (int)type, changeValue }); } } break; } } #endregion #region//选择目标处理 //设置当前选择的boss public void SetCurSelectBoss(Monster m) { if(m == null) { _curSelectBoss = 0; } else { if (m.IsDead()) return; if (m.PropMoudle.Cfg.MonsterType < 3 || m.PropMoudle.Cfg.HPNum <= 1) { return; } if(m.ID != _curSelectedTargetId) { var curBoss = GameCenter.GameSceneSystem.FindMonster(_curSelectBoss); if (curBoss != null && !curBoss.IsDead()) { return; } } _curSelectBoss = m.ID; } } //获取当前选择的boss public Monster GetCurSelectBoss() { var m = GameCenter.GameSceneSystem.FindEntity(_curSelectBoss); if(m == null) { _curSelectBoss = 0; } return m; } //选择目标 protected override void OnSelectTarget( Entity target ) { if( target is RemotePlayer ) { GameCenter.PushFixEvent( LogicEventDefine.EID_EVENT_SHOW_REMOTE_PLAYER_HEAD, target ); } if(target is Monster) { SetCurSelectBoss(target as Monster); } base.OnSelectTarget( target ); } //取消选择目标 protected override void OnDeselectTarget(Entity target) { base.OnDeselectTarget(target); } #endregion } }