123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531 |
- using CommonAI.Zone;
- using CommonAI.Zone.Helper;
- using CommonAI.Zone.Instance;
- using CommonAI.Zone.ZoneEditor;
- using CommonLang;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using XmdsCommon.EditorData;
- using XmdsCommon.Message;
- using XmdsCommon.Plugin;
- using XmdsCommonServer.Message;
- using XmdsCommonServer.Plugin.Scene;
- using XmdsCommonServer.Plugin.XmdsSkillTemplate.Skills;
- namespace XmdsCommonServer.Plugin
- {
- partial class XmdsVirtual_Player
- {
- #region 协议监听.
- public override void ReceiveMsgR2B(object status)
- {
- if (status == null)
- {
- FormatLog("ReceiveMsgR2B status is null", null);
- return;
- }
- if (status is XmdsUnitPropEventB2C)
- {
- OnPlayerPropertiesChanged(status as XmdsUnitPropEventB2C);
- }
- else if (status is PlayerSkillChangeEventR2B)
- {
- OnPlayerSkillsChanged(status as PlayerSkillChangeEventR2B);
- }
- else if (status is XmdsUnitBaseInfoEventB2C)
- {
- OnPlayerBaseInfoChanged(status as XmdsUnitBaseInfoEventB2C);
- }
- else if (status is PlayerRebirthEventR2B)
- {
- OnReceivePlayerRebirthOrder(status as PlayerRebirthEventR2B);
- }
- else if (status is PlayerSummonMountEventR2B)
- {
- OnReceivePlayerSummonMountEventR2B(status as PlayerSummonMountEventR2B);
- }
- else if (status is PlayAvatarEventB2C)
- {
- OnReceivePlayerAvatarEventB2C(status as PlayAvatarEventB2C);
- }
- else if (status is SyncPlayerInventorySizeEventR2B)
- {
- OnReceiveSyncPlayerInventorySizeEventR2B(status as SyncPlayerInventorySizeEventR2B);
- }
- else if (status is TeamInfoEventR2B)
- {
- OnReceiveTeamInfoEventR2B(status as TeamInfoEventR2B);
- }
- else if (status is TeamDataEventR2B)
- {
- OnReceiveTeamDataEventR2B(status as TeamDataEventR2B);
- }
- else if (status is PlayerPKLevelChangeEventR2B)
- {
- OnReceivePlayerPKLvChangeEventR2B(status as PlayerPKLevelChangeEventR2B);
- }
- else if (status is PlayerPKModeChangeEventR2B)
- {
- OnReceivePlayerPKModeChangeEventR2B(status as PlayerPKModeChangeEventR2B);
- }
- else if (status is PlayerPKValueChangeEventR2B)
- {
- OnReceivePlayerPKValueChangeEventR2B(status as PlayerPKValueChangeEventR2B);
- }
- else if (status is PropertyChangeEventR2B)
- {
- OnRceivePropertyChangeEventR2B(status as PropertyChangeEventR2B);
- }
- else if (status is PetDataChangeEventR2B)
- {
- OnReceivePetDataChangeEventR2B(status as PetDataChangeEventR2B);
- }
- else if (status is PetBaseInfoChangeEventR2B)
- {
- OnReceivePetBaseInfoChangeEventR2B(status as PetBaseInfoChangeEventR2B);
- }
- else if (status is PetSkillChangeEventR2B)
- {
- OnReceivePetSkillChangeEventR2B(status as PetSkillChangeEventR2B);
- }
- else if (status is TeamInventorySizeChangeEventR2B)
- {
- OnReceiveTeamInventorySizeChangeEventR2B(status as TeamInventorySizeChangeEventR2B);
- }
- else if (status is PetPropertyChangeEventR2B)
- {
- OnReceivePetPropertyChangeEventR2B(status as PetPropertyChangeEventR2B);
- }
- else if (status is PetFollowModeChangeEventR2B)
- {
- OnReceivePetFollowModeChangeEventR2B(status as PetFollowModeChangeEventR2B);
- }
- }
- /// <summary>
- /// 基础属性变更.
- /// </summary>
- private void OnPlayerBaseInfoChanged(XmdsUnitBaseInfoEventB2C evt)
- {
- if (evt != null && evt.Props != null)
- {
- FormatLog("OnPlayerBaseInfoChanged", null);
- //重置基础信息.
- InitBaseInfo(evt.Props);
- SyncPlayerVisibleData();
- //广播级事件统一由游戏服转给客户端广播.
- this.mUnit.queueEvent(evt);
- }
- else
- {
- FormatLog("OnPlayerBaseInfoChanged Error :XmdsUnitBaseInfoEventB2C.Props is null", null);
- }
- }
- /// <summary>
- /// 重生通知.
- /// </summary>
- private void OnReceivePlayerRebirthOrder(PlayerRebirthEventR2B msg)
- {
- FormatLog("OnReceivePlayerRebirthOrder", null);
- if (this.mUnit.IsDead() == true)
- {
- //Console.WriteLine(" ------- 复活------ " + msg.type);
- switch (msg.type)
- {
- case 1://原地复活.
- if(this.mUnit.GetSceneType() >= CommonAI.Data.SceneType.CROSS_SERVER_NEW)
- {
- DoRebirthInStartRegion(msg);
- }
- else
- {
- this.mUnit.startRebirth(msg.HP, msg.MP);
- this.mUnit.queueEvent(msg.Callback);
- }
- break;
- case 2://出生点复活.
- DoRebirthInStartRegion(msg);
- break;
- case 3://复活点复活.
- {
- XmdsServerScene zss = this.mUnit.Parent as XmdsServerScene;
- ZoneRegion ret = zss.GetNearestRebirthRegion(this.mUnit.X, this.mUnit.Y, this.mUnit.Force);
- if (ret == null)
- {
- DoRebirthInStartRegion(msg);
- }
- else
- {
- this.mUnit.transport(ret.X, ret.Y);
- this.mUnit.startRebirth(msg.HP, msg.MP);
- this.mUnit.queueEvent(msg.Callback);
- }
- }
- break;
- case 4://技能复活.
- this.mUnit.startRebirth(msg.HP, msg.MP);
- break;
- case 5://随机复活点复活
- {
- XmdsServerScene zss = this.mUnit.Parent as XmdsServerScene;
- ZoneRegion ret = zss.GetRandomRebirthRegion(this.mUnit.Force);
- if (ret == null)
- {
- DoRebirthInStartRegion(msg);
- }
- else
- {
- this.mUnit.transport(ret.X, ret.Y);
- this.mUnit.startRebirth(msg.HP, msg.MP);
- this.mUnit.queueEvent(msg.Callback);
- }
- }
- break;
- default:
- break;
- }
- }
- }
- private void DoRebirthInStartRegion(PlayerRebirthEventR2B msg)
- {
- EditorScene es = this.mUnit.Parent as EditorScene;
- ZoneRegion zr = es.GetEditStartRegion(this.mUnit.Force);
- if (zr != null)
- {
- this.mUnit.transport(zr.X, zr.Y);
- //log.WarnFormat("无法找到场景ID为{0}阵营为{1}的出生点", es.Data.ID, this.mUnit.Force);
- }
- else
- {
- this.mUnit.transport(mBirthPosX, mBirthPosY);
- }
- this.mUnit.startRebirth(msg.HP, msg.MP);
- this.mUnit.queueEvent(msg.Callback);
- }
- /// <summary>
- /// 援救通知.
- /// </summary>
- private void OnReceivePlayerSaveEventR2B(PlayerSaveEventR2B msg)
- {
- FormatLog("OnReceivePlayerSaveEventR2B", null);
- if (msg.Saver == null || msg.Decedent == null) { return; }
- mUnit_OnPickUnit(msg.Saver, msg.Decedent, msg.SaveTime);
- }
- /// <summary>
- /// 召唤坐骑通知.
- /// </summary>
- private void OnReceivePlayerSummonMountEventR2B(PlayerSummonMountEventR2B evt)
- {
- //((this.mUnit.Parent as XmdsServerScene).mListener as XmdsZoneNode)
- XmdsServerScene scene = this.mUnit.Parent as XmdsServerScene;
-
- FormatLog("OnReceivePlayerSummonMountEventR2B", null);
- //需要判断一些特殊状态.晕眩,变身,战斗中等等.
- if (evt.IsSummonMount == true)
- {
- bool canRiding = scene.Data.canRiding;
- if (!canRiding || this.IsInPVP() || this.IsInPVE())
- {
- return;
- }
-
- //战斗状态下无法上马或处于异常状态下.
- if (IsInDebuffStatus() || IsBusy() || this.mUnit.IsDead())
- {
- SendMsgToClient(CommonAI.XmdsConstConfig.TIPS_CAN_NOT_RIDE);
- return;
- }
- if(this.mUnit.CurrentActionStatus == UnitActionStatus.DaZuo || this.mUnit.CurrentActionStatus == UnitActionStatus.ClearYaoQi
- || this.mUnit.CurrentActionStatus == UnitActionStatus.Pick || this.mUnit.CurrentActionStatus == UnitActionStatus.DaZuoRecoveryAttr)
- {
- this.mUnit.startIdle(true);
- //this.mUnit.SendForceSync();
- }
- //清除与坐骑状态冲突的BUFF.
- ClearSPBuffState();
- }
- this.StartSummonMount(evt.TimeMS, evt.IsSummonMount, "summonmount");
- }
- /// <summary>
- /// 清除与坐骑状态冲突的BUFF(隐身).
- /// </summary>
- private void ClearSPBuffState()
- {
- //取当前所有BUFF,判断如果有隐身BUFF立即解除该BUFF.
- using (var buffList = ListObjectPool<InstanceUnit.BuffState>.AllocAutoRelease())
- {
- InstanceUnit.BuffState bfs = null;
- List<XmdsBuffVirtual> list = null;
- XmdsBuffProperties prop = null;
- BuffTemplate bt = null;
- this.mUnit.GetAllBuffStatus(buffList);
- if (buffList != null && buffList.Count > 0)
- {
- for (int i = 0; i < buffList.Count; i++)
- {
- bfs = buffList[i];
- bt = bfs.Data;
- prop = bt.Properties as XmdsBuffProperties;
- list = prop.GetBuffVirtualList();
- if (list != null && list.Count != 0)
- {
- for (int k = 0; k < list.Count; k++)
- {
- UnitBuff ub = list[k] as UnitBuff;
- if (ub.GetAbilityID() == (int)XmdsBuffProperties.XmdsBuffAbility.Stealth)
- {
- this.mUnit.removeBuff(bt.ID, "summonmount");
- }
- }
- }
- }
- }
- }
- }
- /// <summary>
- /// 收到外观变更.
- /// </summary>
- private void OnReceivePlayerAvatarEventB2C(PlayAvatarEventB2C evt)
- {
- string extData = "";
- foreach (XmdsAvatarInfo temp in evt.AvatarList)
- {
- extData += (temp.PartTag + ", " + temp.FileName + "; ");
- }
- //log.Info("OnReceivePlayAvatarEventB2C: " + this.GetPlayerUUID() + ", " + extData);
- if (evt != null)
- {
- this.mProp.ServerData.AvatarList = evt.AvatarList;
- SyncPlayerVisibleData();
- this.mUnit.queueEvent(evt);
- }
- }
- /// <summary>
- /// 收到同步可用背包格子数量.
- /// </summary>
- /// <param name="evt"></param>
- private void OnReceiveSyncPlayerInventorySizeEventR2B(SyncPlayerInventorySizeEventR2B evt)
- {
- FormatLog("OnReceiveSyncPlayerInventorySizeEventR2B", null);
- SetInventorySize(evt.Size);
- }
- /// <summary>
- /// 单位PK等级变更.
- /// </summary>
- /// <param name="evt"></param>
- private void OnReceivePlayerPKLvChangeEventR2B(PlayerPKLevelChangeEventR2B evt)
- {
- FormatLog("OnReceivePlayerPKLvChangeEventR2B", null);
- this.mProp.ServerData.UnitPKInfo.CurPKLevel = evt.CurPKLv;
- SyncPlayerVisibleData();
- PlayerPKLvChangeEventB2C evtb2c = new PlayerPKLvChangeEventB2C();
- evtb2c.CurLv = evt.CurPKLv;
- this.mUnit.queueEvent(evtb2c);
- }
- /// <summary>
- /// 单位PK模式变更.
- /// </summary>
- /// <param name="evt"></param>
- private void OnReceivePlayerPKModeChangeEventR2B(PlayerPKModeChangeEventR2B evt)
- {
- log.Info("OnReceivePlayerPKLvChangeEventR2B:" + this.mUnit.PlayerUUID + ", " + evt.CurPKMode);
- this.mProp.ServerData.UnitPKInfo.CurPKMode = evt.CurPKMode;
- SyncPlayerVisibleData();
- this.mUnit.queueEvent(new PlayerPKModeChangeEventB2C(this.mUnit.ID, evt.CurPKMode));
- }
- protected virtual void OnReceivePlayerPKValueChangeEventR2B(PlayerPKValueChangeEventR2B evt)
- {
- FormatLog("OnReceivePlayerPKValueChangeEventR2B", null);
- int c = this.mProp.ServerData.UnitPKInfo.CurPKValue + evt.ChangeValue;
- SyncPKValue(c);
- }
- protected virtual void OnRceivePropertyChangeEventR2B(PropertyChangeEventR2B evt)
- {
- FormatLog("OnRceivePropertyChangeOrder", null);
- bool success = false;
- switch (evt.ChangeType)
- {
- case PropertyChangeEventR2B.PropertyChangeType.HP:
- //药水效果加成
- int valueExt = (int)(mProp.ServerData.BaseInfo.potionAddition * evt.ChangeValue);
- evt.ChangeValue = evt.ChangeValue + valueExt;
- if (evt.Duration > 0)
- {
- mHPRecoveryTask.Init(this, evt, true);
- }
- else
- {
- success = AddHP(evt.ChangeValueType, evt.ChangeValue, false);
- }
- break;
- case PropertyChangeEventR2B.PropertyChangeType.NPC:
- {
- bool sendEvent = false;
- //单位未满血满蓝.
- if (this.mUnit.IsDead() == false &&
- ((this.mUnit.CurrentHP != this.mUnit.MaxHP) ||
- (this.mUnit.CurrentMP != this.mUnit.MaxMP)))
- {
- DoCure();
- sendEvent = true;
- }
- //宠物未满血满蓝.
- if (mPet != null && mPet.mUnit.IsDead() == false &&
- ((this.mPet.mUnit.CurrentHP != this.mPet.mUnit.MaxHP) ||
- (this.mPet.mUnit.CurrentMP != this.mPet.mUnit.MaxMP)))
- {
- mPet.DoCure();
- sendEvent = true;
- }
- //召唤物.
- if (mSummonList != null && mSummonList.Count > 0)
- {
- XmdsVirtual_SummonUnit zv = null;
- for (int i = 0; i < mSummonList.Count; i++)
- {
- zv = mSummonList[i];
- if (zv.mUnit.IsDead() == false &&
- ((zv.mUnit.CurrentHP != zv.mUnit.MaxHP ||
- zv.mUnit.CurrentMP != zv.mUnit.MaxMP)))
- {
- sendEvent = true;
- mSummonList[i].DoCure();
- }
- }
- }
- if (sendEvent)
- {
- this.mUnit.queueEvent(new NPCCureEventB2C());
- }
- }
- break;
- default: break;
- }
- }
- private void OnReceivePetDataChangeEventR2B(PetDataChangeEventR2B evt)
- {
- FormatLog("OnReceivePetDataChangeEventR2B", null);
- switch (evt.OpType)
- {
- case PetDataChangeEventR2B.PetDataChangeType.Add:
- ChangePet(evt.Data);
- break;
- case PetDataChangeEventR2B.PetDataChangeType.Delete:
- DismissPet();
- break;
- case PetDataChangeEventR2B.PetDataChangeType.Replace:
- ChangePet(evt.Data);
- break;
- case PetDataChangeEventR2B.PetDataChangeType.Reset:
- UpdatePetData(evt.Data);
- break;
- }
- }
- private void OnReceivePetBaseInfoChangeEventR2B(PetBaseInfoChangeEventR2B evt)
- {
- FormatLog("OnReceivePetBaseInfoChangeEventR2B", null);
- UpdatePetBaseInfo(evt.BaseInfo);
- }
- private void OnReceivePetSkillChangeEventR2B(PetSkillChangeEventR2B evt)
- {
- FormatLog("OnReceivePetSkillChangeEventR2B", null);
- UpdatePetSkillInfo(evt);
- }
- private void OnReceiveTeamInventorySizeChangeEventR2B(TeamInventorySizeChangeEventR2B evt)
- {
- FormatLog("OnReceivePetSkillChangeEventR2B", null);
- this.mProp.ServerData.Prop.CurTeamInventorySize = evt.size;
- }
- private void OnReceivePetPropertyChangeEventR2B(PetPropertyChangeEventR2B evt)
- {
- FormatLog("OnReceivePetPropertyChangeEventR2B", null);
- if (mPet != null)
- {
- mPet.OnRceivePropertyChangeEventR2B(evt.Order);
- }
- }
- private void OnReceivePetFollowModeChangeEventR2B(PetFollowModeChangeEventR2B evt)
- {
- FormatLog("OnReceivePetFollowModeChangeEventR2B", null);
- if (mPet != null)
- {
- mPet.OnReceivePetFollowModeChangeEventR2B(evt);
- }
- }
-
- #endregion
- }
- }
|