diff options
Diffstat (limited to 'Client/Assets/Scripts/XMainClient/XInput.cs')
-rw-r--r-- | Client/Assets/Scripts/XMainClient/XInput.cs | 555 |
1 files changed, 555 insertions, 0 deletions
diff --git a/Client/Assets/Scripts/XMainClient/XInput.cs b/Client/Assets/Scripts/XMainClient/XInput.cs new file mode 100644 index 00000000..c3cd7f20 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/XInput.cs @@ -0,0 +1,555 @@ +using System;
+using System.Collections.Generic;
+using UnityEngine;
+using XUtliPoolLib;
+
+namespace XMainClient
+{
+ internal class XInput : XSingleton<XInput>
+ {
+ public bool Freezed
+ {
+ get
+ {
+ return XSingleton<XGesture>.singleton.Freezed && XSingleton<XVirtualTab>.singleton.Freezed;
+ }
+ set
+ {
+ bool flag = XSingleton<XScene>.singleton.bSpectator || value;
+ bool flag2 = flag;
+ if (flag2)
+ {
+ bool flag3 = this._freeze_count == 0;
+ if (flag3)
+ {
+ XSingleton<XGesture>.singleton.Freezed = true;
+ XSingleton<XVirtualTab>.singleton.Freezed = true;
+ XSingleton<XActionSender>.singleton.Empty();
+ }
+ this._freeze_count++;
+ bool flag4 = XSingleton<XGame>.singleton.CurrentStage is XConcreteStage;
+ if (flag4)
+ {
+ XSingleton<XDebug>.singleton.AddLog("Freeze++: ", this._freeze_count.ToString(), null, null, null, null, XDebugColor.XDebug_None);
+ }
+ }
+ else
+ {
+ this._freeze_count--;
+ bool flag5 = this._freeze_count == 0;
+ if (flag5)
+ {
+ XSingleton<XGesture>.singleton.Freezed = false;
+ XSingleton<XVirtualTab>.singleton.Freezed = false;
+ }
+ else
+ {
+ bool flag6 = this._freeze_count < 0;
+ if (flag6)
+ {
+ this._freeze_count = 0;
+ }
+ }
+ bool flag7 = XSingleton<XGame>.singleton.CurrentStage is XConcreteStage;
+ if (flag7)
+ {
+ XSingleton<XDebug>.singleton.AddLog("Freeze--: ", this._freeze_count.ToString(), null, null, null, null, XDebugColor.XDebug_None);
+ }
+ }
+ }
+ }
+
+ public bool HasMove
+ {
+ get
+ {
+ return this._hasMove;
+ }
+ }
+
+ public bool HasEnemy
+ {
+ get
+ {
+ return this._hasEnemy;
+ }
+ }
+
+ public bool HasNpc
+ {
+ get
+ {
+ return this._hasNpc;
+ }
+ }
+
+ public bool HasRole
+ {
+ get
+ {
+ return this._hasRole;
+ }
+ }
+
+ public bool HasDummy
+ {
+ get
+ {
+ return this._hasDummy;
+ }
+ }
+
+ public float LastMoveAt
+ {
+ get
+ {
+ return this._last_move_at;
+ }
+ }
+
+ public float LastEntityAt
+ {
+ get
+ {
+ return this._last_entity_at;
+ }
+ }
+
+ public XEntity LastEnemy
+ {
+ get
+ {
+ return this._last_enemy;
+ }
+ }
+
+ public XEntity LastNpc
+ {
+ get
+ {
+ return this._last_npc;
+ }
+ set
+ {
+ this._last_npc = value;
+ this._hasNpc = (this._last_npc != null);
+ }
+ }
+
+ public XEntity LastRole
+ {
+ get
+ {
+ return this._last_role;
+ }
+ }
+
+ public XEntity LastDummy
+ {
+ get
+ {
+ return this._last_dummy;
+ }
+ }
+
+ public Vector3 LastMovePoint
+ {
+ get
+ {
+ return this._last_move_point;
+ }
+ }
+
+ public Vector3 LastGroundPoint
+ {
+ get
+ {
+ return this._last_ground_point;
+ }
+ }
+
+ public bool IsFxShield
+ {
+ get
+ {
+ return this._ally_fx_shield;
+ }
+ }
+
+ public bool IsMyFxShield
+ {
+ get
+ {
+ return this._my_fx_shield;
+ }
+ }
+
+ private GameObject _45hide = null;
+
+ private XEntity _last_enemy = null;
+
+ private XEntity _last_npc = null;
+
+ private XEntity _last_role = null;
+
+ private XEntity _last_dummy = null;
+
+ private Vector3 _last_move_point = Vector3.zero;
+
+ private Vector3 _last_ground_point = Vector3.zero;
+
+ private float _last_move_at = 0f;
+
+ private float _last_entity_at = 0f;
+
+ private RaycastHit _hit;
+
+ private int _freeze_count = 0;
+
+ private bool _hasMove = false;
+
+ private bool _hasEnemy = false;
+
+ private bool _hasNpc = false;
+
+ private bool _hasRole = false;
+
+ private bool _hasDummy = false;
+
+ private bool _ally_fx_shield = false;
+
+ private bool _mob_shield = false;
+
+ private bool _my_fx_shield = false;
+
+ private XTableAsyncLoader _async_loader = null;
+
+ private XOperationTable _reader = new XOperationTable();
+
+ public override bool Init()
+ {
+ bool flag = this._async_loader == null;
+ if (flag)
+ {
+ this._async_loader = new XTableAsyncLoader();
+ this._async_loader.AddTask("Table/XOperation", this._reader, false);
+ this._async_loader.Execute(null);
+ }
+ bool flag2 = !this._async_loader.IsDone;
+ return !flag2;
+ }
+
+ public override void Uninit()
+ {
+ this._async_loader = null;
+ }
+
+ public void UnFreezed()
+ {
+ bool freezed = this.Freezed;
+ if (freezed)
+ {
+ this._freeze_count = 1;
+ this.Freezed = false;
+ }
+ }
+
+ public void OnEnterScene()
+ {
+ this._45hide = null;
+ this._freeze_count = 0;
+ XSingleton<XVirtualTab>.singleton.OnEnterScene();
+ XSingleton<XGesture>.singleton.OnEnterScene();
+ XSingleton<XGyroscope>.singleton.OnEnterScene();
+ this.UpdateShieldOperation();
+ this.UnFreezed();
+ }
+
+ public void OnLeaveScene()
+ {
+ this._last_npc = null;
+ }
+
+ public void UpdateShieldOperation()
+ {
+ XOptionsDocument specificDocument = XDocuments.GetSpecificDocument<XOptionsDocument>(XOptionsDocument.uuID);
+ bool flag = specificDocument != null;
+ if (flag)
+ {
+ this._ally_fx_shield = (specificDocument.GetValue(XOptionsDefine.OD_Shield_Skill_Fx) != 0);
+ this._mob_shield = (specificDocument.GetValue(XOptionsDefine.OD_Shield_Summon) != 0);
+ this._my_fx_shield = (specificDocument.GetValue(XOptionsDefine.OD_Shield_My_Skill_Fx) != 0);
+ bool flag2 = XSingleton<XEntityMgr>.singleton.Player != null;
+ if (flag2)
+ {
+ List<XEntity> ally = XSingleton<XEntityMgr>.singleton.GetAlly(XSingleton<XEntityMgr>.singleton.Player);
+ for (int i = 0; i < ally.Count; i++)
+ {
+ bool flag3 = ally[i].Skill != null && ally[i].Skill.SkillMobs != null;
+ if (flag3)
+ {
+ for (int j = 0; j < ally[i].Skill.SkillMobs.Count; j++)
+ {
+ ally[i].Skill.SkillMobs[j].MobShield = this.MobShield(ally[i].Skill.SkillMobs[j]);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public void UpdateDefaultCameraOperationByScene()
+ {
+ SceneTable.RowData sceneData = XSingleton<XSceneMgr>.singleton.GetSceneData(XSingleton<XScene>.singleton.SceneID);
+ XOperationTable.RowData rowData = null;
+ XOperationMode operationMode = XSingleton<XOperationData>.singleton.OperationMode;
+ if (operationMode != XOperationMode.X25D)
+ {
+ if (operationMode - XOperationMode.X3D <= 1)
+ {
+ rowData = this._reader.GetByID((int)sceneData.OperationSettings[0]);
+ }
+ }
+ else
+ {
+ rowData = this._reader.GetByID((int)sceneData.OperationSettings[1]);
+ }
+ bool flag = rowData != null;
+ if (flag)
+ {
+ XSingleton<XOperationData>.singleton.CameraAngle = rowData.Angle;
+ XSingleton<XOperationData>.singleton.CameraDistance = rowData.Distance;
+ XSingleton<XOperationData>.singleton.AllowVertical = rowData.Vertical;
+ XSingleton<XOperationData>.singleton.AllowHorizontal = rowData.Horizontal;
+ XSingleton<XOperationData>.singleton.MaxVertical = rowData.MaxV;
+ XSingleton<XOperationData>.singleton.MinVertical = rowData.MinV;
+ XSingleton<XOperationData>.singleton.OffSolo = rowData.OffSolo;
+ }
+ }
+
+ public bool FxShield(XEntity e)
+ {
+ return (this._ally_fx_shield && e != null && !e.IsPlayer && XSingleton<XEntityMgr>.singleton.IsAlly(e)) || (this._my_fx_shield && e != null && e.IsPlayer);
+ }
+
+ public bool MobShield(XEntity e)
+ {
+ return this._mob_shield && e != null && e.MobbedBy != null && !e.MobbedBy.IsPlayer && e.MobShieldable && XSingleton<XEntityMgr>.singleton.IsAlly(e);
+ }
+
+ public bool UpdateOperationMode()
+ {
+ bool isPlaying = XSingleton<XCutScene>.singleton.IsPlaying;
+ bool result;
+ if (isPlaying)
+ {
+ XSingleton<XDebug>.singleton.AddErrorLog("Cannot change operation mode during cut-scene playing!", null, null, null, null, null);
+ result = false;
+ }
+ else
+ {
+ bool flag = XSingleton<XGame>.singleton.CurrentStage is XConcreteStage;
+ if (flag)
+ {
+ this.InnerOperationModeUpdate();
+ result = true;
+ }
+ else
+ {
+ result = false;
+ }
+ }
+ return result;
+ }
+
+ private void InnerOperationModeUpdate()
+ {
+ XSingleton<XGyroscope>.singleton.Cancel();
+ XSingleton<XGesture>.singleton.Cancel();
+ XOperationMode operationMode = XSingleton<XOperationData>.singleton.OperationMode;
+ if (operationMode != XOperationMode.X25D)
+ {
+ if (operationMode - XOperationMode.X3D <= 1)
+ {
+ bool flag = this._45hide == null;
+ if (flag)
+ {
+ this._45hide = GameObject.Find("Scene/45hide");
+ }
+ bool flag2 = this._45hide != null && !this._45hide.activeSelf;
+ if (flag2)
+ {
+ this._45hide.SetActive(true);
+ }
+ }
+ }
+ else
+ {
+ bool flag3 = this._45hide == null;
+ if (flag3)
+ {
+ this._45hide = GameObject.Find("Scene/45hide");
+ }
+ bool flag4 = this._45hide != null && this._45hide.activeSelf;
+ if (flag4)
+ {
+ this._45hide.SetActive(false);
+ }
+ }
+ XSingleton<XScene>.singleton.GameCamera.SetSightType();
+ }
+
+ private XEntity HitOnEnemy()
+ {
+ return null;
+ }
+
+ private XEntity HitOnRole()
+ {
+ bool oneUpTouch = XSingleton<XGesture>.singleton.OneUpTouch;
+ if (oneUpTouch)
+ {
+ bool flag = XSingleton<XGame>.singleton.CurrentStage.Stage == EXStage.Hall && XSingleton<XScene>.singleton.GameCamera.UnityCamera != null;
+ if (flag)
+ {
+ Ray ray = XSingleton<XScene>.singleton.GameCamera.UnityCamera.ScreenPointToRay(XSingleton<XGesture>.singleton.TouchPosition);
+ int num = 1 << LayerMask.NameToLayer("Role");
+ bool flag2 = Physics.SphereCast(ray, 0.1f, out this._hit, float.PositiveInfinity, num);
+ if (flag2)
+ {
+ string s = this._hit.collider.gameObject.name.StartsWith("mount_") ? this._hit.collider.gameObject.name.Substring(6) : this._hit.collider.gameObject.name;
+ ulong id = 0UL;
+ bool flag3 = ulong.TryParse(s, out id);
+ if (flag3)
+ {
+ XEntity entity = XSingleton<XEntityMgr>.singleton.GetEntity(id);
+ return (entity != null && entity.IsRole && !entity.IsPlayer) ? entity : null;
+ }
+ return null;
+ }
+ }
+ }
+ return null;
+ }
+
+ private XEntity HitOnDummy()
+ {
+ bool oneUpTouch = XSingleton<XGesture>.singleton.OneUpTouch;
+ if (oneUpTouch)
+ {
+ bool flag = XSingleton<XGame>.singleton.CurrentStage.Stage == EXStage.Hall && XSingleton<XScene>.singleton.GameCamera.UnityCamera != null;
+ if (flag)
+ {
+ Ray ray = XSingleton<XScene>.singleton.GameCamera.UnityCamera.ScreenPointToRay(XSingleton<XGesture>.singleton.TouchPosition);
+ int num = 1 << LayerMask.NameToLayer("Dummy");
+ bool flag2 = Physics.SphereCast(ray, 0.1f, out this._hit, float.PositiveInfinity, num);
+ if (flag2)
+ {
+ ulong id = 0UL;
+ bool flag3 = ulong.TryParse(this._hit.collider.gameObject.name, out id);
+ if (flag3)
+ {
+ XEntity entityConsiderDeath = XSingleton<XEntityMgr>.singleton.GetEntityConsiderDeath(id);
+ return (entityConsiderDeath != null && entityConsiderDeath.IsDummy) ? entityConsiderDeath : null;
+ }
+ return null;
+ }
+ }
+ }
+ return null;
+ }
+
+ private XEntity HitOnNpc()
+ {
+ bool oneUpTouch = XSingleton<XGesture>.singleton.OneUpTouch;
+ if (oneUpTouch)
+ {
+ bool flag = XSingleton<XGame>.singleton.CurrentStage.Stage == EXStage.Hall && XSingleton<XScene>.singleton.GameCamera.UnityCamera != null;
+ if (flag)
+ {
+ Ray ray = XSingleton<XScene>.singleton.GameCamera.UnityCamera.ScreenPointToRay(XSingleton<XGesture>.singleton.TouchPosition);
+ int num = 1 << LayerMask.NameToLayer("Npc");
+ bool flag2 = Physics.SphereCast(ray, 0.1f, out this._hit, float.PositiveInfinity, num);
+ if (flag2)
+ {
+ ulong id = 0UL;
+ bool flag3 = ulong.TryParse(this._hit.collider.gameObject.name, out id);
+ if (flag3)
+ {
+ XEntity entity = XSingleton<XEntityMgr>.singleton.GetEntity(id);
+ return (entity != null && entity.IsNpc) ? entity : null;
+ }
+ return null;
+ }
+ }
+ }
+ return null;
+ }
+
+ private Vector3 HitOnGround()
+ {
+ return Vector3.zero;
+ }
+
+ public void Update()
+ {
+ Vector3 vector = Vector3.zero;
+ this._hasMove = false;
+ this._hasEnemy = false;
+ this._hasNpc = false;
+ this._hasRole = false;
+ this._hasDummy = false;
+ XSingleton<XTouch>.singleton.Update();
+ bool gestured = XSingleton<XGesture>.singleton.Gestured;
+ if (gestured)
+ {
+ XEntity xentity = this.HitOnEnemy();
+ this._hasEnemy = (xentity != null);
+ XEntity xentity2 = this.HitOnNpc();
+ this._hasNpc = (xentity2 != null);
+ bool flag = !this._hasEnemy && !this._hasNpc;
+ if (flag)
+ {
+ xentity2 = this.HitOnRole();
+ this._hasRole = (xentity2 != null);
+ this._last_role = (this._hasRole ? xentity2 : null);
+ bool flag2 = !this._hasRole;
+ if (flag2)
+ {
+ xentity2 = this.HitOnDummy();
+ this._hasDummy = (xentity2 != null);
+ this._last_dummy = (this._hasDummy ? xentity2 : null);
+ bool flag3 = !this._hasDummy;
+ if (flag3)
+ {
+ vector = this.HitOnGround();
+ bool flag4 = vector != Vector3.zero;
+ bool oneTouch = XSingleton<XGesture>.singleton.OneTouch;
+ if (oneTouch)
+ {
+ this._hasMove = flag4;
+ bool hasMove = this._hasMove;
+ if (hasMove)
+ {
+ this._last_move_point = vector;
+ this._last_move_at = Time.time;
+ }
+ }
+ bool flag5 = flag4;
+ if (flag5)
+ {
+ this._last_ground_point = vector;
+ }
+ }
+ }
+ }
+ else
+ {
+ this._last_enemy = xentity;
+ this._last_npc = xentity2;
+ this._last_entity_at = Time.time;
+ }
+ }
+ }
+ }
+}
|