ManaPlayer.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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.Diagnostics;
  9. using System.Collections.Generic;
  10. using Transform = UnityEngine.Transform;
  11. public class ManaPlayer : Regist
  12. {
  13. #region 变量
  14. public static bool Complete;
  15. public static string SelePlayer = "PlayerBlond";
  16. public static Transform SeleTra;
  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 (!Complete)
  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. Complete = true;
  39. }
  40. if (!ManaTutorial.TutorialA || ManaTutorial.TutorialIndexA != 1)
  41. {
  42. SelePlayer = ManaData.GetPlayerString("Player");
  43. GetPlayer();
  44. }
  45. else
  46. {
  47. PlayerPink = ManaReso.Get("Player", Folder.Scene, false, ManaReso.Get("PlayerPos3"), false, ObjType.PlayerPink);
  48. PlayerBlond = ManaReso.Get("Player", Folder.Scene, false, ManaReso.Get("PlayerPos2"), false, ObjType.PlayerBlond);
  49. PlayerBrown = ManaReso.Get("Player", Folder.Scene, false, ManaReso.Get("PlayerPos1"), false, ObjType.PlayerBrown);
  50. if (PlayerPink.GetComponent<Player>() == null)
  51. {
  52. PlayerPink.AddScript<Player>().BuildPink();
  53. }
  54. if (PlayerBlond.GetComponent<Player>() == null)
  55. {
  56. PlayerBlond.AddScript<Player>().BuildBlond();
  57. }
  58. if (PlayerBrown.GetComponent<Player>() == null)
  59. {
  60. PlayerBrown.AddScript<Player>().BuildBrown();
  61. }
  62. PlayerPink.localScale = new Vector3(0.8f, 0.8f, 0.8f);
  63. PlayerBlond.localScale = new Vector3(0.8f, 0.8f, 0.8f);
  64. PlayerBrown.localScale = new Vector3(0.8f, 0.8f, 0.8f);
  65. SelePlayer = "PlayerBlond";
  66. SeleTra = PlayerBlond;
  67. }
  68. }
  69. public override void RegistValueA()
  70. {
  71. Instance = this;
  72. }
  73. public void GetPlayer(string type = null)
  74. {
  75. string player;
  76. if (type == null)
  77. {
  78. player = ManaData.GetPlayerString("Player");
  79. }
  80. else
  81. {
  82. player = type;
  83. }
  84. Transform tra = ManaReso.Get("Player", Folder.Scene, false, transform, ManaReso.Get("PlayerPosTra").position, player.ToEnum<ObjType>());
  85. Player = tra.GetComponent<Player>();
  86. if (Player == null)
  87. {
  88. Player = tra.AddScript<Player>();
  89. if (player == "PlayerPink")
  90. {
  91. Player.BuildPink();
  92. }
  93. else if (player == "PlayerBlond")
  94. {
  95. Player.BuildBlond();
  96. }
  97. else if (player == "PlayerBrown")
  98. {
  99. Player.BuildBrown();
  100. }
  101. }
  102. Player.SetAllCollider(true);
  103. tra.localScale = new Vector3(0.5f, 0.5f, 0.5f);
  104. ManaReso.TraDic.Add(tra.name, tra);
  105. }
  106. }