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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
|
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="DemoHubManager.cs" company="Exit Games GmbH">
// Part of: Photon Unity Demos
// </copyright>
// <summary>
// Used as starting point to let developer choose amongst all demos available.
// </summary>
// <author>developer@exitgames.com</author>
// --------------------------------------------------------------------------------------------------------------------
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using System.Collections.Generic;
using Photon.Pun.Demo.Cockpit;
namespace Photon.Pun.Demo.Hub
{
public class DemoHubManager : MonoBehaviour {
public Text TitleText;
public Text DescriptionText;
public GameObject OpenSceneButton;
public GameObject OpenTutorialLinkButton;
public GameObject OpenDocLinkButton;
string MainDemoWebLink = "https://doc.photonengine.com/en-us/pun/v2/getting-started/pun-intro";
struct DemoData
{
public string Title;
public string Description;
public string Scene;
public string TutorialLink;
public string DocLink;
}
Dictionary<string,DemoData> _data = new Dictionary<string, DemoData>();
string currentSelection;
// Use this for initialization
void Awake () {
PunCockpit.Embedded = false;
OpenSceneButton.SetActive(false);
OpenTutorialLinkButton.SetActive(false);
OpenDocLinkButton.SetActive(false);
// Setup data
_data.Add(
"DemoBoxes",
new DemoData()
{
Title = "Demo Boxes",
Description = "Uses ConnectAndJoinRandom script.\n" +
"(joins a random room or creates one)\n" +
"\n" +
"Instantiates simple prefabs.\n" +
"Synchronizes positions without smoothing.\n" +
"Shows that RPCs target a specific object.",
Scene = "DemoBoxes-Scene"
}
);
_data.Add(
"DemoWorker",
new DemoData()
{
Title = "Demo Worker",
Description = "Joins the default lobby and shows existing rooms.\n" +
"Lets you create or join a room.\n" +
"Instantiates an animated character.\n" +
"Synchronizes position and animation state of character with smoothing.\n" +
"Implements simple in-room Chat via RPC calls.",
Scene = "DemoWorker-Scene"
}
);
_data.Add(
"MovementSmoothing",
new DemoData()
{
Title = "Movement Smoothing",
Description = "Uses ConnectAndJoinRandom script.\n" +
"Shows several basic ways to synchronize positions between controlling client and remote ones.\n" +
"The TransformView is a good default to use.",
Scene = "DemoSynchronization-Scene"
}
);
_data.Add(
"BasicTutorial",
new DemoData()
{
Title = "Basic Tutorial",
Description = "All custom code for connection, player and scene management.\n" +
"Auto synchronization of room levels.\n" +
"Uses PhotonAnimatoView for Animator synch.\n" +
"New Unity UI all around, for Menus and player health HUD.\n" +
"Full step by step tutorial available online.",
Scene = "PunBasics-Launcher" ,
TutorialLink = "https://doc.photonengine.com/en-us/pun/v2/demos-and-tutorials/pun-basics-tutorial/intro"
}
);
_data.Add(
"OwnershipTransfer",
new DemoData()
{
Title = "Ownership Transfer",
Description = "Shows how to transfer the ownership of a PhotonView.\n" +
"The owner will send position updates of the GameObject.\n" +
"Transfer can be edited per PhotonView and set to Fixed (no transfer), Request (owner has to agree) or Takeover (owner can't object).",
Scene = "DemoChangeOwner-Scene"
}
);
_data.Add(
"PickupTeamsScores",
new DemoData()
{
Title = "Pickup, Teams, Scores",
Description = "Uses ConnectAndJoinRandom script.\n" +
"Implements item pickup with RPCs.\n" +
"Uses Custom Properties for Teams.\n" +
"Counts score per player and team.\n" +
"Uses Player extension methods for easy Custom Property access.",
Scene = "DemoPickup-Scene"
}
);
_data.Add(
"Chat",
new DemoData()
{
Title = "Chat",
Description = "Uses the Chat API.\n" +
"Simple UI.\n" +
"You can enter any User ID.\n" +
"Automatically subscribes some channels.\n" +
"Allows simple commands via text.\n" +
"\n" +
"Requires configuration of Chat App ID in ServerSettings.",
Scene = "DemoChat-Scene",
DocLink = "http://j.mp/2iwQkPJ"
}
);
_data.Add(
"RPGMovement",
new DemoData()
{
Title = "RPG Movement",
Description = "Demonstrates how to use the PhotonTransformView component to synchronize position updates smoothly using inter- and extrapolation.\n" +
"\n" +
"This demo also shows how to setup a Mecanim Animator to update animations automatically based on received position updates (without sending explicit animation updates).",
Scene = "DemoRPGMovement-Scene"
}
);
_data.Add(
"MecanimAnimations",
new DemoData()
{
Title = "Mecanim Animations",
Description = "This demo shows how to use the PhotonAnimatorView component to easily synchronize Mecanim animations.\n" +
"\n" +
"It also demonstrates another feature of the PhotonTransformView component which gives you more control how position updates are inter-/extrapolated by telling the component how fast the object moves and turns using SetSynchronizedValues().",
Scene = "DemoMecanim-Scene"
}
);
_data.Add(
"2DGame",
new DemoData()
{
Title = "2D Game Demo",
Description = "Synchronizes animations, positions and physics in a 2D scene.",
Scene = "Demo2DJumpAndRunWithPhysics-Scene"
}
);
_data.Add(
"FriendsAndAuth",
new DemoData()
{
Title = "Friends & Authentication",
Description = "Shows connect with or without (server-side) authentication.\n" +
"\n" +
"Authentication requires minor server-side setup (in Dashboard).\n" +
"\n" +
"Once connected, you can find (made up) friends.\nJoin a room just to see how that gets visible in friends list.",
Scene = "DemoFriends-Scene"
}
);
_data.Add(
"TurnBasedGame",
new DemoData()
{
Title = "'Rock Paper Scissor' Turn Based Game",
Description = "Demonstrate TurnBased Game Mechanics using PUN.\n" +
"\n" +
"It makes use of the TurnBasedManager Utility Script",
Scene = "DemoRPS-Scene"
}
);
_data.Add(
"Asteroids",
new DemoData()
{
Title = "Asteroids",
Description = "Simple asteroid game based on the Unity learning asset.\n",
Scene = "DemoAsteroids-LobbyScene"
}
);
_data.Add(
"SlotRacer",
new DemoData()
{
Title = "Slot Racer",
Description = "Simple SlotRacing game.\n",
Scene = "SlotCar-Scene"
}
);
_data.Add(
"LoadBalancing",
new DemoData()
{
Title = "Load Balancing",
Description = "Shows how to use the raw LoadBalancing system.\n" +
"\n" +
"This is a simple test scene to connect and join a random room, without using PUN but the actual LoadBalancing api only",
Scene = "DemoLoadBalancing-Scene"
}
);
_data.Add(
"PunCockpit",
new DemoData()
{
Title = "Cockpit",
Description = "Controls most aspect of PUN.\n" +
"Connection, Lobby, Room access, Player control",
Scene = "PunCockpit-Scene"
}
);
}
public void SelectDemo(string Reference)
{
currentSelection = Reference;
TitleText.text = _data[currentSelection].Title;
DescriptionText.text = _data[currentSelection].Description;
OpenSceneButton.SetActive(!string.IsNullOrEmpty(_data[currentSelection].Scene));
OpenTutorialLinkButton.SetActive(!string.IsNullOrEmpty(_data[currentSelection].TutorialLink));
OpenDocLinkButton.SetActive(!string.IsNullOrEmpty(_data[currentSelection].DocLink));
}
public void OpenScene()
{
if (string.IsNullOrEmpty(currentSelection))
{
Debug.LogError("Bad setup, a CurrentSelection is expected at this point");
return;
}
SceneManager.LoadScene(_data[currentSelection].Scene);
}
public void OpenTutorialLink()
{
if (string.IsNullOrEmpty(currentSelection))
{
Debug.LogError("Bad setup, a CurrentSelection is expected at this point");
return;
}
Application.OpenURL(_data[currentSelection].TutorialLink);
}
public void OpenDocLink()
{
if (string.IsNullOrEmpty(currentSelection))
{
Debug.LogError("Bad setup, a CurrentSelection is expected at this point");
return;
}
Application.OpenURL(_data[currentSelection].DocLink);
}
public void OpenMainWebLink()
{
Application.OpenURL(MainDemoWebLink);
}
}
}
|