From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../Assets/Scripts/XMainClient/XLevelDoodadMgr.cs | 1080 ++++++++++++++++++++ 1 file changed, 1080 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/XLevelDoodadMgr.cs (limited to 'Client/Assets/Scripts/XMainClient/XLevelDoodadMgr.cs') diff --git a/Client/Assets/Scripts/XMainClient/XLevelDoodadMgr.cs b/Client/Assets/Scripts/XMainClient/XLevelDoodadMgr.cs new file mode 100644 index 00000000..b06069f1 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/XLevelDoodadMgr.cs @@ -0,0 +1,1080 @@ +using System; +using System.Collections.Generic; +using KKSG; +using UILib; +using UnityEngine; +using XMainClient.UI; +using XUtliPoolLib; + +namespace XMainClient +{ + internal class XLevelDoodadMgr : XSingleton + { + private List _doodads = new List(); + + private GameObject _HpbarRoot = null; + + private List _DropedDoodads = new List(); + + private List _TimerToken = new List(); + + private Dictionary _NoticeDictionary = new Dictionary(); + + private XTimerMgr.ElapsedEventHandler _showRollOverNoticeCb = null; + + private XTimerMgr.ElapsedEventHandler _delayGenerateDoodadCb = null; + + private float _DoodadPickCD = 0f; + + public XLevelDoodadMgr() + { + this._showRollOverNoticeCb = new XTimerMgr.ElapsedEventHandler(this.ShowRollOverNotice); + this._delayGenerateDoodadCb = new XTimerMgr.ElapsedEventHandler(this.DelayGenerateDoodad); + } + + public override bool Init() + { + this._HpbarRoot = XSingleton.singleton.HpbarRoot.gameObject; + this._DoodadPickCD = (float)XSingleton.singleton.GetInt("DoodadPickCD") / 100f; + return true; + } + + public override void Uninit() + { + this._doodads.Clear(); + this._DropedDoodads.Clear(); + this._NoticeDictionary.Clear(); + this._HpbarRoot = null; + } + + public void CacheDoodad(List doodads) + { + bool flag = this._doodads.Count > 0; + if (flag) + { + this.OnClearDoodad(); + } + this._doodads.Clear(); + for (int i = 0; i < doodads.Count; i++) + { + DoodadInfo doodadInfo = doodads[i]; + XLevelDoodad xlevelDoodad = new XLevelDoodad(); + xlevelDoodad.index = (uint)i; + xlevelDoodad.wave = doodadInfo.waveid; + xlevelDoodad.type = (XDoodadType)doodadInfo.type; + xlevelDoodad.id = doodadInfo.id; + xlevelDoodad.count = doodadInfo.count; + xlevelDoodad.dropped = false; + xlevelDoodad.picked = false; + xlevelDoodad.lastPickTime = 0f; + this._doodads.Add(xlevelDoodad); + } + } + + public void OnMonsterDie(XEntity entity) + { + XLevelDoodad xlevelDoodad = this.FindWave(entity.Wave); + bool flag = xlevelDoodad == null; + if (!flag) + { + bool dropped = xlevelDoodad.dropped; + if (!dropped) + { + XLevelDynamicInfo waveDynamicInfo = XSingleton.singleton.CurrentSpawner.GetWaveDynamicInfo(entity.Wave); + int num = waveDynamicInfo._TotalCount - waveDynamicInfo._dieCount; + float num2 = 1f / (float)(num + 1); + float num3 = XSingleton.singleton.RandomFloat(0f, 1f); + bool flag2 = num3 <= num2; + if (flag2) + { + xlevelDoodad.dropped = true; + xlevelDoodad.pos = entity.EngineObject.Position; + xlevelDoodad.templateid = entity.Attributes.TypeID; + bool flag3 = entity.IsBoss && xlevelDoodad.id == 1u; + if (flag3) + { + this._doodads.Remove(xlevelDoodad); + } + this.DelayGenerateClientDoodad(xlevelDoodad); + } + } + } + } + + public void ReportServerList(List l) + { + l.Clear(); + for (int i = 0; i < this._doodads.Count; i++) + { + bool picked = this._doodads[i].picked; + if (picked) + { + l.Add((uint)this._doodads[i].wave); + } + } + } + + public void OnLeaveScene() + { + for (int i = 0; i < this._doodads.Count; i++) + { + bool flag = this._doodads[i].dropped && !this._doodads[i].picked; + if (flag) + { + bool flag2 = this._doodads[i].doodad != null; + if (flag2) + { + XResourceLoaderMgr.SafeDestroy(ref this._doodads[i].doodad, true); + } + bool flag3 = this._doodads[i].billboard != null; + if (flag3) + { + XResourceLoaderMgr.SafeDestroy(ref this._doodads[i].billboard, true); + } + } + } + this._doodads.Clear(); + this._NoticeDictionary.Clear(); + } + + public void OnClearDoodad() + { + for (int i = 0; i < this._TimerToken.Count; i++) + { + XSingleton.singleton.KillTimer(this._TimerToken[i]); + } + this._TimerToken.Clear(); + for (int j = 0; j < this._doodads.Count; j++) + { + bool flag = this._doodads[j].dropped && !this._doodads[j].picked; + if (flag) + { + bool flag2 = this._doodads[j].doodad != null; + if (flag2) + { + XResourceLoaderMgr.SafeDestroy(ref this._doodads[j].doodad, true); + } + bool flag3 = this._doodads[j].billboard != null; + if (flag3) + { + XResourceLoaderMgr.SafeDestroy(ref this._doodads[j].billboard, true); + } + } + } + this._doodads.Clear(); + } + + protected XLevelDoodad FindWave(int wave) + { + for (int i = 0; i < this._doodads.Count; i++) + { + bool flag = this._doodads[i].wave == wave; + if (flag) + { + return this._doodads[i]; + } + } + return null; + } + + protected XLevelDoodad FindWaveByIndex(uint index) + { + for (int i = 0; i < this._doodads.Count; i++) + { + bool flag = this._doodads[i].index == index; + if (flag) + { + return this._doodads[i]; + } + } + return null; + } + + private bool GenerateDoodadFx(XLevelDoodad doo, Vector3 pos) + { + XEntityStatistics.RowData byID = XSingleton.singleton.EntityStatistics.GetByID(doo.templateid); + bool flag = byID != null && byID.Type == 1; + if (flag) + { + XEntityPresentation.RowData byPresentID = XSingleton.singleton.EntityInfo.GetByPresentID(byID.PresentID); + Vector3 vector = XSingleton.singleton.GameCamera.UnityCamera.transform.position - pos; + vector.y = 0f; + vector.Normalize(); + float num = float.Parse(XSingleton.singleton.GetValue("DoodadDist")); + bool flag2 = byPresentID != null; + if (flag2) + { + doo.pos += vector * (num + byPresentID.BoundRadius); + pos += vector * (num + byPresentID.BoundRadius); + } + else + { + doo.pos += vector * num; + pos += vector * num; + } + } + ItemList.RowData itemConf = XBagDocument.GetItemConf((int)doo.id); + bool flag3 = itemConf != null; + if (flag3) + { + string doodadFx = itemConf.DoodadFx; + string[] array = doodadFx.Split(XGlobalConfig.ListSeparator); + bool flag4 = array.Length > 1; + if (flag4) + { + int num2 = int.Parse(array[0]); + bool flag5 = num2 == 0; + if (flag5) + { + XFx xfx = XSingleton.singleton.CreateFx(array[2], null, true); + xfx.Play(pos, Quaternion.identity, Vector3.one, 1f); + bool flag6 = doo.id == 1u; + if (flag6) + { + XSingleton.singleton.PlaySoundAt(pos, "Audio/common/Coins"); + } + bool flag7 = !XSingleton.singleton.SyncMode && !XSingleton.singleton.IsCurrentLevelFinished; + if (flag7) + { + bool flag8 = (float)array.Length >= 3f; + uint num3; + if (flag8) + { + num3 = XSingleton.singleton.SetTimer(float.Parse(array[3]), this._delayGenerateDoodadCb, doo); + } + else + { + num3 = XSingleton.singleton.SetTimer(1.5f, this._delayGenerateDoodadCb, doo); + } + doo.token = num3; + this._TimerToken.Add(num3); + } + return true; + } + XSingleton.singleton.PlaySoundAt(pos, "Audio/common/Item_Gem"); + return false; + } + } + return false; + } + + private bool GetDoodadInfo(XLevelDoodad doo, ref string location, ref string name, ref Vector3 offset, ref int quality, ref bool isequip) + { + bool flag = doo == null; + bool result; + if (flag) + { + XSingleton.singleton.AddErrorLog("Doo is null!", null, null, null, null, null); + result = false; + } + else + { + bool flag2 = doo.type == XDoodadType.Item; + if (flag2) + { + FashionList.RowData fashionConf = XBagDocument.GetFashionConf((int)doo.id); + bool flag3 = fashionConf != null; + if (flag3) + { + string text = ""; + string equipPrefabModel = XEquipDocument.GetEquipPrefabModel(fashionConf, XSingleton.singleton.Player.BasicTypeID, out text); + bool flag4 = equipPrefabModel != ""; + if (flag4) + { + location = "Equipments/" + equipPrefabModel; + offset = this.GetDoodadOffset(XSingleton.singleton.Player.BasicTypeID, (FashionPosition)fashionConf.EquipPos); + ItemList.RowData itemConf = XBagDocument.GetItemConf((int)doo.id); + bool flag5 = itemConf == null; + if (flag5) + { + XSingleton.singleton.AddErrorLog("ItemID not exist:" + doo.id, null, null, null, null, null); + return false; + } + name = XSingleton.singleton.ChooseProfString(itemConf.ItemName, 0u); + quality = (int)itemConf.ItemQuality; + } + } + else + { + EquipList.RowData equipConf = XBagDocument.GetEquipConf((int)doo.id); + bool flag6 = equipConf != null; + if (flag6) + { + bool flag7 = equipConf.EquipPos == 0; + string text2; + if (flag7) + { + text2 = XSingleton.singleton.GetValue("DoodadPrefabHead"); + } + else + { + bool flag8 = equipConf.EquipPos == 7; + if (flag8) + { + text2 = XSingleton.singleton.GetValue("DoodadPrefabNecklace"); + } + else + { + bool flag9 = equipConf.EquipPos == 8; + if (flag9) + { + text2 = XSingleton.singleton.GetValue("DoodadPrefabEarring"); + } + else + { + bool flag10 = equipConf.EquipPos == 9; + if (flag10) + { + text2 = XSingleton.singleton.GetValue("DoodadPrefabRing"); + } + else + { + string text3 = ""; + text2 = XEquipDocument.GetDefaultEquipModel(XSingleton.singleton.Player.BasicTypeID, (FashionPosition)equipConf.EquipPos, out text3); + } + } + } + } + bool flag11 = text2 != ""; + if (flag11) + { + location = "Equipments/" + text2; + offset = this.GetDoodadOffsetEquip(XSingleton.singleton.Player.BasicTypeID, (EquipPosition)equipConf.EquipPos); + ItemList.RowData itemConf2 = XBagDocument.GetItemConf((int)doo.id); + bool flag12 = itemConf2 == null; + if (flag12) + { + XSingleton.singleton.AddErrorLog("ItemID not exist:" + doo.id, null, null, null, null, null); + return false; + } + name = XSingleton.singleton.ChooseProfString(itemConf2.ItemName, 0u); + quality = (int)itemConf2.ItemQuality; + isequip = true; + } + } + else + { + ItemList.RowData itemConf3 = XBagDocument.GetItemConf((int)doo.id); + bool flag13 = itemConf3 == null; + if (flag13) + { + XSingleton.singleton.AddErrorLog("ItemID not exist:" + doo.id, null, null, null, null, null); + return false; + } + string[] array = itemConf3.DoodadFx.Split(XGlobalConfig.ListSeparator); + bool flag14 = array.Length < 3; + if (flag14) + { + location = ((array.Length > 1) ? array[1] : array[0]); + name = XSingleton.singleton.ChooseProfString(itemConf3.ItemName, 0u); + quality = (int)itemConf3.ItemQuality; + } + } + } + } + else + { + bool flag15 = doo.type == XDoodadType.Buff || doo.type == XDoodadType.BuffHorse || doo.type == XDoodadType.BuffSkill || doo.type == XDoodadType.BigMeleeItem; + if (flag15) + { + BuffTable.RowData buffData = XSingleton.singleton.GetBuffData((int)doo.id, 1); + bool flag16 = buffData == null; + if (flag16) + { + XSingleton.singleton.AddErrorLog("BuffID not exist:" + doo.id, null, null, null, null, null); + return false; + } + location = buffData.BuffDoodadFx; + name = buffData.BuffName; + quality = -1; + } + } + result = true; + } + return result; + } + + private GameObject GenerateDoodadGO(XLevelDoodad doo, Vector3 pos, string location, bool isequip, int quality, Vector3 offset) + { + bool flag = doo == null; + GameObject result; + if (flag) + { + XSingleton.singleton.AddErrorLog("Doo is null!", null, null, null, null, null); + result = null; + } + else + { + GameObject gameObject = null; + bool flag2 = doo.type == XDoodadType.Buff || doo.type == XDoodadType.BuffHorse || doo.type == XDoodadType.BuffSkill || doo.type == XDoodadType.BigMeleeItem; + if (flag2) + { + gameObject = (XSingleton.singleton.CreateFromPrefab(location, true, false) as GameObject); + } + else + { + GameObject gameObject2 = XSingleton.singleton.CreateFromPrefab(location, true, false) as GameObject; + bool flag3 = gameObject2 == null; + if (flag3) + { + XSingleton.singleton.AddErrorLog("Equip == null", null, null, null, null, null); + return null; + } + if (isequip) + { + string str; + switch (quality) + { + case 3: + str = "Szcs_glow"; + break; + case 4: + str = "Szbz_glow"; + break; + case 5: + str = "Szbh_glow"; + break; + default: + str = "Szty_glow"; + break; + } + gameObject = (XSingleton.singleton.CreateFromPrefab("Prefabs/Effects/Default/" + str, true, false) as GameObject); + bool flag4 = gameObject == null; + if (flag4) + { + return null; + } + Transform transform = XSingleton.singleton.FindChildRecursively(gameObject.transform, "zhuangbei"); + bool flag5 = gameObject2.transform == null || transform == null; + if (flag5) + { + XSingleton.singleton.AddErrorLog("Equip or t = null", null, null, null, null, null); + return null; + } + XSingleton.singleton.AddChild(transform, gameObject2.transform); + gameObject2.transform.localRotation = Quaternion.Euler(-90f, 0f, 0f); + gameObject2.transform.localPosition += offset; + } + else + { + ItemList.RowData itemConf = XBagDocument.GetItemConf((int)doo.id); + bool flag6 = itemConf == null; + if (flag6) + { + XSingleton.singleton.AddErrorLog("Doo.Id not exists : " + (int)doo.id, null, null, null, null, null); + return null; + } + string[] array = itemConf.DoodadFx.Split(XGlobalConfig.ListSeparator); + bool flag7 = array.Length > 1; + if (flag7) + { + int num = int.Parse(array[0]); + bool flag8 = num == 0; + if (flag8) + { + gameObject = gameObject2; + gameObject2.transform.localPosition = pos; + } + else + { + bool flag9 = num == 1; + if (flag9) + { + gameObject = (XSingleton.singleton.CreateFromPrefab(array[2], true, false) as GameObject); + bool flag10 = gameObject == null; + if (flag10) + { + return null; + } + Transform transform2 = XSingleton.singleton.FindChildRecursively(gameObject.transform, "Point_drop01"); + gameObject2.transform.localRotation = Quaternion.Euler(-90f, 0f, 0f); + bool flag11 = gameObject2.transform == null || transform2 == null; + if (flag11) + { + XSingleton.singleton.AddErrorLog("Equip or t = null", null, null, null, null, null); + return null; + } + XSingleton.singleton.AddChild(transform2, gameObject2.transform); + } + } + } + else + { + gameObject = gameObject2; + gameObject2.transform.localPosition = pos; + } + } + } + bool flag12 = gameObject == null; + if (flag12) + { + XSingleton.singleton.AddErrorLog("Go = null!", null, null, null, null, null); + result = null; + } + else + { + float num2 = XSingleton.singleton.TerrainY(pos); + gameObject.transform.position = new Vector3(pos.x, num2 + 0.5f, pos.z); + result = gameObject; + } + } + return result; + } + + private bool AttachDoodadBillboard(XLevelDoodad doo, string name, int quality) + { + bool flag = doo == null; + bool result; + if (flag) + { + result = false; + } + else + { + GameObject gameObject = XSingleton.singleton.CreateFromPrefab("UI/Billboard/DoodadBillboard", true, false) as GameObject; + bool flag2 = gameObject == null; + if (flag2) + { + XSingleton.singleton.AddErrorLog("Billboard create failed", null, null, null, null, null); + result = false; + } + else + { + XSingleton.singleton.AddChild(this._HpbarRoot, gameObject); + gameObject.transform.localScale = new Vector3(0.005f, 0.005f, 0.005f); + doo.billboard = gameObject; + IXUILabel ixuilabel = gameObject.transform.Find("Name").GetComponent("XUILabel") as IXUILabel; + IXUILabelSymbol ixuilabelSymbol = gameObject.transform.Find("Name").GetComponent("XUILabelSymbol") as IXUILabelSymbol; + bool flag3 = ixuilabel != null; + if (flag3) + { + SceneType sceneType = XSingleton.singleton.SceneType; + if (sceneType != SceneType.SCENE_HORSE_RACE && sceneType != SceneType.SCENE_WEEKEND4V4_HORSERACING) + { + bool flag4 = doo.count > 1u; + if (flag4) + { + ixuilabelSymbol.InputText = name + doo.count.ToString(); + } + else + { + ixuilabelSymbol.InputText = name; + } + ixuilabel.SetColor(XSingleton.singleton.GetItemQualityColor(quality)); + } + else + { + ixuilabel.SetText(XStringDefineProxy.GetString("RACE_DOODAD_NAME")); + } + } + bool flag5 = XSingleton.singleton.SceneType == SceneType.SCENE_BATTLEFIELD_FIGHT; + if (flag5) + { + ulong roleid = doo.roleid; + string text = XBattleFieldBattleDocument.Doc.userIdToRole[roleid]; + bool flag6 = text != null; + if (flag6) + { + ixuilabelSymbol.InputText = text + "\n" + ixuilabel.GetText(); + } + } + result = true; + } + } + return result; + } + + private GameObject GenerateDoodadObject(XLevelDoodad doo, Vector3 pos) + { + string text = ""; + string name = ""; + Vector3 zero = Vector3.zero; + int quality = 0; + bool isequip = false; + bool flag = !this.GetDoodadInfo(doo, ref text, ref name, ref zero, ref quality, ref isequip); + GameObject result; + if (flag) + { + XSingleton.singleton.AddErrorLog("doodad info get error", null, null, null, null, null); + result = null; + } + else + { + bool flag2 = text == ""; + if (flag2) + { + result = null; + } + else + { + GameObject gameObject = this.GenerateDoodadGO(doo, pos, text, isequip, quality, zero); + bool flag3 = gameObject == null; + if (flag3) + { + XSingleton.singleton.AddErrorLog("Doodad gameobject create failed", null, null, null, null, null); + result = null; + } + else + { + doo.doodad = gameObject; + doo.pos = pos; + bool flag4 = !this.AttachDoodadBillboard(doo, name, quality); + if (flag4) + { + XSingleton.singleton.AddErrorLog("Doodad billboard create failed", null, null, null, null, null); + result = null; + } + else + { + XDoodadCreateArgs @event = XEventPool.GetEvent(); + @event.doo = doo; + @event.Firer = XSingleton.singleton.Doc; + XSingleton.singleton.FireEvent(@event); + result = gameObject; + } + } + } + } + return result; + } + + private void DelayGenerateClientDoodad(object obj) + { + XLevelDoodad xlevelDoodad = (XLevelDoodad)obj; + this.GenerateDoodad(xlevelDoodad, xlevelDoodad.pos); + } + + protected GameObject GenerateDoodad(XLevelDoodad doo, Vector3 pos) + { + bool flag = this.GenerateDoodadFx(doo, pos); + bool flag2 = flag; + GameObject result; + if (flag2) + { + result = doo.doodad; + } + else + { + result = this.GenerateDoodadObject(doo, pos); + } + return result; + } + + protected Vector3 GetDoodadOffset(uint typeid, FashionPosition pos) + { + string value; + switch (pos) + { + case FashionPosition.FASHION_START: + value = XSingleton.singleton.GetValue("DoodadOffsetHead"); + break; + case FashionPosition.FashionUpperBody: + value = XSingleton.singleton.GetValue("DoodadOffsetUpperBody"); + break; + case FashionPosition.FashionLowerBody: + value = XSingleton.singleton.GetValue("DoodadOffsetLowerBody"); + break; + case FashionPosition.FashionGloves: + value = XSingleton.singleton.GetValue("DoodadOffsetGloves"); + break; + case FashionPosition.FashionBoots: + value = XSingleton.singleton.GetValue("DoodadOffsetBoots"); + break; + case FashionPosition.FashionMainWeapon: + value = XSingleton.singleton.GetValue("DoodadOffsetMainWeapon"); + break; + case FashionPosition.FashionSecondaryWeapon: + value = XSingleton.singleton.GetValue("DoodadOffsetSecWeapon"); + break; + case FashionPosition.FashionWings: + value = XSingleton.singleton.GetValue("DoodadOffsetWing"); + break; + case FashionPosition.FashionTail: + value = XSingleton.singleton.GetValue("DoodadOffsetTail"); + break; + case FashionPosition.FashionDecal: + value = XSingleton.singleton.GetValue("DoodadOffsetDecal"); + break; + default: + value = XSingleton.singleton.GetValue("DoodadOffsetNormal"); + break; + } + string[] array = value.Split(XGlobalConfig.AllSeparators); + float num = float.Parse(array[(int)((typeid - 1u) * 2u)]); + float num2 = float.Parse(array[(int)((typeid - 1u) * 2u + 1u)]); + return new Vector3(num, num2, 0f); + } + + protected Vector3 GetDoodadOffsetEquip(uint typeid, EquipPosition pos) + { + string value; + switch (pos) + { + case EquipPosition.EQUIP_START: + value = XSingleton.singleton.GetValue("DoodadOffsetHead"); + break; + case EquipPosition.Upperbody: + value = XSingleton.singleton.GetValue("DoodadOffsetUpperBody"); + break; + case EquipPosition.Lowerbody: + value = XSingleton.singleton.GetValue("DoodadOffsetLowerBody"); + break; + case EquipPosition.Gloves: + value = XSingleton.singleton.GetValue("DoodadOffsetGloves"); + break; + case EquipPosition.Boots: + value = XSingleton.singleton.GetValue("DoodadOffsetBoots"); + break; + case EquipPosition.Mainweapon: + value = XSingleton.singleton.GetValue("DoodadOffsetMainWeapon"); + break; + case EquipPosition.Secondaryweapon: + value = XSingleton.singleton.GetValue("DoodadOffsetSecWeapon"); + break; + case EquipPosition.Necklace: + value = XSingleton.singleton.GetValue("DoodadOffsetNormal"); + break; + case EquipPosition.Earrings: + value = XSingleton.singleton.GetValue("DoodadOffsetNormal"); + break; + case EquipPosition.Rings: + value = XSingleton.singleton.GetValue("DoodadOffsetNormal"); + break; + default: + value = XSingleton.singleton.GetValue("DoodadOffsetNormal"); + break; + } + string[] array = value.Split(XGlobalConfig.AllSeparators); + float num = float.Parse(array[(int)((typeid - 1u) * 2u)]); + float num2 = float.Parse(array[(int)((typeid - 1u) * 2u + 1u)]); + return new Vector3(num, num2, 0f); + } + + public void OnDoodadPicked(int wave, uint index) + { + bool flag = !XSingleton.singleton.SyncMode; + if (flag) + { + this.OnDoodadPickedSolo(wave, index); + } + else + { + this.OnDoodadPickedSync(wave, index); + } + } + + protected void OnDoodadPickedSolo(int wave, uint index) + { + XLevelDoodad xlevelDoodad = this.FindWaveByIndex(index); + bool flag = xlevelDoodad == null; + if (flag) + { + XSingleton.singleton.AddLog("Pick up some doodad not exists??", null, null, null, null, null, XDebugColor.XDebug_None); + } + else + { + bool flag2 = xlevelDoodad.type == XDoodadType.Buff; + if (flag2) + { + XBuffAddEventArgs @event = XEventPool.GetEvent(); + @event.xBuffDesc.BuffID = (int)xlevelDoodad.id; + @event.xBuffDesc.BuffLevel = (int)xlevelDoodad.count; + @event.Firer = XSingleton.singleton.Player; + @event.xBuffDesc.CasterID = XSingleton.singleton.Player.ID; + XSingleton.singleton.FireEvent(@event); + } + bool flag3 = xlevelDoodad.type == XDoodadType.Item; + if (flag3) + { + XHUDDoodadArgs event2 = XEventPool.GetEvent(); + event2.itemid = (int)xlevelDoodad.id; + event2.count = (int)xlevelDoodad.count; + event2.Firer = XSingleton.singleton.Player; + XSingleton.singleton.FireEvent(event2); + } + this._OnDoodadPickedSucc(xlevelDoodad, XSingleton.singleton.Player); + } + } + + protected void _OnDoodadPickedSucc(XLevelDoodad doo, XEntity p) + { + bool flag = doo.doodad == null; + if (!flag) + { + XDoodadDeleteArgs @event = XEventPool.GetEvent(); + @event.doo = doo; + @event.Firer = XSingleton.singleton.Doc; + XSingleton.singleton.FireEvent(@event); + doo.picked = true; + bool flag2 = doo.type == XDoodadType.Item; + if (flag2) + { + Transform transform = XSingleton.singleton.FindChildRecursively(doo.doodad.transform, "zhuangbei"); + bool flag3 = transform != null && transform.childCount > 0; + if (flag3) + { + GameObject gameObject = transform.GetChild(0).gameObject; + XSingleton.singleton.UnSafeDestroy(gameObject, true, false); + } + } + XResourceLoaderMgr.SafeDestroy(ref doo.doodad, true); + XResourceLoaderMgr.SafeDestroy(ref doo.billboard, true); + bool flag4 = p != null; + if (flag4) + { + XSingleton.singleton.CreateAndPlay("Effects/FX_Particle/Roles/Lzg_Ty/Ty_buff_xishou", p.EngineObject, Vector3.zero, Vector3.one, 1f, true, 5f, true); + } + } + } + + protected void OnDoodadPickedSync(int wave, uint index) + { + XLevelDoodad xlevelDoodad = this.FindWaveByIndex(index); + bool flag = xlevelDoodad == null; + if (!flag) + { + bool flag2 = Time.time - xlevelDoodad.lastPickTime < this._DoodadPickCD; + if (!flag2) + { + xlevelDoodad.lastPickTime = Time.time; + RpcC2G_FetchEnemyDoodadReq rpcC2G_FetchEnemyDoodadReq = new RpcC2G_FetchEnemyDoodadReq(); + rpcC2G_FetchEnemyDoodadReq.oArg.waveid = xlevelDoodad.wave; + rpcC2G_FetchEnemyDoodadReq.oArg.pos = new Vec3(); + rpcC2G_FetchEnemyDoodadReq.oArg.pos.x = xlevelDoodad.pos.x; + rpcC2G_FetchEnemyDoodadReq.oArg.pos.y = xlevelDoodad.pos.y; + rpcC2G_FetchEnemyDoodadReq.oArg.pos.z = xlevelDoodad.pos.z; + rpcC2G_FetchEnemyDoodadReq.oArg.id = xlevelDoodad.id; + rpcC2G_FetchEnemyDoodadReq.oArg.type = (int)xlevelDoodad.type; + rpcC2G_FetchEnemyDoodadReq.oArg.count = xlevelDoodad.count; + rpcC2G_FetchEnemyDoodadReq.oArg.index = xlevelDoodad.index; + XSingleton.singleton.Send(rpcC2G_FetchEnemyDoodadReq); + } + } + } + + public void OnDoodadPickedSyncSucc(uint index, int wave, Vector3 posid, XEntity p, uint maxroll, uint playerroll) + { + XLevelDoodad xlevelDoodad = this.FindWaveByIndex(index); + bool flag = xlevelDoodad == null; + if (!flag) + { + this._OnDoodadPickedSucc(xlevelDoodad, p); + bool flag2 = xlevelDoodad.type == XDoodadType.Item; + if (flag2) + { + this.ShowGetItemNotice(xlevelDoodad, p); + } + } + } + + private void ShowGetItemNotice(XLevelDoodad doo, XEntity p) + { + bool flag = doo.type == XDoodadType.Item; + if (flag) + { + XHUDDoodadArgs @event = XEventPool.GetEvent(); + @event.itemid = (int)doo.id; + @event.count = (int)doo.count; + @event.Firer = p; + XSingleton.singleton.FireEvent(@event); + } + } + + protected void ShowStartRollNotice(XLevelDoodad doo, XEntity p, uint maxroll, uint playerroll) + { + string @string = XStringDefineProxy.GetString("DOODAD_DEPENDING"); + ItemList.RowData itemConf = XBagDocument.GetItemConf((int)doo.id); + string itemQualityRGB = XSingleton.singleton.GetItemQualityRGB((int)itemConf.ItemQuality); + string arg = string.Format("[{0}]{1}[-]", itemQualityRGB, XSingleton.singleton.ChooseProfString(itemConf.ItemName, 0u)); + string text = string.Format(@string, arg); + uint num = XSingleton.singleton.ShowSystemNoticeTip(text); + XSingleton.singleton.SetTimer(1f, this._showRollOverNoticeCb, num); + XSyncDoodadInfo xsyncDoodadInfo = new XSyncDoodadInfo(); + xsyncDoodadInfo.doo = doo; + xsyncDoodadInfo.owner = p; + xsyncDoodadInfo.maxroll = maxroll; + xsyncDoodadInfo.playerroll = playerroll; + this._NoticeDictionary.Add(num, xsyncDoodadInfo); + } + + protected void ShowRollOverNotice(object o) + { + uint num = (uint)o; + XSyncDoodadInfo xsyncDoodadInfo = this._NoticeDictionary[num]; + ItemList.RowData itemConf = XBagDocument.GetItemConf((int)xsyncDoodadInfo.doo.id); + string itemQualityRGB = XSingleton.singleton.GetItemQualityRGB((int)itemConf.ItemQuality); + string text = string.Format("[{0}]{1}[-]", itemQualityRGB, XSingleton.singleton.ChooseProfString(itemConf.ItemName, 0u)); + bool flag = xsyncDoodadInfo.maxroll == xsyncDoodadInfo.playerroll; + if (flag) + { + string @string = XStringDefineProxy.GetString("DOODAD_RESULT_PLAYER"); + string text2 = string.Format(@string, text, xsyncDoodadInfo.maxroll); + XSingleton.singleton.EditSystemNoticeTip(text2, num); + } + else + { + string string2 = XStringDefineProxy.GetString("DOODAD_RESULT"); + string text3 = string.Format(string2, new object[] + { + text, + xsyncDoodadInfo.owner.Name, + xsyncDoodadInfo.maxroll, + xsyncDoodadInfo.playerroll + }); + XSingleton.singleton.EditSystemNoticeTip(text3, num); + } + bool flag2 = xsyncDoodadInfo.doo.type == XDoodadType.Item; + if (flag2) + { + XHUDDoodadArgs @event = XEventPool.GetEvent(); + @event.itemid = (int)xsyncDoodadInfo.doo.id; + @event.count = (int)xsyncDoodadInfo.doo.count; + @event.Firer = xsyncDoodadInfo.owner; + XSingleton.singleton.FireEvent(@event); + } + } + + public void Update() + { + XPlayer player = XSingleton.singleton.Player; + bool flag = !XEntity.ValideEntity(player); + if (!flag) + { + for (int i = 0; i < this._doodads.Count; i++) + { + bool flag2 = this._doodads[i].doodad != null; + if (flag2) + { + bool flag3 = this._doodads[i].billboard != null; + if (flag3) + { + Vector3 position; + position= new Vector3(this._doodads[i].doodad.transform.position.x, this._doodads[i].doodad.transform.position.y + 0.2f, this._doodads[i].doodad.transform.position.z); + this._doodads[i].billboard.transform.position = position; + this._doodads[i].billboard.transform.rotation = XSingleton.singleton.GameCamera.Rotaton; + } + bool flag4 = player != null && this._doodads[i].dropped && !this._doodads[i].picked; + if (flag4) + { + float num = Vector3.Magnitude(player.EngineObject.Position - this._doodads[i].doodad.transform.position); + bool flag5 = num < 1f; + if (flag5) + { + this.OnDoodadPicked(this._doodads[i].wave, this._doodads[i].index); + } + } + } + } + } + } + + public void ReceiveDoodadServerInfo(EnemyDoodadInfo info) + { + XEntityStatistics.RowData byID = XSingleton.singleton.EntityStatistics.GetByID(info.dropperTemplateID); + bool flag = byID != null; + if (flag) + { + bool flag2 = byID.Type == 1; + if (flag2) + { + XSingleton.singleton.SetTimer(0.05f, new XTimerMgr.ElapsedEventHandler(this.GenerateDoodadFromServer), info); + } + else + { + this.GenerateDoodadFromServer(info); + } + } + else + { + this.GenerateDoodadFromServer(info); + } + } + + public void GenerateDoodadFromServer(object obj) + { + EnemyDoodadInfo enemyDoodadInfo = (EnemyDoodadInfo)obj; + XLevelDoodad xlevelDoodad = new XLevelDoodad(); + xlevelDoodad.wave = enemyDoodadInfo.waveid; + Vector3 pos; + pos= new Vector3(enemyDoodadInfo.pos.x, enemyDoodadInfo.pos.y, enemyDoodadInfo.pos.z); + xlevelDoodad.pos = pos; + xlevelDoodad.type = (XDoodadType)enemyDoodadInfo.type; + xlevelDoodad.id = enemyDoodadInfo.id; + xlevelDoodad.count = enemyDoodadInfo.count; + xlevelDoodad.dropped = true; + xlevelDoodad.picked = false; + xlevelDoodad.lastPickTime = 0f; + xlevelDoodad.index = enemyDoodadInfo.index; + xlevelDoodad.token = 0u; + xlevelDoodad.templateid = enemyDoodadInfo.dropperTemplateID; + xlevelDoodad.roleid = enemyDoodadInfo.roleid; + this._doodads.Add(xlevelDoodad); + this.GenerateDoodad(xlevelDoodad, pos); + } + + public void ExternalGenerateDoodad(int doodadid, int type, int waveid, Vector3 pos, uint templateid, uint index, uint count) + { + XLevelDoodad xlevelDoodad = new XLevelDoodad(); + xlevelDoodad.wave = waveid; + xlevelDoodad.pos = pos; + xlevelDoodad.type = (XDoodadType)type; + xlevelDoodad.id = (uint)doodadid; + xlevelDoodad.count = count; + xlevelDoodad.dropped = true; + xlevelDoodad.picked = false; + xlevelDoodad.lastPickTime = 0f; + xlevelDoodad.index = index; + xlevelDoodad.token = 0u; + xlevelDoodad.templateid = templateid; + this._doodads.Add(xlevelDoodad); + this.GenerateDoodad(xlevelDoodad, pos); + } + + public void DelayGenerateDoodad(object obj) + { + bool isCurrentLevelFinished = XSingleton.singleton.IsCurrentLevelFinished; + if (!isCurrentLevelFinished) + { + XLevelDoodad xlevelDoodad = (XLevelDoodad)obj; + bool flag = xlevelDoodad.token > 0u; + if (flag) + { + this._TimerToken.Contains(xlevelDoodad.token); + this._TimerToken.Remove(xlevelDoodad.token); + } + this.GenerateDoodadObject(xlevelDoodad, xlevelDoodad.pos); + } + } + + public List GetDoodadsInScene(XDoodadType type) + { + this._DropedDoodads.Clear(); + for (int i = 0; i < this._doodads.Count; i++) + { + bool flag = this._doodads[i].type == type && this._doodads[i].dropped && !this._doodads[i].picked; + if (flag) + { + this._DropedDoodads.Add(this._doodads[i].doodad); + } + } + return this._DropedDoodads; + } + + public void PickAllDoodad() + { + for (int i = 0; i < this._doodads.Count; i++) + { + bool flag = this._doodads[i].dropped && !this._doodads[i].picked; + if (flag) + { + this.OnDoodadPicked(this._doodads[i].wave, this._doodads[i].index); + } + } + } + + public void OnReconnect() + { + this.OnClearDoodad(); + } + } +} -- cgit v1.1-26-g67d0