ConductController.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. using UnityEngine;
  2. using Sirenix.OdinInspector;
  3. using System.Collections.Generic;
  4. using System;
  5. using System.Linq;
  6. public class ConductController : MonoBehaviour
  7. {
  8. //组件
  9. private PlayerController playerController;
  10. //融魂技
  11. public enum ConductSkills
  12. {
  13. //弓箭手
  14. [LabelText("怨气弹")]
  15. AngryBullet,
  16. [LabelText("扇形飞剑")]
  17. FlyingSwords,
  18. //胖子
  19. [LabelText("合成大胖子")]
  20. Giant,
  21. [LabelText("光球")]
  22. Photon,
  23. [LabelText("增加攻击力")]
  24. AddAttack,
  25. //棒子
  26. [LabelText("泰山压顶")]
  27. Mountain,
  28. [LabelText("气功波")]
  29. WavePower,
  30. [LabelText("御剑术")]
  31. SwordsControl,
  32. }
  33. [LabelText("转换率")] public float[] conversionRate;
  34. [LabelText("融魂技")] public ConductSkills[] conductSkills;
  35. [Serializable] public struct Giant
  36. {
  37. public GameObject bigGiant;
  38. [LabelText("临时血量基数")]
  39. public int temptHp;
  40. [LabelText("临时血量持续时间")]
  41. public float temptTime;
  42. }
  43. private bool ShowGiant() => conductSkills.Contains(ConductSkills.Giant);
  44. [ShowIf("ShowGiant")][LabelText("合成大胖子参数")]
  45. public Giant giant;
  46. [Serializable]public struct Photon
  47. {
  48. public GameObject obj;
  49. [LabelText("血量基数")]
  50. public int photosphereHp;
  51. [DisplayOnly] public bool havePhoton;
  52. [HideInInspector] public Photosphere photosphere;
  53. }
  54. private bool ShowPhotosphere() => conductSkills.Contains(ConductSkills.Photon);
  55. [ShowIf("ShowPhotosphere")][LabelText("光球参数")]
  56. public Photon photon;
  57. private void Awake()
  58. {
  59. playerController = GetComponent<PlayerController>();
  60. }
  61. void Start()
  62. {
  63. }
  64. void Update()
  65. {
  66. }
  67. public void Conduct(int demonicId)
  68. {
  69. int boostNum = playerController.demonicDic[demonicId].Count;
  70. int dienum = (int)(boostNum * conversionRate[demonicId] + 0.5f);
  71. if (dienum == 0 && boostNum >= 1)
  72. {
  73. dienum = 1;
  74. }
  75. if (dienum > 0)
  76. {
  77. GameObject obj;
  78. List<int> dieId = new List<int>();
  79. List<Demonic> dieDemonic = new List<Demonic>();
  80. while (dieId.Count < dienum)
  81. {
  82. int id = UnityEngine.Random.Range(0, boostNum);
  83. if (!dieId.Exists(t => t == id))
  84. {
  85. dieId.Add(id);
  86. dieDemonic.Add(playerController.demonicDic[demonicId][id]);
  87. }
  88. }
  89. foreach (Demonic d in dieDemonic)
  90. {
  91. d.ChangeState(CharacterState.Die);
  92. }
  93. switch (conductSkills[demonicId])
  94. {
  95. /*胖子*/
  96. //融合大胖子
  97. case ConductSkills.Giant:
  98. GameObject demonicObj = PoolManager.Instantiate(giant.bigGiant);
  99. demonicObj.SetActive(false);
  100. BigSoldier bs = demonicObj.GetComponent<BigSoldier>();
  101. bs.id = demonicId + 3;
  102. playerController.demonicDic[bs.id].Add(bs);
  103. if (bs.id < 3)
  104. {
  105. playerController.demonicNums[bs.id].text = playerController.demonicDic[bs.id].Count.ToString();
  106. }
  107. int tempthp = boostNum * giant.temptHp;
  108. bs.playerID = playerController.playerId;
  109. demonicObj.transform.parent = null;
  110. demonicObj.transform.localEulerAngles = Vector3.zero;
  111. bs.boostNum = boostNum;
  112. if (playerController.isInSoulTower)
  113. {
  114. playerController.ls.AddDenomic(bs);
  115. }
  116. bs.player = playerController;
  117. bs.Settings();
  118. bs.GetTemptHP(tempthp, giant.temptTime);
  119. int order = bs.baseSortingOrder + playerController.demonicDic[bs.id].Count;
  120. bs.SetSortingOrder(order);
  121. Vector3 offset = playerController.demonicSummonPos[0] * 2;
  122. if (playerController.bodyTrans.localScale.x > 0)
  123. {
  124. demonicObj.transform.position = transform.position + offset;
  125. if (bs.bodyTrans.localScale.x < 0)
  126. {
  127. bs.Turn();
  128. }
  129. }
  130. else
  131. {
  132. demonicObj.transform.position = transform.position + new Vector3(-offset.x, offset.y, offset.z);
  133. if (bs.bodyTrans.localScale.x > 0)
  134. {
  135. bs.Turn();
  136. }
  137. }
  138. demonicObj.SetActive(true);
  139. break;
  140. //光球
  141. case ConductSkills.Photon:
  142. playerController.conductCanRelease[demonicId] = false;
  143. obj = Instantiate(photon.obj, transform);
  144. obj.transform.position = transform.position + Vector3.up;
  145. Photosphere photosphere = obj.GetComponent<Photosphere>();
  146. photosphere.owner = playerController;
  147. photosphere.conductId = demonicId;
  148. photosphere.hp = boostNum * photon.photosphereHp;
  149. photosphere.conductController = this;
  150. photon.photosphere = photosphere;
  151. photon.havePhoton = true;
  152. break;
  153. // case ConductSkills.AddAttack:
  154. // List<Demonic> newGiants = new List<Demonic>();
  155. // foreach (Demonic d in demonicDic[cacheConductId])
  156. // {
  157. // if (!d.isDie)
  158. // {
  159. // newGiants.Add(d);
  160. // if (d.attackController.addAttackEffect == null)
  161. // {
  162. // d.attackController.addAttackEffect = Instantiate(attackEffect, d.bodyTrans.position, new Quaternion(0, 0, 0, 0), d.bodyTrans);
  163. // }
  164. // d.attackController.addAttackEffect.transform.GetChild(0).gameObject.SetActive(true);
  165. // }
  166. // }
  167. // foreach (Demonic d in newGiants)
  168. // {
  169. // int damage = d.attackController.curDamage;
  170. // d.attackController.curDamage += (int)(addRate * boostNum * damage);
  171. // }
  172. // break;
  173. // //气功师
  174. // case ConductSkills.Mountain:
  175. // conductCanRelease[cacheConductId] = false;
  176. // GameObject curMountain = Instantiate(mountain, null);
  177. // Vector3 moffset = mountainOffset;
  178. // Vector3 sc = curMountain.transform.localScale;
  179. // sc.x = largeX * dienum;
  180. // curMountain.transform.localScale = sc;
  181. // if (bodyTrans.localScale.x < 0)
  182. // {
  183. // moffset.x = mountainOffset.x + sc.x / 2;
  184. // }
  185. // else
  186. // {
  187. // moffset.x = -mountainOffset.x - sc.x / 2;
  188. // }
  189. // Mountain MT = curMountain.GetComponent<Mountain>();
  190. // curMountain.transform.position = transform.position + moffset;
  191. // MT.pc = this;
  192. // MT.id = cacheConductId;
  193. // MT.demonicNum = boostNum;
  194. // break;
  195. // case ConductSkills.WavePower:
  196. // rb.constraints = RigidbodyConstraints.FreezeAll;
  197. // rb.useGravity = false;
  198. // conductCanRelease[cacheConductId] = false;
  199. // obj = Instantiate(wavePowerObj, transform);
  200. // obj.transform.position = transform.position + Vector3.up;
  201. // WavePowerSkill wps = obj.GetComponent<WavePowerSkill>();
  202. // wps.continueTime = wps.singleTime * dienum;
  203. // wps.longFX = (int)bodyTrans.localScale.x;
  204. // wps.damage = wavePowerDamage * boostNum;
  205. // wps.cacheID = cacheConductId;
  206. // wps.pc = this;
  207. // break;
  208. // case ConductSkills.SwordsControl:
  209. // conductCanRelease[cacheConductId] = false;
  210. // obj = Instantiate(flyingSwordsObj, transform);
  211. // obj.transform.position = transform.position + Vector3.up;
  212. // SwordsControl swordsControl = obj.GetComponentInChildren<SwordsControl>();
  213. // swordsControl.owner = this;
  214. // swordsControl.conductId = cacheConductId;
  215. // swordsControl.boostNum = boostNum;
  216. // break;
  217. // //弓箭手
  218. // case ConductSkills.AngryBullet:
  219. // conductCanRelease[cacheConductId] = false;
  220. // obj = Instantiate(angryBulletObj);
  221. // AngryBulletControl angryBulletControl = obj.GetComponent<AngryBulletControl>();
  222. // angryBulletControl.playerController = this;
  223. // angryBulletControl.cacheConductId = cacheConductId;
  224. // angryBulletControl.maxNum = boostNum * angryBulletNum;
  225. // break;
  226. // case ConductSkills.FlyingSwords:
  227. // obj = Instantiate(fanFlyingSwords);
  228. // FanFlyingSwords FFS = obj.GetComponent<FanFlyingSwords>();
  229. // FFS.owner = this;
  230. // FFS.angleRange = flyingSwordsAngleRange;
  231. // FFS.arrivalAngle = flyintSwordsArrivalAngle;
  232. // FFS.swordsNum = boostNum * flyingSwordsNum;
  233. // FFS.Biu();
  234. // break;
  235. }
  236. }
  237. }
  238. public bool HavePhoton(Character attackFrom, int damage)
  239. {
  240. if (photon.havePhoton)
  241. {
  242. photon.photosphere.Reflex(attackFrom.beHitTrigger, damage);
  243. return true;
  244. }
  245. return false;
  246. }
  247. }