ManaPlayer.cs 4.0 KB

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