ManaPlayer.cs 3.5 KB

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