ManaPlayer.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. using DragonBones;
  2. using UnityEngine;
  3. using UnityEngine.UI;
  4. using System;
  5. using System.Xml;
  6. using System.Text;
  7. using System.Collections;
  8. using System.Collections.Generic;
  9. using System.Diagnostics;
  10. using Transform = UnityEngine.Transform;
  11. public class ManaPlayer : Regist
  12. {
  13. #region 变量
  14. public static bool LoadComplete;
  15. public static string SelePlayer = "PlayerBlond";
  16. public static Transform SelePlayerTra;
  17. public static Player Player;
  18. public static Transform PlayerPink;
  19. public static Transform PlayerBlond;
  20. public static Transform PlayerBrown;
  21. public static ManaPlayer Instance;
  22. #endregion
  23. public static void Reload()
  24. {
  25. ManaReso.TraDic.Remove("Player");
  26. Transform tra = Player.transform;
  27. ManaReso.Save(Player);
  28. Instance.GetPlayer();
  29. ManaReso.Get<HudTarget>("C_MiniGame").PosTra = Player.ChildDic["EnterGameTra"];
  30. if (ManaReso.Contains(tra))
  31. {
  32. Destroy(tra.gameObject);
  33. }
  34. }
  35. public override void Instantiate()
  36. {
  37. if (!LoadComplete)
  38. {
  39. UnityFactory.factory.LoadDragonBonesData(ManaReso.Load<TextAsset>("stand_ske", Folder.Config));
  40. UnityFactory.factory.LoadDragonBonesData(ManaReso.Load<TextAsset>("Closet_ske", Folder.Config));
  41. UnityFactory.factory.LoadTextureAtlasData(ManaReso.Load<TextAsset>("stand_tex", Folder.Config), "stand_texture");
  42. UnityFactory.factory.LoadTextureAtlasData(ManaReso.Load<TextAsset>("Closet_tex", Folder.Config), "Closet_texture");
  43. LoadComplete = true;
  44. }
  45. if (!ManaTutorial.TutorialA || ManaTutorial.TutorialIndexA != 1)
  46. {
  47. GetPlayer();
  48. }
  49. else
  50. {
  51. PlayerPink = ManaReso.Get("Player", Folder.Scene, false, ManaReso.Get("PlayerPos3"), false, ObjType.PlayerPink);
  52. PlayerBlond = ManaReso.Get("Player", Folder.Scene, false, ManaReso.Get("PlayerPos2"), false, ObjType.PlayerBlond);
  53. PlayerBrown = ManaReso.Get("Player", Folder.Scene, false, ManaReso.Get("PlayerPos1"), false, ObjType.PlayerBrown);
  54. if (PlayerPink.GetComponent<Player>() == null)
  55. {
  56. PlayerPink.AddScript<Player>().BuildPink();
  57. }
  58. if (PlayerBlond.GetComponent<Player>() == null)
  59. {
  60. PlayerBlond.AddScript<Player>().BuildBlond();
  61. }
  62. if (PlayerBrown.GetComponent<Player>() == null)
  63. {
  64. PlayerBrown.AddScript<Player>().BuildBrown();
  65. }
  66. PlayerPink.localScale = new Vector3(0.8f, 0.8f, 0.8f);
  67. PlayerBlond.localScale = new Vector3(0.8f, 0.8f, 0.8f);
  68. PlayerBrown.localScale = new Vector3(0.8f, 0.8f, 0.8f);
  69. SelePlayer = "PlayerBlond";
  70. SelePlayerTra = PlayerBlond;
  71. }
  72. }
  73. public override void RegistValueA()
  74. {
  75. Instance = this;
  76. }
  77. public void GetPlayer()
  78. {
  79. string player = Data.GetPlayerString("Player");
  80. Transform tra = ManaReso.Get("Player", Folder.Scene, false, transform, ManaReso.Get("PlayerPosTra").position, player.ToEnum<ObjType>());
  81. Player = tra.GetComponent<Player>();
  82. if (Player == null)
  83. {
  84. Player = tra.AddScript<Player>();
  85. if (player == "PlayerPink")
  86. {
  87. Player.BuildPink();
  88. }
  89. else if (player == "PlayerBlond")
  90. {
  91. Player.BuildBlond();
  92. SelePlayer = player;
  93. }
  94. else if (player == "PlayerBrown")
  95. {
  96. Player.BuildBrown();
  97. }
  98. }
  99. tra.localScale = new Vector3(0.5f, 0.5f, 0.5f);
  100. ManaReso.TraDic.Add(tra.name, tra);
  101. }
  102. }