SFSPlazaRoomManager.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646
  1. using System;
  2. using UnityEngine;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using LitJson;
  6. using Sfs2X.Core;
  7. using Sfs2X.Entities;
  8. using Sfs2X.Entities.Data;
  9. using Sfs2X.Requests;
  10. using Sfs2X.Entities.Variables;
  11. using UnityEngine.UI;
  12. public class SFSPlazaRoomManager
  13. {
  14. public class PlazaRoomPlayer
  15. {
  16. #region Config
  17. public string NickName;
  18. public Player Player;
  19. public Transform NickNameTransform;
  20. public Transform MessageBox;
  21. public List<TweenRoot> TweenRoots;
  22. #endregion
  23. public PlazaRoomPlayer(Player player, string nickname)
  24. {
  25. Player = player;
  26. TweenRoots = new List<TweenRoot>();
  27. NickNameTransform = ManaReso.Get("NickName", Folder.UI, false, ManaReso.Get("W_HudParent"), false, ObjType.NickName);
  28. HudTarget hudTarget = NickNameTransform.GetComponent<HudTarget>();
  29. if (hudTarget == null)
  30. {
  31. hudTarget = NickNameTransform.AddComponent<HudTarget>();
  32. }
  33. hudTarget.PosTra = Player.ChildDic["NickName"];
  34. hudTarget.SetPosition();
  35. NickName = string.IsNullOrEmpty(nickname) ? Language.GetStr("UI", "未命名") : nickname;
  36. NickNameTransform.GetComponent<Text>().text = NickName;
  37. MessageBox = ManaReso.Get("MessageBox", Folder.UI, false, ManaReso.Get("W_HudParent"), false, ObjType.MessageBox);
  38. MessageBox.GetComponentInChildren<BestfitText>().VerticalMinSize = 12;
  39. MessageBox.GetComponentInChildren<BestfitText>().VerticalMaxSize = 20;
  40. hudTarget = MessageBox.GetComponent<HudTarget>();
  41. if (hudTarget == null)
  42. {
  43. hudTarget = MessageBox.AddComponent<HudTarget>();
  44. }
  45. hudTarget.PosTra = Player.ChildDic["MessageBox"];
  46. MessageBox.CreateTweenCG(0, 1, 0.25f, true, true, Curve.EaseOutQuad).InOrigin = true;
  47. }
  48. public void Save()
  49. {
  50. foreach (var tweenRoot in TweenRoots)
  51. {
  52. tweenRoot.Pause();
  53. }
  54. ManaReso.Save(Player);
  55. ManaReso.Save(NickNameTransform);
  56. ManaReso.Save(MessageBox);
  57. Player.PlayAnim(Player.IdleAnimationName);
  58. }
  59. public bool IsMoving;
  60. public float Speed = 1f;
  61. public Vector3 Destination;
  62. public TweenVec MoveTween;
  63. public void MoveTo(Vector3 destination)
  64. {
  65. if (destination.Equal(Player.transform.position))
  66. {
  67. return;
  68. }
  69. if (destination.x > Player.transform.position.x)
  70. {
  71. Player.Flip(PlayerDirection.Right);
  72. }
  73. else
  74. {
  75. Player.Flip(PlayerDirection.Left);
  76. }
  77. float duration = Mathf.Clamp(Vector3.Magnitude(destination - Player.transform.position) / 1.5f, 0.25f, 10f) / Speed;
  78. MoveTween = Player.transform.CreateTweenVec3D(destination, duration, false, true, true, Curve.EaseOutQuad);
  79. MoveTween.StartForward();
  80. MoveTween.AddEventOnetime(EventType.ForwardFinish, StopMove);
  81. TweenRoots.Add(MoveTween);
  82. IsMoving = true;
  83. Destination = destination;
  84. Player.PlayAnim(Player.WalkAnimationName);
  85. }
  86. public void StopMove()
  87. {
  88. IsMoving = false;
  89. Player.PlayAnim(Player.IdleAnimationName);
  90. }
  91. public float MessgeTime = 3f;
  92. public Coroutine MessgeCoroutine;
  93. public void ShowMessage(string message)
  94. {
  95. if (MessgeCoroutine != null)
  96. {
  97. Auxiliary.Instance.StopCoroutine(MessgeCoroutine);
  98. }
  99. MessageBox.GetChild(0).GetComponent<Text>().text = message;
  100. MessageBox.TweenForCG();
  101. MessgeCoroutine = Auxiliary.Instance.DelayCall(() => { MessageBox.TweenBacCG(); }, MessgeTime);
  102. }
  103. }
  104. #region Variable
  105. public GardenSmartFox GardenSmartFox;
  106. public User SelfUser;
  107. public PlazaRoomPlayer SelfInstance;
  108. public Room CurrentPlazaRoom;
  109. public bool InPlazaRoom
  110. {
  111. get { return CurrentPlazaRoom != null; }
  112. }
  113. public bool EnteringPlazaRoom;
  114. public bool IsBlackMaskFinish;
  115. public RequestStatus JoinRoomStatus = RequestStatus.Pending;
  116. public Dictionary<User, PlazaRoomPlayer> UserInstanceDictionary = new Dictionary<User, PlazaRoomPlayer>();
  117. #endregion
  118. public void OnEnterPlazaRoomButton()
  119. {
  120. IsBlackMaskFinish = false;
  121. EnteringPlazaRoom = true;
  122. ManaReso.Get("B_SignIn0").TweenBacCG();
  123. ManaReso.Get("T_NickName").TweenBacCG();
  124. ManaCenter.SceneSwitchLock = true;
  125. TweenRoot tweenRoot = ManaReso.Get("V_BlackMask").TweenBacCG();
  126. tweenRoot.AddEventOnetime
  127. (
  128. EventType.BackwardFinish, () =>
  129. {
  130. IsBlackMaskFinish = true;
  131. TryEnterPlazaRoom();
  132. }
  133. );
  134. GardenSmartFox.ExecuteAfterCheckConection
  135. (
  136. () =>
  137. {
  138. GardenSmartFox.SFSPlazaRoomManager.JoinRoomStatus = RequestStatus.Pending;
  139. GardenSmartFox.ExtensionManager.PlazaRoomExtension.JoinPlazaRoom();
  140. },
  141. (succeed, baseEvent) =>
  142. {
  143. if (!succeed)
  144. {
  145. GardenSmartFox.SFSPlazaRoomManager.JoinRoomStatus = RequestStatus.Failed;
  146. TryEnterPlazaRoom();
  147. }
  148. },
  149. (succeed, baseEvent) =>
  150. {
  151. if (!succeed)
  152. {
  153. GardenSmartFox.SFSPlazaRoomManager.JoinRoomStatus = RequestStatus.Failed;
  154. TryEnterPlazaRoom();
  155. }
  156. }
  157. );
  158. }
  159. public void TryEnterPlazaRoom()
  160. {
  161. if (!GardenSmartFox.SFSPlazaRoomManager.IsBlackMaskFinish)
  162. {
  163. return;
  164. }
  165. if (!GardenSmartFox.SFSPlazaRoomManager.EnteringPlazaRoom)
  166. {
  167. return;
  168. }
  169. if (GardenSmartFox.SFSPlazaRoomManager.JoinRoomStatus == RequestStatus.Pending)
  170. {
  171. return;
  172. }
  173. if (GardenSmartFox.SFSPlazaRoomManager.JoinRoomStatus == RequestStatus.Failed)
  174. {
  175. QuitPlazaRoom();
  176. Bubble.Show(null, Language.GetStr("UI", "加入房间失败"), null, null, () => { ManaReso.Get("V_BlackMask").TweenForCG();},null,false);
  177. EnteringPlazaRoom = false;
  178. }
  179. else if (GardenSmartFox.SFSPlazaRoomManager.JoinRoomStatus == RequestStatus.Succeed)
  180. {
  181. EnterPlazaRoom();
  182. EnteringPlazaRoom = false;
  183. }
  184. }
  185. private Vector3 PlayerDefaultPosition;
  186. public void EnterPlazaRoom()
  187. {
  188. PlazaRoom.Initialize();
  189. foreach (var kv in UserInstanceDictionary)
  190. {
  191. if (kv.Value.Player.transform.parent == null)
  192. kv.Value.Player.transform.parent = ManaReso.Get("PlazaRoom");
  193. }
  194. ManaGarden.RetrieveAllElf();
  195. GardenSmartFox.SFSPlazaRoomManager.PlazaRoomSky = ManaReso.Get("PlazaRoomSky");
  196. SkyOriginPosition = GardenSmartFox.SFSPlazaRoomManager.PlazaRoomSky.position;
  197. GardenSmartFox.SFSPlazaRoomManager.PlazaRoomCamera = ManaReso.Get<Camera>("MainCamera");
  198. GardenSmartFox.SFSPlazaRoomManager.CameraOriginPosition = GardenSmartFox.SFSPlazaRoomManager.PlazaRoomCamera.transform.position;
  199. //Debug.Log(GardenSmartFox.User.Id);
  200. SelfUser = GardenSmartFox.User;
  201. PlayerDefaultPosition = ManaReso.Get("PlazaRoomDefaultPosition").position;
  202. SelfInstance = InstantiatePlayer(SelfUser, ManaNickName.NickName, PlayerDefaultPosition, PlayerDirection.Left, ManaData.GetDressDataIDs(ManaPlayer.Player));
  203. SelfInstance.Player.transform.position += new Vector3(0, 0, -0.001f);
  204. UserInstanceDictionary.Add(SelfUser, SelfInstance);
  205. SendInstantiateRequset(-1);
  206. GardenSmartFox.SFSPlazaRoomManager.CameraLeftBorder = ManaReso.Get("PlazaRoomCameraLeftBorder").position.x;
  207. GardenSmartFox.SFSPlazaRoomManager.CameraRightBorder = ManaReso.Get("PlazaRoomCameraRightBorder").position.x;
  208. GardenSmartFox.SFSPlazaRoomManager.PlazaRoomCamera.transform.SetX(GardenSmartFox.SFSPlazaRoomManager.CameraLeftBorder);
  209. ManaReso.Get("V_BlackMask").TweenForCG();
  210. ManaReso.SetActive("C_Main2", false);
  211. ManaReso.SetActive("Garden", false);
  212. ManaReso.SetActive("PlazaRoom", true);
  213. ManaReso.SetActive("W_HudParent", true);
  214. ManaReso.SetActive("X_PlazaRoom", true);
  215. }
  216. public void ExitPlazaRoom()
  217. {
  218. QuitPlazaRoom();
  219. TweenRoot tweenRoot = ManaReso.Get("V_BlackMask").TweenBacCG();
  220. tweenRoot.AddEventOnetime
  221. (
  222. EventType.BackwardFinish,
  223. () =>
  224. {
  225. PlazaRoomSky.position = SkyOriginPosition;
  226. PlazaRoomCamera.transform.position = CameraOriginPosition;
  227. ManaReso.SetActive("C_Main2", true);
  228. ManaReso.SetActive("Garden", true);
  229. ManaReso.SetActive("PlazaRoom", false);
  230. ManaReso.SetActive("W_HudParent", false);
  231. ManaReso.SetActive("X_PlazaRoom", false);
  232. ManaReso.Get("V_BlackMask").TweenForCG();
  233. ManaReso.Get("B_SignIn0").TweenForCG();
  234. ManaReso.Get("T_NickName").TweenForCG();
  235. foreach (var kv in UserInstanceDictionary)
  236. {
  237. kv.Value.Save();
  238. }
  239. UserInstanceDictionary = new Dictionary<User, PlazaRoomPlayer>();
  240. }
  241. );
  242. }
  243. public void QuitPlazaRoom()
  244. {
  245. ManaCenter.SceneSwitchLock = false;
  246. GardenSmartFox.SmartFox.Send(new LeaveRoomRequest(CurrentPlazaRoom));
  247. GardenSmartFox.SFSPlazaRoomManager.CurrentPlazaRoom = null;
  248. }
  249. public SFSPlazaRoomManager(GardenSmartFox gardenSmartFox)
  250. {
  251. GardenSmartFox = gardenSmartFox;
  252. GardenSmartFox.ExtensionManager.PlazaRoomExtension.onExitPlazaRoom += OnExitPlazaRoom;
  253. GardenSmartFox.ExtensionManager.PlazaRoomExtension.onJoinPlazaRoom += OnJoinPlazaRoom;
  254. GardenSmartFox.ExtensionManager.PlazaRoomExtension.onUserExitCurrentPlazaRoom += OnUserExitPlazaRoom;
  255. GardenSmartFox.ExtensionManager.PlazaRoomExtension.onUserEnterCurrentPlazaRoom += OnUserEnterPlazaRoom;
  256. GardenSmartFox.ExtensionManager.PlazaRoomExtension.onSynchronize += Synchronize;
  257. GardenSmartFox.ExtensionManager.PlazaRoomExtension.onReceiveExpression += ReceiveExpression;
  258. GardenSmartFox.ExtensionManager.PlazaRoomExtension.onReceivePublicMessage += ReceivePublicMessage;
  259. GardenSmartFox.ExtensionManager.PlazaRoomExtension.onInstantiate += OnInstantiate;
  260. gardenSmartFox.Connector.onConnectionLost += OnConectionLost;
  261. }
  262. public void Update()
  263. {
  264. if (!InPlazaRoom)
  265. return;
  266. if (EnteringPlazaRoom)
  267. return;
  268. //KeepAliveThread();
  269. CameraControllThread();
  270. }
  271. public float KeepAliveTime = 30;
  272. public float KeepAliveTimer;
  273. public void KeepAliveThread()
  274. {
  275. KeepAliveTimer += Time.deltaTime;
  276. if (KeepAliveTimer > KeepAliveTime)
  277. {
  278. KeepAliveTimer = 0;
  279. GardenSmartFox.AddRequest(GardenSmartFox.ConstructCommandParameter(CommandID.KeepAlive.GetHashCode(), new SFSObject(), 0, GardenSmartFox.SFSPlazaRoomManager.CurrentPlazaRoom.Id), RequestType.Immediate);
  280. }
  281. }
  282. public float CameraLeftBorder;
  283. public float CameraRightBorder;
  284. public Vector3 CameraOriginPosition;
  285. public Camera PlazaRoomCamera;
  286. public void CameraControllThread()
  287. {
  288. if (PlazaRoomCamera == null)
  289. {
  290. return;
  291. }
  292. float x;
  293. if (SelfInstance.Player.transform.position.x <= CameraLeftBorder)
  294. {
  295. x = Mathf.Lerp(PlazaRoomCamera.transform.position.x, CameraLeftBorder, Time.deltaTime);
  296. if (SkyTween != null)
  297. SkyTween.Pause();
  298. }
  299. else if (SelfInstance.Player.transform.position.x >= CameraRightBorder)
  300. {
  301. x = Mathf.Lerp(PlazaRoomCamera.transform.position.x, CameraRightBorder, Time.deltaTime);
  302. if (SkyTween != null)
  303. SkyTween.Pause();
  304. }
  305. else
  306. {
  307. x = Mathf.Lerp(PlazaRoomCamera.transform.position.x, SelfInstance.Player.transform.position.x, Time.deltaTime);
  308. }
  309. PlazaRoomCamera.transform.SetX(x);
  310. }
  311. public void MoveTo(Vector3 destination)
  312. {
  313. GardenSmartFoxManager.GardenSmartFox.SFSPlazaRoomManager.SelfInstance.MoveTo(destination);
  314. GardenSmartFoxManager.GardenSmartFox.SFSPlazaRoomManager.SendSynchronizeDestination(destination);
  315. MoveSky(SelfInstance.MoveTween.Duration, SelfInstance.MoveTween.Delta);
  316. }
  317. private float SkyMoveRatio = 0.1f;
  318. private Vector3 SkyOriginPosition;
  319. private TweenRoot SkyTween;
  320. public Transform PlazaRoomSky;
  321. private void MoveSky(float duration, Vector3 offset)
  322. {
  323. offset *= -SkyMoveRatio;
  324. offset.y = 0;
  325. offset.z = 0;
  326. SkyTween = PlazaRoomSky.transform.CreateTweenVecOffset2D(offset, duration, false, true, true, Curve.Linear);
  327. SkyTween.StartForward();
  328. }
  329. public void OnConectionLost(BaseEvent baseEvent)
  330. {
  331. if (InPlazaRoom)
  332. {
  333. OnExitPlazaRoom();
  334. }
  335. }
  336. public void OnExitPlazaRoom()
  337. {
  338. ExitPlazaRoom();
  339. }
  340. public void OnJoinPlazaRoom(Room room)
  341. {
  342. GardenSmartFox.SFSPlazaRoomManager.CurrentPlazaRoom = room;
  343. JoinRoomStatus = RequestStatus.Succeed;
  344. TryEnterPlazaRoom();
  345. }
  346. public void OnUserExitPlazaRoom(User user)
  347. {
  348. UserInstanceDictionary[user].Save();
  349. UserInstanceDictionary.Remove(user);
  350. }
  351. public void OnUserEnterPlazaRoom(User user)
  352. {
  353. SendInstantiateRequset(user);
  354. }
  355. public void Synchronize(User sender, SFSObject parameter)
  356. {
  357. if (!UserInstanceDictionary.ContainsKey(sender))
  358. return;
  359. if (sender.IsItMe)
  360. return;
  361. if (parameter.ContainsKey(DataID.Destination.GetHashString()))
  362. {
  363. Vector3 destination = parameter.GetUtfString(DataID.Destination.GetHashString()).StringToVector();
  364. SynchronizeDestination(destination, sender);
  365. }
  366. if (parameter.ContainsKey(DataID.Close.GetHashString()))
  367. {
  368. List<int> closeIDs = parameter.GetIntArray(DataID.Destination.GetHashString()).ToList();
  369. SynchronizeClose(closeIDs, sender);
  370. }
  371. //Debug.LogWarning(sender.IsItMe + " : " + jsonData.ToJson());
  372. }
  373. public void SynchronizeClose(List<int> closeIDs, User sender)
  374. {
  375. Player player = UserInstanceDictionary[sender].Player;
  376. foreach (var closeID in closeIDs)
  377. {
  378. CloseUnit closeUnit = ManaPlayer.CloseUnitDic[closeID];
  379. player.ChangeClose(closeUnit.BodyPart, closeUnit.ArmatureName);
  380. }
  381. }
  382. public void SynchronizeDestination(Vector3 destination, User sender)
  383. {
  384. UserInstanceDictionary[sender].MoveTo(destination);
  385. }
  386. private float ExpressionDuration = 1;
  387. public void ReceiveExpression(int expressionID, User sender)
  388. {
  389. PlazaRoomPlayer plazaRoomPlayer = UserInstanceDictionary[sender];
  390. string expressionName = Enum.GetName(typeof(ExpressionID), expressionID);
  391. plazaRoomPlayer.Player.ChangeExpression(expressionName, ExpressionDuration);
  392. string message = $"{plazaRoomPlayer.NickName}:\u3000<({expressionName}按钮)>";
  393. ManaInfoBox.Show(InfoCategory.PlazaRoom, message, Mathf.Infinity, ManaReso.LoadSprite("Expression", Folder.Scene));
  394. ManaReso.SetText("X_CurrentInfoLab", message);
  395. }
  396. public void ReceivePublicMessage(string message, User sender)
  397. {
  398. //Debug.Log(sender.Id);
  399. PlazaRoomPlayer plazaRoomPlayer = UserInstanceDictionary[sender];
  400. plazaRoomPlayer.ShowMessage(message);
  401. message = $"{plazaRoomPlayer.NickName}:\u3000{message}";
  402. ManaInfoBox.Show(InfoCategory.PlazaRoom, message, Mathf.Infinity, ManaReso.LoadSprite("Expression", Folder.Scene));
  403. ManaReso.SetText("X_CurrentInfoLab", message);
  404. }
  405. public void OnInstantiate(User user, SFSObject parameter)
  406. {
  407. if (user.IsItMe)
  408. return;
  409. UserInstanceDictionary.Add(user, InstantiatePlayer(user, parameter));
  410. }
  411. public void SendExpression(ExpressionID expressionID)
  412. {
  413. GardenSmartFoxManager.GardenSmartFox.ExtensionManager.PlazaRoomExtension.SendExpression(expressionID);
  414. }
  415. //private string LastPublicMessage;
  416. public bool SendPublicMessage(string message)
  417. {
  418. if (string.IsNullOrEmpty(message))
  419. {
  420. Bubble.Show(null, Language.GetStr("UI", "内容不能为空"));
  421. return false;
  422. }
  423. //else if (LastPublicMessage == message)
  424. //{
  425. // Bubble.Show(null, Language.GetStr("UI", "请勿重复发送"));
  426. // return false;
  427. //}
  428. else
  429. {
  430. //LastPublicMessage = message;
  431. message = StringFilter.GetFilteredString(message);
  432. GardenSmartFoxManager.GardenSmartFox.ExtensionManager.PlazaRoomExtension.SendPublicMessage(message);
  433. //ManaInfoBox.Show(InfoCategory.PlazaRoom, $"{SelfUser.Name} : {message}", 10, ManaReso.LoadSprite("Expression", Folder.Scene));
  434. return true;
  435. }
  436. }
  437. public void SendInstantiateRequset(User receiver)
  438. {
  439. SendInstantiateRequset(receiver.Id);
  440. }
  441. public void SendInstantiateRequset(int receiverID)
  442. {
  443. SFSObject parameter = new SFSObject();
  444. parameter.PutInt(DataID.SenderID.GetHashString(), GardenSmartFox.User.Id);
  445. parameter.PutIntArray(DataID.Close.GetHashString(), ManaData.GetDressDataIDs(SelfInstance.Player).ToArray());
  446. parameter.PutUtfString(DataID.Position.GetHashString(), SelfInstance.Player.transform.position.VectorToString());
  447. parameter.PutInt(DataID.PlayerDirection.GetHashString(), SelfInstance.Player.PlayerDirection.GetHashCode());
  448. parameter.PutUtfString(DataID.NickName.GetHashString(), ManaNickName.NickName);
  449. GardenSmartFox.AddRequest(GardenSmartFox.ConstructCommandParameter(CommandID.Instantiate.GetHashCode(), parameter, receiverID, GardenSmartFox.SFSPlazaRoomManager.CurrentPlazaRoom.Id), RequestType.Immediate);
  450. if (SelfInstance.IsMoving)
  451. {
  452. SendSynchronizeDestination(SelfInstance.Destination);
  453. }
  454. }
  455. public void SendSynchronizeDestination(Vector3 destination)
  456. {
  457. GardenSmartFoxManager.GardenSmartFox.ExtensionManager.PlazaRoomExtension.SendSynchronizeDestination(destination);
  458. }
  459. public PlazaRoomPlayer InstantiatePlayer(User user, string nickName, Vector3 position, PlayerDirection direction, List<int> dressDataIDs)
  460. {
  461. Transform parent = ManaReso.Get("PlazaRoom", false);
  462. Transform tra = ManaReso.Get("Player", Folder.Scene, false, parent, false, ObjType.Player);
  463. Player player = tra.GetComponent<Player>();
  464. if (player == null)
  465. {
  466. player = tra.AddScript<Player>();
  467. player.Build();
  468. }
  469. foreach (var id in dressDataIDs)
  470. {
  471. CloseUnit closeUnit = ManaPlayer.CloseUnitDic[id];
  472. closeUnit.ChangeDress(player);
  473. }
  474. player.SetAllCollider(false);
  475. player.transform.position = position;
  476. player.Flip(direction);
  477. tra.localScale = new Vector3(0.525f, 0.525f, 0.525f);
  478. return new PlazaRoomPlayer(player, nickName);
  479. }
  480. public PlazaRoomPlayer InstantiatePlayer(User user, SFSObject parameter)
  481. {
  482. List<int> dressDatas = ManaData.GetDressDataIDs(parameter);
  483. Vector3 position = parameter.GetUtfString(DataID.Position.GetHashString()).StringToVector();
  484. PlayerDirection direction = (PlayerDirection) parameter.GetInt(DataID.PlayerDirection.GetHashString());
  485. string nickName = parameter.GetUtfString(DataID.NickName.GetHashString());
  486. PlazaRoomPlayer plazaRoomPlayer = InstantiatePlayer(user, nickName, position, direction, dressDatas);
  487. return plazaRoomPlayer;
  488. }
  489. }