summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/XShowUpComponent.cs
blob: b2c553c9240ef96a7cea9820bad48239118cd1b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
using System;
using XUtliPoolLib;

namespace XMainClient
{
	internal class XShowUpComponent : XComponent
	{
		public override uint ID
		{
			get
			{
				return XShowUpComponent.uuID;
			}
		}

		public XCameraEx ShowCamera
		{
			get
			{
				return this._show_camera;
			}
		}

		public new static readonly uint uuID = XSingleton<XCommon>.singleton.XHash("ShowUp");

		private XCameraEx _show_camera = null;

		private bool _spot_on = false;

		private bool _cast_on = false;

		protected override void EventSubscribe()
		{
			base.RegisterEvent(XEventDefine.XEvent_AttackShowBegin, new XComponent.XEventHandler(this.Begin));
			base.RegisterEvent(XEventDefine.XEvent_AttackShow, new XComponent.XEventHandler(this.Act));
			base.RegisterEvent(XEventDefine.XEvent_AttackShowEnd, new XComponent.XEventHandler(this.ActEnd));
		}

		public override void OnAttachToHost(XObject host)
		{
			base.OnAttachToHost(host);
			this._show_camera = new XCameraEx();
		}

		public override void OnDetachFromHost()
		{
			this._show_camera = null;
			base.OnDetachFromHost();
		}

		public bool Begin(XEventArgs e)
		{
			this._spot_on = true;
			this._cast_on = false;
			XAttackShowBeginArgs xattackShowBeginArgs = e as XAttackShowBeginArgs;
			this._show_camera.PreInstall(xattackShowBeginArgs.XCamera, false);
			XSingleton<XComponentMgr>.singleton.CreateComponent(this._show_camera, XCameraMotionComponent.uuID);
			XSingleton<XComponentMgr>.singleton.CreateComponent(this._show_camera, XCameraShakeComponent.uuID);
			this._show_camera.Installed();
			this._show_camera.Target = this._entity;
			this._show_camera.Root_R_Y = this._entity.EngineObject.Rotation.eulerAngles.y;
			XSingleton<XScene>.singleton.AssociatedCamera = this._show_camera.UnityCamera;
			return true;
		}

		public bool Act(XEventArgs e)
		{
			bool cast_on = this._cast_on;
			if (cast_on)
			{
				this.StopCurrentShow();
			}
			XSingleton<XBulletMgr>.singleton.ClearBullets();
			XAttackShowArgs xattackShowArgs = e as XAttackShowArgs;
			XSkillCore xskillCore = this._entity.SkillMgr.GetSkill(XSingleton<XCommon>.singleton.XHash(xattackShowArgs.name));
			bool flag = xskillCore == null;
			if (flag)
			{
				xskillCore = XSingleton<XSkillFactory>.singleton.Build(this._entity.Present.SkillPrefix, xattackShowArgs.name, this._entity);
			}
			this._entity.SkillMgr.AttachSkill(xskillCore, true);
			XAttackEventArgs @event = XEventPool<XAttackEventArgs>.GetEvent();
			@event.Identify = xskillCore.ID;
			@event.Target = null;
			@event.Demonstration = true;
			@event.AffectCamera = this._show_camera;
			@event.Firer = this._entity;
			XSingleton<XEventMgr>.singleton.FireEvent(@event);
			this._cast_on = true;
			return true;
		}

		public bool ActEnd(XEventArgs e)
		{
			XAttackShowEndArgs xattackShowEndArgs = e as XAttackShowEndArgs;
			bool forceQuit = xattackShowEndArgs.ForceQuit;
			if (forceQuit)
			{
				this.StopCurrentShow();
				this._spot_on = false;
				this._show_camera.Uninitilize();
				XSingleton<XScene>.singleton.AssociatedCamera = XSingleton<XScene>.singleton.GameCamera.UnityCamera;
			}
			else
			{
				bool cast_on = this._cast_on;
				if (cast_on)
				{
					XAttackShowEndArgs @event = XEventPool<XAttackShowEndArgs>.GetEvent();
					@event.Firer = XSingleton<XGame>.singleton.Doc;
					XSingleton<XEventMgr>.singleton.FireEvent(@event);
				}
			}
			this._cast_on = false;
			return true;
		}

		public override void Update(float fDeltaT)
		{
			bool spot_on = this._spot_on;
			if (spot_on)
			{
				this._show_camera.Update(fDeltaT);
			}
		}

		public override void PostUpdate(float fDeltaT)
		{
			bool spot_on = this._spot_on;
			if (spot_on)
			{
				this._show_camera.PostUpdate(fDeltaT);
			}
		}

		private void StopCurrentShow()
		{
			this._cast_on = false;
			this._entity.Skill.EndSkill(true, true);
			XSingleton<XBulletMgr>.singleton.ClearBullets();
		}
	}
}