ManaPlayer.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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. ManaReso.Save(Player);
  27. Instance.GetPlayer();
  28. ManaReso.Get<HudTarget>("C_MiniGame").PosTra = Player.ChildDic["EnterGameTra"];
  29. }
  30. public override void Instantiate()
  31. {
  32. if (!LoadComplete)
  33. {
  34. UnityFactory.factory.LoadDragonBonesData(ManaReso.Load<TextAsset>("stand_ske", Folder.Config));
  35. UnityFactory.factory.LoadDragonBonesData(ManaReso.Load<TextAsset>("Closet_ske", Folder.Config));
  36. UnityFactory.factory.LoadTextureAtlasData(ManaReso.Load<TextAsset>("stand_tex", Folder.Config), "stand_texture");
  37. UnityFactory.factory.LoadTextureAtlasData(ManaReso.Load<TextAsset>("Closet_tex", Folder.Config), "Closet_texture");
  38. LoadComplete = true;
  39. }
  40. if (!ManaTutorial.TutorialA || ManaTutorial.TutorialIndexA != 1)
  41. {
  42. GetPlayer();
  43. }
  44. else
  45. {
  46. PlayerPink = ManaReso.Get("Player", Folder.Scene, false, ManaReso.Get("PlayerPos3"), false, ObjType.PlayerPink);
  47. PlayerBlond = ManaReso.Get("Player", Folder.Scene, false, ManaReso.Get("PlayerPos2"), false, ObjType.PlayerBlond);
  48. PlayerBrown = ManaReso.Get("Player", Folder.Scene, false, ManaReso.Get("PlayerPos1"), false, ObjType.PlayerBrown);
  49. if (PlayerPink.GetComponent<Player>() == null)
  50. {
  51. PlayerPink.AddScript<Player>().BuildPink();
  52. }
  53. if (PlayerBlond.GetComponent<Player>() == null)
  54. {
  55. PlayerBlond.AddScript<Player>().BuildBlond();
  56. }
  57. if (PlayerBrown.GetComponent<Player>() == null)
  58. {
  59. PlayerBrown.AddScript<Player>().BuildBrown();
  60. }
  61. PlayerPink.localScale = new Vector3(0.8f, 0.8f, 0.8f);
  62. PlayerBlond.localScale = new Vector3(0.8f, 0.8f, 0.8f);
  63. PlayerBrown.localScale = new Vector3(0.8f, 0.8f, 0.8f);
  64. SelePlayer = "PlayerBlond";
  65. SelePlayerTra = PlayerBlond;
  66. }
  67. }
  68. public override void RegistValueA()
  69. {
  70. Instance = this;
  71. }
  72. public void GetPlayer(string type = null)
  73. {
  74. string player = Data.GetPlayerString("Player");
  75. if (type == null)
  76. {
  77. player = Data.GetPlayerString("Player");
  78. }
  79. else
  80. {
  81. player = type;
  82. }
  83. Transform tra = ManaReso.Get("Player", Folder.Scene, false, transform, ManaReso.Get("PlayerPosTra").position, player.ToEnum<ObjType>());
  84. Player = tra.GetComponent<Player>();
  85. if (Player == null)
  86. {
  87. Player = tra.AddScript<Player>();
  88. if (player == "PlayerPink")
  89. {
  90. Player.BuildPink();
  91. }
  92. else if (player == "PlayerBlond")
  93. {
  94. Player.BuildBlond();
  95. SelePlayer = player;
  96. }
  97. else if (player == "PlayerBrown")
  98. {
  99. Player.BuildBrown();
  100. }
  101. }
  102. tra.localScale = new Vector3(0.5f, 0.5f, 0.5f);
  103. ManaReso.TraDic.Add(tra.name, tra);
  104. }
  105. }