4456 lines
181 KiB
C#
4456 lines
181 KiB
C#
using System;
|
||
using System.Collections;
|
||
using Games.AI_Logic;
|
||
using Games.Events;
|
||
using Games.GlobeDefine;
|
||
using Games.ImpactModle;
|
||
using Games.Item;
|
||
using Games.Mission;
|
||
using Games.Scene;
|
||
using Games.SkillModle;
|
||
using GCGame;
|
||
using GCGame.Table;
|
||
using Module.Log;
|
||
using UnityEngine;
|
||
using UnityEngine.AI;
|
||
|
||
namespace Games.LogicObj
|
||
{
|
||
public partial class Obj_MainPlayer : Obj_OtherPlayer
|
||
{
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//向服务器同步相关
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//同步位置信息间隔
|
||
private const int _footStepAudioId = 12;
|
||
|
||
private const int c_MultipleRequestCoolDown = 30;
|
||
|
||
private const float _rideSwitchInterval = 1f;
|
||
|
||
// 开始游戏下马间隔时间
|
||
private const float _startRideDelay = 2f;
|
||
|
||
public static float m_fTimeSecond;
|
||
|
||
private static int m_lastLevel = -1;
|
||
|
||
|
||
public float startGhost;
|
||
|
||
private float _medicineTipsTime = 8.0f;
|
||
|
||
private float _nextPaoShangTipUpdate = -1;
|
||
|
||
private float _nextPerSecondUpdate;
|
||
private float _nextRideSwitchTime;
|
||
|
||
//是否需要请求月度活动安排
|
||
private bool m_bNeedRequestMonthMultiple = true;
|
||
|
||
private ulong m_CurUseMountItemGuid;
|
||
|
||
private int m_ModelStoryID = GlobeVar.INVALID_ID;
|
||
|
||
private PlayerData m_playDataTool;
|
||
|
||
private GameItem m_UseItem;
|
||
|
||
private float tempTime;
|
||
|
||
public Obj_MainPlayer()
|
||
{
|
||
IsNoMove = false;
|
||
IsInModelStory = false;
|
||
ReliveEntryTime = 0;
|
||
m_ObjType = GameDefine_Globe.OBJ_TYPE.OBJ_MAIN_PLAYER;
|
||
SetObjPoolLevel(ObjPoolLevel.otherPlayer);
|
||
m_BaseAttr = new BaseAttr();
|
||
}
|
||
|
||
public override bool useXRay
|
||
{
|
||
get { return true; }
|
||
}
|
||
|
||
public override UIPathData HeadUiPath
|
||
{
|
||
get { return Obj_MainPlayerHeadUI.MainpathData; }
|
||
}
|
||
|
||
public override int Profession
|
||
{
|
||
get { return GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Profession; }
|
||
set { GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Profession = value; }
|
||
}
|
||
|
||
public override ulong GuildGUID
|
||
{
|
||
get { return GameManager.gameManager.PlayerDataPool.GuildInfo.GuildGuid; }
|
||
set { GameManager.gameManager.PlayerDataPool.GuildInfo.GuildGuid = value; }
|
||
}
|
||
|
||
public ulong LoverGUID
|
||
{
|
||
get { return GameManager.gameManager.PlayerDataPool.LoverGUID; }
|
||
set { GameManager.gameManager.PlayerDataPool.LoverGUID = value; }
|
||
}
|
||
|
||
public override BaseAttr BaseAttr
|
||
{
|
||
//屏蔽掉自己的 m_BaseAttr,而从GameManager中读取,保证切场景依然存在
|
||
get { return GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr; }
|
||
set { GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr = value; }
|
||
}
|
||
|
||
/// <summary>
|
||
/// 客户端当前选中的敌对目标
|
||
/// </summary>
|
||
public Obj_Character enemyTarget { get; private set; }
|
||
|
||
/// <summary>
|
||
/// 客户端当前选中的友好目标
|
||
/// </summary>
|
||
public Obj_Character friendlyTarget { get; private set; }
|
||
|
||
/// <summary>
|
||
/// 是否当前选中友好目标
|
||
/// </summary>
|
||
public bool targetFriend { get; private set; }
|
||
|
||
/// <summary>
|
||
/// 当前希望显示的目标id
|
||
/// </summary>
|
||
public int? targetId { get; private set; }
|
||
|
||
public override int AdcaneMountId
|
||
{
|
||
get { return GameManager.gameManager.PlayerDataPool.m_objMountParam.AdvanceMountId; }
|
||
set { GameManager.gameManager.PlayerDataPool.m_objMountParam.AdvanceMountId = value; }
|
||
}
|
||
|
||
public int CurFellowObjId
|
||
{
|
||
get { return GameManager.gameManager.PlayerDataPool.FellowContainer.CurFellowObjId; }
|
||
set { GameManager.gameManager.PlayerDataPool.FellowContainer.CurFellowObjId = value; }
|
||
}
|
||
|
||
public int ReliveEntryTime { get; set; }
|
||
|
||
public bool IsInModelStory { get; set; }
|
||
|
||
public bool IsNoMove { get; set; }
|
||
|
||
public int ModelStoryID
|
||
{
|
||
get { return m_ModelStoryID; }
|
||
set { m_ModelStoryID = value; }
|
||
}
|
||
|
||
|
||
public ulong DuelTargetGuid { set; get; }
|
||
|
||
public override int ModelVisualID
|
||
{
|
||
get { return GameManager.gameManager.PlayerDataPool.ModelVisualID; }
|
||
set { GameManager.gameManager.PlayerDataPool.ModelVisualID = value; }
|
||
}
|
||
|
||
public override int WeaponDataID
|
||
{
|
||
get { return GameManager.gameManager.PlayerDataPool.WeaponFashionId; }
|
||
set { GameManager.gameManager.PlayerDataPool.WeaponFashionId = value; }
|
||
}
|
||
|
||
public override ForceUseModelData ForceUseModel
|
||
{
|
||
get { return GameManager.gameManager.PlayerDataPool.ForceUseModel; }
|
||
set { GameManager.gameManager.PlayerDataPool.ForceUseModel = value; }
|
||
}
|
||
|
||
public override float ModelScale
|
||
{
|
||
get { return GameManager.gameManager.PlayerDataPool.ModelScale; }
|
||
set { GameManager.gameManager.PlayerDataPool.ModelScale = value; }
|
||
}
|
||
|
||
public bool NeedRequestMonthMultiple
|
||
{
|
||
get { return m_bNeedRequestMonthMultiple; }
|
||
set { m_bNeedRequestMonthMultiple = value; }
|
||
}
|
||
|
||
protected override void Awake()
|
||
{
|
||
base.Awake();
|
||
var layer = LayerMask.NameToLayer("MainPlayer");
|
||
gameObject.SetLayerRecursively(layer);
|
||
m_fTimeSecond = Time.realtimeSinceStartup;
|
||
m_fAutoTimeSecond = Time.realtimeSinceStartup;
|
||
}
|
||
|
||
private void Start()
|
||
{
|
||
if (GameManager.gameManager.OnLineState == false)
|
||
{
|
||
_IsTeamLeader = IsTeamLeader();
|
||
InitAutoInfo();
|
||
CreateNameBoard();
|
||
InitDamageBoard();
|
||
}
|
||
|
||
if (null != GameManager.gameManager)
|
||
m_playDataTool = GameManager.gameManager.PlayerDataPool;
|
||
|
||
if (PlayerPreferenceData.LeftTabChoose == 1)
|
||
if (GameManager.gameManager.PlayerDataPool.TeamInfo.TeamID >= 0)
|
||
if (null != TeamList.Instance())
|
||
TeamList.Instance().UpdateTeamMember();
|
||
// 绑定声音接收器
|
||
if (GameManager.gameManager.SoundManager != null)
|
||
GameManager.gameManager.SoundManager.GetAudioListener(transform);
|
||
}
|
||
|
||
//更新Obj_MainPlayer逻辑数据
|
||
protected override void Update()
|
||
{
|
||
if (!LoadingWindow._IsLoadingScene)
|
||
{
|
||
//UpdateSkillCDTime();
|
||
//UpdateSpecialSkill();
|
||
//if(!GameManager.gameManager.PlayerDataPool.IsInWeddingCar)
|
||
UpdateTeamFollow();
|
||
base.Update();
|
||
UpdateAutoCombatBreakState();
|
||
// 活动添加
|
||
if (null != m_playDataTool)
|
||
m_playDataTool.Tick_FellowGainCD();
|
||
|
||
tempTime += Time.deltaTime;
|
||
UpdatePerSceond();
|
||
UpdatePaoShangeTip();
|
||
UpdateTarget();
|
||
|
||
MountUpdate();
|
||
}
|
||
}
|
||
|
||
protected override void OnEnable()
|
||
{
|
||
base.OnEnable();
|
||
EventDispatcher.Instance.Add(EventId.ObstacleCreate, OnNavObstacleCreate);
|
||
}
|
||
|
||
protected override void OnDisable()
|
||
{
|
||
base.OnDisable();
|
||
EventDispatcher.Instance.Remove(EventId.ObstacleCreate, OnNavObstacleCreate);
|
||
}
|
||
|
||
protected override void OnDestroy()
|
||
{
|
||
base.OnDestroy();
|
||
if (!GameManager.applicationQuit)
|
||
BaseAttr.onMoveSpeedUpdate -= OnBaseAttrSpeedUpdate;
|
||
}
|
||
|
||
protected override void OnDisableStateStart(int addState)
|
||
{
|
||
base.OnDisableStateStart(addState);
|
||
EventDispatcher.Instance.Dispatch(EventId.MainPlayerAddDisable, addState);
|
||
}
|
||
|
||
protected override void OnDisableStateEnd(int removeState)
|
||
{
|
||
base.OnDisableStateEnd(removeState);
|
||
EventDispatcher.Instance.Dispatch(EventId.MainPlayerRemoveDisable, removeState);
|
||
}
|
||
|
||
public override bool Init(ObjParent_Init_Data initData)
|
||
{
|
||
speedAdaption = true;
|
||
InitMaterialManager();
|
||
ToggleDynamicShadow();
|
||
// 初始化渲染参数管理器,在未加载模型前也可以保留参数
|
||
Profession = GameManager.gameManager.PlayerDataPool.EnterSceneCache.Profession;
|
||
IsShowWing = GameManager.gameManager.PlayerDataPool.EnterSceneCache.EnterSceneIsShowWing;
|
||
GUID = GameManager.gameManager.PlayerDataPool.EnterSceneCache.Guid;
|
||
ModelID = GameManager.gameManager.PlayerDataPool.EnterSceneCache
|
||
.EnterSceneCharModelID; //初始化人物模型ID 对应charModel表
|
||
ModelVisualID = GameManager.gameManager.PlayerDataPool.EnterSceneCache.ModelVisualID; //装备或者时装 对应ItemVisual表
|
||
WeaponDataID = GameManager.gameManager.PlayerDataPool.EnterSceneCache.WeaponDataID; //武器时装ID
|
||
WeaponEffectGem = GameManager.gameManager.PlayerDataPool.EnterSceneCache.WeaponEffectGem;
|
||
EffectAuraId = GameManager.gameManager.PlayerDataPool.EnterSceneCache.EffectAuraId;
|
||
WingModelAuraid = GameManager.gameManager.PlayerDataPool.EnterSceneCache.WingModelAuraId;
|
||
AdvanceWingId = GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.AdvanceWingId;
|
||
AdcaneMountId = GameManager.gameManager.PlayerDataPool.m_objMountParam.AdvanceMountId;
|
||
_LinkID = GameManager.gameManager.PlayerDataPool.m_objMountParam._LinkID;
|
||
DoubleRidingState = GameManager.gameManager.PlayerDataPool.m_objMountParam._MountState;
|
||
OrnamentFootPrintID = GameManager.gameManager.PlayerDataPool.PlayerOrnamentStateInfo.OrnamentFootprintID;
|
||
//进场景的时候保存初始化默认的武器ID
|
||
//GlobalData.EnterSceneWeaponId = GameManager.gameManager.PlayerDataPool.EnterSceneCache.WeaponDataID;
|
||
//初始化RoleBaseID
|
||
BaseAttr.RoleBaseID = GameManager.gameManager.PlayerDataPool.EnterSceneCache.EnterSceneRoleBaseID;
|
||
BaseAttr.Force = GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Force;
|
||
//初始化ServerID
|
||
ServerID = GameManager.gameManager.PlayerDataPool.EnterSceneCache.EnterSceneServerID;
|
||
m_ServerName = GameManager.gameManager.PlayerDataPool.EnterSceneCache.ServerName;
|
||
var tabItemVisual = TableManager.GetItemVisualByID(ModelVisualID);
|
||
if (tabItemVisual == null)
|
||
{
|
||
ModelVisualID = GlobeVar.DEFAULT_VISUAL_ID;
|
||
tabItemVisual = TableManager.GetItemVisualByID(GlobeVar.DEFAULT_VISUAL_ID);
|
||
if (tabItemVisual == null)
|
||
return false;
|
||
}
|
||
|
||
var nCharmodelID = GetCharModelID(tabItemVisual, Profession);
|
||
var charModel = TableManager.GetCharModelByID(nCharmodelID);
|
||
if (charModel == null)
|
||
return false;
|
||
CreateMagicModel(GameManager.gameManager.PlayerDataPool.EnterSceneCache.EnterSceneMagiclID);
|
||
//ModelID = nCharmodelID;
|
||
BaseAttr.HeadPic = charModel.HeadPic;
|
||
m_DeltaHeight = charModel.HeadInfoHeight * ModelScale;
|
||
OptHeadPicChange();
|
||
|
||
CanLogic = true;
|
||
|
||
//朝向屏幕
|
||
//FaceToScreen();
|
||
FaceToDir(GameManager.gameManager.PlayerDataPool.EnterSceneCache.Facedir);
|
||
SyncSetPos(new Vector2(GameManager.gameManager.PlayerDataPool.EnterSceneCache.EnterScenePos.x,
|
||
GameManager.gameManager.PlayerDataPool.EnterSceneCache.EnterScenePos.z));
|
||
//SetPosition(GameManager.gameManager.PlayerDataPool.EnterSceneCache.EnterScenePos);
|
||
//向服务器发送EnterSceneOK消息包
|
||
//CG_ENTER_SCENE_OK packet = (CG_ENTER_SCENE_OK)PacketDistributed.CreatePacket(MessageID.PACKET_CG_ENTER_SCENE_OK);
|
||
//packet.IsOK = 1;
|
||
//packet.SendPacket();
|
||
|
||
if (IsDie())
|
||
OnCorpse();
|
||
|
||
VipCost = GameManager.gameManager.PlayerDataPool.VipCost;
|
||
OtherCombatValue = GameManager.gameManager.PlayerDataPool.PoolCombatValue;
|
||
PaoShangState = GameManager.gameManager.PlayerDataPool.EnterSceneCache.PaoShangState;
|
||
//如果主角已经创建,清理服务器数据,防止重复建立,并且准备下次切换场景使用
|
||
GameManager.gameManager.PlayerDataPool.EnterSceneCache.ClearEnterSceneInfo();
|
||
|
||
gameObject.name = "MainPlayer";
|
||
BindParent = GameManager.gameManager.PlayerDataPool.MainBindParent;
|
||
UpdateBindChildren(GameManager.gameManager.PlayerDataPool.MainBindChildren);
|
||
// 如果主角有缓存的强制模型,则直接使用强制模型
|
||
var modelID = ForceUseModel == null ? nCharmodelID : ForceUseModel.modelData.Id;
|
||
LogModule.DebugLog(string.Format("MainPlayer Create : {0} {1}", nCharmodelID, modelID));
|
||
CreateModel(ForceUseModel == null ? nCharmodelID : ForceUseModel.modelData.Id);
|
||
|
||
var initData1 = initData as Obj_Player_Init_Data;
|
||
if (initData1 != null)
|
||
InitImpactInfo(initData1);
|
||
//LastHeartBeatTime = -1;
|
||
ObjManager.Instance.AddPoolObj(this);
|
||
ObjManager.Instance.SetMainPlayer(this);
|
||
OnPlayerEnterScene();
|
||
InitPlayerInfo();
|
||
// 不允许立刻下马
|
||
if (AdcaneMountId > 0)
|
||
_nextRideSwitchTime = Time.unscaledTime + _startRideDelay;
|
||
else
|
||
_nextRideSwitchTime = 0f;
|
||
// 如果处于组队跟随战斗状态,立刻转入自动战斗
|
||
//if (FollowState == TeamFollowState.followCombat)
|
||
// EnterAutoCombat();
|
||
//ActiveAfterLoading();
|
||
// var sceneAssembly = FindObjectOfType<SceneAssembly>();
|
||
// if (sceneAssembly != null)
|
||
// sceneAssembly.LoadAtPosition(Position);
|
||
return true;
|
||
}
|
||
|
||
public void PlaySceneEffect()
|
||
{
|
||
var scene = TableManager.GetSceneClassByID(GameManager.gameManager.RunningScene);
|
||
if (scene != null && scene.EffectID >= 0 && ObjEffectLogic != null)
|
||
ObjEffectLogic.PlayEffect(scene.EffectID); //进入场景播放的特效
|
||
}
|
||
|
||
// 重载模型回调
|
||
protected override void CreateModelOver(Hashtable table)
|
||
{
|
||
base.CreateModelOver(table);
|
||
|
||
if (EffectPanel.Instance)
|
||
EffectPanel.Instance.RefreshModelCamera();
|
||
if (BackPackLogic.Instance()) //背包使用时装的时候刷新一下CameraTexture
|
||
BackPackLogic.Instance()._PlayerEquipInfo.UpdateShowModel();
|
||
if (AdvanceMountPanelCtr.Instance)
|
||
AdvanceMountPanelCtr.Instance.fashionPanel.RefreshAdvanceItemState();
|
||
|
||
if (GameManager.gameManager.PlayerDataPool.IsInMeditateState)
|
||
RestartMeditateState();
|
||
|
||
CreateChildModel(new Child_Init_Data
|
||
{
|
||
childLevel = GameManager.gameManager.PlayerDataPool.ChildData.CurCarryChildData.childLevel,
|
||
childName = GameManager.gameManager.PlayerDataPool.ChildData.CurCarryChildData.childName,
|
||
childFashionId = GameManager.gameManager.PlayerDataPool.ChildData.CurCarryChildData.childFashionId,
|
||
childGender = GameManager.gameManager.PlayerDataPool.ChildData.CurCarryChildData.childGender,
|
||
childGuid = GameManager.gameManager.PlayerDataPool.ChildData.CurCarryChildData.childGuid,
|
||
bindPlayerGuid = GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Guid
|
||
}, transform.position);
|
||
}
|
||
|
||
public void RestartMeditateState()
|
||
{
|
||
if (MeditateProgress.Instance && MeditateProgress.Instance.isActiveAndEnabled)
|
||
MeditateProgress.Instance.EnterMeditateState();
|
||
}
|
||
|
||
public override void DestroyObj()
|
||
{
|
||
if (GameManager.gameManager != null && GameManager.gameManager.SoundManager != null)
|
||
{
|
||
stepId = GlobeVar.INVALID_ID;
|
||
GameManager.gameManager.SoundManager.GetAudioListener(null);
|
||
}
|
||
|
||
// 2018.11.22 增加一个追踪主角被不正常析构的打印
|
||
// 2018.12.03 貌似OnDestroy无法正确获得Stack Trace,现在移动到这个位置来
|
||
if (!LoadingWindow._IsLoadingScene)
|
||
LogModule.ErrorLog(string.Format(
|
||
"Main Player {0}, Guid {1} at Scene {2}, is not supposed to be destroyed outside loading scene!",
|
||
ServerID, GUID,
|
||
GameManager.gameManager == null
|
||
? "Unknown Scene"
|
||
: GameManager.gameManager.RunningScene.ToString()));
|
||
base.DestroyObj();
|
||
}
|
||
|
||
public override void CreateWeaponOver(string strWeaponPoint, GameObject WeponObj)
|
||
{
|
||
base.CreateWeaponOver(strWeaponPoint, WeponObj);
|
||
EventDispatcher.Instance.Dispatch(EventId.MainPlayerModelChange);
|
||
}
|
||
|
||
public void SyncPlayerY()
|
||
{
|
||
// 同步主角Y坐标到服务器
|
||
var syncPosY = (CG_SYN_POSY) PacketDistributed.CreatePacket(MessageID.PACKET_CG_SYN_POSY);
|
||
syncPosY.SetPosy(Position.y.ToServerPos());
|
||
syncPosY.SendPacket();
|
||
}
|
||
|
||
public void InitPlayerInfo()
|
||
{
|
||
if ((int) GameDefine_Globe.SCENE_DEFINE.SCENE_LOGIN != GameManager.gameManager.RunningScene)
|
||
{
|
||
_IsTeamLeader = IsTeamLeader();
|
||
InitAutoInfo();
|
||
if (HeadUi == null)
|
||
CreateNameBoard();
|
||
InitDamageBoard();
|
||
//更新人物头像显示
|
||
/*OptHPChange();
|
||
OptMPChange();
|
||
OptXPChange();
|
||
OptLevelChange();
|
||
OptForceChange();
|
||
//OptStealthLevChange();
|
||
OptNameChange();*/
|
||
AskPKINfo(); //请求玩家PK信息
|
||
AskLvLCap(); //请求封印等级
|
||
AskDoubleExp(); //刷新双倍经验信息
|
||
AskMeridiaSoulData();
|
||
//OptChangPKModle();
|
||
OnExpChange();
|
||
OnOffLineExpChange();
|
||
ShowPlayerTitleInvestitive();
|
||
ShowSimpleAttackIcon();
|
||
//在监狱的话 打开PK界面 放在更新公告之前
|
||
if (GameManager.gameManager.RunningScene == (int) GameDefine_Globe.SCENE_DEFINE.SCENE_JIANYU)
|
||
UIManager.ShowUI(UIInfo.PKSetInfo);
|
||
NoticeLogic.TryOpen();
|
||
}
|
||
|
||
if (PlayerPreferenceData.LeftTabChoose == 1)
|
||
if (GameManager.gameManager.PlayerDataPool.TeamInfo.TeamID >= 0)
|
||
if (null != TeamList.Instance())
|
||
TeamList.Instance().UpdateTeamMember();
|
||
}
|
||
|
||
private void AskMeridiaSoulData()
|
||
{
|
||
MeridiaSoulData.Instance.SendAskDataCmd();
|
||
}
|
||
|
||
private void AskPKINfo()
|
||
{
|
||
var send = (CG_ASK_PKINFO) PacketDistributed.CreatePacket(MessageID.PACKET_CG_ASK_PKINFO);
|
||
send.SetObjId(ServerID);
|
||
send.SendPacket();
|
||
}
|
||
|
||
//请求等级封印信息
|
||
private void AskLvLCap()
|
||
{
|
||
var packet = (CG_REQ_SERVER_LVL_CAP) PacketDistributed.CreatePacket(MessageID.PACKET_CG_REQ_SERVER_LVL_CAP);
|
||
packet.Noparam = 1;
|
||
packet.SendPacket();
|
||
}
|
||
|
||
public void AskDoubleExp()
|
||
{
|
||
//优先显示双倍
|
||
if (AdditionData.doubleExpDisableTime > Time.realtimeSinceStartup)
|
||
UpdateImpact(99995, 1, 1, AdditionData.doubleExpDisableTime - (int) Time.realtimeSinceStartup);
|
||
else if (AdditionData.onePointFiveExpDisableTime > Time.realtimeSinceStartup) //1.5
|
||
UpdateImpact(99998, 1, 1, AdditionData.onePointFiveExpDisableTime - (int) Time.realtimeSinceStartup);
|
||
}
|
||
|
||
public bool IsReadyInScene()
|
||
{
|
||
return enabled && ModelNode.model != null;
|
||
}
|
||
|
||
//开始每秒一次的循环
|
||
private void UpdatePerSceond()
|
||
{
|
||
if (Time.unscaledTime > _nextPerSecondUpdate)
|
||
{
|
||
// 注:精确计算,需要防止跳帧的情况
|
||
_nextPerSecondUpdate = Time.unscaledTime + 1f;
|
||
//一秒同步一次心跳包
|
||
UpdateReliveEntryTime();
|
||
//更新自动打怪
|
||
UpdateAuto();
|
||
//自动使用药品
|
||
AutoUseHPMPDrug();
|
||
}
|
||
}
|
||
|
||
|
||
private void UpdateTarget()
|
||
{
|
||
// ****** 检测当前目标状态 ********
|
||
// 注:null 可能表示物体摧毁,但指针被引用;重新赋值null以确保指针释放;
|
||
if (enemyTarget == null
|
||
|| enemyTarget.IsDie()
|
||
|| enemyTarget.IsDisableState(DISABLESTATE.Disable_BeSelect)
|
||
|| !enemyTarget.IsInSelectRange(Position))
|
||
enemyTarget = null;
|
||
if (friendlyTarget == null
|
||
|| friendlyTarget.IsDisableState(DISABLESTATE.Disable_BeSelect)
|
||
|| !friendlyTarget.IsInSelectRange(Position))
|
||
friendlyTarget = null;
|
||
|
||
if (IsDisableState(DISABLESTATE.Disable_Select))
|
||
{
|
||
enemyTarget = null;
|
||
friendlyTarget = null;
|
||
return;
|
||
}
|
||
|
||
RefreshTarget(true);
|
||
}
|
||
|
||
private void RefreshTarget(bool sendPack)
|
||
{
|
||
if (targetFriend)
|
||
// 选中友好目标结束后,切换为选中敌对目标
|
||
if (friendlyTarget == null)
|
||
targetFriend = false;
|
||
var target = targetFriend ? friendlyTarget : enemyTarget;
|
||
if (target != null)
|
||
{
|
||
if (targetId != target.ServerID)
|
||
UpdateSelectDisplay(target, sendPack);
|
||
}
|
||
else
|
||
{
|
||
if (targetId != null)
|
||
UpdateSelectDisplay(target, sendPack);
|
||
}
|
||
}
|
||
|
||
private void UpdateSelectDisplay(Obj_Character character, bool sendPack)
|
||
{
|
||
if (character == null)
|
||
{
|
||
EventDispatcher.Instance.Dispatch(EventId.CancleTarget, -1);
|
||
targetId = null;
|
||
GameManager.gameManager.ActiveScene.DeactiveSelectCircle();
|
||
if (sendPack)
|
||
SendSelectObjPacket(-1);
|
||
}
|
||
else
|
||
{
|
||
targetId = character.ServerID;
|
||
GameManager.gameManager.ActiveScene.ActiveSelectCircle(character.gameObject);
|
||
EventDispatcher.Instance.Dispatch(EventId.ChangeTarget, character);
|
||
SendSelectObjPacket(targetId.Value);
|
||
}
|
||
}
|
||
|
||
private void UpdatePaoShangeTip()
|
||
{
|
||
if (_nextPaoShangTipUpdate < 0)
|
||
{
|
||
_nextPaoShangTipUpdate = Time.time + 5f;
|
||
return;
|
||
}
|
||
|
||
if (Time.time < _nextPaoShangTipUpdate)
|
||
return;
|
||
_nextPaoShangTipUpdate = Time.time + 5f;
|
||
if (GameManager.gameManager.PlayerDataPool.nGharryObjID != -1)
|
||
return;
|
||
if (GameManager.gameManager.PlayerDataPool.IsHaveGuild() == false)
|
||
return;
|
||
var mission = GameManager.gameManager.MissionManager.GetMissionByType(MISSIONTYPE.MISSION_GUILDPAOSHANG);
|
||
if (mission == null || mission.m_yStatus != 1)
|
||
return;
|
||
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{34011}"));
|
||
}
|
||
|
||
public override void OverrideModel(ForceUseModelData modelData, float scale)
|
||
{
|
||
base.OverrideModel(modelData, scale);
|
||
// 主角变身时,取消骑乘状态
|
||
AskUnMount(false, true);
|
||
}
|
||
|
||
private void UpdateReliveEntryTime()
|
||
{
|
||
var ftimeSec = Time.realtimeSinceStartup;
|
||
var nTimeData = (int) (ftimeSec - m_fTimeSecond);
|
||
if (nTimeData > 0)
|
||
{
|
||
if (ReliveEntryTime > 0)
|
||
{
|
||
ReliveEntryTime = ReliveEntryTime - nTimeData;
|
||
if (ReliveEntryTime < 0)
|
||
ReliveEntryTime = 0;
|
||
}
|
||
|
||
m_fTimeSecond = ftimeSec;
|
||
}
|
||
}
|
||
|
||
public void UpdatePlayerPos(int posX, int posZ, int effectId)
|
||
{
|
||
StopMove();
|
||
if (NavAgent != null)
|
||
NavAgent.enabled = false;
|
||
SyncSetPos(new Vector2(posX, posZ));
|
||
if (ObjEffectLogic != null)
|
||
ObjEffectLogic.PlayEffect(effectId);
|
||
if (NavAgent != null)
|
||
{
|
||
NavAgent.enabled = true;
|
||
NavAgent.destination = m_ObjTransform.position;
|
||
}
|
||
|
||
startGhost = 0;
|
||
}
|
||
|
||
private void InitDamageBoard()
|
||
{
|
||
DamageBoardManager.PreloadDamageBoard();
|
||
}
|
||
|
||
public override void InitNameBoard(Obj_HeadUI headUiItem)
|
||
{
|
||
base.InitNameBoard(headUiItem);
|
||
OptChangPKModle();
|
||
}
|
||
|
||
public override void UpdateVipInfo()
|
||
{
|
||
base.UpdateVipInfo();
|
||
OnVipCostChange();
|
||
}
|
||
|
||
public void ShowPlayerTitleInvestitive()
|
||
{
|
||
if (null != m_headUIObj)
|
||
m_headUIObj.ShowTitleInvestitive(
|
||
GameManager.gameManager.PlayerDataPool.TitleInvestitive.GetCurrentTitle());
|
||
else
|
||
StartCoroutine(SetTitleInverstitive());
|
||
}
|
||
|
||
public IEnumerator SetTitleInverstitive()
|
||
{
|
||
while (true)
|
||
{
|
||
yield return new WaitForSeconds(1);
|
||
if (null != m_headUIObj)
|
||
{
|
||
m_headUIObj.ShowTitleInvestitive(
|
||
GameManager.gameManager.PlayerDataPool.TitleInvestitive.GetCurrentTitle());
|
||
yield break;
|
||
}
|
||
}
|
||
}
|
||
|
||
//切换场景调用接口
|
||
public void OnPlayerEnterScene()
|
||
{
|
||
GlobalData._EnterSceneStartTime = Time.time;
|
||
GameManager.gameManager.PlayerDataPool.IsInMeditateState = false;
|
||
UIManager.CloseUI(UIInfo.MeditateProgress);
|
||
UIManager.CloseUI(UIInfo.TreasureSignUp);
|
||
UIManager.ShowUI(UIInfo.LockPanel);
|
||
UIManager.ShowUI(UIInfo.MissionClickPanel);
|
||
if (GameManager.gameManager.OnLineState == false)
|
||
Position = DefaultPosition();
|
||
SceneLogic.InitCameraControl();
|
||
if (ChatFrameLogic.Instance() != null)
|
||
ChatFrameLogic.Instance().UpdateAutoFightBtnState();
|
||
if (CenterTipsLogic.Instance() != null)
|
||
CenterTipsLogic.Instance().OnAutoMoveStateChange();
|
||
|
||
//添加主角AI组件
|
||
if (Controller == null)
|
||
Controller = gameObject.AddComponent<AIController>();
|
||
var playerCombat = gameObject.EnsureComponent<AI_PlayerCombat>();
|
||
playerCombat.LockAction();
|
||
InitNavAgent();
|
||
|
||
Controller.SwitchCurrentAI(Controller.NormalAI);
|
||
|
||
ReliveEntryTime = GameManager.gameManager.PlayerDataPool.ReliveEntryTime;
|
||
if (OneDragonAuto.One_DragonAuto != null)
|
||
OneDragonAuto.One_DragonAuto.OnEnterScene(this);
|
||
|
||
SpeaiclSceneUIControl();
|
||
ChangeSceneSpecialOpt();
|
||
|
||
GameManager.gameManager.AutoSearch.FLastChangeSceneUpdateTime = 0.0f; //更换场景之后可以立即传送
|
||
GameManager.gameManager.AutoSearch.AutoSearchTelePort.ChangeSceneOver();
|
||
GameManager.gameManager.AutoSearch.RoadSignManager.ChangeSceneOver();
|
||
FirstEnterGameOpt();
|
||
|
||
//在副本里面接取或者完成的任务继续自动寻路
|
||
//出了副本之后自动寻路(分两种情况,非原地切换场景的会走到这里,原地进副本的不会进到这里)
|
||
if (!GameManager.gameManager.ActiveScene.IsCopyScene() &&
|
||
GameManager.gameManager.PlayerDataPool.AutoSearchMissionId != -1)
|
||
{
|
||
GameManager.gameManager.MissionManager.MissionPathFinder(GameManager.gameManager.PlayerDataPool
|
||
.AutoSearchMissionId);
|
||
GameManager.gameManager.PlayerDataPool.AutoSearchMissionId = -1;
|
||
}
|
||
|
||
//环任务完成之后显示确认是否继续
|
||
if (!GameManager.gameManager.ActiveScene.IsCopyScene() &&
|
||
GameManager.gameManager.PlayerDataPool.AutoShowTurnOverEnsureMissionId != -1)
|
||
{
|
||
GameManager.gameManager.MissionManager.OpenEnsureBoxAndAcceptMission(GameManager.gameManager
|
||
.PlayerDataPool.AutoShowTurnOverEnsureMissionId);
|
||
GameManager.gameManager.PlayerDataPool.AutoShowTurnOverEnsureMissionId = -1;
|
||
}
|
||
|
||
EventDispatcher.Instance.Dispatch(EventId.OnChangeSceneOver);
|
||
SetComboSkillToCooldown();
|
||
if (Singleton<CollectItem>.Instance != null)
|
||
Singleton<CollectItem>.Instance.ClearMissionCollectitemInfo();
|
||
ActivityStartTip.OPenTip(null);
|
||
if (FirstShowScene.Instance() != null)
|
||
FirstShowScene.Instance().MainPlayerFirstFaceTo(this);
|
||
}
|
||
|
||
public void SpeaiclSceneUIControl()
|
||
{
|
||
if (GameManager.gameManager.RunningScene == GameManager.gameManager.PlayerDataPool.pvpIfo._PvpBattleSceneId)
|
||
{
|
||
UIManager.ShowUI(UIInfo.PvpTeamInfoPanel);
|
||
UIManager.ShowUI(UIInfo.MiniMapRoot);
|
||
|
||
UIManager.CloseUI(UIInfo.MissionDialogAndLeftTabsRoot);
|
||
UIManager.CloseUI(UIInfo.ActiveBtns);
|
||
UIManager.CloseUI(UIInfo.MarketingActsRoot);
|
||
if (FunctionButtonLogic.Instance())
|
||
{
|
||
FunctionButtonLogic.Instance().IsCanShwoBaseBtns = false;
|
||
FunctionButtonLogic.Instance().HideWndPart(2);
|
||
}
|
||
}
|
||
else if (GameManager.gameManager.RunningScene == GameManager.gameManager.PlayerDataPool.pvpIfo._PvpSceneId)
|
||
{
|
||
UIManager.ShowUI(UIInfo.PvpSceneInfo);
|
||
UIManager.ShowUI(UIInfo.PvpRoomPanel);
|
||
|
||
UIManager.CloseUI(UIInfo.PvpTeamInfoPanel);
|
||
UIManager.CloseUI(UIInfo.ActiveBtns);
|
||
|
||
if (FunctionButtonLogic.Instance()) FunctionButtonLogic.Instance().HideWndPart(2);
|
||
|
||
UIManager.CloseUI(UIInfo.MissionDialogAndLeftTabsRoot);
|
||
UIManager.CloseUI(UIInfo.MiniMapRoot);
|
||
UIManager.CloseUI(UIInfo.MarketingActsRoot);
|
||
}
|
||
else if (GameManager.gameManager.RunningScene == 590) //暂时只有这一个地方用到
|
||
{
|
||
//这边只管关闭
|
||
UIManager.CloseUI(UIInfo.ActiveBtns);
|
||
if (FunctionButtonLogic.Instance()) FunctionButtonLogic.Instance().HideWndPart(2);
|
||
UIManager.CloseUI(UIInfo.MissionDialogAndLeftTabsRoot);
|
||
UIManager.CloseUI(UIInfo.MiniMapRoot);
|
||
UIManager.CloseUI(UIInfo.MarketingActsRoot);
|
||
|
||
//跨服场景UI在锁屏的时候被关闭了,这边重新申请打开
|
||
var req = new ReqCrossSerInfo();
|
||
req.flag = 1;
|
||
req.SendMsg();
|
||
}
|
||
else
|
||
{
|
||
//切换场景的时候会有无法清除的问题,这边再做一次判断.
|
||
if (PvpSceneInfo.Instance && PvpSceneInfo.Instance.isActiveAndEnabled)
|
||
UIManager.CloseUI(UIInfo.PvpSceneInfo);
|
||
if (PvpRoomPanel.Instance && PvpRoomPanel.Instance.isActiveAndEnabled)
|
||
UIManager.CloseUI(UIInfo.PvpRoomPanel);
|
||
|
||
UIManager.ShowUI(UIInfo.ActiveBtns, delegate(bool bSucess, object param)
|
||
{
|
||
if (bSucess) ActiveBtns.Instance().ShowPanel();
|
||
});
|
||
UIManager.ShowUI(UIInfo.FunctionButtonRoot, delegate
|
||
{
|
||
if (FunctionButtonLogic.Instance()) FunctionButtonLogic.Instance().HideWndPart(3);
|
||
});
|
||
UIManager.ShowUI(UIInfo.MissionDialogAndLeftTabsRoot);
|
||
UIManager.ShowUI(UIInfo.MarketingActsRoot);
|
||
//副本界面关闭对话
|
||
if (GameManager.gameManager.ActiveScene.IsCopyScene()
|
||
&& GameManager.gameManager.RunningScene != 718 && GameManager.gameManager.RunningScene != 1002 &&
|
||
GameManager.gameManager.RunningScene != 712) //出生副本又要特殊处理
|
||
{
|
||
if (MissionDialogAndLeftTabsLogic.Instance())
|
||
{
|
||
var sceneClass = TableManager.GetSceneClassByID(GameManager.gameManager.RunningScene);
|
||
if (sceneClass != null)
|
||
{
|
||
var isShowMission = sceneClass.IsShowMission == 1;
|
||
MissionDialogAndLeftTabsLogic.Instance()._IsShowFirst = isShowMission;
|
||
MissionDialogAndLeftTabsLogic.Instance().ShowDefaultToggle(isShowMission);
|
||
}
|
||
}
|
||
|
||
if (CopyScenePanelCtr.Instance && CopyScenePanelCtr.Instance.isActiveAndEnabled)
|
||
UIManager.CloseUI(UIInfo.CopyScenePanelCtr);
|
||
}
|
||
else
|
||
{
|
||
UIManager.ShowUI(UIInfo.MiniMapRoot);
|
||
if (!MissionDialogAndLeftTabsLogic.Instance() ||
|
||
!MissionDialogAndLeftTabsLogic.Instance().isActiveAndEnabled)
|
||
UIManager.ShowUI(UIInfo.MissionDialogAndLeftTabsRoot);
|
||
|
||
if (FunctionButtonLogic.Instance())
|
||
if (FunctionButtonLogic.Instance().ShowOrHideBtn != null)
|
||
{
|
||
FunctionButtonLogic.Instance().ShowOrHideBtn.SetActive(true);
|
||
FunctionButtonLogic.Instance().IsCanShwoBaseBtns = true;
|
||
}
|
||
}
|
||
|
||
if (SceneItemUseTip.Instance() != null)
|
||
SceneItemUseTip.Instance().ShowSceneItems();
|
||
UIManager.CloseUI(UIInfo.PvpTeamInfoPanel);
|
||
if (PvpRoomPanel.Instance && PvpRoomPanel.Instance.isActiveAndEnabled)
|
||
UIManager.CloseUI(UIInfo.PvpRoomPanel);
|
||
}
|
||
}
|
||
|
||
//行酒令相关检查
|
||
public void CheckGuildWine()
|
||
{
|
||
}
|
||
|
||
public void ChangeSceneSpecialOpt() //切换场景之后的特殊操作
|
||
{
|
||
GameManager.gameManager.PlayerDataPool.EnterSceneCache.ClearEnterSceneInfo();
|
||
//婚宴场景需要申请当前人物的身份信息
|
||
if (GameManager.gameManager.RunningScene == GlobeVar.BANQUETSCENEID)
|
||
{
|
||
var req = new ReqBanQuetSceneInfo();
|
||
req.flag = 1;
|
||
req.SendMsg();
|
||
}
|
||
|
||
//进入副本关闭活动界面
|
||
if (GameManager.gameManager.ActiveScene.IsCopyScene())
|
||
{
|
||
//GCGame.Utils.HideMainTopRightUI(false);
|
||
GameManager.gameManager.PlayerDataPool.OldAutoCombat = isAutoCombat ? 1 : 0;
|
||
if (GameManager.gameManager.PlayerDataPool.EnterSceneCache.EnterCopySceneID ==
|
||
(int) GameDefine_Globe.SCENE_DEFINE.SCENE_GUILDWARMAIN)
|
||
{
|
||
UIManager.ShowUI(UIInfo.GuildWarLeftTab);
|
||
}
|
||
else
|
||
{
|
||
UIManager.CloseUI(UIInfo.GuildWarLeftTab);
|
||
if (FunctionButtonLogic.Instance())
|
||
if (FunctionButtonLogic.Instance().ShowOrHideBtn != null)
|
||
FunctionButtonLogic.Instance().ShowOrHideBtn.SetActive(true);
|
||
}
|
||
|
||
UIManager.CloseUI(UIInfo.GuildBoss);
|
||
UIManager.CloseUI(UIInfo.GuildMainInfoWnd);
|
||
UIManager.CloseUI(UIInfo.Activity);
|
||
UIManager.CloseUI(UIInfo.GuildWarTip);
|
||
|
||
//下坐骑
|
||
if (GameManager.gameManager.PlayerDataPool.m_objMountParam.AdvanceMountId > 0)
|
||
{
|
||
var req =
|
||
(CG_MOUNT_UNMOUNT) PacketDistributed.CreatePacket(MessageID.PACKET_CG_MOUNT_UNMOUNT);
|
||
req.SetMountID(GameManager.gameManager.PlayerDataPool.m_objMountParam.AdvanceMountId);
|
||
req.SendPacket();
|
||
}
|
||
}
|
||
else
|
||
{
|
||
Utils.ShowMainTopRightUI();
|
||
GameManager.gameManager.PlayerDataPool.OldAutoCombat = -1;
|
||
UIManager.ShowUI(UIInfo.MissionDialogAndLeftTabsRoot);
|
||
UIManager.CloseUI(UIInfo.GuildWarLeftTab);
|
||
}
|
||
|
||
if (GameManager.gameManager.RunningScene == GlobeVar.CROSSSERVERSCENEID)
|
||
UIManager.ShowUI(UIInfo.CrossServerMap);
|
||
else
|
||
UIManager.CloseUI(UIInfo.CrossServerMap);
|
||
|
||
//帮会预演场景做一下特殊处理(PVP在倒计时结束再调用,因为存在一个同步双方信息等待的时间,所以不能通过配表等待固定的时间实现)
|
||
if (GameManager.gameManager.PlayerDataPool.EnterSceneCache.EnterCopySceneID !=
|
||
(int) GameDefine_Globe.SCENE_DEFINE.SCENE_GUILDPREWAR
|
||
&& GameManager.gameManager.PlayerDataPool.EnterSceneCache.EnterCopySceneID !=
|
||
GameManager.gameManager.PlayerDataPool.pvpIfo._PvpBattleSceneId)
|
||
RefreshPlayerAutoCombat();
|
||
ActivityDataManager.Instance.FeastWine();
|
||
var guildOther = TableManager.GetGuildOtherByID(0);
|
||
if (guildOther != null)
|
||
if (GameManager.gameManager.RunningScene == guildOther.SceneId)
|
||
Utils.ShowMainTopRightUI();
|
||
//从门派挑战场景里面出来之后打开门派挑战UI
|
||
if (GameManager.gameManager.PlayerDataPool.EnterSceneCache.BeforeEnterCopySceneID ==
|
||
(int) GameDefine_Globe.SCENE_DEFINE.SCENE_FACIONCHALLENGECOPYSCENEID)
|
||
UIManager.ShowUI(UIInfo.SportsPanel, delegate(bool bSucess, object param)
|
||
{
|
||
if (bSucess) SportsPanel.Instance.OnMenuItemClick((int) SportsPanel.SportsType.FactionChallenge);
|
||
});
|
||
|
||
if (string.IsNullOrEmpty(GameManager.gameManager.PlayerDataPool.TreasureTip) == false)
|
||
MessageBoxLogic.OpenOKBox(
|
||
StrDictionary.GetServerDictionaryFormatString(GameManager.gameManager.PlayerDataPool.TreasureTip));
|
||
GameManager.gameManager.PlayerDataPool.TreasureTip = "";
|
||
if (GlobalData.NeedShowCopyBaseUISceneId != -1)
|
||
if (GameManager.gameManager.PlayerDataPool.EnterSceneCache.BeforeEnterCopySceneID ==
|
||
GlobalData.NeedShowCopyBaseUISceneId)
|
||
UIManager.ShowUI(UIInfo.CopyScenePanelCtr, delegate(bool bSucess, object param)
|
||
{
|
||
if (bSucess)
|
||
{
|
||
if (CopyScenePanelCtr.Instance)
|
||
{
|
||
CopyScenePanelCtr.Instance.OnMenuItemClick(GlobalData.NeedShowCopyBaseSubPageIndex);
|
||
if (GlobalData.NeedShowCopyBaseSubPageIndex == 0)
|
||
if (StroyCopySceneRootCtrl.GteInstance())
|
||
{
|
||
StroyCopySceneRootCtrl.GteInstance()._Select
|
||
.OnToggleClick(GlobalData.NeedShowSubPageIndex);
|
||
if (StroyCopySceneRootCtrl.GteInstance())
|
||
StroyCopySceneRootCtrl.GteInstance()
|
||
.SetOutSetFubenId(GlobalData.NeedShowCopyBaseUISceneId,
|
||
GlobalData.NeedShowSubPageIndex);
|
||
}
|
||
}
|
||
|
||
GlobalData.NeedShowCopyBaseUISceneId = -1;
|
||
GlobalData.NeedShowCopyBaseSubPageIndex = 0;
|
||
GlobalData.NeedShowSubPageIndex = 0;
|
||
}
|
||
});
|
||
|
||
//在副本里面接取或者完成的任务继续自动寻路
|
||
//出了副本之后自动寻路(分两种情况,非原地切换场景的不会走到这里,原地进副本的会进到这里)
|
||
if (!GameManager.gameManager.ActiveScene.IsCopyScene() &&
|
||
GameManager.gameManager.PlayerDataPool.AutoSearchMissionId != -1)
|
||
{
|
||
GameManager.gameManager.MissionManager.MissionPathFinder(GameManager.gameManager.PlayerDataPool
|
||
.AutoSearchMissionId);
|
||
GameManager.gameManager.PlayerDataPool.AutoSearchMissionId = -1;
|
||
}
|
||
|
||
//高昌出来切换PK模式
|
||
if (GameManager.gameManager.ActiveScene.IsCopyScene() == false)
|
||
{
|
||
var fuben = TableManager.GetFubenByID(
|
||
GameManager.gameManager.PlayerDataPool.EnterSceneCache.BeforeEnterCopySceneID);
|
||
if (fuben != null &&
|
||
fuben.ActivityType == (int) ActivityDataManager.Activity_Type.ACTIVITY_TYPE_TREASURE_GLOD)
|
||
{
|
||
var pkChange =
|
||
(CG_CHANGE_PKMODLE) PacketDistributed.CreatePacket(MessageID.PACKET_CG_CHANGE_PKMODLE);
|
||
pkChange.SetObjId(ServerID);
|
||
pkChange.SetPKModle(0);
|
||
pkChange.SendPacket();
|
||
}
|
||
}
|
||
|
||
//有些野外也需要显示一些特殊UI
|
||
Utils.CheckFubenShowUI();
|
||
}
|
||
|
||
private void FirstEnterGameOpt()
|
||
{
|
||
if (GlobalData.IsFirstTimeEnterScene)
|
||
{
|
||
GlobalData.IsFirstTimeEnterScene = false;
|
||
// SdkControl.instance.SubmitData(m_BaseAttr.Level > 1 ? RoleDataSubmit.EnterGame : RoleDataSubmit.Create);
|
||
// PlatformHelper.SubMitInfo(2); //进入游戏
|
||
CheckGuildMatch();
|
||
}
|
||
|
||
|
||
//CheckGuildMatch();
|
||
var ask = (CG_ASK_GIFT_CONFIG) PacketDistributed.CreatePacket(MessageID.PACKET_CG_ASK_GIFT_CONFIG);
|
||
ask.SetNoData(0);
|
||
ask.SendPacket();
|
||
|
||
var send =
|
||
(CG_GUILD_REQ_INFO) PacketDistributed.CreatePacket(MessageID.PACKET_CG_GUILD_REQ_INFO);
|
||
send.SetReqType((int) CG_GUILD_REQ_INFO.REQ_TYPE.REQ_TYPE_APPLY_LIST);
|
||
send.SendPacket();
|
||
|
||
|
||
GameManager.gameManager.PlayerDataPool.GuildInfo.AskXiulianInfo();
|
||
|
||
//请求当前进阶信息
|
||
AskForAdvanceInfo();
|
||
|
||
WorldBossData.Instance.AskHomeBossInfo();
|
||
GameManager.gameManager.PlayerDataPool.FellowBookData.AskFellowBookInfo();
|
||
}
|
||
|
||
private void AskForAdvanceInfo()
|
||
{
|
||
var req = (CG_REQ_ADVANCE) PacketDistributed.CreatePacket(MessageID.PACKET_CG_REQ_ADVANCE);
|
||
req.SetOptionType((int) AdvanceBase.ReqType.REQ_INFO);
|
||
req.SetType(-1);
|
||
req.SetParam1(0);
|
||
req.SetParam2(0);
|
||
req.SendPacket();
|
||
}
|
||
|
||
private void CheckGuildMatch()
|
||
{
|
||
if (GameManager.gameManager.ActiveScene.IsCopyScene() == false &&
|
||
GameManager.gameManager.PlayerDataPool.GuildInfo.GuildMatchCam != -1)
|
||
{
|
||
if (ActivityDataManager.Instance.IsActivityState(
|
||
(int) ActivityDataManager.Activity_Type.ACTIVITY_TYPE_GUILD_UNION_MATCH,
|
||
ActivityDataManager.ActivityState.Playing) == false)
|
||
return;
|
||
|
||
MessageBoxLogic.OpenOKCancelBox(StrDictionary.GetClientDictionaryString("#{29028}"), null, delegate
|
||
{
|
||
var system = TableManager.GetSystemParamByID(9);
|
||
if (system != null)
|
||
{
|
||
var sparam = system.StringValue.Split(',');
|
||
if (sparam.Length < 3)
|
||
return;
|
||
int roleId;
|
||
float x;
|
||
float z;
|
||
if (!int.TryParse(sparam[0], out roleId)) return;
|
||
|
||
if (!float.TryParse(sparam[1], out x)) return;
|
||
|
||
if (!float.TryParse(sparam[2], out z)) return;
|
||
|
||
GameManager.gameManager.AutoSearch.BackGuild(
|
||
GameManager.gameManager.PlayerDataPool.GuildInfo.GuildGuid, roleId, x, z);
|
||
}
|
||
});
|
||
}
|
||
}
|
||
|
||
public override void UpdateAttrBroadcastPackt(GC_BROADCAST_ATTR packet)
|
||
{
|
||
base.UpdateAttrBroadcastPackt(packet);
|
||
for (var i = 0; i < packet.propIntArrayCount; ++i)
|
||
{
|
||
var propType = (PropID.PropertyID) packet.GetPropIntArray(i).Propid;
|
||
var propValue = packet.GetPropIntArray(i).Propval;
|
||
SetPropStatic(propType, propValue);
|
||
}
|
||
|
||
for (var i = 0; i < packet.propInt64ArrayCount; i++)
|
||
{
|
||
var propType = (PropID.PropertyID) packet.GetPropInt64Array(i).Propid;
|
||
var propValue = packet.GetPropInt64Array(i).Propval;
|
||
SetPropStatic(propType, propValue);
|
||
}
|
||
}
|
||
|
||
public static void SetPropStatic(PropID.PropertyID propID, int value)
|
||
{
|
||
var _mainPlayer = Singleton<ObjManager>.GetInstance().MainPlayer;
|
||
var playerDataPool = GameManager.gameManager.PlayerDataPool;
|
||
|
||
switch (propID)
|
||
{
|
||
case PropID.PropertyID.CURHP:
|
||
{
|
||
playerDataPool.MainPlayerBaseAttr.HP = value;
|
||
if (_mainPlayer != null)
|
||
_mainPlayer.OptHPChange();
|
||
|
||
if (RoleViewLogic.Instance() != null)
|
||
RoleViewLogic.Instance().UpdateCurAttr();
|
||
}
|
||
break;
|
||
case PropID.PropertyID.MAXHP:
|
||
{
|
||
playerDataPool.MainPlayerBaseAttr.MaxHP = value;
|
||
if (_mainPlayer != null)
|
||
_mainPlayer.OptHPChange();
|
||
|
||
if (RoleViewLogic.Instance() != null)
|
||
RoleViewLogic.Instance().UpdateCurAttr();
|
||
}
|
||
break;
|
||
case PropID.PropertyID.MAXHPCAP:
|
||
{
|
||
playerDataPool.MainPlayerBaseAttr.CurMaxHP = value;
|
||
if (_mainPlayer != null)
|
||
_mainPlayer.OptHPChange();
|
||
|
||
if (RoleViewLogic.Instance() != null)
|
||
RoleViewLogic.Instance().UpdateCurAttr();
|
||
}
|
||
break;
|
||
case PropID.PropertyID.CURMP:
|
||
{
|
||
playerDataPool.MainPlayerBaseAttr.MP = value;
|
||
if (_mainPlayer != null)
|
||
_mainPlayer.OptMPChange();
|
||
|
||
if (RoleViewLogic.Instance() != null)
|
||
RoleViewLogic.Instance().UpdateCurAttr();
|
||
}
|
||
break;
|
||
case PropID.PropertyID.MAXMP:
|
||
{
|
||
playerDataPool.MainPlayerBaseAttr.MaxMP = value;
|
||
if (_mainPlayer != null)
|
||
_mainPlayer.OptMPChange();
|
||
|
||
if (RoleViewLogic.Instance() != null)
|
||
RoleViewLogic.Instance().UpdateCurAttr();
|
||
}
|
||
break;
|
||
case PropID.PropertyID.CURXP:
|
||
{
|
||
playerDataPool.MainPlayerBaseAttr.XP = value;
|
||
if (_mainPlayer != null)
|
||
_mainPlayer.OptXPChange();
|
||
|
||
if (RoleViewLogic.Instance() != null)
|
||
RoleViewLogic.Instance().UpdateCurAttr();
|
||
}
|
||
break;
|
||
case PropID.PropertyID.LEVEL:
|
||
{
|
||
playerDataPool.MainPlayerBaseAttr.Level = value;
|
||
if (_mainPlayer)
|
||
{
|
||
for (var j = 0; j < LoginData.loginRoleList.Count; j++)
|
||
if (LoginData.loginRoleList[j].guid == _mainPlayer.GUID)
|
||
{
|
||
LoginData.loginRoleList[j].level = playerDataPool.MainPlayerBaseAttr.Level;
|
||
UserConfigData.AddRoleInfo();
|
||
break;
|
||
}
|
||
|
||
if (_mainPlayer != null)
|
||
_mainPlayer.OptLevelChange();
|
||
GameManager.gameManager.PlayerDataPool.GuildInfo.XiulianRedPoint();
|
||
//活动红点刷新
|
||
ActivityRedStateCtr.Instance.RefreshActState();
|
||
if (_mainPlayer != null)
|
||
GameManager.gameManager.MissionManager.NotifyMissionUI(-1, "add");
|
||
//foreach (var m_ValuePair in GameManager.gameManager.MissionManager.MissionList.m_aMission)
|
||
// GameManager.gameManager.MissionManager.NotifyMissionUI(m_ValuePair.Value.m_nMissionID,
|
||
// "add");
|
||
|
||
//if (_mainPlayer != null)
|
||
//_mainPlayer.UpdateSelectDrug();
|
||
}
|
||
|
||
if (RoleViewLogic.Instance() != null)
|
||
RoleViewLogic.Instance().UpdateCurAttr();
|
||
WorldBossData.Instance.BossRedTip();
|
||
// 每当等级更新时,需要更具配置显示礼包领取提示
|
||
var openLevels = TableManager.GetStrDictionaryByID(64001, 0).StrDictionary;
|
||
var lastLevels = TableManager.GetStrDictionaryByID(64002, 0).StrDictionary;
|
||
if (!string.IsNullOrEmpty(openLevels) && !string.IsNullOrEmpty(lastLevels))
|
||
{
|
||
var openLevelSingle = openLevels.Split('|');
|
||
var lastLevelSingle = lastLevels.Split('|');
|
||
|
||
// 在配置区间内的等级才进行显示
|
||
// isNew 表示是否找到新的需要显示的等级
|
||
// 因为会出现达到等级后,礼包一直不领取的情况
|
||
// 礼包提示则要一直显示差距为0,直到领取礼包或者新的提示出现
|
||
var isNew = false;
|
||
for (var i = 0; i < openLevelSingle.Length && i < lastLevelSingle.Length; ++i)
|
||
{
|
||
var open = Convert.ToInt32(openLevelSingle[i]);
|
||
var last = Convert.ToInt32(lastLevelSingle[i]);
|
||
|
||
var guid = GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Guid.ToString();
|
||
|
||
// 同时检测改账号已获得的最高等级,没拿过的等级才显示
|
||
if (PlayerPrefs.GetInt("MaxGiftLevel" + guid) < last)
|
||
{
|
||
isNew = true;
|
||
var levels = new int[2];
|
||
levels[0] = last - value;
|
||
levels[1] = last;
|
||
if (value >= open && value <= last)
|
||
UIManager.ShowUI(UIInfo.LevelGiftBagTip,
|
||
(bSuccess, param) =>
|
||
{
|
||
if (bSuccess)
|
||
{
|
||
var pLevels = (int[]) param;
|
||
LevelGiftBagTip.Instance.ShowLevel(pLevels[0], pLevels[1]);
|
||
}
|
||
}, levels);
|
||
}
|
||
}
|
||
|
||
if (isNew == false)
|
||
if (LevelGiftBagTip.Instance != null &&
|
||
LevelGiftBagTip.Instance.gameObject.activeInHierarchy)
|
||
LevelGiftBagTip.Instance.ShowLevel(0);
|
||
}
|
||
// 配置错误
|
||
else
|
||
{
|
||
if (LevelGiftBagTip.Instance != null)
|
||
UIManager.CloseUI(UIInfo.LevelGiftBagTip);
|
||
}
|
||
}
|
||
break;
|
||
case PropID.PropertyID.ACTVAL:
|
||
{
|
||
playerDataPool.MainPlayerBaseAttr.CurStamina = value;
|
||
if (_mainPlayer != null)
|
||
_mainPlayer.OnExpChange();
|
||
WorldBossData.Instance.BossRedTip();
|
||
if (RoleViewLogic.Instance() != null)
|
||
RoleViewLogic.Instance().UpdateCurAttr();
|
||
|
||
if (LiveSkillLogic.Instance())
|
||
LiveSkillLogic.Instance().UpdateProp();
|
||
}
|
||
break;
|
||
case PropID.PropertyID.YINLIANG:
|
||
{
|
||
playerDataPool.Money.SetMoney(MONEYTYPE.MONEYTYPE_COIN, value);
|
||
if (BackPackLogic.Instance())
|
||
BackPackLogic.Instance().UpdateMoneyInfo();
|
||
if (CangKuLogic.Instance())
|
||
CangKuLogic.Instance().UpdateBackPack_Money();
|
||
|
||
if (null != GUIData.delMoneyChanged) GUIData.delMoneyChanged();
|
||
}
|
||
break;
|
||
case PropID.PropertyID.YUANBAO:
|
||
{
|
||
playerDataPool.Money.SetMoney(MONEYTYPE.MONEYTYPE_YUANBAO, value);
|
||
if (BackPackLogic.Instance())
|
||
BackPackLogic.Instance().UpdateMoneyInfo();
|
||
if (CangKuLogic.Instance())
|
||
CangKuLogic.Instance().UpdateBackPack_Money();
|
||
if (null != GUIData.delMoneyChanged) GUIData.delMoneyChanged();
|
||
}
|
||
break;
|
||
case PropID.PropertyID.BIND_YUANBAO:
|
||
{
|
||
playerDataPool.Money.SetMoney(MONEYTYPE.MONEYTYPE_YUANBAO_BIND, value);
|
||
if (BackPackLogic.Instance())
|
||
BackPackLogic.Instance().UpdateMoneyInfo();
|
||
if (CangKuLogic.Instance())
|
||
CangKuLogic.Instance().UpdateBackPack_Money();
|
||
if (null != GUIData.delMoneyChanged) GUIData.delMoneyChanged();
|
||
}
|
||
break;
|
||
case PropID.PropertyID.BIND_YINLIANG:
|
||
{
|
||
playerDataPool.Money.SetMoney(MONEYTYPE.MONEYTYPE_COIN_BIND, value);
|
||
if (BackPackLogic.Instance())
|
||
BackPackLogic.Instance().UpdateMoneyInfo();
|
||
if (CangKuLogic.Instance())
|
||
CangKuLogic.Instance().UpdateBackPack_Money();
|
||
|
||
if (null != GUIData.delMoneyChanged) GUIData.delMoneyChanged();
|
||
}
|
||
break;
|
||
case PropID.PropertyID.CHAELLENGESCORE:
|
||
{
|
||
playerDataPool.Money.SetMoney(MONEYTYPE.MONEYTYPE_USERCHALLENGE, value);
|
||
|
||
if (null != GUIData.delMoneyChanged) GUIData.delMoneyChanged();
|
||
}
|
||
break;
|
||
case PropID.PropertyID.SNATCHSCORE:
|
||
{
|
||
playerDataPool.Money.SetMoney(MONEYTYPE.MONEYTYPE_SNATCHSCORE, value);
|
||
|
||
if (null != GUIData.delMoneyChanged) GUIData.delMoneyChanged();
|
||
}
|
||
break;
|
||
case PropID.PropertyID.ABILITYLEVEL:
|
||
{
|
||
//playerDataPool.MainPlayerBaseAttr.Xiewei = value;
|
||
|
||
if (SkillRootLogic.Instance() != null)
|
||
SkillRootLogic.Instance().UpdateXiuwei();
|
||
}
|
||
break;
|
||
case PropID.PropertyID.FIGHTSCORE:
|
||
{
|
||
playerDataPool.MainPlayerBaseAttr.FightScore = value;
|
||
}
|
||
break;
|
||
case PropID.PropertyID.QINGYIZHI:
|
||
{
|
||
playerDataPool.MainPlayerBaseAttr.QingYiScore = value;
|
||
}
|
||
break;
|
||
case PropID.PropertyID.SHOUZENG:
|
||
{
|
||
playerDataPool.MainPlayerBaseAttr.ShouZengScore = value;
|
||
}
|
||
break;
|
||
case PropID.PropertyID.MODELVISUALID:
|
||
{
|
||
playerDataPool.ModelVisualID = value;
|
||
}
|
||
break;
|
||
case PropID.PropertyID.WEAPONDATAID:
|
||
{
|
||
playerDataPool.WeaponFashionId = value;
|
||
}
|
||
break;
|
||
case PropID.PropertyID.PROP_COUNTTRY:
|
||
{
|
||
playerDataPool.MainPlayerBaseAttr.Force = value;
|
||
_mainPlayer.BaseAttr.Force = value;
|
||
_mainPlayer.SetSpricelName();
|
||
}
|
||
break;
|
||
case PropID.PropertyID.CHARACTORPROP_MAX:
|
||
{
|
||
_mainPlayer.BaseAttr.WarForce = value;
|
||
playerDataPool.MainPlayerBaseAttr.WarForce = value;
|
||
_mainPlayer.SetSpricelName();
|
||
}
|
||
break;
|
||
case PropID.PropertyID.RECHECKNUM:
|
||
{
|
||
playerDataPool.MainPlayerBaseAttr.RecheckNum = value;
|
||
}
|
||
break;
|
||
case PropID.PropertyID.LOGINDAYS:
|
||
{
|
||
playerDataPool.MainPlayerBaseAttr.LoginDays = value;
|
||
}
|
||
break;
|
||
case PropID.PropertyID.JADECOST:
|
||
{
|
||
playerDataPool.MainPlayerBaseAttr.JadgeCost = value;
|
||
}
|
||
break;
|
||
case PropID.PropertyID.PAYCOUNT:
|
||
{
|
||
playerDataPool.MainPlayerBaseAttr.PayCount = value;
|
||
var req = new ReqRechargeGoodsList();
|
||
req.SendMsg();
|
||
}
|
||
break;
|
||
case PropID.PropertyID.TIMEDOUBLE:
|
||
{
|
||
playerDataPool.MainPlayerBaseAttr.TimeDouble = value;
|
||
}
|
||
break;
|
||
case PropID.PropertyID.ADVANCEMOUNTID:
|
||
{
|
||
GameManager.gameManager.PlayerDataPool.m_objMountParam.AutoFlagMountID = value; //当前幻化ID
|
||
if (AdvanceMountPanelCtr.Instance &&
|
||
AdvanceMountPanelCtr.Instance.showPanel.gameObject.activeInHierarchy)
|
||
{
|
||
AdvanceMountPanelCtr.Instance.fashionPanel.RefreshAdvanceItemState();
|
||
AdvanceMountPanelCtr.Instance.showPanel.InitShowModel();
|
||
}
|
||
}
|
||
break;
|
||
case PropID.PropertyID.ADVANCEGODWEAPONID:
|
||
{
|
||
playerDataPool.MainPlayerBaseAttr.AdvanceGodweaponId = value;
|
||
if (AdvanceMountPanelCtr.Instance && AdvanceMountPanelCtr.Instance.gameObject.activeInHierarchy)
|
||
AdvanceMountPanelCtr.Instance.fashionPanel.RefreshAdvanceItemState();
|
||
}
|
||
break;
|
||
case PropID.PropertyID.ADVANCEWISHID:
|
||
{
|
||
playerDataPool.MainPlayerBaseAttr.AdvanceWishId = value;
|
||
if (AdvanceMountPanelCtr.Instance && AdvanceMountPanelCtr.Instance.gameObject.activeInHierarchy)
|
||
AdvanceMountPanelCtr.Instance.fashionPanel.RefreshAdvanceItemState();
|
||
}
|
||
break;
|
||
case PropID.PropertyID.ADVANCESEALID:
|
||
{
|
||
playerDataPool.MainPlayerBaseAttr.AdvanceSealId = value;
|
||
if (AdvanceMountPanelCtr.Instance && AdvanceMountPanelCtr.Instance.gameObject.activeInHierarchy)
|
||
AdvanceMountPanelCtr.Instance.fashionPanel.RefreshAdvanceItemState();
|
||
}
|
||
break;
|
||
case PropID.PropertyID.ADVANCEMASKID:
|
||
{
|
||
playerDataPool.MainPlayerBaseAttr.AdvanceMaskId = value;
|
||
if (AdvanceMountPanelCtr.Instance && AdvanceMountPanelCtr.Instance.gameObject.activeInHierarchy)
|
||
AdvanceMountPanelCtr.Instance.fashionPanel.RefreshAdvanceItemState();
|
||
}
|
||
break;
|
||
case PropID.PropertyID.ADVANCECROWNID:
|
||
{
|
||
playerDataPool.MainPlayerBaseAttr.AdvanceCrownId = value;
|
||
if (AdvanceMountPanelCtr.Instance && AdvanceMountPanelCtr.Instance.gameObject.activeInHierarchy)
|
||
AdvanceMountPanelCtr.Instance.fashionPanel.RefreshAdvanceItemState();
|
||
}
|
||
break;
|
||
//case PropID.PropertyID.CROSSSERVERSCORE:
|
||
// {
|
||
// playerDataPool.MainPlayerBaseAttr.CrossServerScore = value;
|
||
// }
|
||
// break;
|
||
//case PropID.PropertyID.MENPAI:
|
||
// {
|
||
// playerDataPool.Menpaijifen = value;
|
||
// }
|
||
// break;
|
||
//case PropID.PropertyID.GUANNING:
|
||
// {
|
||
// playerDataPool.Guanningjifen = value;
|
||
// }
|
||
// break;
|
||
//case PropID.PropertyID.BIWU:
|
||
// {
|
||
// playerDataPool.Biwujifen = value;
|
||
// }
|
||
// break;
|
||
// case PropID.PropertyID.DUOBAO:
|
||
// {
|
||
// playerDataPool.Duobaojifen = value;
|
||
// }
|
||
// break;
|
||
//case PropID.PropertyID.QINGYIZHI:
|
||
// {
|
||
// playerDataPool.Qingyijifen = value;
|
||
// }
|
||
// break;
|
||
//case PropID.PropertyID.SHOUZENG:
|
||
// {
|
||
// playerDataPool.Shouzengjifen = value;
|
||
// }
|
||
// break;
|
||
default:
|
||
{
|
||
playerDataPool.SetPropInt(propID, value);
|
||
if (null != GUIData.delMoneyChanged) GUIData.delMoneyChanged();
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
|
||
public static void SetPropStatic(PropID.PropertyID propID, long value)
|
||
{
|
||
var _mainPlayer = Singleton<ObjManager>.GetInstance().MainPlayer;
|
||
var playerDataPool = GameManager.gameManager.PlayerDataPool;
|
||
switch (propID)
|
||
{
|
||
case PropID.PropertyID.CURHP:
|
||
{
|
||
playerDataPool.MainPlayerBaseAttr.HP = value;
|
||
if (_mainPlayer != null)
|
||
_mainPlayer.OptHPChange();
|
||
|
||
if (RoleViewLogic.Instance() != null)
|
||
RoleViewLogic.Instance().UpdateCurAttr();
|
||
}
|
||
break;
|
||
case PropID.PropertyID.MAXHP:
|
||
{
|
||
playerDataPool.MainPlayerBaseAttr.MaxHP = value;
|
||
if (_mainPlayer != null)
|
||
_mainPlayer.OptHPChange();
|
||
|
||
if (RoleViewLogic.Instance() != null)
|
||
RoleViewLogic.Instance().UpdateCurAttr();
|
||
}
|
||
break;
|
||
case PropID.PropertyID.MAXHPCAP:
|
||
{
|
||
playerDataPool.MainPlayerBaseAttr.CurMaxHP = value;
|
||
if (_mainPlayer != null)
|
||
_mainPlayer.OptHPChange();
|
||
|
||
if (RoleViewLogic.Instance() != null)
|
||
RoleViewLogic.Instance().UpdateCurAttr();
|
||
}
|
||
break;
|
||
|
||
case PropID.PropertyID.PROPUSER_EXP:
|
||
{
|
||
playerDataPool.MainPlayerBaseAttr.Exp = value;
|
||
if (_mainPlayer != null)
|
||
_mainPlayer.OnExpChange();
|
||
|
||
if (RoleViewLogic.Instance() != null)
|
||
RoleViewLogic.Instance().UpdateCurAttr();
|
||
|
||
if (SkillRootLogic.Instance() != null)
|
||
SkillRootLogic.Instance().UpdateSkillCost();
|
||
|
||
SkillRootLogic.CanAnySkillLvUp();
|
||
if (SkillRootLogic.Instance())
|
||
SkillRootLogic.Instance().UpdateRedTips();
|
||
}
|
||
break;
|
||
case PropID.PropertyID.PRIVATEEXP:
|
||
{
|
||
playerDataPool.MainPlayerBaseAttr.SkillExp = value;
|
||
//if (_mainPlayer != null)
|
||
// _mainPlayer.OnExpChange();
|
||
|
||
if (RoleViewLogic.Instance() != null)
|
||
RoleViewLogic.Instance().UpdateCurAttr();
|
||
if (SkillRootLogic.Instance() != null)
|
||
SkillRootLogic.Instance().UpdateSkillCost();
|
||
|
||
SkillRootLogic.CanAnySkillLvUp();
|
||
if (SkillRootLogic.Instance())
|
||
SkillRootLogic.Instance().UpdateRedTips();
|
||
}
|
||
break;
|
||
case PropID.PropertyID.HEADEXP:
|
||
{
|
||
playerDataPool.MainPlayerBaseAttr.HeadExp = value;
|
||
//if (_mainPlayer != null)
|
||
// _mainPlayer.OnExpChange();
|
||
|
||
if (RoleViewLogic.Instance() != null)
|
||
RoleViewLogic.Instance().UpdateCurAttr();
|
||
if (SkillRootLogic.Instance() != null)
|
||
SkillRootLogic.Instance().UpdateSkillCost();
|
||
}
|
||
break;
|
||
case PropID.PropertyID.YINLIANG:
|
||
{
|
||
playerDataPool.Money.SetMoney(MONEYTYPE.MONEYTYPE_COIN, value);
|
||
if (BackPackLogic.Instance())
|
||
BackPackLogic.Instance().UpdateMoneyInfo();
|
||
|
||
if (CangKuLogic.Instance())
|
||
CangKuLogic.Instance().UpdateBackPack_Money();
|
||
|
||
if (null != GUIData.delMoneyChanged) GUIData.delMoneyChanged();
|
||
}
|
||
break;
|
||
case PropID.PropertyID.BIND_YINLIANG:
|
||
{
|
||
playerDataPool.Money.SetMoney(MONEYTYPE.MONEYTYPE_COIN_BIND, value);
|
||
if (BackPackLogic.Instance())
|
||
BackPackLogic.Instance().UpdateMoneyInfo();
|
||
|
||
if (CangKuLogic.Instance())
|
||
CangKuLogic.Instance().UpdateBackPack_Money();
|
||
|
||
if (null != GUIData.delMoneyChanged) GUIData.delMoneyChanged();
|
||
|
||
if (SkillRootLogic.Instance())
|
||
SkillRootLogic.Instance().UpdateRedTips();
|
||
SkillRootLogic.CanAnySkillLvUp();
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
|
||
public void OnPlayerLeaveScene()
|
||
{
|
||
CopyInUpRight.ClearData();
|
||
if (GameManager.gameManager != null && GameManager.gameManager.AutoSearch != null)
|
||
GameManager.gameManager.AutoSearch.RoadSignManager.LeaveScene();
|
||
if (MissionDialogAndLeftTabsLogic.Instance())
|
||
MissionDialogAndLeftTabsLogic.Instance().SetSwitchBtn(false);
|
||
|
||
Singleton<SignPostManager>.Instance.LeaveScene();
|
||
|
||
if (OneDragonAuto.One_DragonAuto != null)
|
||
OneDragonAuto.One_DragonAuto.OnLeaveScene();
|
||
SceneData.CopyOverTime = 0;
|
||
|
||
|
||
EventDispatcher.Instance.Dispatch(EventId.CancleTarget, -1);
|
||
}
|
||
|
||
// ********************************************************
|
||
// ******************** 移动和动画相关 ********************
|
||
// ********************************************************
|
||
/// <summary>
|
||
/// 选定当前目标并试图移动过去
|
||
/// </summary>
|
||
// 为手指和鼠标点选留的特殊接口,使用这个接口会使角色向目标移动,并创建移动结束事件
|
||
public void SetClientTargetByClick(Obj_Character character)
|
||
{
|
||
// 特殊处理自动连续技能,期间不允许切换怪物
|
||
if (IsUsingSkill
|
||
&& SkillCore.CurrentSkillBase.SkillClass.ContainFlag((int) SKILLCLASS.AUTOREPEAT))
|
||
{
|
||
}
|
||
else if (IsDisableControl() || IsDisableState(DISABLESTATE.Disable_Select))
|
||
{
|
||
}
|
||
//else if (character == null)
|
||
//{
|
||
// RemoveSelectTarget();
|
||
//}
|
||
// 不可选中目标,不允许点选
|
||
else if (character.IsDisableState(DISABLESTATE.Disable_BeSelect))
|
||
{
|
||
}
|
||
else
|
||
{
|
||
// 不允许选择基类角色和宠物
|
||
if (character.ObjType != GameDefine_Globe.OBJ_TYPE.OBJ_CHARACTER)
|
||
{
|
||
var isEnemy = Reputation.CanAttack(character);
|
||
// 如果是敌对目标,试图移动后执行普攻
|
||
if (isEnemy)
|
||
{
|
||
// 不允许选择已死亡的敌对角色
|
||
if (!character.IsDie())
|
||
{
|
||
SetSelectTarget(character);
|
||
// 没有普攻或者普攻不能攻击目标,则不作相应
|
||
var simpleSkillData = GetFirstSimpleAttack();
|
||
if (simpleSkillData != null && ValidTargetTypeBySkillBase(character,
|
||
simpleSkillData.ComboBaseTable.PriorityTarget))
|
||
if (ValidSkillRangeOnTarget(simpleSkillData.ComboExTableFinal,
|
||
simpleSkillData.ComboBaseTable, character))
|
||
InteractWithCharacter(character);
|
||
else if (!MainPlayMoveToTarget(character,
|
||
new MoveToTargetTillSkill(simpleSkillData),
|
||
new MoveSuccessToClickCharacter(this, character)))
|
||
FaceTo(character.Position);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
// 友方角色死亡后可以选择,但是不执行自动寻路到目标
|
||
SetSelectTarget(character);
|
||
if (!character.IsDie())
|
||
{
|
||
var stopRange = character.BaseAttr.RoleData.DialogRadius;
|
||
if ((character.Position - Position).RemoveY().sqrMagnitude < stopRange.ToSquare())
|
||
InteractWithCharacter(character);
|
||
else if (!MainPlayMoveToTarget(character, new MoveToTargetTillDistance(stopRange),
|
||
new MoveSuccessToClickCharacter(this, character)))
|
||
// 移动失败,可能是受到控制等特殊情况
|
||
FaceTo(character.Position);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 选定当前目标,返回是否选定成功
|
||
/// </summary>
|
||
public bool SetSelectTarget(Obj_Character character, bool sendPack = true)
|
||
{
|
||
var result = false;
|
||
if (character == null)
|
||
RemoveSelectTarget(sendPack);
|
||
else if (character.IsInSelectRange(Position))
|
||
// 如果处于不可选定的状态,就完全忽略这个指令
|
||
// 同样在不可选择目标的状态也忽略指令
|
||
if (!IsDisableState(DISABLESTATE.Disable_Select))
|
||
{
|
||
var canAttack = Reputation.CanAttack(character);
|
||
if (canAttack)
|
||
result = !character.IsDie();
|
||
else
|
||
result = !character.IsDie() || character.ObjType == GameDefine_Globe.OBJ_TYPE.OBJ_OTHER_PLAYER;
|
||
if (result)
|
||
{
|
||
targetFriend = !canAttack;
|
||
if (targetFriend)
|
||
{
|
||
friendlyTarget = character;
|
||
}
|
||
else
|
||
{
|
||
enemyTarget = character;
|
||
// 注:选定敌人后,不回落到友好目标
|
||
friendlyTarget = null;
|
||
}
|
||
|
||
RefreshTarget(sendPack);
|
||
}
|
||
}
|
||
|
||
return result;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 点选NPC的情况产生默认交互流程
|
||
/// </summary>
|
||
private void InteractWithCharacter(Obj_Character character)
|
||
{
|
||
var reputation = Reputation.GetObjReputionType(character);
|
||
// 目前策略,敌对目标直接进行攻击;
|
||
// 如果是NPC,中立目标也进行攻击;友方目标进行对话;
|
||
// 其他类型不予以处理;
|
||
if (reputation == CharacterDefine.REPUTATION_TYPE.REPUTATION_HOSTILE)
|
||
{
|
||
if (SkillAllowSimpleAttack)
|
||
{
|
||
TryStartSimpleAttack();
|
||
OnEnterCombat(character);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
var npc = character as Obj_NPC;
|
||
if (npc != null)
|
||
if (npc.CanTalkTo())
|
||
{
|
||
if (npc.BaseAttr != null && npc.BaseAttr.RoleData != null &&
|
||
npc.BaseAttr.RoleData.DialogRadius >= 0f)
|
||
{
|
||
Singleton<DialogCore>.GetInstance().Show(npc);
|
||
// 暂时保留这个流程 - 实际会导致服务器和客户端选中目标不一致
|
||
SetSelectTarget(npc);
|
||
character.FaceTo(m_ObjTransform.position);
|
||
}
|
||
}
|
||
else if (Reputation.CanAttack(reputation))
|
||
{
|
||
if (SkillAllowSimpleAttack)
|
||
{
|
||
TryStartSimpleAttack();
|
||
OnEnterCombat(character);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 移除当前目标
|
||
/// </summary>
|
||
public void RemoveSelectTarget(bool sendPack = true)
|
||
{
|
||
friendlyTarget = null;
|
||
enemyTarget = null;
|
||
RefreshTarget(sendPack);
|
||
}
|
||
|
||
private void SendSelectObjPacket(int id)
|
||
{
|
||
var packet = (CG_ASK_SELOBJ_INFO) PacketDistributed.CreatePacket(MessageID.PACKET_CG_ASK_SELOBJ_INFO);
|
||
packet.SetObjId(ServerID);
|
||
packet.SetSeleobjId(id);
|
||
packet.SendPacket();
|
||
}
|
||
|
||
public override void OptChangPKModle()
|
||
{
|
||
var targets = Singleton<ObjManager>.GetInstance().ObjPools;
|
||
foreach (var targetObj in targets.Values)
|
||
{
|
||
var otherPlayer = targetObj as Obj_OtherPlayer;
|
||
if (otherPlayer == null)
|
||
continue;
|
||
if (otherPlayer != this)
|
||
{
|
||
if (otherPlayer.m_headUIObj != null)
|
||
{
|
||
otherPlayer.m_headUIObj.UpdateOtherPkModel(otherPlayer);
|
||
otherPlayer.SetSpricelName();
|
||
}
|
||
|
||
if (enemyTarget == otherPlayer)
|
||
SetSelectTarget(otherPlayer);
|
||
}
|
||
}
|
||
}
|
||
|
||
public override void RideOrUnMount(int nMountID)
|
||
{
|
||
base.RideOrUnMount(nMountID);
|
||
if (GameManager.gameManager.PlayerDataPool.IsHaveTeam() &&
|
||
GameManager.gameManager.PlayerDataPool.TeamInfo.IsCaptain())
|
||
TeamLeaderRideUpdate();
|
||
}
|
||
|
||
protected override void RideMount(int nMountID)
|
||
{
|
||
base.RideMount(nMountID);
|
||
_nextRideSwitchTime = Time.unscaledTime + _rideSwitchInterval;
|
||
}
|
||
|
||
protected override void UnMount()
|
||
{
|
||
base.UnMount();
|
||
_nextRideSwitchTime = Time.unscaledTime + _rideSwitchInterval;
|
||
}
|
||
|
||
public void AskRideMount(bool isTip = true)
|
||
{
|
||
var scene = TableManager.GetSceneClassByID(GameManager.gameManager.RunningScene);
|
||
if (scene == null || scene.CanMount != 1)
|
||
{
|
||
if (isTip)
|
||
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{47021}"));
|
||
return;
|
||
}
|
||
|
||
// 战斗状态不能上坐骑
|
||
if (isCombat)
|
||
{
|
||
if (isTip)
|
||
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{4922}"));
|
||
return;
|
||
}
|
||
|
||
//跑商状态不能上坐骑
|
||
if (IsInPaoShang())
|
||
return;
|
||
// 变身状态不试图骑马
|
||
if (ForceUseModel != null)
|
||
return;
|
||
// 不受控制状态不试图骑马
|
||
if (MovementState > MoveState.MainPlayMove || IsDisableState(DISABLESTATE.Chaos) ||
|
||
IsDisableState(DISABLESTATE.Disable_Move))
|
||
return;
|
||
if (GameManager.gameManager.PlayerDataPool.m_objMountParam.AutoFlagMountID <= 0)
|
||
return;
|
||
if (AdcaneMountId == GameManager.gameManager.PlayerDataPool.m_objMountParam.AutoFlagMountID)
|
||
return;
|
||
// 特殊移动状态不响应骑乘切换
|
||
if (MovementState > MoveState.MainPlayMove)
|
||
return;
|
||
if (_nextRideSwitchTime < Time.unscaledTime)
|
||
{
|
||
EnterMoveFreeze();
|
||
_nextRideSwitchTime = Time.unscaledTime + _rideSwitchInterval;
|
||
var packet = (CG_MOUNT_MOUNT) PacketDistributed.CreatePacket(MessageID.PACKET_CG_MOUNT_MOUNT);
|
||
packet.SetMountID(GameManager.gameManager.PlayerDataPool.m_objMountParam.AutoFlagMountID);
|
||
packet.SendPacket();
|
||
}
|
||
else if (isTip)
|
||
{
|
||
GUIData.AddNotifyData("#{2443}");
|
||
}
|
||
}
|
||
|
||
public void AskUnMount(bool isTip = true, bool force = false)
|
||
{
|
||
if (AdcaneMountId > 0)
|
||
if (force || _nextRideSwitchTime < Time.unscaledTime)
|
||
{
|
||
EnterMoveFreeze();
|
||
_nextRideSwitchTime = Time.unscaledTime + _rideSwitchInterval;
|
||
var packet = (CG_MOUNT_UNMOUNT) PacketDistributed.CreatePacket(MessageID.PACKET_CG_MOUNT_UNMOUNT);
|
||
packet.SetMountID(GameManager.gameManager.PlayerDataPool.m_objMountParam.AdvanceMountId);
|
||
packet.SendPacket();
|
||
}
|
||
else if (isTip)
|
||
{
|
||
GUIData.AddNotifyData("#{2443}");
|
||
}
|
||
}
|
||
|
||
// 是否装备坐骑
|
||
public int GetEquipMountID()
|
||
{
|
||
return GameManager.gameManager.PlayerDataPool.m_objMountParam.AdvanceMountId;
|
||
}
|
||
|
||
public int IsOnMount()
|
||
{
|
||
return GameManager.gameManager.PlayerDataPool.m_objMountParam.AdvanceMountId;
|
||
}
|
||
|
||
//当前召出伙伴
|
||
public Obj_Fellow GetCurFellow()
|
||
{
|
||
if (CurFellowObjId >= 0)
|
||
{
|
||
var charobj = Singleton<ObjManager>.GetInstance().FindObjCharacterInScene(CurFellowObjId);
|
||
if (charobj != null && charobj.ObjType == GameDefine_Globe.OBJ_TYPE.OBJ_FELLOW)
|
||
return charobj as Obj_Fellow;
|
||
}
|
||
|
||
return null;
|
||
}
|
||
|
||
public void AutoUseHPMPDrug()
|
||
{
|
||
var autoMedicInfo = GameManager.gameManager.PlayerDataPool.ClientCustomDateManager.PlayerCustomData
|
||
.autoMedicInfo;
|
||
var playerLv = GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level;
|
||
//是否开启自动吃药开关
|
||
var m_HpAutoToggleOn = autoMedicInfo.isAutoHpOn == 1;
|
||
var m_MpAutoToggleOn = autoMedicInfo.isAutoMpOn == 1;
|
||
|
||
var AutoHpPercent = autoMedicInfo.hpPercent;
|
||
var AutoMpPercent = autoMedicInfo.mpPercent;
|
||
if (!m_MpAutoToggleOn && !m_HpAutoToggleOn)
|
||
return;
|
||
|
||
Tab_CommonItem temp;
|
||
var backPack = GameManager.gameManager.PlayerDataPool.BackPack;
|
||
var AutoHpID = -1;
|
||
if (autoMedicInfo != null
|
||
&& autoMedicInfo.autoHpIdList != null
|
||
&& autoMedicInfo.autoHpIdList.Count > 0)
|
||
for (var index = 0; index < autoMedicInfo.autoHpIdList.Count; index++)
|
||
if (backPack.GetItemCountByDataId(autoMedicInfo.autoHpIdList[index]) > 0)
|
||
{
|
||
temp = TableManager.GetCommonItemByID(autoMedicInfo.autoHpIdList[index]);
|
||
if (temp != null && temp.MinLevelRequire <= playerLv)
|
||
{
|
||
AutoHpID = autoMedicInfo.autoHpIdList[index];
|
||
break;
|
||
}
|
||
}
|
||
|
||
var AutoMpID = -1;
|
||
if (autoMedicInfo != null
|
||
&& autoMedicInfo.autoMpIdList != null
|
||
&& autoMedicInfo.autoMpIdList.Count > 0)
|
||
for (var index = 0; index < autoMedicInfo.autoMpIdList.Count; index++)
|
||
if (backPack.GetItemCountByDataId(autoMedicInfo.autoMpIdList[index]) > 0)
|
||
{
|
||
temp = TableManager.GetCommonItemByID(autoMedicInfo.autoMpIdList[index]);
|
||
if (temp != null && temp.MinLevelRequire <= playerLv)
|
||
{
|
||
AutoMpID = autoMedicInfo.autoMpIdList[index];
|
||
break;
|
||
}
|
||
}
|
||
|
||
if (AutoHpID == -1 || AutoMpID == -1)
|
||
{
|
||
var descID = -1;
|
||
if (AutoHpID == AutoMpID)
|
||
descID = 71003;
|
||
else if (AutoHpID == -1)
|
||
descID = 71000;
|
||
else
|
||
descID = 71001;
|
||
|
||
var shopID = 2;
|
||
var plyerLevel = GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level;
|
||
var tab = TableManager.GetSceneClassByID(GameManager.gameManager.RunningScene);
|
||
if ((tab.Type == 1 || tab.Type == 0)
|
||
&& plyerLevel > 40
|
||
&& tempTime > _medicineTipsTime)
|
||
if (ExtraFunTipRoot.Instance() != null && !ExtraFunTipRoot.Instance()._Medicine.activeSelf)
|
||
{
|
||
_medicineTipsTime = float.PositiveInfinity;
|
||
ExtraFunTipRoot.Instance()._MedicineDescID = descID;
|
||
if (!ExtraFunTipRoot.Instance()._Medicine.activeSelf)
|
||
if (!MessageBoxLogic.Instance() || !MessageBoxLogic.Instance().gameObject.activeInHierarchy)
|
||
MessageBoxLogic.OpenOKCancelBox(
|
||
StrDictionary.GetClientDictionaryString("#{" + descID + "}"), null,
|
||
() => { SysShopController.ShowShop(shopID, true); },
|
||
disableCallBack: () =>
|
||
{
|
||
if (ExtraFunTipRoot.Instance() != null)
|
||
ExtraFunTipRoot.Instance()._Medicine.SetActive(true);
|
||
});
|
||
}
|
||
}
|
||
else
|
||
{
|
||
ExtraFunTipRoot.Instance()._Medicine.SetActive(false);
|
||
}
|
||
|
||
if (AutoHpID == -1 && AutoMpID == -1)
|
||
{
|
||
if (PlayerFrameLogic.Instance())
|
||
PlayerFrameLogic.Instance().ShowLackAutoMedicItemBuff(true);
|
||
}
|
||
else
|
||
{
|
||
if (PlayerFrameLogic.Instance())
|
||
PlayerFrameLogic.Instance().ShowLackAutoMedicItemBuff(false);
|
||
}
|
||
|
||
|
||
if (AutoHpPercent * 0.99f * BaseAttr.MaxHP > BaseAttr.HP && !IsDie())
|
||
AutoPercent((int) MedicSubClass.HP_DY);
|
||
|
||
//设置挂机,自动吃药 tt198507不挂机也可以自动吃药
|
||
if (AutoMpPercent * 0.99f * BaseAttr.MaxMP > BaseAttr.MP && !IsDie())
|
||
AutoPercent((int) MedicSubClass.MP_DY);
|
||
}
|
||
|
||
public override void OptHPChange() //血量变化后的操作
|
||
{
|
||
var playerDataPool = GameManager.gameManager.PlayerDataPool;
|
||
if (playerDataPool == null || playerDataPool.MainPlayerBaseAttr == null)
|
||
return;
|
||
//更新血条
|
||
if (PlayerFrameLogic.Instance() != null)
|
||
PlayerFrameLogic.Instance().ChangeHP(playerDataPool.MainPlayerBaseAttr.HP,
|
||
playerDataPool.MainPlayerBaseAttr.MaxHP, playerDataPool.MainPlayerBaseAttr.CurMaxHP);
|
||
float rate = 1;
|
||
if (playerDataPool.MainPlayerBaseAttr.MaxHP > 0)
|
||
rate = playerDataPool.MainPlayerBaseAttr.HP / (float) playerDataPool.MainPlayerBaseAttr.MaxHP;
|
||
if (rate <= 0.2f)
|
||
{
|
||
if (IsDie() == false)
|
||
UIManager.ShowUI(UIInfo.HitTip);
|
||
}
|
||
else
|
||
{
|
||
UIManager.CloseUI(UIInfo.HitTip);
|
||
}
|
||
|
||
if (m_headUIObj != null) m_headUIObj.SetNewHp(rate);
|
||
}
|
||
|
||
public override void OptMPChange() //法力变化后的操作
|
||
{
|
||
if (PlayerFrameLogic.Instance() != null)
|
||
PlayerFrameLogic.Instance().ChangeMP(BaseAttr.MP, BaseAttr.MaxMP);
|
||
}
|
||
|
||
public override void OptXPChange() //XP变化后的操作
|
||
{
|
||
}
|
||
|
||
public void OnVipCostChange()
|
||
{
|
||
if (null != PlayerFrameLogic.Instance())
|
||
PlayerFrameLogic.Instance().ChangeVip(VipCost);
|
||
}
|
||
|
||
public override void OptLevelChange() //等级变化后的操作
|
||
{
|
||
if (m_lastLevel > 0)
|
||
{
|
||
if (m_lastLevel != BaseAttr.Level)
|
||
{
|
||
//升级特效移至CenterTipsLogic播放
|
||
//PlayEffect(52);
|
||
LevelUpController.ShowTipByID(1433);
|
||
GameManager.gameManager.SoundManager.PlaySoundEffect(106); //upgrading
|
||
m_lastLevel = BaseAttr.Level;
|
||
//GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{4805}", BaseAttr.Level));
|
||
UIManager.ShowUI(UIInfo.CenterTipsRoot,
|
||
(isSuccess, param) =>
|
||
{
|
||
if (isSuccess && CenterTipsLogic.Instance() != null)
|
||
CenterTipsLogic.Instance().EnShowQueue(CenterTipsLogic.ShowInfoType.LevelUp);
|
||
});
|
||
//如果背包界面开着 刷新下背包物品显示(根据是否满足级别会有标红)
|
||
if (BackPackLogic.Instance())
|
||
BackPackLogic.Instance().UpdateBackPack();
|
||
if (BtnInteraction.Instance)
|
||
BtnInteraction.Instance.ReqInteractionState();
|
||
//LevelUpButtonActive();
|
||
if (m_lastLevel >= GlobeVar.MAX_AUTOEQUIT_LIVE &&
|
||
VipData.GetVipLv() >= GlobeVar.USE_AUTOFIGHT_VIPLEVEL)
|
||
UpdateSelectEquip();
|
||
|
||
GuideLogic.OnLevelUpStatic(BaseAttr.Level);
|
||
//刷新技能红点
|
||
if (SkillRootLogic.Instance())
|
||
SkillRootLogic.Instance().UpdateRedTips();
|
||
SkillRootLogic.CanAnySkillLvUp();
|
||
SdkControl.instance.SubmitData(RoleDataSubmit.LevelUp); //角色升级
|
||
}
|
||
}
|
||
else
|
||
{
|
||
m_lastLevel = BaseAttr.Level;
|
||
//InitLevelButtonActive();
|
||
}
|
||
|
||
AdvanceBase.UpdateAllRedPoint(); //等级变化的时候刷新进阶红点状态
|
||
|
||
//等级变化的时候判断是否要添加对应后的指引任务
|
||
GameManager.gameManager.MissionManager.AddGuidMissionToList();
|
||
|
||
if (null != PlayerFrameLogic.Instance())
|
||
PlayerFrameLogic.Instance().ChangeLev(BaseAttr.Level);
|
||
if (ExpLogic.Instance() != null)
|
||
ExpLogic.Instance().OnLevelChange();
|
||
if (FunctionButtonLogic.Instance())
|
||
FunctionButtonLogic.Instance().UpdateButtonAwardTips();
|
||
if (RoleViewLogic.Instance()) RoleViewLogic.Instance().ReqSimpleAttr();
|
||
if (ExerciseRoomPanel.Instance) ExerciseRoomPanel.Instance.RefreshRecommendInfo();
|
||
|
||
if (ExtraFunTipRoot.Instance())
|
||
ExtraFunTipRoot.Instance().UpdateRoleLevel();
|
||
if (MeditateCtr.Instance)
|
||
MeditateCtr.Instance.OnLevelChange(BaseAttr.Level);
|
||
if (FunctionPreviewCtr.Instance) FunctionPreviewCtr.Instance.OnLevelChange();
|
||
|
||
if (SkillBarLogic.Instance() != null)
|
||
{
|
||
//每次升级 更新一下SkillBarItem 用于刷新绝技开启后的界面
|
||
if (GameManager.gameManager.PlayerDataPool.HasInitOwnSkill)
|
||
SkillBarLogic.Instance().RefreshSkillBarInfo();
|
||
//刷新一下任务面板
|
||
GameManager.gameManager.MissionManager.NotifyMissionUI(-1, "add");
|
||
//foreach (var m_ValuePair in GameManager.gameManager.MissionManager.MissionList.m_aMission)
|
||
// // 通知客户端更新UI
|
||
// GameManager.gameManager.MissionManager.NotifyMissionUI(m_ValuePair.Value.m_nMissionID, "add");
|
||
}
|
||
|
||
//境界相关信息更新
|
||
MeridiaSoulData.Instance.CheckIsHasUp();
|
||
if (ActiveBtns.Instance() != null)
|
||
ActiveBtns.Instance().InitBtnInfo();
|
||
EventDispatcher.Instance.Dispatch(EventId.MainPlayerLevelUP);
|
||
}
|
||
|
||
|
||
public override void OptHeadPicChange() //头像变化后的操作
|
||
{
|
||
if (null != PlayerFrameLogic.Instance())
|
||
PlayerFrameLogic.Instance().ChangeHeadPic(BaseAttr.HeadPic);
|
||
}
|
||
|
||
public override void OptNameChange() //名字变化后的操作
|
||
{
|
||
if (null != PlayerFrameLogic.Instance())
|
||
PlayerFrameLogic.Instance().ChangeName(BaseAttr.RoleName);
|
||
|
||
if (m_headUIObj != null)
|
||
SetSpricelName();
|
||
//m_headUIObj.SetName(BaseAttr.RoleName);
|
||
|
||
var gharry =
|
||
Singleton<ObjManager>.Instance.FindObjCharacterInScene(GameManager.gameManager.PlayerDataPool
|
||
.nGharryObjID);
|
||
if (gharry != null)
|
||
{
|
||
var obj_gharry = gharry as Obj_GuildGharry;
|
||
if (obj_gharry != null) obj_gharry.OwerNameChange(BaseAttr.RoleName);
|
||
}
|
||
|
||
//更新登陆界面信息
|
||
for (var i = 0; i < LoginData.loginRoleList.Count; i++)
|
||
if (LoginData.loginRoleList[i].guid == GUID)
|
||
{
|
||
LoginData.loginRoleList[i].name = BaseAttr.RoleName;
|
||
UserConfigData.AddRoleInfo();
|
||
break;
|
||
}
|
||
}
|
||
|
||
public override void OnExpChange()
|
||
{
|
||
if (ExpLogic.Instance() != null)
|
||
ExpLogic.Instance().UpdateExp();
|
||
|
||
if (ExtraFunTipRoot.Instance())
|
||
ExtraFunTipRoot.Instance().UpdateRoleLevel();
|
||
}
|
||
|
||
public void ShowSimpleAttackIcon()
|
||
{
|
||
if (SkillBarLogic.Instance() && SkillBarLogic.Instance().isActiveAndEnabled)
|
||
SkillBarLogic.Instance().SetSimpleAttackIcon();
|
||
}
|
||
|
||
public void OnOffLineExpChange()
|
||
{
|
||
if (ExpLogic.Instance() != null)
|
||
ExpLogic.Instance().UpdateOffLineExp();
|
||
}
|
||
|
||
public override void OptPKValueChange()
|
||
{
|
||
base.OptPKValueChange();
|
||
SetSpricelName();
|
||
if (IsInJianYu())
|
||
if (BaseAttr.PKValue == 0)
|
||
MessageBoxLogic.OpenOKCancelBox(StrDictionary.GetClientDictionaryString("#{35004}"), "",
|
||
LeaveWanton);
|
||
}
|
||
|
||
public void LeaveWanton()
|
||
{
|
||
if (IsInJianYu())
|
||
{
|
||
var pkInfo = TableManager.GetPKDetailInfoByID(1);
|
||
if (pkInfo == null)
|
||
return;
|
||
var point = new AutoSearchPoint(GameManager.gameManager.RunningScene, pkInfo.PosX, pkInfo.PosZ, 0);
|
||
if (GameManager.gameManager && GameManager.gameManager.AutoSearch)
|
||
{
|
||
GameManager.gameManager.AutoSearch.BuildPath(point);
|
||
var RoleBase = TableManager.GetRoleBaseAttrByID(pkInfo.DataID);
|
||
if (null != RoleBase && null != GameManager.gameManager.AutoSearch.Path)
|
||
{
|
||
GameManager.gameManager.AutoSearch.Path.AutoSearchTargetName = RoleBase.Name;
|
||
GameManager.gameManager.AutoSearch.Path.autoSearchRadius = RoleBase.DialogRadius;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
public override void OptWarForceChange()
|
||
{
|
||
SetSpricelName();
|
||
//重置周围玩家名字颜色
|
||
var targets = Singleton<ObjManager>.GetInstance().ObjPools;
|
||
foreach (var targetObj in targets.Values)
|
||
if (targetObj != null && targetObj.ObjType == GameDefine_Globe.OBJ_TYPE.OBJ_OTHER_PLAYER)
|
||
{
|
||
var _Player = targetObj as Obj_OtherPlayer;
|
||
if (_Player)
|
||
_Player.SetSpricelName();
|
||
}
|
||
}
|
||
|
||
public override void OptForceChange() //势力变化后的操作
|
||
{
|
||
SetSpricelName();
|
||
//重置周围玩家名字颜色
|
||
var targets = Singleton<ObjManager>.GetInstance().ObjPools;
|
||
foreach (var targetObj in targets.Values)
|
||
if (targetObj != null && targetObj.ObjType == GameDefine_Globe.OBJ_TYPE.OBJ_OTHER_PLAYER)
|
||
{
|
||
var _Player = targetObj as Obj_OtherPlayer;
|
||
if (_Player)
|
||
_Player.SetSpricelName();
|
||
}
|
||
}
|
||
|
||
public void AskCombatValue(bool bPowerRemind)
|
||
{
|
||
var packet = (CG_COMBATVALUE_ASK) PacketDistributed.CreatePacket(MessageID.PACKET_CG_COMBATVALUE_ASK);
|
||
packet.ShowPowerRemind = bPowerRemind ? 1 : 0;
|
||
packet.SendPacket();
|
||
}
|
||
|
||
public override bool OnCorpse()
|
||
{
|
||
var liveToDie = !BaseAttr.Die;
|
||
base.OnCorpse();
|
||
//BaseAttr.Die = true;
|
||
// 死亡 弹出复活UI
|
||
if (isNeedShowReliveUI()) //做一个判断
|
||
UIManager.ShowUI(UIInfo.Relive);
|
||
if (liveToDie)
|
||
EventDispatcher.Instance.Dispatch(EventId.MainPlayerDie);
|
||
//UIManager.ShowUI(UIInfo.Relive);
|
||
//切换到死亡状态
|
||
//CurObjAnimState = GameDefine_Globe.OBJ_ANIMSTATE.STATE_DEATH;
|
||
return true;
|
||
}
|
||
|
||
//Obj死亡时候调用
|
||
public override bool OnDie()
|
||
{
|
||
var result = base.OnDie();
|
||
if (result)
|
||
{
|
||
//BaseAttr.Die = true;
|
||
// 死亡 弹出复活UI
|
||
|
||
// 玩家死亡停止自动寻路
|
||
if (null != GameManager.gameManager.AutoSearch)
|
||
GameManager.gameManager.AutoSearch.Stop();
|
||
LeveAutoCombat();
|
||
//if (null != NavAgent)
|
||
// Destroy(NavAgent);
|
||
UIManager.CloseUI(UIInfo.HitTip);
|
||
if (isNeedShowReliveUI()) //加一个判断 在挑战副本中死亡不会显示复活UI
|
||
UIManager.ShowUI(UIInfo.Relive);
|
||
//UIManager.ShowUI(UIInfo.Relive);
|
||
ProcessInput.Instance.ReleaseInput();
|
||
// 死亡时移除当前选定角色
|
||
RemoveSelectTarget();
|
||
ObjEffectLogic.CleanImpacts();
|
||
//JoyStickLogic.Instance().CloseWindow();
|
||
UpdateAutoAnteMortem();
|
||
SetComboSkillToCooldown();
|
||
EventDispatcher.Instance.Dispatch(EventId.MainPlayerDie);
|
||
}
|
||
|
||
return result;
|
||
}
|
||
|
||
public void SetComboSkillToCooldown()
|
||
{
|
||
// 清空技能连读情况
|
||
// 注:即使服务器的cd更新先到,同一帧清理一次也不影响实际效果
|
||
for (var i = 0; i < OwnSkillInfo.Length; i++)
|
||
if (OwnSkillInfo[i] != null &&
|
||
OwnSkillInfo[i].IsValid() &&
|
||
OwnSkillInfo[i].ComboExTable != OwnSkillInfo[i].SkillExTable)
|
||
OwnSkillInfo[i].ResetCooldown();
|
||
}
|
||
|
||
private bool isNeedShowReliveUI()
|
||
{
|
||
if (GameManager.gameManager.RunningScene ==
|
||
(int) GameDefine_Globe.SCENE_DEFINE.SCENE_FACIONCHALLENGE) //门派挑战副本
|
||
return false;
|
||
|
||
var tab = TableManager.GetSceneClassByID(GameManager.gameManager.RunningScene);
|
||
if (tab != null)
|
||
if (tab.GetReliveIDbyIndex(0) == -1
|
||
&& tab.GetReliveIDbyIndex(1) == -1
|
||
&& tab.GetReliveIDbyIndex(2) == -1)
|
||
return false;
|
||
|
||
return true;
|
||
}
|
||
|
||
public override bool OnRelife(bool isMotion = false)
|
||
{
|
||
base.OnRelife(isMotion);
|
||
//BaseAttr.Die = false;
|
||
// 复活 关闭复活UI
|
||
UIManager.CloseUI(UIInfo.Relive);
|
||
GameManager.gameManager.PlayerDataPool.ReliveData.ClearUp();
|
||
RefreshPlayerAutoCombat();
|
||
UpdateAutoAnteMortem();
|
||
// 队长清除位置
|
||
_leaderPosList.Clear();
|
||
_leaderPosList.Add(Position);
|
||
// 跟随队员监视是否应该开启自动战斗
|
||
var followState = GameManager.gameManager.PlayerDataPool.TeamInfo.GetFollowState();
|
||
if (followState == TeamFollowState.followCombat &&
|
||
!isAutoCombat)
|
||
EnterAutoCombat();
|
||
return true;
|
||
}
|
||
|
||
public void SendNoticMsg(bool IsFilterRepeat, string strMsg, params object[] args)
|
||
{
|
||
GUIData.AddNotifyData2Client(IsFilterRepeat, strMsg, args);
|
||
}
|
||
|
||
//玩家是否接受外部移动指令
|
||
public override bool IsCanOperate_Move(bool showWarning)
|
||
{
|
||
if (IsInModelStory || IsNoMove)
|
||
return false;
|
||
return base.IsCanOperate_Move(showWarning);
|
||
}
|
||
|
||
//切磋
|
||
public void ReqDuelOption(CG_COMPETITION_OPTION.COMPETITION_TYPE type, ulong guid, int param)
|
||
{
|
||
var send = (CG_COMPETITION_OPTION) PacketDistributed.CreatePacket(MessageID.PACKET_CG_COMPETITION_OPTION);
|
||
send.SetOptiontype((int) type);
|
||
send.SetGuid(guid);
|
||
send.SetParam(param);
|
||
send.SendPacket();
|
||
}
|
||
|
||
//
|
||
public void ReqDuel(ulong targetGuid)
|
||
{
|
||
//向服务器发送邀请某人加入队伍消息
|
||
var msg = (CG_DUEL_REQUEST) PacketDistributed.CreatePacket(MessageID.PACKET_CG_DUEL_REQUEST);
|
||
msg.Guid = targetGuid;
|
||
msg.SendPacket();
|
||
}
|
||
|
||
public void DuelWithMe(ulong targetGuid, string playerName)
|
||
{
|
||
DuelTargetGuid = targetGuid;
|
||
var text = StrDictionary.GetClientDictionaryString("{#1666}", playerName);
|
||
var title = Utils.GetDicByID(1657);
|
||
MessageBoxLogic.OpenOKCancelBox(text, title, AgreeDuelWithOther, RefuseDuelWithOther);
|
||
}
|
||
|
||
public void AgreeDuelWithOther()
|
||
{
|
||
DecideDuelWithOrNot(1);
|
||
}
|
||
|
||
public void RefuseDuelWithOther()
|
||
{
|
||
DecideDuelWithOrNot(0);
|
||
}
|
||
|
||
public void DecideDuelWithOrNot(int agree)
|
||
{
|
||
var msg = (CG_DUEL_RESPONSE) PacketDistributed.CreatePacket(MessageID.PACKET_CG_DUEL_RESPONSE);
|
||
msg.Guid = DuelTargetGuid;
|
||
msg.Agree = agree;
|
||
msg.SendPacket();
|
||
}
|
||
|
||
// 随玩家等级开放按钮
|
||
private void LevelUpButtonActive()
|
||
{
|
||
if (FunctionButtonLogic.Instance() != null)
|
||
FunctionButtonLogic.Instance().LevelUpButtonActive();
|
||
}
|
||
|
||
private void InitLevelButtonActive()
|
||
{
|
||
if (FunctionButtonLogic.Instance() != null)
|
||
FunctionButtonLogic.Instance().InitButtonActive();
|
||
}
|
||
|
||
public int GetStaminaFull()
|
||
{
|
||
return GlobeVar.MAX_STAMINA + BaseAttr.Level;
|
||
}
|
||
|
||
public void ReqViewOtherPlayer(ulong targetGuid, OtherRoleViewLogic.OPEN_TYPE oPenType)
|
||
{
|
||
//UIManager.ShowUI(UIInfo.OtherPlayerInfoRoot, delegate (bool bSucess, object param) {
|
||
// if (bSucess)
|
||
// {
|
||
// OtherPlayerInfoRootCtr.Instance.SetViewRoleGuid(targetGuid);
|
||
// }
|
||
//});
|
||
|
||
//OtherRoleViewLogic.SetOpenType(oPenType);
|
||
var askPak = (CG_ASK_OTHERROLE_DATA) PacketDistributed.CreatePacket(MessageID.PACKET_CG_ASK_OTHERROLE_DATA);
|
||
askPak.SetGuid(targetGuid);
|
||
askPak.SetDataType((int) OtherPlayerInfoRootCtr.MenuType.Equip);
|
||
askPak.SendPacket();
|
||
}
|
||
|
||
public void ReqHideFellow()
|
||
{
|
||
//请求隐藏伙伴
|
||
if (CurFellowObjId == -1)
|
||
return;
|
||
var askPak = (CG_ASK_HIDE_FELLOW) PacketDistributed.CreatePacket(MessageID.PACKET_CG_ASK_HIDE_FELLOW);
|
||
askPak.SetType(1);
|
||
askPak.SendPacket();
|
||
}
|
||
|
||
public void ReqShowFellow()
|
||
{
|
||
//请求显示伙伴
|
||
var askPak = (CG_ASK_SHOW_FELLOW) PacketDistributed.CreatePacket(MessageID.PACKET_CG_ASK_SHOW_FELLOW);
|
||
askPak.SetPosx((int) (Position.x * 100));
|
||
askPak.SetPosz((int) (Position.z * 100));
|
||
askPak.SetType(1);
|
||
askPak.SendPacket();
|
||
}
|
||
|
||
public bool IsInJianYu()
|
||
{
|
||
return GameManager.gameManager.RunningScene == (int) GameDefine_Globe.SCENE_DEFINE.SCENE_JIANYU;
|
||
}
|
||
|
||
public void SetChangeNameCDTime(int remainTime)
|
||
{
|
||
////没使用,小于当前服务器时间,直接可以使用
|
||
//if(remainTime < GlobalData.ServerAnsiTime)
|
||
//{
|
||
|
||
//}
|
||
|
||
if (remainTime > GlobalData.ServerAnsiTime)
|
||
{
|
||
//提示玩家还需要多久才能使用
|
||
remainTime -= GlobalData.ServerAnsiTime;
|
||
var remainDay = remainTime / (3600 * 24);
|
||
var remainHour = (remainTime - remainDay * 24 * 3600) / 3600;
|
||
var remainMinute = (remainTime - remainDay * 24 * 3600 - remainHour * 3600) / 60;
|
||
GUIData.AddNotifyData(
|
||
StrDictionary.GetClientDictionaryString("#{42626}", remainDay, remainHour, remainMinute));
|
||
}
|
||
else
|
||
{
|
||
UIManager.ShowUI(UIInfo.ChangeNameBox,
|
||
delegate { ChangeNameBox.ItemGUID = m_UseItem.Guid; }); //只发改名协议 不发使用物品的协议。
|
||
}
|
||
}
|
||
|
||
public bool IsSpecialItem(GameItem item)
|
||
{
|
||
//召唤怪物的道具
|
||
var commonItem = TableManager.GetCommonItemByID(item.DataID);
|
||
if (commonItem == null)
|
||
return true;
|
||
m_UseItem = item;
|
||
var m_SubClassId = commonItem.SubClassID;
|
||
if (m_SubClassId == (int) PrizeSubClass.CALLMONSTER)
|
||
{
|
||
var usableItem = TableManager.GetUsableItemByID(item.DataID);
|
||
if (usableItem == null)
|
||
return true;
|
||
AutoSearchCallMonster(usableItem.UseParamB, new Vector3(usableItem.UseParamC, 0, usableItem.UseParamD),
|
||
item);
|
||
return true;
|
||
}
|
||
|
||
//时装的使用直接发激活协议
|
||
if (item.GetClass() == (int) ItemClass.FASHION)
|
||
{
|
||
var buyPacket =
|
||
(CG_BUY_FASHION) PacketDistributed.CreatePacket(MessageID.PACKET_CG_BUY_FASHION);
|
||
buyPacket.SetFashionID(GlobalData.GetFshionItemIdByDataId(item.DataID));
|
||
buyPacket.SetIsWear(1); //直接穿戴
|
||
buyPacket.SetItemID(item.DataID);
|
||
|
||
buyPacket.SendPacket();
|
||
return true;
|
||
}
|
||
|
||
//改名卡 打开对应的UI 特殊处理
|
||
if (commonItem.ClassID == (int) ItemClass.CHANGENAME)
|
||
{
|
||
//使用之前判断道具的CD是否处于冷却状态
|
||
var req = (CG_REQ_CHANGENAME_CD_ENDTIME) PacketDistributed.CreatePacket(MessageID
|
||
.PACKET_CG_REQ_CHANGENAME_CD_ENDTIME);
|
||
req.SetNilparam(1);
|
||
req.SendPacket(); //请求返回剩余的CD时间
|
||
return true;
|
||
}
|
||
|
||
//有些物品使有的时候需要给特定的玩家对象发送一段话
|
||
if (item.SignDataID != GlobeVar.INVALID_GUID)
|
||
{
|
||
UIManager.ShowUI(UIInfo.GiftWordsRoot, OnUseSignItem, item);
|
||
return true;
|
||
}
|
||
|
||
//进阶直升丹
|
||
if (item.GetClass() == (int) ItemClass.PRIZE)
|
||
{
|
||
var usableItem = TableManager.GetUsableItemByID(item.DataID);
|
||
if (usableItem == null)
|
||
return false;
|
||
|
||
if (item.GetSubClass() == (int) PrizeSubClass.MOUNTLEVELADVANCE
|
||
|| item.GetSubClass() == (int) PrizeSubClass.WINGLEVELADVANCE
|
||
|| item.GetSubClass() == (int) PrizeSubClass.MASKLEVELADVANCE
|
||
|| item.GetSubClass() == (int) PrizeSubClass.RINGLEVELADVANCE
|
||
|| item.GetSubClass() == (int) PrizeSubClass.GUQINLEVELADVANACE
|
||
|| item.GetSubClass() == (int) PrizeSubClass.HUOPAOLEVELADVANCE
|
||
|| item.GetSubClass() == (int) PrizeSubClass.HUNQILEVELADVANCE)
|
||
{
|
||
if (!AdvanceCanadvanceCtr.GetInstance().IsAdvanceFuncOpen(usableItem.UseParamA))
|
||
{
|
||
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{2182}"));
|
||
return true;
|
||
}
|
||
|
||
if (GameManager.gameManager.PlayerDataPool.m_AdvanceData.GetAdvanceGrade(item.GetSubClass() - 36) <
|
||
usableItem.UseParamB - 1)
|
||
{
|
||
MessageBoxLogic.OpenOKCancelBox(
|
||
StrDictionary.GetClientDictionaryString("#{68003}", usableItem.Name),
|
||
"", delegate
|
||
{
|
||
var useitem =
|
||
(CG_USE_ITEM) PacketDistributed.CreatePacket(MessageID.PACKET_CG_USE_ITEM);
|
||
useitem.SetItemguid(item.Guid);
|
||
useitem.SendPacket();
|
||
|
||
UIManager.CloseUI(UIInfo.MessageBox);
|
||
}, delegate { UIManager.CloseUI(UIInfo.MessageBox); });
|
||
|
||
return true;
|
||
}
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
|
||
public void UseItem(GameItem item)
|
||
{
|
||
//使用前判断是否物品限制
|
||
//if (!ItemLimtInfoCtr.GetInstance().CanUseItem(item.DataID))
|
||
// return;
|
||
|
||
//特殊使用的物品
|
||
if (IsSpecialItem(item))
|
||
return;
|
||
|
||
|
||
if (false == item.IsMountItem())
|
||
{
|
||
var useitem = (CG_USE_ITEM) PacketDistributed.CreatePacket(MessageID.PACKET_CG_USE_ITEM);
|
||
useitem.SetItemguid(item.Guid);
|
||
useitem.SendPacket();
|
||
|
||
LogModule.DebugLog("send use item:" + item.Guid);
|
||
}
|
||
}
|
||
|
||
public void BulkUseItem(GameItem item, int count)
|
||
{
|
||
//使用前判断是否物品限制
|
||
if (!GameManager.gameManager.PlayerDataPool.ItemLimitInfo.CanUseItem(item.DataID))
|
||
return;
|
||
|
||
//特殊使用的物品
|
||
if (IsSpecialItem(item))
|
||
return;
|
||
|
||
if (false == item.IsMountItem())
|
||
{
|
||
var useitem = (CG_USE_ITEM) PacketDistributed.CreatePacket(MessageID.PACKET_CG_USE_ITEM);
|
||
useitem.SetItemguid(item.Guid);
|
||
useitem.SetUsecount(count);
|
||
useitem.SendPacket();
|
||
}
|
||
}
|
||
|
||
//自动寻路
|
||
public void AutoSearchCallMonster(int sceneID, Vector3 pos, GameItem gameItem)
|
||
{
|
||
BreakAutoCombatState();
|
||
// 自动寻路
|
||
var point = new AutoSearchPoint(sceneID, pos.x, pos.z);
|
||
if (GameManager.gameManager && GameManager.gameManager.AutoSearch)
|
||
{
|
||
GameManager.gameManager.AutoSearch.BuildPath(point);
|
||
if (null != GameManager.gameManager.AutoSearch.Path)
|
||
{
|
||
GameManager.gameManager.AutoSearch.Path.autoSearchRadius = 2;
|
||
GameManager.gameManager.AutoSearch.Path.finishCallBack = AutoSearchCallMonsterCallBack;
|
||
GameManager.gameManager.AutoSearch.Path.callBackParam = gameItem;
|
||
}
|
||
}
|
||
}
|
||
|
||
private void AutoSearchCallMonsterCallBack(object param)
|
||
{
|
||
var gameItem = param as GameItem;
|
||
if (gameItem == null)
|
||
return;
|
||
|
||
//发协议
|
||
if (null != Singleton<ObjManager>.Instance.MainPlayer &&
|
||
Singleton<ObjManager>.Instance.MainPlayer.CheckUseItem(gameItem))
|
||
{
|
||
//var ask = (CG_MISSION_SUMMON)PacketDistributed.CreatePacket(MessageID.PACKET_CG_MISSION_SUMMON);
|
||
//Singleton<ObjManager>.Instance.MainPlayer.UseItem(gameItem);
|
||
//CG_USE_ITEM useitem = (CG_USE_ITEM)PacketDistributed.CreatePacket(MessageID.PACKET_CG_USE_ITEM);
|
||
//useitem.SetItemguid(gameItem.Guid);
|
||
//useitem.SendPacket();
|
||
}
|
||
}
|
||
|
||
|
||
public void OnUseSignItem(bool bSuccess, object param)
|
||
{
|
||
if (bSuccess == false)
|
||
return;
|
||
var item = (GameItem) param;
|
||
if (item == null)
|
||
return;
|
||
var table = new Hashtable();
|
||
table["item"] = item;
|
||
EventDispatcher.Instance.SendMessage(EventId.OpenUseItemWithDialogWnd, table);
|
||
}
|
||
|
||
//private void UseMountItem(GameItem item)
|
||
//{
|
||
// //int nMountID = item.GetMountId();
|
||
// //if (nMountID < 0 || nMountID >= GameManager.gameManager.PlayerDataPool.m_objMountParam.MountCollect.Length)
|
||
// //{
|
||
// // CG_USE_ITEM useitem = (CG_USE_ITEM)PacketDistributed.CreatePacket(MessageID.PACKET_CG_USE_ITEM);
|
||
// // useitem.SetItemguid(item.Guid);
|
||
// // useitem.SendPacket();
|
||
// // return;
|
||
// //}
|
||
|
||
// //if (0 == GameManager.gameManager.PlayerDataPool.m_objMountParam.MountCollect[nMountID])
|
||
// //{
|
||
// // CG_USE_ITEM useitem = (CG_USE_ITEM)PacketDistributed.CreatePacket(MessageID.PACKET_CG_USE_ITEM);
|
||
// // useitem.SetItemguid(item.Guid);
|
||
// // useitem.SendPacket();
|
||
// // return;
|
||
// //}
|
||
|
||
// //m_CurUseMountItemGuid = item.Guid;
|
||
// //string strTip = "";
|
||
// //if (GameManager.gameManager.PlayerDataPool.m_objMountParam.GetMoountLeftTime(nMountID) < 0)
|
||
// //{
|
||
// // //已经拥有永久坐骑
|
||
// // strTip = StrDictionary.GetClientDictionaryString("#{2969}", item.GetName());
|
||
// //}
|
||
// //else
|
||
// //{
|
||
// // if (item.IsTimeLimitItem())
|
||
// // {
|
||
// // float fItemLeftDays = (float)item.GetLeftTime() / (float)86400;
|
||
// // int nLeftDays = Mathf.RoundToInt(fItemLeftDays);
|
||
// // strTip = StrDictionary.GetClientDictionaryString("#{2967}", item.GetName(), nLeftDays);
|
||
// // }
|
||
// // else
|
||
// // {
|
||
// // strTip = StrDictionary.GetClientDictionaryString("#{2968}");
|
||
// // }
|
||
// //}
|
||
// //string strTitle = StrDictionary.GetClientDictionaryString("#{1000}");
|
||
// //MessageBoxLogic.OpenOKCancelBox(strTip, strTitle, OnUseMountItemOk, null);
|
||
//}
|
||
|
||
private void OnUseMountItemOk()
|
||
{
|
||
var useitem = (CG_USE_ITEM) PacketDistributed.CreatePacket(MessageID.PACKET_CG_USE_ITEM);
|
||
useitem.SetItemguid(m_CurUseMountItemGuid);
|
||
useitem.SendPacket();
|
||
m_CurUseMountItemGuid = GlobeVar.INVALID_GUID;
|
||
}
|
||
|
||
public bool CheckUseItem(GameItem item)
|
||
{
|
||
var canuse = TableManager.GetCommonItemByID(item.DataID).CanUse;
|
||
if (canuse == 1)
|
||
return true;
|
||
return false;
|
||
}
|
||
|
||
public void EquipItem(GameItem item)
|
||
{
|
||
var equipitem = (CG_EQUIP_ITEM) PacketDistributed.CreatePacket(MessageID.PACKET_CG_EQUIP_ITEM);
|
||
equipitem.SetEquipguid(item.Guid);
|
||
equipitem.SendPacket();
|
||
}
|
||
|
||
public bool CheckEquipItem(GameItem item)
|
||
{
|
||
return true;
|
||
}
|
||
|
||
public void UnEquipItem(GameItem item)
|
||
{
|
||
//背包是否还有空间
|
||
if (GameManager.gameManager.PlayerDataPool.BackPack.GetCanContainerSize() <= 0)
|
||
{
|
||
Singleton<ObjManager>.Instance.MainPlayer.SendNoticMsg(false, "#{2102}");
|
||
return;
|
||
}
|
||
|
||
var equipitem = (CG_UNEQUIP_ITEM) PacketDistributed.CreatePacket(MessageID.PACKET_CG_UNEQUIP_ITEM);
|
||
equipitem.SetEquipguid(item.Guid);
|
||
equipitem.SendPacket();
|
||
|
||
if (BackPackLogic.Instance() != null)
|
||
{
|
||
//BackPackLogic.Instance().TakeOffGuid = item.Guid;
|
||
}
|
||
|
||
if (RoleViewLogic.Instance() != null)
|
||
{
|
||
//RoleViewLogic.Instance().TakeOffGuid = item.Guid;
|
||
}
|
||
|
||
if (BackPackUiTag.Instance() != null) Invoke("RefreshBackPack", 1f);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 当背包在装备页时脱掉装备,背包更新
|
||
/// </summary>
|
||
public void RefreshBackPack()
|
||
{
|
||
if (BackPackUiTag.Instance() != null)
|
||
{
|
||
var pageCount = BackPackUiTag.Instance().pageCount;
|
||
if (pageCount == 1) BackPackUiTag.Instance().ShowPlayerEquip();
|
||
}
|
||
}
|
||
|
||
|
||
public bool CheckUnEquipItem(GameItem item)
|
||
{
|
||
return true;
|
||
}
|
||
|
||
public void ThrowItem(GameItem item)
|
||
{
|
||
var equipitem = (CG_THROW_ITEM) PacketDistributed.CreatePacket(MessageID.PACKET_CG_THROW_ITEM);
|
||
equipitem.SetItemguid(item.Guid);
|
||
equipitem.SendPacket();
|
||
}
|
||
|
||
public bool CheckThrowItem(GameItem item)
|
||
{
|
||
return true;
|
||
}
|
||
|
||
public void CangKuPutIn(GameItem item)
|
||
{
|
||
var pak = (CG_PUT_ITEM_STORAGEPACK) PacketDistributed.CreatePacket(MessageID
|
||
.PACKET_CG_PUT_ITEM_STORAGEPACK);
|
||
pak.SetGuid(item.Guid);
|
||
if (CangKuLogic.Instance() != null)
|
||
pak.SetPage(CangKuLogic.Instance().SelectedPage);
|
||
else
|
||
pak.SetPage(0);
|
||
pak.SendPacket();
|
||
}
|
||
|
||
public void CangKuTakeOut(GameItem item)
|
||
{
|
||
var pak = (CG_TAKE_ITEM_STORAGEPACK) PacketDistributed.CreatePacket(MessageID
|
||
.PACKET_CG_TAKE_ITEM_STORAGEPACK);
|
||
pak.SetGuid(item.Guid);
|
||
pak.SetPage(0);
|
||
pak.SendPacket();
|
||
}
|
||
|
||
public int GetTotalEquipCombatValue()
|
||
{
|
||
var totalCombatValue = 0;
|
||
var itempack = GameManager.gameManager.PlayerDataPool.EquipPack;
|
||
for (var index = 0; index < itempack.ContainerSize; index++)
|
||
{
|
||
var equip = itempack.GetItem(index);
|
||
if (equip != null && equip.IsValid())
|
||
{
|
||
//totalCombatValue += equip.GetCombatValue();
|
||
}
|
||
}
|
||
|
||
return totalCombatValue;
|
||
}
|
||
|
||
public int GetTotalGemCombatValue()
|
||
{
|
||
var totalCombatValue = 0;
|
||
|
||
return totalCombatValue;
|
||
}
|
||
|
||
public bool IsNameWithCombineServerSign()
|
||
{
|
||
if (!Singleton<ObjManager>.Instance.MainPlayer)
|
||
return false;
|
||
if (GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.RoleName.Contains("*"))
|
||
return true;
|
||
return false;
|
||
}
|
||
|
||
|
||
public void ReqMonthMultiple()
|
||
{
|
||
var msg = (CG_REQ_MONTHMULTIPLE) PacketDistributed.CreatePacket(MessageID.PACKET_CG_REQ_MONTHMULTIPLE);
|
||
msg.NoParam = 1;
|
||
msg.SendPacket();
|
||
|
||
//m_bNeedRequestMasterInfo = false;
|
||
StartCoroutine(ResetRequestMonthMultipleFlag());
|
||
}
|
||
|
||
private IEnumerator ResetRequestMonthMultipleFlag()
|
||
{
|
||
yield return new WaitForSeconds(c_MultipleRequestCoolDown);
|
||
|
||
m_bNeedRequestMonthMultiple = true;
|
||
}
|
||
|
||
#region 双人坐骑相关
|
||
|
||
public void MountUpdate()
|
||
{
|
||
if (IsMountClient())
|
||
{
|
||
var driverPlayer = Singleton<ObjManager>.Instance.FindOtherPlayerByGuid(_LinkID);
|
||
if (driverPlayer == null)
|
||
return;
|
||
SetPosition(new Vector2(driverPlayer.transform.position.x, driverPlayer.transform.position.z));
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 主角特殊移动模块
|
||
|
||
/// <summary>
|
||
/// 主角是否允许玩家输入移动指令
|
||
/// </summary>
|
||
/// <param name="showWarning"></param>
|
||
/// <returns></returns>
|
||
// 注:允许移动指令 同 可以移动是两个概念;如主角混乱时,可以移动,但是不接受移动指令
|
||
public bool IsCanAcceptMoveOrder(bool showWarning)
|
||
{
|
||
var result = IsCanOperate_Move(showWarning);
|
||
if (result && IsDisableControl())
|
||
result = false;
|
||
|
||
var playerObj = this as Obj_OtherPlayer;
|
||
if (playerObj != null && playerObj.IsMountClient())
|
||
{
|
||
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{1251}"));
|
||
result = false;
|
||
}
|
||
|
||
return result;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 主角向目标移动逻辑
|
||
/// </summary>
|
||
public bool MainPlayMoveToTarget(Obj_Character target, MoveToTargetCondition condition,
|
||
MoveSuccessAction moveOverAction = null, bool isMoveOrder = true, bool bIsAutoSearch = false)
|
||
{
|
||
var result = isMoveOrder ? IsCanAcceptMoveOrder(true) : IsCanOperate_Move(false);
|
||
if (result)
|
||
{
|
||
result = MovementState <= MoveState.MainPlayMove;
|
||
if (result)
|
||
{
|
||
TryCleanAutoSearch(bIsAutoSearch);
|
||
var playerMoveToTarget = MoveModule as MainPlayerMoveToTarget;
|
||
if (playerMoveToTarget != null)
|
||
playerMoveToTarget.SwitchTarget(target, condition, moveOverAction);
|
||
else
|
||
StartMoveModule(new MainPlayerMoveToTarget(this, null, target, condition, moveOverAction));
|
||
// 清空PendingSkill - 如果是PendingSkill流程,之后再加上PendingSkill记录
|
||
CleanPendingSkill();
|
||
LockJoyStick();
|
||
}
|
||
}
|
||
|
||
return result;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 主角向位置移动逻辑
|
||
/// </summary>
|
||
public bool MainPlayMoveToPos(Vector3 targetPos, float stopRange = 0f, MoveSuccessAction moveOverAction = null,
|
||
bool isMoveOrder = true, bool bIsAutoSearch = false)
|
||
{
|
||
var result = isMoveOrder ? IsCanAcceptMoveOrder(true) : IsCanOperate_Move(false);
|
||
|
||
if (result)
|
||
{
|
||
result = MovementState <= MoveState.MainPlayMove;
|
||
if (result)
|
||
{
|
||
if (MovementState == MoveState.Static)
|
||
if (FunctionExLogic.Instance() != null)
|
||
FunctionExLogic.Instance().ShowDetail(false);
|
||
|
||
TryCleanAutoSearch(bIsAutoSearch);
|
||
var mainPlayerMoveToPos = MoveModule as MainPlayerMoveToPos;
|
||
if (mainPlayerMoveToPos != null)
|
||
mainPlayerMoveToPos.SwitchTarget(targetPos, stopRange, moveOverAction);
|
||
else
|
||
StartMoveModule(new MainPlayerMoveToPos(this, null, targetPos, stopRange, moveOverAction));
|
||
// 清空PendingSkill - 如果是PendingSkill流程,之后再加上PendingSkill记录
|
||
CleanPendingSkill();
|
||
}
|
||
|
||
var mainPlayer = Singleton<ObjManager>.Instance.MainPlayer;
|
||
if (mainPlayer.NavAgent != null && mainPlayer.NavAgent.isActiveAndEnabled &&
|
||
mainPlayer.NavAgent.hasPath)
|
||
{
|
||
var distance = mainPlayer.NavAgent.path.GetTotalDistance();
|
||
if ( /*distance > 50f &&*/ distance >= 10f)
|
||
mainPlayer.AskRideMount(false);
|
||
}
|
||
}
|
||
|
||
return result;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 主角试图跳跃到某位置
|
||
/// </summary>
|
||
public void MainPlayerStartJumpWait(int jumpId)
|
||
{
|
||
var jumpModule = new MainPlayerJumpWait(this);
|
||
// 仅仅对处于MainPlayerMoveToPos进行缓存,其他类型移动不处理
|
||
Vector3? destination = null;
|
||
var stopRange = 0f;
|
||
var moveToPos = MoveModule as MainPlayerMoveToPos;
|
||
if (moveToPos != null)
|
||
{
|
||
destination = moveToPos.TargetPos;
|
||
stopRange = moveToPos.StopRange;
|
||
}
|
||
else
|
||
{
|
||
var ride = MoveModule as MainPlayerRide;
|
||
if (ride != null)
|
||
{
|
||
destination = ride.destination;
|
||
stopRange = ride.stopRange;
|
||
}
|
||
}
|
||
|
||
var jumpData = TableManager.GetJumpByID(jumpId);
|
||
// 如果当前目标点,距离超过当前位置一定距离,认为是远程寻路操作,记录传送后目标位置
|
||
if (destination != null &&
|
||
(destination.Value - Position).RemoveY().sqrMagnitude > jumpData.RangeRadius.ToSquare())
|
||
{
|
||
jumpModule.LastDestination = destination;
|
||
jumpModule.LastStopRange = stopRange;
|
||
}
|
||
|
||
//AskUnMount(false, true);
|
||
StartMoveModule(jumpModule);
|
||
SendJumpToServer(jumpId);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 主角特殊跳跃功能
|
||
/// </summary>
|
||
public override void EndJumpWait(int jumpId)
|
||
{
|
||
// 注:当前处理方式为,如果跳跃中,有任意一段速度小于0,则使用传送逻辑,否则使用跳跃逻辑
|
||
var jumpData = CommonUtility.TryGetTable(jumpId, a => TableManager.GetJumpByID(a));
|
||
if (jumpData != null)
|
||
{
|
||
var jumpModule = MoveModule as MainPlayerJumpWait;
|
||
// 启动跳跃模组
|
||
if (jumpData.Duration > 0f)
|
||
{
|
||
#if UNITY_EDITOR
|
||
if (debugMove)
|
||
LogModule.WarningLog("Jump To Jump Point: " + jumpData.JumpId);
|
||
#endif
|
||
Vector3? lastDestination = null;
|
||
var stopRange = 0f;
|
||
if (jumpModule != null)
|
||
{
|
||
lastDestination = jumpModule.LastDestination;
|
||
stopRange = jumpModule.LastStopRange;
|
||
StopMove(MoveState.JumpDelay);
|
||
}
|
||
|
||
// // 强制取消骑乘
|
||
// // 暂时处理方式是自行取消当前骑乘状态,不等待服务器回复
|
||
// UnMount();
|
||
// AskUnMount(false, true);
|
||
MainPlayerLeap(jumpData.JumpId, lastDestination, stopRange);
|
||
UpdatePositionForLeap(jumpData);
|
||
}
|
||
// 传送到最后目标位置
|
||
else
|
||
{
|
||
#if UNITY_EDITOR
|
||
if (debugMove)
|
||
LogModule.WarningLog("Teleport To Jump Point: " + jumpData.JumpId);
|
||
#endif
|
||
var finalPoint = jumpData.GetFinialJumpData();
|
||
if (jumpModule != null)
|
||
{
|
||
var lastDestination = jumpModule.LastDestination;
|
||
var lastStopRange = jumpModule.LastStopRange;
|
||
MainPlayerFixPos(new Vector2(finalPoint.EndPosX, finalPoint.EndPosZ));
|
||
if (lastDestination != null)
|
||
MainPlayMoveToPos(lastDestination.Value,
|
||
lastStopRange,
|
||
bIsAutoSearch: GameManager.gameManager.AutoSearch.IsAutoSearching);
|
||
}
|
||
else
|
||
{
|
||
MainPlayerFixPos(new Vector2(finalPoint.EndPosX, finalPoint.EndPosZ));
|
||
}
|
||
}
|
||
}
|
||
else if (MovementState == MoveState.JumpDelay)
|
||
{
|
||
StopMove(MoveState.JumpDelay);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 主角特殊位置校正接口
|
||
/// </summary>
|
||
public void MainPlayerFixPos(Vector2 position)
|
||
{
|
||
// 特殊处理主角的位置补正,防止位置补正打断主角移动
|
||
if (IsFollowTeam || MovementState != MoveState.MainPlayMove || !IsCanOperate_Move(false))
|
||
{
|
||
SyncSetPos(position);
|
||
}
|
||
else
|
||
{
|
||
// 重置寻路机位置并继续当前移动
|
||
var hasPath = NavAgent != null && NavAgent.isActiveAndEnabled && NavAgent.hasPath;
|
||
if (hasPath)
|
||
{
|
||
ServerPos = ActiveScene.GetTerrainPosition(position.InsertY(Position.y));
|
||
#if UNITY_EDITOR
|
||
if (debugMove)
|
||
LogModule.ErrorLog("Sync Set Position: " + position.ToPreciseString() + " - " +
|
||
ServerPos.ToPreciseString() + " - " +
|
||
Vector3.Distance(ServerPos, Position));
|
||
#endif
|
||
var destination = NavAgent.destination;
|
||
NavAgent.Warp(ServerPos);
|
||
NavAgent.SetDestination(destination);
|
||
_nextSyncPosTime = 0f;
|
||
}
|
||
else
|
||
{
|
||
SyncSetPos(position);
|
||
}
|
||
}
|
||
}
|
||
|
||
private void TryCleanAutoSearch(bool bIsAutoSearch)
|
||
{
|
||
if (bIsAutoSearch)
|
||
BreakAutoCombatState();
|
||
else if (GameManager.gameManager.AutoSearch != null)
|
||
GameManager.gameManager.AutoSearch.Stop();
|
||
}
|
||
|
||
#region 主角位置上传机制
|
||
|
||
/// <summary>
|
||
/// 同步间隔时间
|
||
/// </summary>
|
||
public const float posSyncInterval = 0.2f;
|
||
|
||
/// <summary>
|
||
/// 角色预测移动的时间
|
||
/// </summary>
|
||
public const float posPredictTime = 0.3f;
|
||
|
||
/// <summary>
|
||
/// 下一次同步位置的时间
|
||
/// </summary>
|
||
private float _nextSyncPosTime;
|
||
|
||
// ******** 寻路机状态 ********
|
||
// 强制上传角度容错值,角色速度改变超过这个数值,就立即上传
|
||
private const float _forceSyncAngleThreshold = 360f / 16f;
|
||
|
||
// 角色上次同步所在位置 - 寻路机会先执行一次位移再有速度,使用速度判断时,防止丢掉第一个Delta;
|
||
private Vector3 _lastPosition;
|
||
|
||
// 上一次上传时,寻路机速度
|
||
private Vector3 _lastSyncVelocity;
|
||
|
||
// 上一帧寻路机是否存在路径
|
||
private bool _lastNavHasPath;
|
||
|
||
// 上一帧寻路机是否已经停止(连续两帧不存在路径)
|
||
private bool _lastNavStop;
|
||
|
||
//// 上一帧NavMeshAgent是否处于停止状态 - 注:由于NavMeshAgent诡异的设计,停止状态和移动状态不互斥
|
||
//private bool _lastNavStop;
|
||
|
||
// ******** End ********
|
||
private void ResetNavAgentState()
|
||
{
|
||
_lastSyncVelocity = Vector3.zero;
|
||
_lastNavHasPath = false;
|
||
_lastNavStop = true;
|
||
}
|
||
|
||
private void SyncCurrentNavAgentState()
|
||
{
|
||
// 注:Unity的NavMeshAgent行为非常诡异:
|
||
// 启动时,当前帧无路径,第二帧有路径但无位移,第三帧有速度有位移
|
||
// 停止时,当前帧无路径,第二帧继续移动
|
||
// 所以同步策略为,路径出现后,跳一帧开始同步Move;路径消失后,跳一帧开始同步Stop
|
||
// 路径存在时,角色正常拥有速度,且速度和上一帧超过一定度数,额外发送一个预测包
|
||
var hasPath = NavAgent.path.corners.Length > 1;
|
||
var currentMove = hasPath;
|
||
var currentStop = !hasPath && !_lastNavHasPath;
|
||
#if UNITY_EDITOR
|
||
if (debugMove)
|
||
LogModule.DebugLog("Current Position: " + Position.ToPreciseString() + "Has Path: " + hasPath +
|
||
" Velocity: " +
|
||
NavAgent.velocity + " Stop: " + currentStop + " - " + Time.frameCount);
|
||
#endif
|
||
// Stop包也是要等一帧,是一样的逻辑
|
||
if (currentMove)
|
||
if (!_lastNavHasPath)
|
||
{
|
||
SendMoveToServer();
|
||
}
|
||
else
|
||
{
|
||
if (Time.unscaledTime > _nextSyncPosTime)
|
||
{
|
||
SendMoveToServer();
|
||
}
|
||
else
|
||
{
|
||
// 已经有速度
|
||
if (NavAgent.velocity.magnitude >= navAgentMinSpeedSqr)
|
||
if (_lastSyncVelocity.magnitude < navAgentMinSpeedSqr)
|
||
_lastSyncVelocity = NavAgent.velocity;
|
||
// 上次启动或者同步速度和现在有差距
|
||
else if (Vector3.Angle(NavAgent.velocity, _lastSyncVelocity) > _forceSyncAngleThreshold)
|
||
SendMoveToServer();
|
||
}
|
||
}
|
||
|
||
// 注:_lastNavStop可以被技能包停止角色置为true。
|
||
// 使用技能导致角色停止,会跳过Stop协议发包
|
||
if (currentStop && !_lastNavStop)
|
||
SendStopToServer();
|
||
_lastNavHasPath = hasPath;
|
||
_lastNavStop = currentStop;
|
||
}
|
||
|
||
// 注:发送跳跃包
|
||
private void SendJumpToServer(int leapId)
|
||
{
|
||
_lastSyncVelocity = Vector3.zero;
|
||
#if UNITY_EDITOR
|
||
if (debugMove)
|
||
LogModule.WarningLog(string.Format("Jump Packet at {0} to point {1} on {2}", Position.ToPreciseString(),
|
||
leapId, Time.frameCount));
|
||
#endif
|
||
var jumpProtocol = (CG_JUMP) PacketDistributed.CreatePacket(MessageID.PACKET_CG_JUMP);
|
||
jumpProtocol.SetTargetguid(GUID);
|
||
jumpProtocol.SetJumpid(leapId);
|
||
jumpProtocol.SetTag(0);
|
||
jumpProtocol.SendPacket();
|
||
}
|
||
|
||
// 注:Stop是当前帧的位置
|
||
private void SendStopToServer()
|
||
{
|
||
_lastSyncVelocity = Vector3.zero;
|
||
#if UNITY_EDITOR
|
||
if (debugMove)
|
||
LogModule.WarningLog(
|
||
string.Format("Stop Packet at {0} on {1}", Position.ToPreciseString(), Time.frameCount));
|
||
#endif
|
||
var stopProtocol = (CG_STOP) PacketDistributed.CreatePacket(MessageID.PACKET_CG_STOP);
|
||
stopProtocol.SetPosx(Position.x.ToServerPos());
|
||
stopProtocol.SetPosy(Position.y.ToServerPos());
|
||
stopProtocol.SetPosz(Position.z.ToServerPos());
|
||
stopProtocol.SetFacddir(CommonUtility.DirToServerRadian(ObjTransform.forward.RemoveY()));
|
||
stopProtocol.SendPacket();
|
||
}
|
||
|
||
// 注:Move是上一帧位置开始
|
||
private void SendMoveToServer()
|
||
{
|
||
_nextSyncPosTime = Time.unscaledTime + posSyncInterval;
|
||
var moveDelta = NavAgent.speed * posPredictTime;
|
||
var predictPoint = NavAgent.path.GetPointOnPath(Position, moveDelta);
|
||
var moveProtocol = (CG_MOVE) PacketDistributed.CreatePacket(MessageID.PACKET_CG_MOVE);
|
||
_lastSyncVelocity = (NavAgent.path.corners[1] - NavAgent.path.corners[0]).normalized * NavAgent.speed;
|
||
moveProtocol.SetCurms(Mathf.FloorToInt(Time.unscaledTime * 1000f));
|
||
moveProtocol.SetCurposx(Position.x.ToServerPos());
|
||
moveProtocol.SetCurposy(Position.y.ToServerPos());
|
||
moveProtocol.SetCurposz(Position.z.ToServerPos());
|
||
moveProtocol.SetDesposx(predictPoint.x.ToServerPos());
|
||
moveProtocol.SetDesposy(predictPoint.y.ToServerPos());
|
||
moveProtocol.SetDesposz(predictPoint.z.ToServerPos());
|
||
moveProtocol.SendPacket();
|
||
#if UNITY_EDITOR
|
||
if (debugMove)
|
||
LogModule.WarningLog(string.Format("Move Packet from {0} to {1}, delta {2} at {3}",
|
||
Position.ToPreciseString(), predictPoint.ToPreciseString(),
|
||
Vector3.Distance(predictPoint, Position), CommonUtility.GetCurrentUnityTimeString()));
|
||
#endif
|
||
}
|
||
|
||
#endregion
|
||
|
||
// 默认摇杆锁定时间
|
||
private const float _defaultJoyStickLockDuration = 0.5f;
|
||
|
||
// 用于监听主角是否处于移动状态的标志位
|
||
private bool _isLastFrameMoving;
|
||
|
||
// 摇杆可以使用时间
|
||
private float _joyStickUnlockTime;
|
||
|
||
private void LockJoyStick(float lockDuration = _defaultJoyStickLockDuration)
|
||
{
|
||
_joyStickUnlockTime = Time.unscaledTime + lockDuration;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 主角受到服务器控制而不是客户端
|
||
/// </summary>
|
||
public bool IsDisableControl()
|
||
{
|
||
return IsFollowTeam || IsHaveChaosBuff();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 主角是否正在执行对位置移动
|
||
/// </summary>
|
||
public bool IsMoveToPos()
|
||
{
|
||
return MoveModule is MainPlayerMoveToPos;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 场景中新创建一个带有NavObstacle的物体时
|
||
/// </summary>
|
||
private void OnNavObstacleCreate(object args)
|
||
{
|
||
// 高级移动会在移动结束后执行落地检测或者其他情况执行
|
||
const MoveState maxState = MoveState.MainPlayMove;
|
||
if (MovementState <= maxState && NavAgent != null)
|
||
{
|
||
var navMeshObstacle = (NavMeshObstacle) args;
|
||
var localPos = navMeshObstacle.transform.worldToLocalMatrix.MultiplyPoint3x4(Position);
|
||
// 试图将寻路机半径转换到障碍本地坐标系
|
||
var radiusPos =
|
||
navMeshObstacle.transform.worldToLocalMatrix.MultiplyPoint3x4(
|
||
Position + NavAgent.radius * Vector3.forward);
|
||
var radius = (localPos - radiusPos).magnitude;
|
||
// 如果主角寻路机碰撞障碍物
|
||
bool hit;
|
||
// 无效赋值,仅仅用于编译通过
|
||
var safePos = Vector3.zero;
|
||
switch (navMeshObstacle.shape)
|
||
{
|
||
case NavMeshObstacleShape.Box:
|
||
{
|
||
var v = (localPos - navMeshObstacle.center).RemoveY();
|
||
v.x = Mathf.Abs(v.x);
|
||
v.y = Mathf.Abs(v.y);
|
||
var u = v - navMeshObstacle.size.RemoveY() * 0.5f;
|
||
u.x = Mathf.Max(0f, u.x);
|
||
u.y = Mathf.Max(0f, u.y);
|
||
hit = radius * radius > u.sqrMagnitude;
|
||
// 如果碰撞,则进行简单的aabb对aabb推移
|
||
if (hit)
|
||
{
|
||
v = (localPos - navMeshObstacle.center).RemoveY();
|
||
v.x = v.x > 0
|
||
? Mathf.Max(navMeshObstacle.size.x * 0.5f, v.x)
|
||
: Mathf.Min(-navMeshObstacle.size.x * 0.5f, v.x);
|
||
v.y = v.y > 0
|
||
? Mathf.Max(navMeshObstacle.size.y * 0.5f, v.y)
|
||
: Mathf.Min(-navMeshObstacle.size.y * 0.5f, v.y);
|
||
safePos = v.InsertY();
|
||
}
|
||
}
|
||
break;
|
||
case NavMeshObstacleShape.Capsule:
|
||
{
|
||
var v = (localPos - navMeshObstacle.center).RemoveY();
|
||
var totalRadius = radius + navMeshObstacle.radius;
|
||
hit = totalRadius * totalRadius > v.sqrMagnitude;
|
||
// 如果碰撞,执行圆对圆推移
|
||
if (hit)
|
||
if (v == Vector2.zero)
|
||
{
|
||
safePos = navMeshObstacle.center + Vector3.forward * navMeshObstacle.radius;
|
||
}
|
||
else
|
||
{
|
||
v = v.normalized;
|
||
v = v.normalized * totalRadius;
|
||
safePos = navMeshObstacle.center + v.InsertY();
|
||
}
|
||
}
|
||
break;
|
||
default:
|
||
throw new ArgumentOutOfRangeException();
|
||
}
|
||
|
||
if (hit)
|
||
{
|
||
var source = Position;
|
||
// 注:不能调用StopMove,函数可能从某个MoveModule的EndMove调用
|
||
safePos = navMeshObstacle.transform.localToWorldMatrix.MultiplyPoint3x4(safePos);
|
||
SetPosition(safePos.RemoveY());
|
||
StopMove();
|
||
SendNavPosFix(source, Position);
|
||
}
|
||
}
|
||
}
|
||
|
||
protected override void SendNavPosFix(Vector3 originalPos, Vector3 fixedPos)
|
||
{
|
||
base.SendNavPosFix(originalPos, fixedPos);
|
||
var packet =
|
||
(CG_REQ_CORRECT_POSITION) PacketDistributed.CreatePacket(MessageID.PACKET_CG_REQ_CORRECT_POSITION);
|
||
packet.SetPosx(Mathf.FloorToInt(fixedPos.x.ToServerPos()));
|
||
packet.SetPosy(Mathf.FloorToInt(fixedPos.y.ToServerPos()));
|
||
packet.SetPosz(Mathf.FloorToInt(fixedPos.z.ToServerPos()));
|
||
packet.SendPacket();
|
||
}
|
||
|
||
protected override void UpdateMove()
|
||
{
|
||
var followState = FollowState;
|
||
// 试图校正输入状态,仅仅在不跟随时有效
|
||
if (followState != TeamFollowState.notFollow)
|
||
{
|
||
// 如果玩家试图在组队跟随中启用移动,就报错并重置输入状态
|
||
if (ProcessInput.Instance != null && ProcessInput.Instance.FrameType == ControlFrameType.ControlStart)
|
||
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{5128}"));
|
||
}
|
||
else
|
||
{
|
||
// ****** 检测主角输入状态 ********
|
||
if (!IsDie() && MovementState <= MoveState.MainPlayMove && ProcessInput.Instance != null)
|
||
if (!IsDisableControl() ||
|
||
IsCanAcceptMoveOrder(ProcessInput.Instance.FrameType == ControlFrameType.ControlStart))
|
||
switch (ProcessInput.Instance.FrameType)
|
||
{
|
||
case ControlFrameType.JoyStickEnd:
|
||
StopMove();
|
||
break;
|
||
case ControlFrameType.ControlStart:
|
||
case ControlFrameType.Controlling:
|
||
if (_joyStickUnlockTime < Time.unscaledTime ||
|
||
ProcessInput.Instance.FrameType == ControlFrameType.ControlStart)
|
||
{
|
||
// 如果是用ControlStart冲破锁定,则解除锁定状态
|
||
_joyStickUnlockTime = 0f;
|
||
if (ProcessInput.Instance.UpdatePos)
|
||
MainPlayMoveToPos(ProcessInput.Instance.MovePoint);
|
||
// 移动开始指令冲破自动战斗和一条龙控制
|
||
BreakAutoCombatState();
|
||
if (OneDragonAuto.One_DragonAuto != null)
|
||
OneDragonAuto.One_DragonAuto.NeedCheckOneDragonEnterCopy = false;
|
||
}
|
||
|
||
if (null != GameManager.gameManager.ActiveScene)
|
||
// 移动圈创建:处于Touch输入状态,并且角色在移动;
|
||
if (ProcessInput.Instance.InputType == ControlInputType.Touch)
|
||
if (MovementState == MoveState.MainPlayMove)
|
||
GameManager.gameManager.ActiveScene.ActiveMovingCircle(ProcessInput.Instance
|
||
.MovePoint);
|
||
break;
|
||
}
|
||
else
|
||
ProcessInput.Instance.ReleaseInput();
|
||
|
||
// 移动圈移除条件0:主角不处于移动状态;
|
||
// 移动圈移除条件1:不处于Touch输入状态,也不处于None;
|
||
if ((MovementState != MoveState.MainPlayMove || ProcessInput.Instance == null ||
|
||
ProcessInput.Instance.InputType != ControlInputType.None &&
|
||
ProcessInput.Instance.InputType != ControlInputType.Touch) &&
|
||
GameManager.gameManager.ActiveScene != null)
|
||
GameManager.gameManager.ActiveScene.DeactiveMovingCircle();
|
||
}
|
||
|
||
// ****** 检测主角移动状态 ********
|
||
// 特殊处理组队跟随 - 组队跟随移动时,主角回退为OtherPlayer
|
||
if (followState == TeamFollowState.followMove)
|
||
{
|
||
base.UpdateMove();
|
||
ResetNavAgentState();
|
||
}
|
||
else
|
||
{
|
||
// ****** 主角特殊的移动模组检查机制 ******
|
||
// 主角不自动补正位置
|
||
if (MoveModule != null)
|
||
if (!MoveModule.UpdateMove())
|
||
{
|
||
var moveWithAction = MoveModule as IMainPlayerMoveWithAction;
|
||
MoveModule.EndMove();
|
||
MoveModule = null;
|
||
if (moveWithAction != null)
|
||
moveWithAction.InvokeMoveFinish();
|
||
}
|
||
|
||
// ****** End ******
|
||
//UpdateJumpState();
|
||
// ****** 主角移动状态判断区域 ******
|
||
// 注:暂时逻辑不认为组队跟随为主角移动,如果需要的话再修改
|
||
var isMoving = MovementState == MoveState.MainPlayMove;
|
||
if (isMoving != _isLastFrameMoving)
|
||
{
|
||
_isLastFrameMoving = isMoving;
|
||
if (isMoving)
|
||
{
|
||
// 打断Predict技能
|
||
//打断 移动可以打断的技能
|
||
if (IsPredictSkill && PredictSkillBase.IsMoveBreak == 1)
|
||
RemovePredictByBaseId();
|
||
// 播放主角脚步声
|
||
stepId = GetCurrentStepId();
|
||
}
|
||
else
|
||
{
|
||
// 移动结束移除PendingSkill
|
||
CleanPendingSkill();
|
||
//移动圈消失
|
||
if (null != GameManager.gameManager.ActiveScene)
|
||
GameManager.gameManager.ActiveScene.DeactiveMovingCircle();
|
||
// 如果是正常停止,则发送CG_STOP协议到服务器;被其他类型移动模组覆盖,则立刻运动
|
||
//if (MoveModule == null)
|
||
// SendStopToServer();
|
||
// 关闭主角脚步声
|
||
stepId = GlobeVar.INVALID_ID;
|
||
}
|
||
}
|
||
|
||
//if (isMoving)
|
||
// SendMoveToServer();
|
||
// 注:寻路机帧会比实际Update和LateUpdate晚,因此必须在下一帧才能获得正常的寻路机状态;
|
||
// 直接追踪寻路机状态来执行同步 - 如果寻路机处于移动中,方向改变或者超过同步周期则进行一次同步;转换到停止状态就同步一次Stop;
|
||
// 无视角色状态等情况,一切仅与NavAgent相关;跳过切换到TeleMove和LightState等特殊状态的Stop指令;
|
||
if (Time.unscaledTime > startGhost && NavAgent != null && NavAgent.isActiveAndEnabled)
|
||
SyncCurrentNavAgentState();
|
||
else
|
||
ResetNavAgentState();
|
||
// 保存当前ServerPos,防止切换到组队跟随或者混乱时,无法获得当前位置
|
||
if (MovementState <= MoveState.MainPlayMove)
|
||
ServerPos = Position;
|
||
|
||
CharacterMoveAnim();
|
||
// 检查是否由OffmeshLink执行传送
|
||
if (MoveModule != null && MoveModule.MoveState == MoveState.MainPlayMove &&
|
||
NavAgent != null && NavAgent.isActiveAndEnabled && NavAgent.isOnOffMeshLink)
|
||
{
|
||
var jumpPoint = NavAgent.currentOffMeshLinkData.offMeshLink.GetComponent<Obj_JumpPoint>();
|
||
if (jumpPoint != null)
|
||
{
|
||
jumpPoint.LockDistanceCheck();
|
||
MainPlayerStartJumpWait(jumpPoint.GetJumpId());
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
protected override bool IsMotionRunning()
|
||
{
|
||
if (IsDisableControl())
|
||
return base.IsMotionRunning();
|
||
return IsCanOperate_Move(false) && ProcessInput.Instance != null &&
|
||
(ProcessInput.Instance.InputType == ControlInputType.Axis ||
|
||
ProcessInput.Instance.InputType == ControlInputType.JoyStick)
|
||
|| base.IsMotionRunning();
|
||
}
|
||
|
||
private int GetCurrentStepId()
|
||
{
|
||
return mountData == null ? _footStepAudioId : mountData.SoundID;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 使用这个Property来管理当前使用中的脚步Id
|
||
/// </summary>
|
||
public int stepId
|
||
{
|
||
get { return _stepId; }
|
||
set
|
||
{
|
||
if (_stepId != value)
|
||
{
|
||
var previous = _stepId;
|
||
_stepId = value;
|
||
if (previous > GlobeVar.INVALID_ID)
|
||
GameManager.gameManager.SoundManager.StopSoundEffect(previous, GetInstanceID());
|
||
if (_stepId > GlobeVar.INVALID_ID)
|
||
GameManager.gameManager.SoundManager.PlaySoundEffect(previous, GetInstanceID());
|
||
}
|
||
}
|
||
}
|
||
|
||
private int _stepId = GlobeVar.INVALID_ID;
|
||
|
||
protected override void OnMountCreate(ObjPartRoot mountObj, object dataTable)
|
||
{
|
||
base.OnMountCreate(mountObj, dataTable);
|
||
if (MovementState == MoveState.Move)
|
||
stepId = GetCurrentStepId();
|
||
EnterMoveFreeze();
|
||
if (SceneLogic.CameraController != null)
|
||
SceneLogic.CameraController.ModifyFocusOffset(mount_DeltaHeigh * Vector3.up);
|
||
}
|
||
|
||
protected override void OnMountDestroy(ObjPartRoot mountObj)
|
||
{
|
||
base.OnMountDestroy(mountObj);
|
||
if (SceneLogic.CameraController != null)
|
||
SceneLogic.CameraController.ModifyFocusOffset(Vector3.zero);
|
||
}
|
||
|
||
protected override void RemoveMount()
|
||
{
|
||
base.RemoveMount();
|
||
if (MovementState == MoveState.Move)
|
||
stepId = GetCurrentStepId();
|
||
EnterMoveFreeze();
|
||
if (UnMountEventCallBack != null)
|
||
{
|
||
Singleton<EventSystem>.GetInstance().PushEvent(UnMountEventCallBack);
|
||
UnMountEventCallBack = null; //执行一遍回调之后需要清空
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 角色上马和下马时,禁止移动一段时间
|
||
/// </summary>
|
||
// 注:现实际被用于角色传送预测等一系列需要短时间禁止移动的操作
|
||
public void EnterMoveFreeze(float? time = null)
|
||
{
|
||
var ride = MoveModule as MainPlayerRide;
|
||
if (ride != null)
|
||
{
|
||
ride.ResetDelay(time);
|
||
}
|
||
else if (MovementState < MoveState.Freeze)
|
||
{
|
||
ride = new MainPlayerRide(this);
|
||
ride.ResetDelay(time);
|
||
var moveToPos = MoveModule as MainPlayerMoveToPos;
|
||
if (moveToPos != null)
|
||
{
|
||
ride.destination = moveToPos.TargetPos;
|
||
ride.stopRange = moveToPos.StopRange;
|
||
}
|
||
|
||
StartMoveModule(ride);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 主角移动结束后,试图点击目标角色
|
||
/// </summary>
|
||
public class MoveSuccessToClickCharacter : MoveSuccessAction
|
||
{
|
||
public readonly Obj_Character character;
|
||
public readonly Obj_MainPlayer mainPlayer;
|
||
|
||
public MoveSuccessToClickCharacter(Obj_MainPlayer mainPlayer, Obj_Character character)
|
||
{
|
||
this.mainPlayer = mainPlayer;
|
||
this.character = character;
|
||
}
|
||
|
||
public override void InvokeAction()
|
||
{
|
||
if (mainPlayer != null && character != null)
|
||
mainPlayer.InteractWithCharacter(character);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 主角移动结束后,试图对目标角色使用特定技能
|
||
/// </summary>
|
||
public class MoveSuccessToUseSkill : MoveSuccessAction
|
||
{
|
||
public readonly Tab_SkillBase firstSkillBase;
|
||
public readonly Obj_MainPlayer mainPlayer;
|
||
|
||
public MoveSuccessToUseSkill(Obj_MainPlayer mainPlayer, OwnSkillData ownSkill)
|
||
{
|
||
this.mainPlayer = mainPlayer;
|
||
firstSkillBase = ownSkill.SkillBaseTable;
|
||
}
|
||
|
||
public override void InvokeAction()
|
||
{
|
||
if (mainPlayer != null)
|
||
{
|
||
mainPlayer.CleanPendingSkill();
|
||
// 特殊处理普攻类型
|
||
if (firstSkillBase.SkillClass.ContainFlag((int) SKILLCLASS.SIMPLEATTACK))
|
||
{
|
||
mainPlayer.TryStartSimpleAttack();
|
||
}
|
||
else
|
||
{
|
||
var ownSkill = mainPlayer.OwnSkillInfo.Find(a => a.SkillBaseTable == firstSkillBase);
|
||
if (ownSkill != null)
|
||
mainPlayer.TryStartTargetSkill(ownSkill);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 向目标移动,直到接近到距离
|
||
/// </summary>
|
||
public class MoveToTargetTillDistance : MoveToTargetCondition
|
||
{
|
||
private readonly float _distanceSqr;
|
||
|
||
public MoveToTargetTillDistance(float distance)
|
||
{
|
||
_distanceSqr = distance.ToSquare();
|
||
}
|
||
|
||
public override MoveToTargetState GetMoveState(Obj_Character mainPlayer, Obj_Character target)
|
||
{
|
||
if (target.IsDie() && target.ObjType != GameDefine_Globe.OBJ_TYPE.OBJ_OTHER_PLAYER)
|
||
return MoveToTargetState.Failure;
|
||
if ((target.Position - mainPlayer.Position).RemoveY().sqrMagnitude < _distanceSqr)
|
||
return MoveToTargetState.Success;
|
||
// 校正目标位置
|
||
return MoveToTargetState.Keep;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 向目标移动,直到可以发起技能
|
||
/// </summary>
|
||
public class MoveToTargetTillSkill : MoveToTargetCondition
|
||
{
|
||
// 可连段技能记录第一段id作为唯一识别标记
|
||
private readonly Tab_SkillBase _firstSkillBase;
|
||
|
||
private readonly Tab_SkillBase _skillBase;
|
||
private readonly Tab_SkillEx _skillEx;
|
||
|
||
public MoveToTargetTillSkill(OwnSkillData ownSkill)
|
||
{
|
||
_firstSkillBase = ownSkill.SkillBaseTable;
|
||
_skillEx = ownSkill.ComboExTable;
|
||
_skillBase = ownSkill.ComboBaseTable;
|
||
}
|
||
|
||
public override MoveToTargetState GetMoveState(Obj_Character character, Obj_Character target)
|
||
{
|
||
var result = MoveToTargetState.Failure;
|
||
var mainPlayer = character as Obj_MainPlayer;
|
||
if (mainPlayer != null)
|
||
{
|
||
// 如果技能降段,或者其他情况不再存在,则取消技能使用
|
||
var ownSkill = mainPlayer.OwnSkillInfo.Find(a => a.SkillBaseTable == _firstSkillBase);
|
||
if (ownSkill != null)
|
||
{
|
||
ownSkill.UpdateCombo();
|
||
if (ownSkill.ComboExTable == _skillEx &&
|
||
ValidTargetTypeBySkillBase(target, ownSkill.ComboBaseTable.PriorityTarget))
|
||
result = mainPlayer.ValidSkillRangeForNonDash(ownSkill.ComboExTableFinal,
|
||
ownSkill.ComboBaseTable, target,
|
||
skillCastOverwalk)
|
||
? MoveToTargetState.Success
|
||
: MoveToTargetState.Keep;
|
||
}
|
||
}
|
||
|
||
return result;
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 主角移动模块
|
||
|
||
public interface IMainPlayerMoveWithAction
|
||
{
|
||
void InvokeMoveFinish();
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 主角专用的移动模块基类
|
||
/// </summary>
|
||
public abstract class MainPlayerMoveBase : ObjCommonMoveBase, IMainPlayerMoveWithAction
|
||
{
|
||
private MoveSuccessAction _onMoveFinish;
|
||
protected bool moveSuccess;
|
||
|
||
protected MainPlayerMoveBase(Obj_Character character, Quaternion? rotation, float stopRange,
|
||
MoveSuccessAction onMoveFinish) : base(character, rotation)
|
||
{
|
||
SetParameters(stopRange, onMoveFinish);
|
||
}
|
||
|
||
public override bool useRunMotion
|
||
{
|
||
get { return true; }
|
||
}
|
||
|
||
public float StopRange { get; private set; }
|
||
|
||
public override MoveState MoveState
|
||
{
|
||
get { return MoveState.MainPlayMove; }
|
||
}
|
||
|
||
public void InvokeMoveFinish()
|
||
{
|
||
if (moveSuccess && _onMoveFinish != null)
|
||
_onMoveFinish.InvokeAction();
|
||
}
|
||
|
||
public override void ResetMove()
|
||
{
|
||
BeforeMove();
|
||
if (rotation != null)
|
||
character.Rotation = rotation.Value;
|
||
character.EnableMovingRotation(rotation == null);
|
||
character.NavAgent.speed = character.MoveSpeed;
|
||
}
|
||
|
||
protected void SetParameters(float stopRange, MoveSuccessAction onMoveFinish)
|
||
{
|
||
StopRange = Mathf.Max(stopRange, minStopDistance);
|
||
_onMoveFinish = onMoveFinish;
|
||
}
|
||
|
||
// 特殊接口,保证主角移动路径可以立刻被计算,而不是等到帧末
|
||
protected Vector3 MoveToPosition(Vector3 position)
|
||
{
|
||
var path = character.NavAgent.path;
|
||
if (character.NavAgent.CalculatePath(position, path)
|
||
&& character.NavAgent.SetPath(path)
|
||
&& path.corners.Length > 0)
|
||
//character.NavAgent.SetPath(path);
|
||
position = path.corners[path.corners.Length - 1];
|
||
else
|
||
position = character.Position;
|
||
|
||
return position;
|
||
//var path = character.NavAgent.path;
|
||
//if (character.NavAgent.CalculatePath(position, path))
|
||
// character.NavAgent.SetPath(path);
|
||
//if (!character.NavAgent.CalculatePath(position, path) || !character.NavAgent.SetPath(path))
|
||
// character.NavAgent.ResetPath();
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 主角专用向目标移动模块
|
||
/// </summary>
|
||
protected class MainPlayerMoveToTarget : MainPlayerMoveBase
|
||
{
|
||
private MoveToTargetCondition _condition;
|
||
private Vector3 _lastTargetPos;
|
||
|
||
public MainPlayerMoveToTarget(Obj_Character character, Quaternion? rotation, Obj_Character target,
|
||
MoveToTargetCondition condition, MoveSuccessAction onMoveFinish) :
|
||
base(character, rotation, minStopDistance, onMoveFinish)
|
||
{
|
||
Target = target;
|
||
_condition = condition;
|
||
}
|
||
|
||
public Obj_Character Target { get; private set; }
|
||
|
||
public void SwitchTarget(Obj_Character target, MoveToTargetCondition condition,
|
||
MoveSuccessAction onMoveFinish)
|
||
{
|
||
Target = target;
|
||
_condition = condition;
|
||
SetParameters(minStopDistance, onMoveFinish);
|
||
ResetMove();
|
||
}
|
||
|
||
public override void ResetMove()
|
||
{
|
||
base.ResetMove();
|
||
_lastTargetPos = Target.Position;
|
||
// 特殊处理:防止自带阻挡区域的怪物
|
||
var moveTarget = ActiveScene.GetTerrainPosition(_lastTargetPos);
|
||
MoveToPosition(moveTarget);
|
||
}
|
||
|
||
public override bool UpdateMove()
|
||
{
|
||
var result = false;
|
||
if (Target != null)
|
||
{
|
||
var state = _condition.GetMoveState(character, Target);
|
||
if (state == MoveToTargetState.Keep)
|
||
{
|
||
// 校正目标位置
|
||
if ((Target.Position - _lastTargetPos).RemoveY().sqrMagnitude >
|
||
navAgentPercision.ToSquare())
|
||
{
|
||
_lastTargetPos = Target.Position;
|
||
// 不做地形校正 - 能够移动的目标不应该具备CarveNavMesh的能力
|
||
MoveToPosition(_lastTargetPos);
|
||
}
|
||
|
||
result = true;
|
||
}
|
||
else
|
||
{
|
||
moveSuccess = state == MoveToTargetState.Success;
|
||
}
|
||
}
|
||
|
||
return result;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 主角专用向位置移动模块
|
||
/// </summary>
|
||
protected class MainPlayerMoveToPos : MainPlayerMoveBase
|
||
{
|
||
public MainPlayerMoveToPos(Obj_Character character, Quaternion? rotation, Vector3 targetPos,
|
||
float stopRange,
|
||
MoveSuccessAction onMoveFinish) :
|
||
base(character, rotation, stopRange, onMoveFinish)
|
||
{
|
||
TargetPos = targetPos;
|
||
}
|
||
|
||
public Vector3 TargetPos { get; private set; }
|
||
|
||
public void SwitchTarget(Vector3 targetPos, float stopRange, MoveSuccessAction onMoveFinish)
|
||
{
|
||
TargetPos = targetPos;
|
||
SetParameters(stopRange, onMoveFinish);
|
||
ResetMove();
|
||
}
|
||
|
||
public override void ResetMove()
|
||
{
|
||
base.ResetMove();
|
||
// 防止试图移动的位置不可达到
|
||
TargetPos = MoveToPosition(TargetPos);
|
||
}
|
||
|
||
public override bool UpdateMove()
|
||
{
|
||
var result = false;
|
||
// 检定是否位置符合目标
|
||
if ((character.Position.RemoveY() - TargetPos.RemoveY()).sqrMagnitude < StopRange.ToSquare())
|
||
moveSuccess = true;
|
||
else
|
||
result = true;
|
||
return result;
|
||
}
|
||
}
|
||
|
||
|
||
private class MainPlayerLerpModule : ObjOverrideMoveBase, IMainPlayerMoveWithAction
|
||
{
|
||
/// <summary>
|
||
/// 最大动画容错时间
|
||
/// </summary>
|
||
// 如果开始和结束动画持续不出现,则超过这个时间会强制执行下一步
|
||
private const float _maxAnimTime = 2f;
|
||
|
||
// 当前状态:0 = 起跳; 1 = 起跳动画已开始;2 = 跳跃中;3 = 落地; 4 = 落地动画已开始
|
||
private int _currentState;
|
||
|
||
private LeapParameters _leapParameters;
|
||
|
||
private float _startTime;
|
||
|
||
//private bool _endParticle;
|
||
|
||
public MainPlayerLerpModule(Obj_Character character, Quaternion? rotation,
|
||
LeapParameters leapParameters) : base(
|
||
character, rotation)
|
||
{
|
||
_leapParameters = leapParameters;
|
||
}
|
||
|
||
public override MoveState MoveState
|
||
{
|
||
get { return MoveState.Leap; }
|
||
}
|
||
|
||
public void InvokeMoveFinish()
|
||
{
|
||
if (_leapParameters.movePosition != null)
|
||
{
|
||
var mainPlayer = character as Obj_MainPlayer;
|
||
// 注:不打断自动寻路逻辑
|
||
if (mainPlayer != null)
|
||
mainPlayer.MainPlayMoveToPos(_leapParameters.movePosition.Value, _leapParameters.stopRange,
|
||
isMoveOrder: false,
|
||
bIsAutoSearch: GameManager.gameManager.AutoSearch.IsAutoSearching);
|
||
}
|
||
}
|
||
|
||
public void ResetData(LeapParameters leapParameters)
|
||
{
|
||
_leapParameters = leapParameters;
|
||
ResetMove();
|
||
}
|
||
|
||
public override void ResetMove()
|
||
{
|
||
if (rotation != null)
|
||
character.Rotation = rotation.Value;
|
||
else
|
||
character.FaceTo(_leapParameters.endPoint, true);
|
||
character.EnableMovingRotation(false);
|
||
DisableNavAgent();
|
||
_startTime = Time.time;
|
||
//_endParticle = false;
|
||
// 特殊处理 - 如果没有起跳动画,则直接进入跳跃中
|
||
if (_leapParameters.startAnim != null &&
|
||
character.AnimLogic.HasMotionState(_leapParameters.startAnim.AnimName))
|
||
{
|
||
_currentState = 0;
|
||
character.AnimLogic.Play(_leapParameters.startAnim);
|
||
}
|
||
else
|
||
{
|
||
StartLeapAction();
|
||
}
|
||
}
|
||
|
||
public override bool UpdateMove()
|
||
{
|
||
var result = true;
|
||
switch (_currentState)
|
||
{
|
||
case 0:
|
||
{
|
||
// 起跳动画超时
|
||
if (Time.time > _startTime + _maxAnimTime)
|
||
StartLeapAction();
|
||
// 起跳动画开始
|
||
else if (character.AnimLogic.IsPlayAnim(_leapParameters.startAnim))
|
||
_currentState = 1;
|
||
}
|
||
break;
|
||
case 1:
|
||
{
|
||
// 起跳动画结束
|
||
if (Time.time > _startTime + _maxAnimTime ||
|
||
!character.AnimLogic.IsPlayAnim(_leapParameters.startAnim))
|
||
StartLeapAction();
|
||
}
|
||
break;
|
||
case 2:
|
||
{
|
||
var duration = Time.time - _startTime;
|
||
//if (!_endParticle && duration > _leapParameters.endTime - 1f)
|
||
// EndAnimParticle();
|
||
// 冲刺阶段
|
||
if (duration < _leapParameters.dashEndTime)
|
||
{
|
||
character.Position = Vector3.Lerp(_leapParameters.startPoint, _leapParameters.dashEndPoint,
|
||
duration / _leapParameters.dashEndTime);
|
||
}
|
||
// 结束阶段
|
||
else if (duration > _leapParameters.endTime)
|
||
{
|
||
character.Position = _leapParameters.endPoint;
|
||
if (_leapParameters.endAnim == null ||
|
||
!character.AnimLogic.HasMotionState(_leapParameters.endAnim.AnimName))
|
||
{
|
||
result = EndLerpAction();
|
||
}
|
||
else
|
||
{
|
||
_currentState = 3;
|
||
character.AnimLogic.Play(_leapParameters.endAnim);
|
||
_startTime = Time.time;
|
||
}
|
||
}
|
||
// 抛物线阶段
|
||
else
|
||
{
|
||
var point = Vector3.Lerp(_leapParameters.startPoint, _leapParameters.endPoint,
|
||
duration / _leapParameters.endTime);
|
||
var deltaTime = duration - _leapParameters.dashEndTime;
|
||
point.y = _leapParameters.dashEndPoint.y + deltaTime * _leapParameters.speedV +
|
||
0.5f * _leapParameters.gravity * deltaTime * deltaTime;
|
||
character.Position = point;
|
||
}
|
||
}
|
||
break;
|
||
case 3:
|
||
{
|
||
// 落地动画超时
|
||
if (Time.time > _startTime + _maxAnimTime)
|
||
result = EndLerpAction();
|
||
// 落地动画开始
|
||
else if (character.AnimLogic.IsPlayAnim(_leapParameters.endAnim))
|
||
_currentState = 4;
|
||
}
|
||
break;
|
||
case 4:
|
||
{
|
||
if (Time.time > _startTime + _maxAnimTime ||
|
||
!character.AnimLogic.IsPlayAnim(_leapParameters.endAnim))
|
||
result = EndLerpAction();
|
||
}
|
||
break;
|
||
// _currentState = 5时,如果启动下一段Leap不成功,则等一帧退出Leap模块
|
||
default:
|
||
result = false;
|
||
break;
|
||
}
|
||
|
||
return result;
|
||
}
|
||
|
||
//private void EndAnimParticle()
|
||
//{
|
||
// _endParticle = true;
|
||
// if (character.AnimLogic != null &&
|
||
// _leapParameters.loopAnim != null)
|
||
// character.AnimLogic.RemoveStartEffect(_leapParameters.loopAnim);
|
||
//}
|
||
|
||
private void StartLeapAction()
|
||
{
|
||
_currentState = 2;
|
||
if (_leapParameters.loopAnim != null)
|
||
character.AnimLogic.Play(_leapParameters.loopAnim);
|
||
_startTime = Time.time;
|
||
}
|
||
|
||
// Hack: 如果有下一个跳跃,直接为角色启动下一次跳跃,不退出;否则正常退出跳跃状态
|
||
private bool EndLerpAction()
|
||
{
|
||
var result = false;
|
||
_currentState = 5;
|
||
//if (!_endParticle)
|
||
// EndAnimParticle();
|
||
if (_leapParameters.nextLeap > -1)
|
||
{
|
||
var mainPlayer = character as Obj_MainPlayer;
|
||
if (mainPlayer != null)
|
||
mainPlayer.MainPlayerLeap(_leapParameters.nextLeap, _leapParameters.movePosition,
|
||
_leapParameters.stopRange);
|
||
result = true;
|
||
}
|
||
|
||
return result;
|
||
}
|
||
|
||
public override void EndMove()
|
||
{
|
||
// 即使被强制结束,也会重置角色到预订位置
|
||
var endPoint = _leapParameters.endPoint;
|
||
var nextLerp = _leapParameters.nextLeap;
|
||
while (nextLerp > -1)
|
||
{
|
||
var jumpData = TableManager.GetJumpByID(nextLerp);
|
||
nextLerp = jumpData.NextJumpId;
|
||
endPoint = new Vector3(jumpData.EndPosX, jumpData.EndPosY, jumpData.EndPosZ);
|
||
}
|
||
|
||
// 注:只有在至少取得一次表的条件下需要采样位置
|
||
if (_leapParameters.nextLeap > -1)
|
||
endPoint = ActiveScene.GetTerrainPosition(endPoint);
|
||
character.ServerPos = endPoint;
|
||
character.Position = endPoint;
|
||
character.EnableMovingRotation(true);
|
||
EnableNavAgent();
|
||
}
|
||
}
|
||
|
||
public void MainPlayerLeap(int leapId, Vector3? movePosition, float stopRange)
|
||
{
|
||
var leapData = CommonUtility.TryGetTable(leapId, a => TableManager.GetJumpByID(a));
|
||
if (leapData != null)
|
||
{
|
||
var leapParameter = new LeapParameters(Position, leapData, movePosition, stopRange);
|
||
if (MovementState == MoveState.Leap)
|
||
((MainPlayerLerpModule) MoveModule).ResetData(leapParameter);
|
||
else
|
||
StartMoveModule(new MainPlayerLerpModule(this, null, leapParameter));
|
||
}
|
||
}
|
||
|
||
public class MainPlayerRide : ObjOverrideMoveBase, IMainPlayerMoveWithAction
|
||
{
|
||
// 上马和下马冻结角色移动0.5f
|
||
public const float defaultWaitTime = 0.5f;
|
||
|
||
private float _rideEndTime;
|
||
|
||
public MainPlayerRide(Obj_Character character) : base(character, null)
|
||
{
|
||
}
|
||
|
||
/// <summary>
|
||
/// 缓存骑马前的目标位置
|
||
/// </summary>
|
||
public Vector3? destination { get; set; }
|
||
|
||
public float stopRange { get; set; }
|
||
|
||
public override MoveState MoveState
|
||
{
|
||
get { return MoveState.Freeze; }
|
||
}
|
||
|
||
public void InvokeMoveFinish()
|
||
{
|
||
if (destination != null)
|
||
{
|
||
var mainPlayer = character as Obj_MainPlayer;
|
||
// 注:不打断自动寻路逻辑
|
||
if (mainPlayer != null)
|
||
mainPlayer.MainPlayMoveToPos(destination.Value, stopRange,
|
||
isMoveOrder: false,
|
||
bIsAutoSearch: GameManager.gameManager.AutoSearch.IsAutoSearching);
|
||
}
|
||
}
|
||
|
||
public override void ResetMove()
|
||
{
|
||
}
|
||
|
||
public void ResetDelay(float? time)
|
||
{
|
||
_rideEndTime = Time.unscaledTime + (time ?? defaultWaitTime);
|
||
}
|
||
|
||
public override bool UpdateMove()
|
||
{
|
||
if (GameManager.gameManager.PlayerDataPool.IsInMeditateState)
|
||
{
|
||
//#if UNITY_EDITOR
|
||
// Debug.LogError("Meditate Break AutoSearch");
|
||
//#endif
|
||
var mainPlayer = (Obj_MainPlayer) character;
|
||
destination = mainPlayer.transform.position;
|
||
return false;
|
||
}
|
||
|
||
return Time.unscaledTime < _rideEndTime;
|
||
}
|
||
|
||
public override void EndMove()
|
||
{
|
||
}
|
||
}
|
||
|
||
public class MainPlayerJumpWait : ObjOverrideMoveBase
|
||
{
|
||
// 跳跃仅等待两秒,两秒后如果跳跃仍然未完成,就解除跳跃
|
||
public const float maxWaitTime = 2f;
|
||
|
||
private float _jumpEndTime;
|
||
|
||
public MainPlayerJumpWait(Obj_Character character) : base(character, null)
|
||
{
|
||
}
|
||
|
||
/// <summary>
|
||
/// 缓存跳跃前的目标位置,跳跃后用于恢复状态
|
||
/// </summary>
|
||
public Vector3? LastDestination { get; set; }
|
||
|
||
/// <summary>
|
||
/// 缓存跳跃前停止距离
|
||
/// </summary>
|
||
public float LastStopRange { get; set; }
|
||
|
||
public override MoveState MoveState
|
||
{
|
||
get { return MoveState.JumpDelay; }
|
||
}
|
||
|
||
public override void ResetMove()
|
||
{
|
||
_jumpEndTime = Time.unscaledTime + maxWaitTime;
|
||
DisableNavAgent();
|
||
}
|
||
|
||
public override bool UpdateMove()
|
||
{
|
||
return Time.unscaledTime < _jumpEndTime;
|
||
}
|
||
|
||
public override void EndMove()
|
||
{
|
||
character.ServerPos = character.Position;
|
||
EnableNavAgent();
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 跳跃移动额外参数
|
||
/// </summary>
|
||
public class LeapParameters
|
||
{
|
||
/// <summary>
|
||
/// 冲刺结束位置
|
||
/// </summary>
|
||
public readonly Vector3 dashEndPoint;
|
||
|
||
/// <summary>
|
||
/// 冲刺结束时间
|
||
/// </summary>
|
||
public readonly float dashEndTime;
|
||
|
||
/// <summary>
|
||
/// 结束动画
|
||
/// </summary>
|
||
public readonly Tab_Animation endAnim;
|
||
|
||
/// <summary>
|
||
/// 经过校正的结束位置
|
||
/// </summary>
|
||
public readonly Vector3 endPoint;
|
||
|
||
/// <summary>
|
||
/// 运动结束时间
|
||
/// </summary>
|
||
public readonly float endTime;
|
||
|
||
/// <summary>
|
||
/// 重力加速度
|
||
/// </summary>
|
||
public readonly float gravity;
|
||
|
||
/// <summary>
|
||
/// 跳跃中动画
|
||
/// </summary>
|
||
public readonly Tab_Animation loopAnim;
|
||
|
||
/// <summary>
|
||
/// 缓存移动目标位置
|
||
/// </summary>
|
||
public readonly Vector3? movePosition;
|
||
|
||
/// <summary>
|
||
/// 下一段跳跃
|
||
/// </summary>
|
||
public readonly int nextLeap;
|
||
|
||
/// <summary>
|
||
/// 冲刺垂直速度
|
||
/// </summary>
|
||
public readonly float speedV;
|
||
|
||
/// <summary>
|
||
/// 开始动画
|
||
/// </summary>
|
||
public readonly Tab_Animation startAnim;
|
||
|
||
/// <summary>
|
||
/// 经过校正的开始位置
|
||
/// </summary>
|
||
public readonly Vector3 startPoint;
|
||
|
||
/// <summary>
|
||
/// 缓存移动停止距离
|
||
/// </summary>
|
||
public readonly float stopRange;
|
||
|
||
public LeapParameters(Vector3 start, Tab_Jump jumpTable, Vector3? movePosition, float stopRange)
|
||
{
|
||
startPoint = start;
|
||
endPoint = new Vector3(jumpTable.EndPosX, jumpTable.EndPosY, jumpTable.EndPosZ);
|
||
if (jumpTable.NextJumpId < 0)
|
||
endPoint = ActiveScene.GetTerrainPosition(endPoint);
|
||
endTime = jumpTable.Duration.ToClientTime();
|
||
var speedH = (endPoint - start).RemoveY().magnitude / endTime;
|
||
dashEndTime = jumpTable.SprintPosX / speedH;
|
||
speedV = jumpTable.SprintPosZ / dashEndTime;
|
||
var x = endPoint - startPoint;
|
||
x.y = 0f;
|
||
x = x.normalized;
|
||
var dashDelta = x * jumpTable.SprintPosX + Vector3.up * jumpTable.SprintPosZ;
|
||
dashEndPoint = start + dashDelta;
|
||
var parabolaTime = endTime - dashEndTime;
|
||
gravity = 2 * (endPoint.y - dashEndPoint.y - speedV * parabolaTime) / parabolaTime / parabolaTime;
|
||
this.movePosition = movePosition;
|
||
this.stopRange = stopRange;
|
||
nextLeap = jumpTable.NextJumpId;
|
||
var id = jumpTable.GetAnimationbyIndex(0);
|
||
if (id > GlobeVar.INVALID_ID)
|
||
startAnim = TableManager.GetAnimationByID(id);
|
||
id = jumpTable.GetAnimationbyIndex(1);
|
||
if (id >= GlobeVar.INVALID_ID)
|
||
loopAnim = TableManager.GetAnimationByID(id);
|
||
id = jumpTable.GetAnimationbyIndex(2);
|
||
if (id >= GlobeVar.INVALID_ID)
|
||
endAnim = TableManager.GetAnimationByID(id);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 主角移动结束后行为类型
|
||
/// </summary>
|
||
public abstract class MoveSuccessAction
|
||
{
|
||
public abstract void InvokeAction();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 主角向目标移动,检测通过的条件
|
||
/// </summary>
|
||
public abstract class MoveToTargetCondition
|
||
{
|
||
/// <summary>
|
||
/// 检查主角和目标之间是否满足移动成功条件
|
||
/// </summary>
|
||
public abstract MoveToTargetState GetMoveState(Obj_Character mainPlayer, Obj_Character target);
|
||
}
|
||
|
||
public enum MoveToTargetState
|
||
{
|
||
Keep, // 继续移动
|
||
Failure, // 移动失败 - 移动后释放技能时,目标死亡或者技能被锁定等
|
||
Success // 移动成功
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 主角阴影相关
|
||
|
||
public static bool UseDynamicShadow
|
||
{
|
||
get { return _useDynamicShadow; }
|
||
set
|
||
{
|
||
if (_useDynamicShadow != value)
|
||
{
|
||
_useDynamicShadow = value;
|
||
var mainPlayer = Singleton<ObjManager>.Instance.MainPlayer;
|
||
if (mainPlayer != null)
|
||
mainPlayer.ToggleDynamicShadow();
|
||
}
|
||
}
|
||
}
|
||
|
||
private static bool _useDynamicShadow = true;
|
||
private bool _useShadow = true;
|
||
|
||
private void ToggleDynamicShadow()
|
||
{
|
||
ResetShadow();
|
||
}
|
||
|
||
protected override void SetShadow(bool isOn)
|
||
{
|
||
_useShadow = isOn;
|
||
ResetShadow();
|
||
}
|
||
|
||
private void ResetShadow()
|
||
{
|
||
var dynamic = _useShadow && UseDynamicShadow;
|
||
var blob = _useShadow && !UseDynamicShadow;
|
||
SetDynamicShadow(dynamic);
|
||
base.SetShadow(blob);
|
||
}
|
||
|
||
protected override bool UseRealtimeShadow()
|
||
{
|
||
return UseDynamicShadow;
|
||
}
|
||
|
||
#endregion
|
||
}
|
||
} |