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/XReviveDocument.cs | 317 +++++++++++++++++++++ 1 file changed, 317 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/XReviveDocument.cs (limited to 'Client/Assets/Scripts/XMainClient/XReviveDocument.cs') diff --git a/Client/Assets/Scripts/XMainClient/XReviveDocument.cs b/Client/Assets/Scripts/XMainClient/XReviveDocument.cs new file mode 100644 index 00000000..90added7 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/XReviveDocument.cs @@ -0,0 +1,317 @@ +using System; +using KKSG; +using XMainClient.UI; +using XMainClient.UI.UICommon; +using XUtliPoolLib; + +namespace XMainClient +{ + internal class XReviveDocument : XDocComponent + { + public override uint ID + { + get + { + return XReviveDocument.uuID; + } + } + + public bool CanVipRevive + { + get + { + return this._can_vip_revive; + } + } + + public uint VipReviveCount + { + get + { + return this._vip_revive_count; + } + set + { + this._vip_revive_count = value; + } + } + + public string LeaveSceneTip + { + get + { + return this._leave_scene_tip; + } + } + + public string BuffStringTip + { + get + { + return this._buff_string_tip; + } + } + + public uint NormalCostID + { + get + { + bool flag = this._normal_cost_list.Count == 0; + uint result; + if (flag) + { + result = 0u; + } + else + { + bool flag2 = this._revive_cost_time < this._normal_cost_list.Count; + if (flag2) + { + result = this._normal_cost_list[this._revive_cost_time, 0]; + } + else + { + result = this._normal_cost_list[this._normal_cost_list.Count - 1, 0]; + } + } + return result; + } + } + + public uint NormalCostCount + { + get + { + bool flag = this._normal_cost_list.Count == 0; + uint result; + if (flag) + { + result = 0u; + } + else + { + bool flag2 = this._revive_cost_time < this._normal_cost_list.Count; + if (flag2) + { + result = this._normal_cost_list[this._revive_cost_time, 1]; + } + else + { + result = this._normal_cost_list[this._normal_cost_list.Count - 1, 1]; + } + } + return result; + } + } + + public uint SpecialCostID + { + get + { + bool flag = this._special_cost_list.Count == 0; + uint result; + if (flag) + { + result = 0u; + } + else + { + bool flag2 = this._revive_cost_time < this._special_cost_list.Count; + if (flag2) + { + result = this._special_cost_list[this._revive_cost_time, 0]; + } + else + { + result = this._special_cost_list[this._special_cost_list.Count - 1, 0]; + } + } + return result; + } + } + + public uint SpecialCostCount + { + get + { + bool flag = this._special_cost_list.Count == 0; + uint result; + if (flag) + { + result = 0u; + } + else + { + bool flag2 = this._revive_cost_time < this._special_cost_list.Count; + if (flag2) + { + result = this._special_cost_list[this._revive_cost_time, 1]; + } + else + { + result = this._special_cost_list[this._special_cost_list.Count - 1, 1]; + } + } + return result; + } + } + + public int ReviveUsedTime + { + get + { + return this._revive_used_time; + } + } + + public int ReviveMaxTime + { + get + { + return this._revive_max_time; + } + } + + public int ReviveCostTime + { + get + { + return this._revive_cost_time; + } + } + + public new static readonly uint uuID = XSingleton.singleton.XHash("ReviveDocument"); + + private string _leave_scene_tip = ""; + + private string _buff_string_tip = ""; + + private SeqListRef _normal_cost_list; + + private SeqListRef _special_cost_list; + + private int _revive_used_time = 0; + + private int _revive_max_time = 0; + + private int _revive_cost_time = 0; + + private ReviveType _sync_revive_type = ReviveType.ReviveNone; + + private bool _can_vip_revive = false; + + private uint _vip_revive_count = 0u; + + private bool _auto_revive = false; + + private bool _auto_revive_limit = false; + + private float _auto_revive_time = 0f; + + private uint _auto_revive_token = 0u; + + public override void OnEnterSceneFinally() + { + base.OnEnterSceneFinally(); + SceneTable.RowData sceneData = XSingleton.singleton.GetSceneData(XSingleton.singleton.SceneID); + this._leave_scene_tip = XSingleton.singleton.ReplaceReturn(sceneData.LeaveSceneTip); + this._buff_string_tip = XSingleton.singleton.ReplaceReturn(sceneData.ReviveBuffTip); + this._revive_max_time = (int)sceneData.ReviveNumb; + this._revive_used_time = 0; + this._revive_cost_time = 0; + this._normal_cost_list = sceneData.ReviveCost; + this._special_cost_list = sceneData.ReviveMoneyCost; + this._can_vip_revive = (sceneData.CanVIPRevive == 0); + this._vip_revive_count = (uint)sceneData.VipReviveLimit; + this.ResetAutoReviveData(); + } + + public void SetReviveData(int usedtime, int costtime, ReviveType type) + { + this._revive_used_time = usedtime; + this._revive_cost_time = costtime; + this._sync_revive_type = type; + } + + public void SendReviveRpc(ReviveType type) + { + RpcC2G_Revive rpcC2G_Revive = new RpcC2G_Revive(); + rpcC2G_Revive.oArg.type = type; + XSingleton.singleton.Send(rpcC2G_Revive); + } + + public void SendLeaveScene() + { + XSingleton.singleton.SendLevelFailData(); + XSingleton.singleton.ReqLeaveScene(); + } + + public void ResetAutoReviveData() + { + this._auto_revive = false; + this._auto_revive_limit = false; + this._auto_revive_time = 0f; + } + + public void SetAutoReviveData(bool haslimit, float time = 2f) + { + this._auto_revive = true; + this._auto_revive_limit = haslimit; + this._auto_revive_time = time; + } + + public void StartRevive() + { + bool syncMode = XSingleton.singleton.SyncMode; + if (syncMode) + { + ReviveType sync_revive_type = this._sync_revive_type; + if (sync_revive_type - ReviveType.ReviveItem <= 1 || sync_revive_type == ReviveType.ReviveVIP) + { + DlgBase.singleton.SetVisible(true, true); + } + } + else + { + bool auto_revive = this._auto_revive; + if (auto_revive) + { + XSingleton.singleton.KillTimer(this._auto_revive_token); + this._auto_revive_token = XSingleton.singleton.SetTimer(this._auto_revive_time, new XTimerMgr.ElapsedEventHandler(this.SendAutoReviveRpc), null); + } + else + { + DlgBase.singleton.SetVisible(true, true); + } + } + } + + private void SendAutoReviveRpc(object o) + { + RpcC2G_Revive rpcC2G_Revive = new RpcC2G_Revive(); + rpcC2G_Revive.oArg.type = ReviveType.ReviveSprite; + rpcC2G_Revive.oArg.clientinfo = new ClientReviveInfo(); + rpcC2G_Revive.oArg.clientinfo.islimit = this._auto_revive_limit; + XSingleton.singleton.Send(rpcC2G_Revive); + } + + public void ShowSpecialRevive() + { + bool flag = !DlgBase.singleton.IsVisible(); + if (!flag) + { + DlgBase.singleton.ShowSpecialReviveFrame(); + } + } + + protected override void OnReconnected(XReconnectedEventArgs arg) + { + bool auto_revive = this._auto_revive; + if (auto_revive) + { + XSingleton.singleton.KillTimer(this._auto_revive_token); + this.ShowSpecialRevive(); + } + } + } +} -- cgit v1.1-26-g67d0