467 lines
18 KiB
C#
467 lines
18 KiB
C#
using ProtoBuf;
|
||
using Thousandto.Plugins.Common;
|
||
using Thousandto.Code.Center;
|
||
using Thousandto.Core.Base;
|
||
using Thousandto.Code.Global;
|
||
using Thousandto.Cfg.Data;
|
||
using Thousandto.Core.Asset;
|
||
using AppPersistData = UnityEngine.Gonbest.MagicCube.AppPersistData;
|
||
|
||
namespace Thousandto.Code.Logic.Network
|
||
{
|
||
/// <summary>
|
||
/// 实现消息的回调方法 -- 主角玩家的协议
|
||
/// </summary>
|
||
public partial class HandleMsgResult : IHandleMsgResult
|
||
{
|
||
//更新在线玩家的战斗属性信息
|
||
public void GS2U_ResPlayerOnLineAttribute(MSG_Player.ResPlayerOnLineAttribute result)
|
||
{
|
||
GameCenter.GameSceneSystem.RefreshLocalPlayerBattleAttribute(result);
|
||
}
|
||
|
||
//玩家的战斗属性改变
|
||
public void GS2U_ResPlayerAttributeChange(MSG_Player.ResPlayerAttributeChange result)
|
||
{
|
||
GameCenter.GameSceneSystem.RefreshLocalPlayerBattleAttribute(result.changeList);
|
||
}
|
||
|
||
//玩家的基础属性信息
|
||
public void GS2U_ResPlayerBaseInfo(MSG_Player.ResPlayerBaseInfo msg)
|
||
{
|
||
if (msg == null)
|
||
return;
|
||
//设置替代模型的位置
|
||
LocalPlayerRoot.SetLocalPlayerID(msg.roleID);
|
||
GameCenter.GameSetting.RoleSetting.RoleID = msg.roleID;
|
||
var lp = GameCenter.GameSceneSystem.GetLocalPlayer();
|
||
if (lp == null)
|
||
{
|
||
lp = GameCenter.GameSceneSystem.RefreshLocalPlayer(new LocalPlayerInitInfo(msg));
|
||
//GameCenter.SceneRestoreSystem.InitSceneData(GameCenter.GameSceneSystem.ActivedScene.GetUnitySceneRoot().gameObject);
|
||
}
|
||
else
|
||
{
|
||
lp.SyncInfo(new LocalPlayerInitInfo(msg));
|
||
}
|
||
|
||
AppPersistData.LastRoleID = msg.roleID.ToString();
|
||
AppPersistData.LastRoleName = msg.name;
|
||
|
||
UnityEngine.PlayerPrefs.SetString("role", msg.name + "_" + msg.roleID);
|
||
|
||
//以下是统计信息------------------------
|
||
if (GameCenter.SDKSystem.IsCreatePlayerFlag)
|
||
{
|
||
GameCenter.SDKSystem.ActionEvent(ActionEventCode.CreateChar, msg.name, "" + msg.roleID);
|
||
//UnityEngine.Debug.Log("创建角色 " + msg.name + " : " + msg.roleID);
|
||
}
|
||
else
|
||
{
|
||
GameCenter.SDKSystem.ActionEvent(ActionEventCode.SelectChar, msg.name, "" + msg.roleID);
|
||
//UnityEngine.Debug.Log("选择角色 " + msg.name + " : " + msg.roleID);
|
||
|
||
}
|
||
//登录类型,普通登录=1,掉线重连=2 ,跨天登记=3
|
||
CoreSDK.SDKCacheData.LoginType = "1";
|
||
GameCenter.SDKSystem.SetRoleInfo();
|
||
GameCenter.SDKSystem.SetGuildName(msg.guildName);
|
||
//GameCenter.SDKSystem.SetGoldBalance(msg.haveGoldNum);
|
||
GameCenter.SDKSystem.SendEventServerInfo();
|
||
|
||
//到这里,角色信息才是完整的,才能发送创建角色事件
|
||
if (GameCenter.SDKSystem.IsCreatePlayerFlag)
|
||
GameCenter.SDKSystem.SendEventCreateRole();
|
||
|
||
//请求累计在线时间
|
||
MSG_Player.ReqGetAccunonlinetime reqMsg = new MSG_Player.ReqGetAccunonlinetime();
|
||
reqMsg.Send();
|
||
}
|
||
|
||
// 转职结果
|
||
public void GS2U_ResChangeJobResult(MSG_Player.ResChangeJobResult result)
|
||
{
|
||
//GameCenter.TransferSystemMsg.GS2U_ResChangeJobResult(result);
|
||
}
|
||
|
||
//增加反击对象
|
||
public void GS2U_ResAddHatred(MSG_Player.ResAddHatred result)
|
||
{
|
||
LocalPlayer lp = GameCenter.GameSceneSystem.GetLocalPlayer();
|
||
if (lp != null)
|
||
{
|
||
lp.AddStrikeBackCharacter(result.playerId);
|
||
}
|
||
}
|
||
//删除反击对象
|
||
public void GS2U_ResDelHatred(MSG_Player.ResDelHatred result)
|
||
{
|
||
LocalPlayer lp = GameCenter.GameSceneSystem.GetLocalPlayer();
|
||
if (lp != null)
|
||
{
|
||
lp.DeleteStrikeBackCharacter(result.playerId);
|
||
}
|
||
}
|
||
//清除反击对象
|
||
public void GS2U_ResCleanHatred(MSG_Player.ResCleanHatred result)
|
||
{
|
||
LocalPlayer lp = GameCenter.GameSceneSystem.GetLocalPlayer();
|
||
if (lp != null)
|
||
{
|
||
lp.ClearStrikeBackCharacter();
|
||
}
|
||
}
|
||
|
||
//等级改变
|
||
public void GS2U_ResLevelChange(MSG_Player.ResLevelChange result)
|
||
{
|
||
NetHandler.OnResLevelChange(result);
|
||
}
|
||
|
||
public void GS2U_ResPracticeInfo(MSG_Player.ResPracticeInfo result)
|
||
{
|
||
//GameCenter.offLineExpSystem.GS2U_ResPracticeInfo( result );
|
||
}
|
||
public void GS2U_ResPracticeSetDo(MSG_Player.ResPracticeSetDo result)
|
||
{
|
||
//GameCenter.offLineExpSystem.GS2U_ResPracticeSetDo( result );
|
||
}
|
||
public void GS2U_ResPracticeGetResult(MSG_Player.ResPracticeGetResult result)
|
||
{
|
||
//GameCenter.offLineExpSystem.GS2U_ResPracticeGetResult( result );
|
||
}
|
||
|
||
//在线时长
|
||
public void GS2U_ResAccunonlinetime(MSG_Player.ResAccunonlinetime result)
|
||
{
|
||
var lp = GameCenter.GameSceneSystem.GetLocalPlayer();
|
||
if(lp != null)
|
||
{
|
||
lp.PropMoudle.AllOnLineTime = result.time;
|
||
}
|
||
}
|
||
public void GS2U_ResUpdataExpRate(MSG_Player.ResUpdataExpRate result)
|
||
{
|
||
LocalPlayer lp = GameCenter.GameSceneSystem.GetLocalPlayer();
|
||
if (lp != null)
|
||
{
|
||
lp.PropMoudle.ExpRate = result.expRate;
|
||
}
|
||
}
|
||
|
||
public void GS2U_ResUpdataPkValue(MSG_Player.ResUpdataPkValue result)
|
||
{
|
||
//if (GameCenter.GameSceneSystem.ActivedScene != null)
|
||
//{
|
||
// Player p = GameCenter.GameSceneSystem.ActivedScene.Find<Player>(result.playerId);
|
||
// if (p != null)
|
||
// {
|
||
// p.PropMoudle.PkValue = (uint)result.pkValue;
|
||
// p.UpdateNameColor();
|
||
// }
|
||
//}
|
||
}
|
||
|
||
public void GS2U_ResUpdataPkStateResult(MSG_Player.ResUpdataPkStateResult result)
|
||
{
|
||
if (result.reason == 0)
|
||
{
|
||
if (GameCenter.GameSceneSystem.ActivedScene != null)
|
||
{
|
||
LocalPlayer lp = GameCenter.GameSceneSystem.GetLocalPlayer();
|
||
if (lp != null)
|
||
{
|
||
var oldPkMode = lp.PropMoudle.PkModel;
|
||
lp.PropMoudle.PkModel = (PKMode)result.curPkState;
|
||
GameCenter.PushFixEvent(LogicEventDefine.EID_EVENT_PKMODE_CHANGED);
|
||
if (oldPkMode != lp.PropMoudle.PkModel)
|
||
{
|
||
var remotePlayerlit = GameCenter.GameSceneSystem.FindEntityAll<RemotePlayer>();
|
||
for (int i = 0; i < remotePlayerlit.Count; ++i)
|
||
{
|
||
remotePlayerlit[i].UpdateNameColor();
|
||
}
|
||
|
||
if (result.notice)
|
||
{
|
||
switch ((PKMode)result.curPkState)
|
||
{
|
||
case PKMode.PeaceMode:
|
||
GameCenter.MsgPromptSystem.ShowPrompt(Thousandto.Cfg.Data.DeclareMessageString.Get(Thousandto.Cfg.Data.DeclareMessageString.C_PKPMDE_DESC_PEACE));
|
||
break;
|
||
case PKMode.AllMode:
|
||
GameCenter.MsgPromptSystem.ShowPrompt(Thousandto.Cfg.Data.DeclareMessageString.Get(Thousandto.Cfg.Data.DeclareMessageString.C_PKMODE_QUANTI_DESC));
|
||
break;
|
||
case PKMode.SelfServer:
|
||
GameCenter.MsgPromptSystem.ShowPrompt(Thousandto.Cfg.Data.DeclareMessageString.Get(Thousandto.Cfg.Data.DeclareMessageString.C_PKMODE_BENFU_DESC));
|
||
break;
|
||
case PKMode.GuildMode:
|
||
GameCenter.MsgPromptSystem.ShowPrompt(Thousandto.Cfg.Data.DeclareMessageString.Get(Thousandto.Cfg.Data.DeclareMessageString.C_PKMODE_XIANMENG_DESC));
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
enum FightPowerChangeReason
|
||
{
|
||
BASE = 1,//基本属性加成
|
||
EQUIP = 2,//装备属性
|
||
BUFF = 3,//BUFF属性
|
||
MEDICINESATTRIBUTE = 4,//属性药
|
||
HORSE = 5, //坐骑属性加成
|
||
DRAGOON = 6, //骑兵系统加成
|
||
ACHIEVEMENT = 7, //成就系统加成
|
||
CLOAK = 8, //披风属性加成
|
||
MARRIAGE = 9, //婚姻
|
||
CARD = 10, //图鉴
|
||
PET = 11, //宠物
|
||
GUILD_HanLin = 12,//公会翰林属性
|
||
Soul = 13, //战魂
|
||
TITLE = 14, //称号
|
||
VIP = 15, //VIP
|
||
MASTER = 16, //师门
|
||
FASHION = 17, //时装
|
||
SkillBuff = 999, //技能buf
|
||
}
|
||
|
||
public void GS2U_ResPlayerFightPointChange(MSG_Player.ResPlayerFightPointChange result)
|
||
{
|
||
if (GameCenter.GameSceneSystem.ActivedScene != null)
|
||
{
|
||
LocalPlayer lp = GameCenter.GameSceneSystem.GetLocalPlayer();
|
||
if (lp != null)
|
||
{
|
||
lp.FightPower = result.fightPoint;
|
||
}
|
||
}
|
||
}
|
||
|
||
public void GS2U_ResPlayerSummaryInfo(MSG_Player.ResPlayerSummaryInfo result)
|
||
{
|
||
GameCenter.PushFixEvent(UIEventDefine.UISocialTipsForm_OPEN, result);
|
||
}
|
||
|
||
//查看其它玩家
|
||
public void GS2U_ResLookOtherPlayerResult(MSG_Player.ResLookOtherPlayerResult result)
|
||
{
|
||
//if (GameCenter.FormStateSystem.GetFormState("UIGuildForm") == FormStateCode.FSC_OPENED)
|
||
//{
|
||
GameCenter.PushFixEvent(UIEventDefine.UILookOterPlayerForm_OPEN, result);
|
||
//}
|
||
}
|
||
|
||
public void GS2U_ResFightOrUnFight(MSG_Player.ResFightOrUnFight result)
|
||
{
|
||
var lp = GameCenter.GameSceneSystem.GetLocalPlayer();
|
||
if (lp != null && lp.FightState != result.isFight)
|
||
{
|
||
lp.FightState = result.isFight;
|
||
if (result.isFight)
|
||
{
|
||
//进入战斗状态
|
||
GameCenter.MsgPromptSystem.ShowPrompt(DeclareMessageString.Get(DeclareMessageString.C_ENTER_FIGHTSTATE));
|
||
}
|
||
else
|
||
{
|
||
//离开战斗状态
|
||
GameCenter.MsgPromptSystem.ShowPrompt(DeclareMessageString.Get(DeclareMessageString.C_LEAVE_FIGHTSTATE));
|
||
}
|
||
}
|
||
}
|
||
|
||
public void GS2U_ResMainUIGuideID(MSG_Player.ResMainUIGuideID result)
|
||
{
|
||
}
|
||
|
||
public void GS2U_ResPlayerTodayData(MSG_Player.ResPlayerTodayData result)
|
||
{
|
||
//GameCenter.WeaponGrowthSystem.LoginDays = result.accumOnlineDays;
|
||
}
|
||
|
||
public void GS2U_ResBeginGather(MSG_Map.ResBeginGather result)
|
||
{
|
||
//UnityEngine.Debug.Log("====begin sky res=====");
|
||
Player p = GameCenter.GameSceneSystem.FindEntity<Player>(result.roleId);
|
||
if (p != null)
|
||
{
|
||
p.Action_Collect(result.gatherId);
|
||
}
|
||
}
|
||
|
||
public void GS2U_ResEndGather(MSG_Map.ResEndGather result)
|
||
{
|
||
RemotePlayer p = GameCenter.GameSceneSystem.FindEntity<RemotePlayer>(result.roleId);
|
||
if (p != null && p.Fsm != null && p.Fsm.CurrentState is Collect)
|
||
{
|
||
//UnityEngine.Debug.Log("====end sky res=====");
|
||
Collect c = p.Fsm.CurrentState as Collect;
|
||
c.FinishTransition();
|
||
p.Stop_Action(false);
|
||
}
|
||
//GameCenter.SkyCitySystem.ResEndGather(result);
|
||
}
|
||
|
||
public void GS2U_ResChangeRoleNameResult(MSG_Player.ResChangeRoleNameResult result)
|
||
{
|
||
if (!result.isSuccess)
|
||
return;
|
||
|
||
var player = GameCenter.GameSceneSystem.FindEntity<Player>(result.roleId);
|
||
if (player != null)
|
||
{
|
||
player.PropMoudle.Name = result.newName;
|
||
GameCenter.PushFixEvent(LogicEventDefine.EID_EVENT_HUD_UPDATE_HEADINFO, player);
|
||
if (player.IsLocalPlayer())
|
||
{
|
||
GameCenter.MsgPromptSystem.ShowPrompt(Thousandto.Cfg.Data.DeclareMessageString.Get(Thousandto.Cfg.Data.DeclareMessageString.C_CHANGEJOB_TIPS_SUC));
|
||
}
|
||
}
|
||
}
|
||
|
||
public void GS2U_ResMaxHpChange(MSG_Player.ResMaxHpChange result)
|
||
{
|
||
var character = GameCenter.GameSceneSystem.FindEntity<Character>((ulong)result.roleId);
|
||
if (character != null)
|
||
{
|
||
character.PropMoudle.SetBattleProp(AllBattleProp.MaxHP, result.maxHp);
|
||
if (character.IsLocalPlayer())
|
||
{
|
||
var lp = character as LocalPlayer;
|
||
lp.CheckLifeHint();
|
||
}
|
||
}
|
||
}
|
||
|
||
//打开阵营选择界面
|
||
public void GS2U_ResClientToChoiceBirthGroup(MSG_Player.ResClientToChoiceBirthGroup result)
|
||
{
|
||
//GameCenter.PushFixEvent(UIEventDefine.UIChooseCampForm_OPEN);
|
||
}
|
||
public void GS2U_ResNotUpLevel(MSG_Player.ResNotUpLevel result)
|
||
{
|
||
|
||
}
|
||
public void GS2U_ResChangeJobTips(MSG_Player.ResChangeJobTips result)
|
||
{
|
||
//提示可以转职了
|
||
}
|
||
|
||
//接收到开服时间
|
||
public void GS2U_ResOpenServerTime(MSG_Player.ResOpenServerTime result)
|
||
{
|
||
}
|
||
|
||
public void GS2U_ResPeakLevelPanel(MSG_Player.ResPeakLevelPanel result)
|
||
{
|
||
//GameCenter.DianFengLvSystem.GS2U_ResPeakLevelPanel(result);
|
||
}
|
||
public void GS2U_ResActiveFateStar(MSG_Player.ResActiveFateStar result)
|
||
{
|
||
//if (result.ids.gender == 4)
|
||
// GameCenter.DianFengLvSystem.GS2U_ResActiveFateStar(result);
|
||
//else if (result.ids.gender == 5)
|
||
//{
|
||
// GameCenter.DianFengFiveSystem.GS2U_ResActiveFateStar(result);
|
||
//}
|
||
}
|
||
|
||
//转职广播
|
||
public void GS2U_ResPlayerGenderNotice(MSG_Player.ResPlayerGenderNotice result)
|
||
{
|
||
//Player player = GameCenter.GameSceneSystem.FindEntity<Player>((ulong)result.playerId);
|
||
//if (player != null)
|
||
//{
|
||
// int cfgId = GameCenter.TransferSystem.GetModelCfgId((int)player.Occ, (int)player.PropMoudle.GradeLevel);
|
||
// if (cfgId != 0)
|
||
// {
|
||
// player.EquipWithType(FSkinPartCode.TransVfx, cfgId);
|
||
// }
|
||
//}
|
||
}
|
||
//五转
|
||
public void GS2U_ResChangeJobPanel(MSG_Player.ResChangeJobPanel result)
|
||
{
|
||
//if (result.gender == 5)
|
||
//{
|
||
// //五转
|
||
// GameCenter.DianFengFiveSystem.GS2U_ResChangeJobPanel(result);
|
||
//}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 血脉系统升级返回消息
|
||
/// </summary>
|
||
/// <param name="result"></param>
|
||
public void GS2U_ResUpgradeBlood(MSG_Player.ResUpgradeBlood result)
|
||
{
|
||
//GameCenter.BloodVenationSystem.GS2U_ResUpgradeBlood(result);
|
||
}
|
||
|
||
public void GS2U_ResOpenBloodPannel(MSG_Player.ResOpenBloodPannel result)
|
||
{
|
||
//GameCenter.BloodVenationSystem.GS2U_ResOpenBloodPannel(result);
|
||
}
|
||
|
||
//转换职业
|
||
public void GS2U_ResPlayerCareerChange(MSG_Player.ResPlayerCareerChange result)
|
||
{
|
||
/*
|
||
if(result.state == 0 && (ulong)result.roleId == LocalPlayerRoot.LocalPlayerID)
|
||
{
|
||
GameCenter.MsgPromptSystem.ShowMsgBox(string.Format(DeclareMessageString.Get(DeclareMessageString.C_CHANGEOCC_SUCCTIPS), PlayerPropetry.GetOccName((Occupation)result.careerNo)), DeclareMessageString.Get(DeclareMessageString.C_MSGBOX_OK), null, (code) =>
|
||
{
|
||
//回到登录界面
|
||
GameCenter.GameSceneSystem.ReturnToLogin();
|
||
});
|
||
}
|
||
*/
|
||
}
|
||
|
||
public void GS2U_ResSendGift(MSG_Player.ResSendGift result) { }
|
||
public void GS2U_ResGetGiftLog(MSG_Player.ResGetGiftLog result) { }
|
||
|
||
public void GS2U_SyncXiSuiData(MSG_Player.SyncXiSuiData result)
|
||
{
|
||
var player = GameCenter.GameSceneSystem.FindEntity<Player>((ulong)result.roleID);
|
||
if(player != null)
|
||
{
|
||
player.PropMoudle.XiSuiLevel = result.xsLvl;
|
||
}
|
||
}
|
||
|
||
public void GS2U_ResGenderClassChange(MSG_Player.ResGenderClassChange result)
|
||
{
|
||
var lp = GameCenter.GameSceneSystem.GetLocalPlayer();
|
||
if(lp != null)
|
||
{
|
||
lp.ChangeJobLevel = result.genderClass;
|
||
}
|
||
}
|
||
|
||
public void GS2U_ResNewGiftLog(MSG_Player.ResNewGiftLog result) { }
|
||
|
||
public void GS2U_ResReadGiftLog(MSG_Player.ResReadGiftLog result) { }
|
||
|
||
public void GS2U_G2SSynPlayerSocialInfo(MSG_Player.G2SSynPlayerSocialInfo result) { }
|
||
|
||
public void GS2U_G2SReqPlayerSummaryInfo(MSG_Player.G2SReqPlayerSummaryInfo result) { }
|
||
|
||
public void GS2U_ResPlayerSettingCustomHeadResult(MSG_Player.ResPlayerSettingCustomHeadResult result)
|
||
{
|
||
if(result.head != null)
|
||
{
|
||
var player = GameCenter.GameSceneSystem.FindEntity<RemotePlayer>((ulong)result.roleId);
|
||
if (player != null)
|
||
{
|
||
player.TexHeadPicID = result.head.customHeadPath;
|
||
player.IsShowHeadPic = result.head.useCustomHead;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|