diff options
Diffstat (limited to 'Client/Assets/Scripts/XMainClient/XLevelDoodadMgr.cs')
-rw-r--r-- | Client/Assets/Scripts/XMainClient/XLevelDoodadMgr.cs | 1080 |
1 files changed, 1080 insertions, 0 deletions
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<XLevelDoodadMgr>
+ {
+ private List<XLevelDoodad> _doodads = new List<XLevelDoodad>();
+
+ private GameObject _HpbarRoot = null;
+
+ private List<GameObject> _DropedDoodads = new List<GameObject>();
+
+ private List<uint> _TimerToken = new List<uint>();
+
+ private Dictionary<uint, XSyncDoodadInfo> _NoticeDictionary = new Dictionary<uint, XSyncDoodadInfo>();
+
+ 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<XGameUI>.singleton.HpbarRoot.gameObject;
+ this._DoodadPickCD = (float)XSingleton<XGlobalConfig>.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<DoodadInfo> 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<XLevelSpawnMgr>.singleton.CurrentSpawner.GetWaveDynamicInfo(entity.Wave);
+ int num = waveDynamicInfo._TotalCount - waveDynamicInfo._dieCount;
+ float num2 = 1f / (float)(num + 1);
+ float num3 = XSingleton<XCommon>.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<uint> 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<XTimerMgr>.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<XEntityMgr>.singleton.EntityStatistics.GetByID(doo.templateid);
+ bool flag = byID != null && byID.Type == 1;
+ if (flag)
+ {
+ XEntityPresentation.RowData byPresentID = XSingleton<XEntityMgr>.singleton.EntityInfo.GetByPresentID(byID.PresentID);
+ Vector3 vector = XSingleton<XScene>.singleton.GameCamera.UnityCamera.transform.position - pos;
+ vector.y = 0f;
+ vector.Normalize();
+ float num = float.Parse(XSingleton<XGlobalConfig>.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<XFxMgr>.singleton.CreateFx(array[2], null, true);
+ xfx.Play(pos, Quaternion.identity, Vector3.one, 1f);
+ bool flag6 = doo.id == 1u;
+ if (flag6)
+ {
+ XSingleton<XAudioMgr>.singleton.PlaySoundAt(pos, "Audio/common/Coins");
+ }
+ bool flag7 = !XSingleton<XGame>.singleton.SyncMode && !XSingleton<XLevelFinishMgr>.singleton.IsCurrentLevelFinished;
+ if (flag7)
+ {
+ bool flag8 = (float)array.Length >= 3f;
+ uint num3;
+ if (flag8)
+ {
+ num3 = XSingleton<XTimerMgr>.singleton.SetTimer(float.Parse(array[3]), this._delayGenerateDoodadCb, doo);
+ }
+ else
+ {
+ num3 = XSingleton<XTimerMgr>.singleton.SetTimer(1.5f, this._delayGenerateDoodadCb, doo);
+ }
+ doo.token = num3;
+ this._TimerToken.Add(num3);
+ }
+ return true;
+ }
+ XSingleton<XAudioMgr>.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<XDebug>.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<XEntityMgr>.singleton.Player.BasicTypeID, out text);
+ bool flag4 = equipPrefabModel != "";
+ if (flag4)
+ {
+ location = "Equipments/" + equipPrefabModel;
+ offset = this.GetDoodadOffset(XSingleton<XEntityMgr>.singleton.Player.BasicTypeID, (FashionPosition)fashionConf.EquipPos);
+ ItemList.RowData itemConf = XBagDocument.GetItemConf((int)doo.id);
+ bool flag5 = itemConf == null;
+ if (flag5)
+ {
+ XSingleton<XDebug>.singleton.AddErrorLog("ItemID not exist:" + doo.id, null, null, null, null, null);
+ return false;
+ }
+ name = XSingleton<UiUtility>.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<XGlobalConfig>.singleton.GetValue("DoodadPrefabHead");
+ }
+ else
+ {
+ bool flag8 = equipConf.EquipPos == 7;
+ if (flag8)
+ {
+ text2 = XSingleton<XGlobalConfig>.singleton.GetValue("DoodadPrefabNecklace");
+ }
+ else
+ {
+ bool flag9 = equipConf.EquipPos == 8;
+ if (flag9)
+ {
+ text2 = XSingleton<XGlobalConfig>.singleton.GetValue("DoodadPrefabEarring");
+ }
+ else
+ {
+ bool flag10 = equipConf.EquipPos == 9;
+ if (flag10)
+ {
+ text2 = XSingleton<XGlobalConfig>.singleton.GetValue("DoodadPrefabRing");
+ }
+ else
+ {
+ string text3 = "";
+ text2 = XEquipDocument.GetDefaultEquipModel(XSingleton<XEntityMgr>.singleton.Player.BasicTypeID, (FashionPosition)equipConf.EquipPos, out text3);
+ }
+ }
+ }
+ }
+ bool flag11 = text2 != "";
+ if (flag11)
+ {
+ location = "Equipments/" + text2;
+ offset = this.GetDoodadOffsetEquip(XSingleton<XEntityMgr>.singleton.Player.BasicTypeID, (EquipPosition)equipConf.EquipPos);
+ ItemList.RowData itemConf2 = XBagDocument.GetItemConf((int)doo.id);
+ bool flag12 = itemConf2 == null;
+ if (flag12)
+ {
+ XSingleton<XDebug>.singleton.AddErrorLog("ItemID not exist:" + doo.id, null, null, null, null, null);
+ return false;
+ }
+ name = XSingleton<UiUtility>.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<XDebug>.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<UiUtility>.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<XBuffTemplateManager>.singleton.GetBuffData((int)doo.id, 1);
+ bool flag16 = buffData == null;
+ if (flag16)
+ {
+ XSingleton<XDebug>.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<XDebug>.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<XResourceLoaderMgr>.singleton.CreateFromPrefab(location, true, false) as GameObject);
+ }
+ else
+ {
+ GameObject gameObject2 = XSingleton<XResourceLoaderMgr>.singleton.CreateFromPrefab(location, true, false) as GameObject;
+ bool flag3 = gameObject2 == null;
+ if (flag3)
+ {
+ XSingleton<XDebug>.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<XResourceLoaderMgr>.singleton.CreateFromPrefab("Prefabs/Effects/Default/" + str, true, false) as GameObject);
+ bool flag4 = gameObject == null;
+ if (flag4)
+ {
+ return null;
+ }
+ Transform transform = XSingleton<XCommon>.singleton.FindChildRecursively(gameObject.transform, "zhuangbei");
+ bool flag5 = gameObject2.transform == null || transform == null;
+ if (flag5)
+ {
+ XSingleton<XDebug>.singleton.AddErrorLog("Equip or t = null", null, null, null, null, null);
+ return null;
+ }
+ XSingleton<UiUtility>.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<XDebug>.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<XResourceLoaderMgr>.singleton.CreateFromPrefab(array[2], true, false) as GameObject);
+ bool flag10 = gameObject == null;
+ if (flag10)
+ {
+ return null;
+ }
+ Transform transform2 = XSingleton<XCommon>.singleton.FindChildRecursively(gameObject.transform, "Point_drop01");
+ gameObject2.transform.localRotation = Quaternion.Euler(-90f, 0f, 0f);
+ bool flag11 = gameObject2.transform == null || transform2 == null;
+ if (flag11)
+ {
+ XSingleton<XDebug>.singleton.AddErrorLog("Equip or t = null", null, null, null, null, null);
+ return null;
+ }
+ XSingleton<UiUtility>.singleton.AddChild(transform2, gameObject2.transform);
+ }
+ }
+ }
+ else
+ {
+ gameObject = gameObject2;
+ gameObject2.transform.localPosition = pos;
+ }
+ }
+ }
+ bool flag12 = gameObject == null;
+ if (flag12)
+ {
+ XSingleton<XDebug>.singleton.AddErrorLog("Go = null!", null, null, null, null, null);
+ result = null;
+ }
+ else
+ {
+ float num2 = XSingleton<XScene>.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<XResourceLoaderMgr>.singleton.CreateFromPrefab("UI/Billboard/DoodadBillboard", true, false) as GameObject;
+ bool flag2 = gameObject == null;
+ if (flag2)
+ {
+ XSingleton<XDebug>.singleton.AddErrorLog("Billboard create failed", null, null, null, null, null);
+ result = false;
+ }
+ else
+ {
+ XSingleton<UiUtility>.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<XScene>.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<UiUtility>.singleton.GetItemQualityColor(quality));
+ }
+ else
+ {
+ ixuilabel.SetText(XStringDefineProxy.GetString("RACE_DOODAD_NAME"));
+ }
+ }
+ bool flag5 = XSingleton<XScene>.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<XDebug>.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<XDebug>.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<XDebug>.singleton.AddErrorLog("Doodad billboard create failed", null, null, null, null, null);
+ result = null;
+ }
+ else
+ {
+ XDoodadCreateArgs @event = XEventPool<XDoodadCreateArgs>.GetEvent();
+ @event.doo = doo;
+ @event.Firer = XSingleton<XGame>.singleton.Doc;
+ XSingleton<XEventMgr>.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<XGlobalConfig>.singleton.GetValue("DoodadOffsetHead");
+ break;
+ case FashionPosition.FashionUpperBody:
+ value = XSingleton<XGlobalConfig>.singleton.GetValue("DoodadOffsetUpperBody");
+ break;
+ case FashionPosition.FashionLowerBody:
+ value = XSingleton<XGlobalConfig>.singleton.GetValue("DoodadOffsetLowerBody");
+ break;
+ case FashionPosition.FashionGloves:
+ value = XSingleton<XGlobalConfig>.singleton.GetValue("DoodadOffsetGloves");
+ break;
+ case FashionPosition.FashionBoots:
+ value = XSingleton<XGlobalConfig>.singleton.GetValue("DoodadOffsetBoots");
+ break;
+ case FashionPosition.FashionMainWeapon:
+ value = XSingleton<XGlobalConfig>.singleton.GetValue("DoodadOffsetMainWeapon");
+ break;
+ case FashionPosition.FashionSecondaryWeapon:
+ value = XSingleton<XGlobalConfig>.singleton.GetValue("DoodadOffsetSecWeapon");
+ break;
+ case FashionPosition.FashionWings:
+ value = XSingleton<XGlobalConfig>.singleton.GetValue("DoodadOffsetWing");
+ break;
+ case FashionPosition.FashionTail:
+ value = XSingleton<XGlobalConfig>.singleton.GetValue("DoodadOffsetTail");
+ break;
+ case FashionPosition.FashionDecal:
+ value = XSingleton<XGlobalConfig>.singleton.GetValue("DoodadOffsetDecal");
+ break;
+ default:
+ value = XSingleton<XGlobalConfig>.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<XGlobalConfig>.singleton.GetValue("DoodadOffsetHead");
+ break;
+ case EquipPosition.Upperbody:
+ value = XSingleton<XGlobalConfig>.singleton.GetValue("DoodadOffsetUpperBody");
+ break;
+ case EquipPosition.Lowerbody:
+ value = XSingleton<XGlobalConfig>.singleton.GetValue("DoodadOffsetLowerBody");
+ break;
+ case EquipPosition.Gloves:
+ value = XSingleton<XGlobalConfig>.singleton.GetValue("DoodadOffsetGloves");
+ break;
+ case EquipPosition.Boots:
+ value = XSingleton<XGlobalConfig>.singleton.GetValue("DoodadOffsetBoots");
+ break;
+ case EquipPosition.Mainweapon:
+ value = XSingleton<XGlobalConfig>.singleton.GetValue("DoodadOffsetMainWeapon");
+ break;
+ case EquipPosition.Secondaryweapon:
+ value = XSingleton<XGlobalConfig>.singleton.GetValue("DoodadOffsetSecWeapon");
+ break;
+ case EquipPosition.Necklace:
+ value = XSingleton<XGlobalConfig>.singleton.GetValue("DoodadOffsetNormal");
+ break;
+ case EquipPosition.Earrings:
+ value = XSingleton<XGlobalConfig>.singleton.GetValue("DoodadOffsetNormal");
+ break;
+ case EquipPosition.Rings:
+ value = XSingleton<XGlobalConfig>.singleton.GetValue("DoodadOffsetNormal");
+ break;
+ default:
+ value = XSingleton<XGlobalConfig>.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<XGame>.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<XDebug>.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<XBuffAddEventArgs>.GetEvent();
+ @event.xBuffDesc.BuffID = (int)xlevelDoodad.id;
+ @event.xBuffDesc.BuffLevel = (int)xlevelDoodad.count;
+ @event.Firer = XSingleton<XEntityMgr>.singleton.Player;
+ @event.xBuffDesc.CasterID = XSingleton<XEntityMgr>.singleton.Player.ID;
+ XSingleton<XEventMgr>.singleton.FireEvent(@event);
+ }
+ bool flag3 = xlevelDoodad.type == XDoodadType.Item;
+ if (flag3)
+ {
+ XHUDDoodadArgs event2 = XEventPool<XHUDDoodadArgs>.GetEvent();
+ event2.itemid = (int)xlevelDoodad.id;
+ event2.count = (int)xlevelDoodad.count;
+ event2.Firer = XSingleton<XEntityMgr>.singleton.Player;
+ XSingleton<XEventMgr>.singleton.FireEvent(event2);
+ }
+ this._OnDoodadPickedSucc(xlevelDoodad, XSingleton<XEntityMgr>.singleton.Player);
+ }
+ }
+
+ protected void _OnDoodadPickedSucc(XLevelDoodad doo, XEntity p)
+ {
+ bool flag = doo.doodad == null;
+ if (!flag)
+ {
+ XDoodadDeleteArgs @event = XEventPool<XDoodadDeleteArgs>.GetEvent();
+ @event.doo = doo;
+ @event.Firer = XSingleton<XGame>.singleton.Doc;
+ XSingleton<XEventMgr>.singleton.FireEvent(@event);
+ doo.picked = true;
+ bool flag2 = doo.type == XDoodadType.Item;
+ if (flag2)
+ {
+ Transform transform = XSingleton<XCommon>.singleton.FindChildRecursively(doo.doodad.transform, "zhuangbei");
+ bool flag3 = transform != null && transform.childCount > 0;
+ if (flag3)
+ {
+ GameObject gameObject = transform.GetChild(0).gameObject;
+ XSingleton<XResourceLoaderMgr>.singleton.UnSafeDestroy(gameObject, true, false);
+ }
+ }
+ XResourceLoaderMgr.SafeDestroy(ref doo.doodad, true);
+ XResourceLoaderMgr.SafeDestroy(ref doo.billboard, true);
+ bool flag4 = p != null;
+ if (flag4)
+ {
+ XSingleton<XFxMgr>.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<XClientNetwork>.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<XHUDDoodadArgs>.GetEvent();
+ @event.itemid = (int)doo.id;
+ @event.count = (int)doo.count;
+ @event.Firer = p;
+ XSingleton<XEventMgr>.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<UiUtility>.singleton.GetItemQualityRGB((int)itemConf.ItemQuality);
+ string arg = string.Format("[{0}]{1}[-]", itemQualityRGB, XSingleton<UiUtility>.singleton.ChooseProfString(itemConf.ItemName, 0u));
+ string text = string.Format(@string, arg);
+ uint num = XSingleton<UiUtility>.singleton.ShowSystemNoticeTip(text);
+ XSingleton<XTimerMgr>.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<UiUtility>.singleton.GetItemQualityRGB((int)itemConf.ItemQuality);
+ string text = string.Format("[{0}]{1}[-]", itemQualityRGB, XSingleton<UiUtility>.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<UiUtility>.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<UiUtility>.singleton.EditSystemNoticeTip(text3, num);
+ }
+ bool flag2 = xsyncDoodadInfo.doo.type == XDoodadType.Item;
+ if (flag2)
+ {
+ XHUDDoodadArgs @event = XEventPool<XHUDDoodadArgs>.GetEvent();
+ @event.itemid = (int)xsyncDoodadInfo.doo.id;
+ @event.count = (int)xsyncDoodadInfo.doo.count;
+ @event.Firer = xsyncDoodadInfo.owner;
+ XSingleton<XEventMgr>.singleton.FireEvent(@event);
+ }
+ }
+
+ public void Update()
+ {
+ XPlayer player = XSingleton<XEntityMgr>.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<XScene>.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<XEntityMgr>.singleton.EntityStatistics.GetByID(info.dropperTemplateID);
+ bool flag = byID != null;
+ if (flag)
+ {
+ bool flag2 = byID.Type == 1;
+ if (flag2)
+ {
+ XSingleton<XTimerMgr>.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<XLevelFinishMgr>.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<GameObject> 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();
+ }
+ }
+}
|