PlayerController.cs 67 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using Spine;
  5. using Spine.Unity;
  6. using UnityEngine.LowLevel;
  7. using UnityEngine.Playables;
  8. using System.ComponentModel;
  9. using Unity.VisualScripting;
  10. using System;
  11. using Base.Common;
  12. using cfg;
  13. using static UnityEngine.EventSystems.EventTrigger;
  14. using UnityEngine.InputSystem;
  15. using TMPro;
  16. public enum PlayerAttackState
  17. {
  18. Idle = 0,
  19. WalkForward = 1,
  20. WalkBack = 2,
  21. }
  22. public class PlayerController : MoveCharacter
  23. {
  24. [Header("玩家属性")]
  25. public int playerId;
  26. public Vector2 pos;
  27. public bool canJump;
  28. public bool endTranSummon; //是否在结束变身后召唤英灵
  29. public Animator aniCollider;
  30. [Header("变身英灵")]
  31. public bool isUltimate; //英灵释放大招
  32. public bool keyTransfigurateRelease; //松开英灵释放大招键
  33. public List<GameObject> changePrefabs;
  34. public int[] needCorpses;
  35. private GameObject spiritObj; //当前变身的对象
  36. public int endChange = 0; //结束变身后召唤的英灵
  37. public Vector2 rightDir;
  38. [Header("玩家组件")]
  39. public UIHP uiMp;
  40. private Spirits spirits;
  41. public Collider soulCollector;
  42. public SkeletonMecanim skeletonMecanim;
  43. private SpiritSystem spiritSystem;
  44. [Header("血量")]
  45. private int curHp;
  46. private int curTotalHp;
  47. [Header("蓝耗")]
  48. public float mp;
  49. public float totalMp;
  50. public float totalMp_2Players; //双人模式下总蓝量
  51. public bool isMpRepel = true;
  52. public bool isRapedReply;
  53. public float mpReplySpeed;
  54. public float mpReplySpeed_2Players; //双人模式下蓝量回复速度
  55. public float rapidReplySpeed;
  56. public float lostMp;
  57. private float addMp = 10;
  58. public GameObject soul;
  59. public GameObject rapidReplyEffect;
  60. [Tooltip("场上每多一个同种类兵种,召唤兵种蓝耗+x")] public float[] addCostMp;
  61. [Header("移动属性")]
  62. public Vector2 moveVec; //玩家不动时移动数据
  63. [HideInInspector]
  64. public Vector2 leftDir;
  65. [Header("冲刺属性")]
  66. public float rushSpeed = 100;
  67. public float rushCostMp = 5;
  68. public Vector3 rushDir;
  69. public float rushInvincibleTime = 0.2f;
  70. [HideInInspector]
  71. public float rushTime;
  72. public float totalRushTime = 0.5f;
  73. [HideInInspector]
  74. public float cacheRushTime; //无法Rush时按下Rush键不会Rush,手感不好,缓存几帧,在这几帧内落地会立即Rush;
  75. public float totalCacheRushTime = 0.1f;
  76. [Header("链条属性")]
  77. public float sprintCostMp = 5;
  78. [HideInInspector]
  79. public float cachePullRopeTime;
  80. public float totalCachePullRopeTime = 0.1f;
  81. [Header("跳跃属性")]
  82. public float jumpSpeed = 10;
  83. public float airJumpSpeed = 10;
  84. public int airJumped;
  85. public int airJumpNumber = 1; //最大跳跃次数
  86. public float canAirJumpSpeed = 5;//y轴速度大于这个值时不能进行空中跳跃
  87. [HideInInspector]
  88. public float canJumpTime; //离开平台后仍然可以跳跃的时间,用于提升手感
  89. public float leaveGroundCanJumpTime = 0.1f;
  90. [HideInInspector]
  91. public float cacheJumpTime; //即将落地时按下跳跃键不会跳跃,手感不好,缓存几帧,在这几帧内落地会立即跳跃;
  92. public float totalCacheJumpTime = 0.1f;
  93. [Header("飞行属性")]
  94. public float flySpeed = 5;
  95. public float maxFlyHeight;
  96. [Header("召唤属性")]
  97. [HideInInspector]
  98. public float cacheDir; //召唤的时候按左右召唤结束不会响应手感不好,缓存一下,召唤后摇期间有左右响应的话会转向
  99. [HideInInspector]
  100. public bool cacheRush; //召唤的时候按冲刺结束不会响应手感不好,缓存一下,召唤后摇期间按下冲刺的话会冲刺
  101. [HideInInspector]
  102. public float summonTime;
  103. [HideInInspector]
  104. public float cacheSummonTime; //无法召唤时按下召唤键不会召唤,手感不好,缓存几帧,在这几帧内落地会立即召唤;
  105. [HideInInspector]
  106. public int cacheSummonId;
  107. [Header("召唤使魔")]
  108. public TextMeshProUGUI[] demonicNums;
  109. public GameObject[] cannotConductFXs;
  110. public List<GameObject> demonicPrefabs;
  111. public List<Vector3> demonicSummonPos;
  112. public Dictionary<int, List<Demonic>> demonicDic; //0:弓兵,1:胖子,2:棒子,3:融合后的弓兵,4:融合后的胖子,5:融合后的棒子
  113. [Header("攻击")]
  114. public PlayerAttackState attackState;
  115. public float attackMoveSpeed = 5f;
  116. [HideInInspector]
  117. public float cacheAttackTime; //无法攻击时按下攻击键不会攻击,手感不好,缓存几帧,在这几帧内落地会立即攻击;
  118. public float totalCacheAttackTime = 0.1f;
  119. [Header("复活")]
  120. public float reviveTime; //复活时间
  121. public float totalReviveTime;
  122. [Header("玩家是否在基地")]
  123. public bool isBaseBtnOut = false;
  124. [Header("八卦")]
  125. public ChooseYinYang chooseYinYang;
  126. [Header("锁魂塔")]
  127. public GameObject curSoulTower;
  128. //指挥功能
  129. private float conductTime; //指挥按键长按时间
  130. private int nowConductButton = -1; //现在按下的指挥键(0.J/1.K/2.L/-1.无)
  131. private int cacheConductId;
  132. [Header("召唤相应时间")] [Tooltip("在此时间内松手为召唤")] public float totalCacheSummonTime;
  133. [Header("融魂相应时间")] [Tooltip("在此时间以外松手为融魂")] public float[] canConductTime;
  134. [Header("融魂技")] [Tooltip("选择相应的融魂技能")] public ConductSkills[] conductSkills;
  135. public bool[] conductCanRelease; //能否进入指挥技蓄力状态
  136. public ConductReadyTip conductReadyTip; //指挥技就绪
  137. private bool isReadyConduct;
  138. [Header("时间倍率")] [Tooltip("时间速度放慢到正常的几倍")] public float timeSlowingMultiplier;
  139. [DisplayOnly]public float fixedDeltaTime;
  140. public float readyTipFxTime;
  141. [Header("转换率")] public float[] conversionRate;
  142. //大胖子
  143. [Header("融合临时血量基数")] public int temptHp;
  144. [Header("融合血量持续时间")] public float temptTime;
  145. public GameObject[] bigGiant;
  146. //光球
  147. public GameObject photosphereObj;
  148. [Header("光球血量基数")] public int photosphereHp;
  149. //攻击力
  150. [Header("增加攻击力特效")]
  151. public GameObject attackEffect;
  152. [Header("攻击力献祭比例")]
  153. public float addRate;
  154. //泰山压顶
  155. [Header("泰山压顶")]
  156. public GameObject mountain;
  157. public Vector3 mountainOffset;
  158. public float largeX;
  159. //气功波
  160. public GameObject wavePowerObj;
  161. [Header("气功波伤害基数")] public int wavePowerDamage;
  162. //御剑术
  163. public GameObject flyingSwordsObj;
  164. //怨气弹
  165. public GameObject angryBulletObj;
  166. [Header("怨气弹数量基数")] public int angryBulletNum;
  167. //扇形飞剑
  168. public GameObject fanFlyingSwords;
  169. [Header("飞剑角度范围")] public float flyingSwordsAngleRange;
  170. [Header("飞剑角度入射角")] public float flyintSwordsArrivalAngle;
  171. [Header("飞剑数量基数")] public int flyingSwordsNum;
  172. public enum ConductSkills
  173. {
  174. Giant, //胖子:合成大胖子
  175. Photosphere, //胖子:光球
  176. AddAttack, //胖子:增加攻击力
  177. Mountain, //气功师:泰山压顶
  178. WavePower, //气功师:气功波
  179. SwordsControl, //气功师:御剑术
  180. AngryBullet, //弓箭手:怨气弹
  181. FlyingSwords, //扇形飞剑
  182. }
  183. public bool btnJumpPress
  184. {
  185. get
  186. {
  187. //return Input.GetKeyDown(KeyCode.Space) || isClickBtnJump;
  188. return isClickBtnJump;
  189. }
  190. }
  191. [HideInInspector]
  192. public bool isClickBtnJump;
  193. public bool btnRushPress
  194. {
  195. get
  196. {
  197. //return Input.GetKeyDown(KeyCode.LeftShift) || isClickBtnRush;
  198. return isClickBtnRush;
  199. }
  200. }
  201. [HideInInspector]
  202. public bool isClickBtnRush;
  203. public bool btnRushKeep
  204. {
  205. get
  206. {
  207. //return Input.GetKey(KeyCode.LeftShift) || isKeepBtnRush;
  208. return LBisHold || isKeepBtnRush;
  209. }
  210. }
  211. [HideInInspector]
  212. public bool isKeepBtnRush;
  213. public bool btnTransfiguratePress
  214. {
  215. get
  216. {
  217. //return Input.GetKeyDown(KeyCode.L) || isClickBtnEast;
  218. return isClickBtnTransfigurate;
  219. }
  220. }
  221. [HideInInspector]
  222. public bool isClickBtnTransfigurate;
  223. public bool btnEastPress
  224. {
  225. get
  226. {
  227. return isClickBtnEast;
  228. }
  229. }
  230. [HideInInspector]
  231. public bool isClickBtnEast;
  232. public bool btnEastUp
  233. {
  234. get
  235. {
  236. return isBtnEastUp;
  237. }
  238. }
  239. [HideInInspector]
  240. public bool isBtnEastUp;
  241. public bool btnSouthPress
  242. {
  243. get
  244. {
  245. //return Input.GetKeyDown(KeyCode.K) || isClickBtnSouth;
  246. return isClickBtnSouth;
  247. }
  248. }
  249. [HideInInspector]
  250. public bool isClickBtnSouth;
  251. public bool btnSouthUp
  252. {
  253. get
  254. {
  255. //return Input.GetKeyDown(KeyCode.K) || isClickBtnSouth;
  256. return isBtnSouthUp;
  257. }
  258. }
  259. [HideInInspector]
  260. public bool isBtnSouthUp;
  261. public bool btnWestPress
  262. {
  263. get
  264. {
  265. return isClickBtnWest;
  266. }
  267. }
  268. [HideInInspector]
  269. public bool isClickBtnWest;
  270. public bool btnWestUp
  271. {
  272. get
  273. {
  274. return isBtnWestUp;
  275. }
  276. }
  277. [HideInInspector]
  278. public bool isBtnWestUp;
  279. public bool btnNorthPress
  280. {
  281. get
  282. {
  283. return isClickBtnNorth;
  284. }
  285. }
  286. [HideInInspector]
  287. public bool isClickBtnNorth;
  288. public bool btnNorthUp
  289. {
  290. get
  291. {
  292. return isBtnNorthUp;
  293. }
  294. }
  295. [HideInInspector]
  296. public bool isBtnNorthUp;
  297. public bool btnSpiritSummon
  298. {
  299. get
  300. {
  301. //return Input.GetKeyDown(KeyCode.I) || isClickBtnNorth;
  302. return isSpiritSummon;
  303. }
  304. }
  305. [HideInInspector]
  306. public bool isSpiritSummon;
  307. public bool btnSpiritSummon1
  308. {
  309. get
  310. {
  311. //return Input.GetKeyDown(KeyCode.I) || isClickBtnNorth;
  312. return isSpiritSummon1;
  313. }
  314. }
  315. [HideInInspector]
  316. public bool isSpiritSummon1;
  317. public bool btnSpiritSummon2
  318. {
  319. get
  320. {
  321. //return Input.GetKeyDown(KeyCode.I) || isClickBtnNorth;
  322. return isSpiritSummon2;
  323. }
  324. }
  325. [HideInInspector]
  326. public bool isSpiritSummon2;
  327. public bool btnSpiritSummon3
  328. {
  329. get
  330. {
  331. //return Input.GetKeyDown(KeyCode.I) || isClickBtnNorth;
  332. return isSpiritSummon3;
  333. }
  334. }
  335. [HideInInspector]
  336. public bool isSpiritSummon3;
  337. public bool btnNorthKeep
  338. {
  339. get
  340. {
  341. //return Input.GetKey(KeyCode.I) || isKeepBtnNorth;
  342. return isKeepBtnNorth;
  343. }
  344. }
  345. [HideInInspector]
  346. public bool isKeepBtnNorth;
  347. public override void Init()
  348. {
  349. base.Init();
  350. uiHp = GameManager.instance.p1uiHP;
  351. uiMp = GameManager.instance.p1uiMP;
  352. mp = totalMp;
  353. uiMp.Show(mp, totalMp);
  354. demonicNums = new TextMeshProUGUI[3];
  355. for (int i = 0; i < 3; i++)
  356. {
  357. demonicNums[i] = GameManager.instance.demonicNum[i].GetComponentInChildren<TextMeshProUGUI>();
  358. }
  359. cannotConductFXs = new GameObject[3];
  360. for (int i = 0; i < 3; i++)
  361. {
  362. cannotConductFXs[i] = GameManager.instance.demonicNum[i].transform.GetChild(3).gameObject;
  363. }
  364. }
  365. private void Awake()
  366. {
  367. PlayerInput playerInput = transform.GetComponent<PlayerInput>();
  368. spirits = GetComponent<Spirits>();
  369. playerId = playerInput.playerIndex;
  370. transform.position = new Vector3(pos.x, pos.y, 0);
  371. switch (playerId)
  372. {
  373. case 0:
  374. PlayersInput.instance[0] = this;
  375. PlayersInput.instance[1] = this;
  376. SpiritSystem.isP1Out = true;
  377. SpiritSystem.isP1In = false;
  378. SpiritSystem.player1 = gameObject;
  379. SpiritSystem.p1Spirits = GetComponent<Spirits>();
  380. break;
  381. case 1:
  382. PlayersInput.instance[1] = this;
  383. SpiritSystem.isP2Out = true;
  384. SpiritSystem.isP2In = false;
  385. SpiritSystem.player2 = gameObject;
  386. SpiritSystem.p2Spirits = GetComponent<Spirits>();
  387. //切换为双人计算蓝量方式
  388. PlayerController p1 = PlayersInput.instance[0];
  389. mpReplySpeed = mpReplySpeed_2Players;
  390. p1.mpReplySpeed = mpReplySpeed_2Players;
  391. totalMp = totalMp_2Players;
  392. p1.totalMp = totalMp_2Players;
  393. if (mp > totalMp)
  394. {
  395. mp = totalMp;
  396. }
  397. if (p1.mp > totalMp)
  398. {
  399. p1.mp = totalMp;
  400. }
  401. uiMp.Show(mp, totalMp);
  402. p1.uiMp.Show(p1.mp, totalMp);
  403. break;
  404. default:
  405. break;
  406. }
  407. demonicDic = new Dictionary<int, List<Demonic>>();
  408. for (int i = 0; i < 5; i++)
  409. {
  410. demonicDic.Add(i, new List<Demonic>());
  411. }
  412. Init();
  413. spiritSystem = GameObject.Find("SpiritSystem").GetComponent<SpiritSystem>();
  414. fixedDeltaTime = Time.fixedDeltaTime;
  415. }
  416. private void Update()
  417. {
  418. if (LBisHold)
  419. {
  420. isKeepBtnRush = true;
  421. }
  422. if (floatState != 0)
  423. {
  424. CharacterFloat();
  425. }
  426. /* //到时间自动解除变身
  427. if (endChange != 0)
  428. {
  429. pastChangeTime += Time.deltaTime;
  430. if (pastChangeTime >= changeTime)
  431. {
  432. EndTransfiguration(endChange);
  433. endChange = 0;
  434. pastChangeTime = 0;
  435. }
  436. }
  437. */
  438. //if (isTransfiguration)
  439. //{
  440. // bodyTrans.position = spiritObj.transform.position;
  441. //}
  442. if (isInvisible)
  443. {
  444. invisibleTime -= Time.deltaTime;
  445. if (invisibleTime <= 0)
  446. {
  447. isInvisible = false;
  448. ChangeMat(1);
  449. }
  450. }
  451. if (haveTransmit)
  452. {
  453. transmitTime -= Time.deltaTime;
  454. if (transmitTime <= 0)
  455. {
  456. haveTransmit = false;
  457. portalsController.rbs.Remove(rb);
  458. }
  459. }
  460. if (rightDir.x < -0.5 || rightDir.x > 0.5)
  461. {
  462. ChangeSpirit();
  463. }
  464. }
  465. void OnSprintingPress()
  466. {
  467. LBisHold = true;
  468. isClickBtnRush = true;
  469. isKeepBtnRush = true;
  470. }
  471. void OnSprintingRelease()
  472. {
  473. LBisHold = false;
  474. }
  475. //手柄按下LB
  476. [HideInInspector]
  477. public bool LBisHold;
  478. //读取手柄参数
  479. private void OnMove(InputValue value)
  480. {
  481. if (canMove)
  482. {
  483. leftDir = value.Get<Vector2>();
  484. }
  485. else
  486. {
  487. leftDir = Vector3.zero;
  488. }
  489. moveVec = value.Get<Vector2>();
  490. }
  491. void OnJump()
  492. {
  493. if (canJump && canMove)
  494. {
  495. isClickBtnJump = true;
  496. }
  497. }
  498. void OnSummon0()
  499. {
  500. if (!isFloat && canMove && nowConductButton == -1)
  501. {
  502. isClickBtnWest = true;
  503. nowConductButton = 0;
  504. conductTime = 0;
  505. }
  506. }
  507. void OnSummon0Up()
  508. {
  509. if (nowConductButton == 0)
  510. {
  511. isBtnWestUp = true;
  512. cacheConductId = nowConductButton;
  513. nowConductButton = -1;
  514. }
  515. }
  516. void OnSummon1()
  517. {
  518. if (!isFloat && canMove && nowConductButton == -1)
  519. {
  520. isClickBtnSouth = true;
  521. nowConductButton = 1;
  522. conductTime = 0;
  523. }
  524. }
  525. void OnSummon1Up()
  526. {
  527. if (nowConductButton == 1)
  528. {
  529. isBtnSouthUp = true;
  530. cacheConductId = nowConductButton;
  531. nowConductButton = -1;
  532. }
  533. }
  534. void OnSummon2()
  535. {
  536. if (!isFloat && canMove && nowConductButton == -1)
  537. {
  538. isClickBtnEast = true;
  539. nowConductButton = 2;
  540. conductTime = 0;
  541. }
  542. }
  543. void OnSummon2Up()
  544. {
  545. if (nowConductButton == 2)
  546. {
  547. isBtnEastUp = true;
  548. cacheConductId = nowConductButton;
  549. nowConductButton = -1;
  550. }
  551. }
  552. //选英灵 (手柄右扳机,键盘TAB)
  553. void OnChooseSpirit()
  554. {
  555. switch (playerId)
  556. {
  557. case 0:
  558. SpiritSystem.isP1CardChangeR = true;
  559. break;
  560. case 1:
  561. SpiritSystem.isP2CardChangeR = true;
  562. break;
  563. default:
  564. break;
  565. }
  566. }
  567. //选英灵(手柄右摇杆,小键盘左右)
  568. void OnChooseSpirit_LR(InputValue value)
  569. {
  570. rightDir = value.Get<Vector2>();
  571. }
  572. //召唤英灵
  573. void OnTransfigurate()
  574. {
  575. if (!keyTransfigurateRelease && !isFloat && canMove && !isBaseBtnOut)
  576. {
  577. isClickBtnTransfigurate = true;
  578. }
  579. }
  580. //松开变身英灵键
  581. void OnTransfigurateUp()
  582. {
  583. if (!isBaseBtnOut)
  584. {
  585. keyTransfigurateRelease = true;
  586. }
  587. }
  588. public void Jump()
  589. {
  590. SetUpSpeed(jumpSpeed);
  591. ani.Play("jump", 0, 0);
  592. }
  593. public void AirJump()
  594. {
  595. SetUpSpeed(airJumpSpeed);
  596. ani.Play("jump", 0, 0);
  597. }
  598. public void SetUpSpeed(float speed)
  599. {
  600. ChangeState(CharacterState.Rise);
  601. Vector3 velocity = rb.velocity;
  602. CheckTurn();
  603. velocity.y = speed;
  604. rb.velocity = velocity;
  605. //animalAni.SetInteger("state", (int)PlayerState.Rise);
  606. }
  607. public bool CheckSummon()
  608. {
  609. if (btnTransfiguratePress)
  610. {
  611. if (spirits.ultimateTimes[spirits.nowSpirit] > 0)
  612. {
  613. Summon((int)spirits.ownSpirits[spirits.nowSpirit] + 3);
  614. return true;
  615. }
  616. }
  617. if (state != CharacterState.Conduct && nowConductButton != -1 && conductTime > totalCacheSummonTime)
  618. {
  619. CheckTurn();
  620. if (conductCanRelease[nowConductButton])
  621. {
  622. ChangeState(CharacterState.Conduct);
  623. return true;
  624. }
  625. return false;
  626. }
  627. if (isBtnEastUp || isBtnWestUp || isBtnSouthUp)
  628. {
  629. if (cacheSummonTime >= 0 && conductTime <= totalCacheSummonTime)
  630. {
  631. CheckTurn();
  632. if (!CheckCanSummon(cacheSummonId))
  633. {
  634. return false;
  635. }
  636. Summon(cacheSummonId);
  637. return true;
  638. }
  639. }
  640. return false;
  641. }
  642. public bool CheckConduct()
  643. {
  644. if (isBtnEastUp || isBtnWestUp || isBtnSouthUp)
  645. {
  646. if (isReadyConduct)
  647. {
  648. Conduct();
  649. }
  650. isReadyConduct = false;
  651. return true;
  652. }
  653. if (!isReadyConduct && nowConductButton != -1)
  654. {
  655. if (conductTime >= canConductTime[nowConductButton] * timeSlowingMultiplier)
  656. {
  657. isReadyConduct = true;
  658. if (!conductReadyTip.isShowing1 && !conductReadyTip.isShowingNoDemonic)
  659. {
  660. int boostNum = demonicDic[nowConductButton].Count;
  661. int dienum = Mathf.RoundToInt(boostNum * conversionRate[nowConductButton]);
  662. if (boostNum == 1)
  663. {
  664. dienum = 1;
  665. }
  666. if (dienum > 0)
  667. {
  668. conductReadyTip.Show(1);
  669. }
  670. else
  671. {
  672. conductReadyTip.Show(3, nowConductButton);
  673. }
  674. }
  675. }
  676. else if (conductTime >= (canConductTime[nowConductButton] - readyTipFxTime) * timeSlowingMultiplier)
  677. {
  678. if (!conductReadyTip.isShowing0 && !conductReadyTip.isShowingNoDemonic)
  679. {
  680. int boostNum = demonicDic[nowConductButton].Count;
  681. int dienum = Mathf.RoundToInt(boostNum * conversionRate[nowConductButton]);
  682. if (boostNum == 1)
  683. {
  684. dienum = 1;
  685. }
  686. if (dienum > 0)
  687. {
  688. conductReadyTip.Show(0);
  689. }
  690. else
  691. {
  692. conductReadyTip.Show(2, nowConductButton);
  693. }
  694. }
  695. }
  696. else
  697. {
  698. if (Time.timeScale == 1)
  699. {
  700. Time.timeScale = timeSlowingMultiplier;
  701. Time.fixedDeltaTime = fixedDeltaTime * Time.timeScale;
  702. int boostNum = demonicDic[nowConductButton].Count;
  703. int dienum = Mathf.RoundToInt(boostNum * conversionRate[nowConductButton]);
  704. if (boostNum == 1)
  705. {
  706. dienum = 1;
  707. }
  708. if (dienum == 0)
  709. {
  710. conductReadyTip.Show(2, nowConductButton);
  711. CannotConductFX(nowConductButton);
  712. }
  713. }
  714. conductReadyTip.Init();
  715. }
  716. }
  717. return false;
  718. }
  719. public void Conduct()
  720. {
  721. int boostNum = demonicDic[cacheConductId].Count;
  722. int dienum = Mathf.RoundToInt(boostNum * conversionRate[cacheConductId]);
  723. if (dienum == 0 && boostNum >= 1)
  724. {
  725. dienum = 1;
  726. }
  727. if (dienum > 0)
  728. {
  729. GameObject obj;
  730. List<int> dieId = new List<int>();
  731. List<Demonic> dieDemonic = new List<Demonic>();
  732. while (dieId.Count < dienum)
  733. {
  734. int id = UnityEngine.Random.Range(0, boostNum);
  735. if (!dieId.Exists(t => t == id))
  736. {
  737. dieId.Add(id);
  738. dieDemonic.Add(demonicDic[cacheConductId][id]);
  739. }
  740. }
  741. foreach (Demonic d in dieDemonic)
  742. {
  743. d.ChangeState(CharacterState.Die);
  744. }
  745. switch (conductSkills[cacheConductId])
  746. {
  747. //巨人
  748. case ConductSkills.Giant:
  749. GameObject demonicObj = PoolManager.Instantiate(bigGiant[cacheConductId]);
  750. demonicObj.SetActive(false);
  751. BigSoldier bs = demonicObj.GetComponent<BigSoldier>();
  752. bs.id = cacheConductId + 3;
  753. demonicDic[bs.id].Add(bs);
  754. if(bs.id < 3)
  755. {
  756. demonicNums[bs.id].text = demonicDic[bs.id].Count.ToString();
  757. }
  758. int tempthp = boostNum * temptHp;
  759. bs.playerID = playerId;
  760. demonicObj.transform.parent = null;
  761. demonicObj.transform.localEulerAngles = Vector3.zero;
  762. bs.boostNum = boostNum;
  763. if (isInSoulTower)
  764. {
  765. ls.AddDenomic(bs);
  766. }
  767. bs.player = this;
  768. bs.Settings();
  769. bs.GetTemptHP(tempthp, temptTime);
  770. int order = bs.baseSortingOrder + demonicDic[bs.id].Count;
  771. bs.SetSortingOrder(order);
  772. Vector3 offset = demonicSummonPos[0] * 2;
  773. if (bodyTrans.localScale.x > 0)
  774. {
  775. demonicObj.transform.position = transform.position + offset;
  776. if (bs.bodyTrans.localScale.x < 0)
  777. {
  778. bs.Turn();
  779. }
  780. }
  781. else
  782. {
  783. demonicObj.transform.position = transform.position + new Vector3(-offset.x, offset.y, offset.z);
  784. if (bs.bodyTrans.localScale.x > 0)
  785. {
  786. bs.Turn();
  787. }
  788. }
  789. demonicObj.SetActive(true);
  790. break;
  791. case ConductSkills.Photosphere:
  792. conductCanRelease[cacheConductId] = false;
  793. obj = Instantiate(photosphereObj, transform);
  794. obj.transform.position = transform.position + Vector3.up;
  795. Photosphere photosphere = obj.GetComponent<Photosphere>();
  796. photosphere.owner = this;
  797. photosphere.conductId = cacheConductId;
  798. photosphere.hp = boostNum * photosphereHp;
  799. break;
  800. case ConductSkills.AddAttack:
  801. List<Demonic> newGiants = new List<Demonic>();
  802. foreach (Demonic d in demonicDic[cacheConductId])
  803. {
  804. if (!d.isDie)
  805. {
  806. newGiants.Add(d);
  807. if (d.attackController.addAttackEffect == null)
  808. {
  809. d.attackController.addAttackEffect = Instantiate(attackEffect, d.bodyTrans.position, new Quaternion(0, 0, 0, 0), d.bodyTrans);
  810. }
  811. d.attackController.addAttackEffect.transform.GetChild(0).gameObject.SetActive(true);
  812. }
  813. }
  814. foreach (Demonic d in newGiants)
  815. {
  816. int damage = d.attackController.curDamage;
  817. d.attackController.curDamage += (int)(addRate * boostNum * damage);
  818. }
  819. break;
  820. //气功师
  821. case ConductSkills.Mountain:
  822. conductCanRelease[cacheConductId] = false;
  823. GameObject curMountain = Instantiate(mountain, null);
  824. Vector3 moffset = mountainOffset;
  825. Vector3 sc = curMountain.transform.localScale;
  826. sc.x = largeX * dienum;
  827. curMountain.transform.localScale = sc;
  828. if (bodyTrans.localScale.x < 0)
  829. {
  830. moffset.x = mountainOffset.x + sc.x / 2;
  831. }
  832. else
  833. {
  834. moffset.x = -mountainOffset.x - sc.x / 2;
  835. }
  836. Mountain MT = curMountain.GetComponent<Mountain>();
  837. curMountain.transform.position = transform.position + moffset;
  838. MT.pc = this;
  839. MT.id = cacheConductId;
  840. MT.demonicNum = boostNum;
  841. break;
  842. case ConductSkills.WavePower:
  843. canMove = false;
  844. rb.constraints = RigidbodyConstraints.FreezeAll;
  845. rb.useGravity = false;
  846. conductCanRelease[cacheConductId] = false;
  847. obj = Instantiate(wavePowerObj, transform);
  848. obj.transform.position = transform.position + Vector3.up;
  849. WavePowerSkill wps = obj.GetComponent<WavePowerSkill>();
  850. wps.continueTime = wps.singleTime * dienum;
  851. wps.longFX = (int)bodyTrans.localScale.x;
  852. wps.damage = wavePowerDamage * boostNum;
  853. wps.cacheID = cacheConductId;
  854. wps.pc = this;
  855. break;
  856. case ConductSkills.SwordsControl:
  857. conductCanRelease[cacheConductId] = false;
  858. obj = Instantiate(flyingSwordsObj, transform);
  859. obj.transform.position = transform.position + Vector3.up;
  860. SwordsControl swordsControl = obj.GetComponentInChildren<SwordsControl>();
  861. swordsControl.owner = this;
  862. swordsControl.conductId = cacheConductId;
  863. swordsControl.boostNum = boostNum;
  864. break;
  865. //弓箭手
  866. case ConductSkills.AngryBullet:
  867. conductCanRelease[cacheConductId] = false;
  868. obj = Instantiate(angryBulletObj);
  869. AngryBulletControl angryBulletControl = obj.GetComponent<AngryBulletControl>();
  870. angryBulletControl.playerController = this;
  871. angryBulletControl.cacheConductId = cacheConductId;
  872. angryBulletControl.maxNum = boostNum * angryBulletNum;
  873. break;
  874. case ConductSkills.FlyingSwords:
  875. obj = Instantiate(fanFlyingSwords);
  876. FanFlyingSwords FFS = obj.GetComponent<FanFlyingSwords>();
  877. FFS.owner = this;
  878. FFS.angleRange = flyingSwordsAngleRange;
  879. FFS.arrivalAngle = flyintSwordsArrivalAngle;
  880. FFS.swordsNum = boostNum * flyingSwordsNum;
  881. FFS.Biu();
  882. break;
  883. }
  884. }
  885. else
  886. {
  887. print("使魔不足");
  888. }
  889. }
  890. private int cannotConductfx;
  891. private void CannotConductFX(int id)
  892. {
  893. cannotConductfx = id;
  894. cannotConductFXs[id].SetActive(true);
  895. Invoke("CannotConductFXFade", 0.2f);
  896. }
  897. private void CannotConductFXFade()
  898. {
  899. cannotConductFXs[cannotConductfx].SetActive(false);
  900. }
  901. //角色处于可自由活动状态时的通用切换状态逻辑,如Idle、Run状态,以及别的状态结束时准备回到Idle状态前
  902. public bool CheckPlayerChangeState(CharacterState excludeState = CharacterState.None)
  903. {
  904. if (!foot.TrigGround)
  905. {
  906. if (excludeState != CharacterState.Summon)
  907. {
  908. if (CheckSummon())
  909. {
  910. return true;
  911. }
  912. }
  913. if ((btnRushPress || cacheRushTime > 0 || cacheRush) && mp >= rushCostMp)
  914. {
  915. if (excludeState != CharacterState.Rush)
  916. {
  917. cacheRush = false;
  918. ChangeState(CharacterState.Rush);
  919. return true;
  920. }
  921. }
  922. if (rb.velocity.y > 0)
  923. {
  924. if (excludeState != CharacterState.Rise)
  925. {
  926. ChangeState(CharacterState.Rise);
  927. return true;
  928. }
  929. }
  930. else
  931. {
  932. if (excludeState != CharacterState.Fall)
  933. {
  934. ChangeState(CharacterState.Fall);
  935. return true;
  936. }
  937. }
  938. }
  939. else
  940. {
  941. airJumped = 0;
  942. //if (btnNorthPress || cacheAttackTime > 0)
  943. //{
  944. // if (excludeState != CharacterState.Attack)
  945. // {
  946. // Attack_summon();
  947. // return true;
  948. // }
  949. //}
  950. if (excludeState != CharacterState.Summon)
  951. {
  952. if (CheckSummon())
  953. {
  954. return true;
  955. }
  956. }
  957. if ((btnRushPress || cacheRushTime > 0 || cacheRush) && mp >= rushCostMp)
  958. {
  959. if (excludeState != CharacterState.Rush)
  960. {
  961. cacheRush = false;
  962. ChangeState(CharacterState.Rush);
  963. return true;
  964. }
  965. }
  966. if (btnJumpPress || cacheJumpTime > 0)
  967. {
  968. if (excludeState != CharacterState.Rise)
  969. {
  970. Jump();
  971. ChangeState(CharacterState.Rise);
  972. return true;
  973. }
  974. }
  975. if (leftDir.y < -0.5)
  976. {
  977. Platform platform = foot.trigGroundList[0].GetComponent<Platform>();
  978. if (platform != null && platform.canDown)
  979. {
  980. foot.trigGroundList.Remove(platform.gameObject);
  981. }
  982. }
  983. if (canFly)
  984. {
  985. if (leftDir.x > 0.3f || leftDir.x < -0.3f || leftDir.y > 0.3f || leftDir.y < -0.3f)
  986. {
  987. if (excludeState != CharacterState.Run)
  988. {
  989. ChangeState(CharacterState.Run);
  990. return true;
  991. }
  992. }
  993. else
  994. {
  995. if (excludeState != CharacterState.Idle)
  996. {
  997. ChangeState(CharacterState.Idle);
  998. return true;
  999. }
  1000. }
  1001. }
  1002. else
  1003. {
  1004. if (leftDir.x > 0.3f || leftDir.x < -0.3f)
  1005. {
  1006. if (excludeState != CharacterState.Run)
  1007. {
  1008. ChangeState(CharacterState.Run);
  1009. return true;
  1010. }
  1011. }
  1012. else
  1013. {
  1014. if (excludeState != CharacterState.Idle)
  1015. {
  1016. ChangeState(CharacterState.Idle);
  1017. return true;
  1018. }
  1019. }
  1020. }
  1021. }
  1022. return false;
  1023. }
  1024. public override Vector3 GetMoveDir()
  1025. {
  1026. return leftDir;
  1027. }
  1028. public void CachedPlayerInput()
  1029. {
  1030. if (btnRushPress)
  1031. {
  1032. cacheRushTime = totalCacheRushTime;
  1033. }
  1034. if (btnJumpPress)
  1035. {
  1036. cacheJumpTime = totalCacheJumpTime;
  1037. }
  1038. if (btnNorthPress)
  1039. {
  1040. cacheAttackTime = totalCacheAttackTime;
  1041. }
  1042. if (btnWestPress)
  1043. {
  1044. cacheSummonTime = totalCacheSummonTime;
  1045. cacheSummonId = 0;
  1046. }
  1047. if (btnSouthPress)
  1048. {
  1049. cacheSummonTime = totalCacheSummonTime;
  1050. cacheSummonId = 1;
  1051. }
  1052. if (btnEastPress)
  1053. {
  1054. cacheSummonTime = totalCacheSummonTime;
  1055. cacheSummonId = 2;
  1056. }
  1057. //if (btnSpiritSummon)
  1058. //{
  1059. // cacheSummonTime = totalCacheSummonTime;
  1060. // cacheSummonId = 3;
  1061. //}
  1062. //if (btnSpiritSummon1)
  1063. //{
  1064. // cacheSummonTime = totalCacheSummonTime;
  1065. // cacheSummonId = 4;
  1066. //}
  1067. //if (btnSpiritSummon2)
  1068. //{
  1069. // cacheSummonTime = totalCacheSummonTime;
  1070. // cacheSummonId = 5;
  1071. //}
  1072. //if (btnSpiritSummon3)
  1073. //{
  1074. // cacheSummonTime = totalCacheSummonTime;
  1075. // cacheSummonId = 6;
  1076. //}
  1077. }
  1078. public override void OnState()
  1079. {
  1080. base.OnState();
  1081. cacheJumpTime -= Time.deltaTime;
  1082. cacheSummonTime -= Time.deltaTime;
  1083. canJumpTime -= Time.deltaTime;
  1084. invincibleTime -= Time.deltaTime;
  1085. summonTime -= Time.deltaTime;
  1086. rushTime -= Time.deltaTime;
  1087. cacheRushTime -= Time.deltaTime;
  1088. dieKeepTime -= Time.deltaTime;
  1089. weakTime -= Time.deltaTime;
  1090. beRepelValue += Time.deltaTime;
  1091. if (nowConductButton != -1)
  1092. {
  1093. conductTime += Time.deltaTime;
  1094. }
  1095. CachedPlayerInput();
  1096. Vector3 velocity = rb.velocity;
  1097. switch (state)
  1098. {
  1099. case CharacterState.Idle:
  1100. if (CheckPlayerChangeState(CharacterState.Idle))
  1101. {
  1102. break;
  1103. }
  1104. rb.velocity = Vector3.right * velocityAddition;
  1105. break;
  1106. case CharacterState.Run:
  1107. if (CheckPlayerChangeState(CharacterState.Run))
  1108. {
  1109. break;
  1110. }
  1111. CheckTurn();
  1112. if (canFly)
  1113. {
  1114. rb.velocity = leftDir.normalized * moveSpeed;
  1115. }
  1116. else
  1117. {
  1118. if (leftDir.x > 0.3f)
  1119. {
  1120. rb.velocity = new Vector3(moveSpeed + velocityAddition, 0, 0);
  1121. }
  1122. else if (leftDir.x < -0.3f)
  1123. {
  1124. rb.velocity = new Vector3(-moveSpeed + velocityAddition, 0, 0);
  1125. }
  1126. }
  1127. break;
  1128. case CharacterState.Rise:
  1129. if (CheckSummon())
  1130. {
  1131. break;
  1132. }
  1133. if ((btnRushPress || cacheRushTime > 0) && mp >= rushCostMp)
  1134. {
  1135. ChangeState(CharacterState.Rush);
  1136. break;
  1137. }
  1138. if (btnJumpPress || cacheJumpTime > 0)
  1139. {
  1140. if (airJumped < airJumpNumber && rb.velocity.y < canAirJumpSpeed)
  1141. {
  1142. airJumped++;
  1143. AirJump();
  1144. break;
  1145. }
  1146. }
  1147. rb.velocity = AirMove(rb.velocity);
  1148. if (rb.velocity.y <= 0)
  1149. {
  1150. ChangeState(CharacterState.Fall);
  1151. break;
  1152. }
  1153. break;
  1154. case CharacterState.Fall:
  1155. if (CheckSummon())
  1156. {
  1157. break;
  1158. }
  1159. if ((btnRushPress || cacheRushTime > 0) && mp >= rushCostMp)
  1160. {
  1161. ChangeState(CharacterState.Rush);
  1162. break;
  1163. }
  1164. if (foot.TrigGround)
  1165. {
  1166. if (CheckPlayerChangeState(CharacterState.Fall))
  1167. {
  1168. break;
  1169. }
  1170. }
  1171. //if (foot.canStepPlayers.Count > 0)
  1172. //{
  1173. // Jump(jumpSpeed / 2);
  1174. // StepOther();
  1175. // break;
  1176. //}
  1177. //if (foot.canStepEnemyList.Count > 0)
  1178. //{
  1179. // Jump(jumpSpeed / 2);
  1180. // StepEnemy();
  1181. // break;
  1182. //}
  1183. if (btnJumpPress || cacheJumpTime > 0)
  1184. {
  1185. if (canJumpTime > 0)
  1186. {
  1187. Jump();
  1188. break;
  1189. }
  1190. else
  1191. {
  1192. if (airJumped < airJumpNumber)
  1193. {
  1194. airJumped++;
  1195. AirJump();
  1196. break;
  1197. }
  1198. }
  1199. }
  1200. rb.velocity = AirMove(rb.velocity);
  1201. break;
  1202. //case CharacterState.Hurt:
  1203. // if (hurtKeepTime <= 0 && rb.velocity.magnitude < hurtChangeVelocity)
  1204. // {
  1205. // if (CheckPlayerChangeState())
  1206. // {
  1207. // break;
  1208. // }
  1209. // }
  1210. // Vector3 vel = rb.velocity;
  1211. // if (!foot.TrigGround)
  1212. // {
  1213. // if (canfly)
  1214. // {
  1215. // vel.y = vel.y * (1 - decelerationRatio * Time.deltaTime);
  1216. // }
  1217. // else
  1218. // {
  1219. // vel += Vector3.up * extraFallGravity * Time.deltaTime;
  1220. // }
  1221. // }
  1222. // vel.x = vel.x * (1 - decelerationRatio * Time.deltaTime);
  1223. // rb.velocity = vel;
  1224. // CachedPlayerInput();
  1225. // break;
  1226. case CharacterState.Coma:
  1227. break;
  1228. case CharacterState.Attack:
  1229. if (attackController.attackTime <= 0)
  1230. {
  1231. if (btnNorthKeep)
  1232. {
  1233. ChangeState(CharacterState.KeepAttack);
  1234. break;
  1235. }
  1236. if (CheckPlayerChangeState(CharacterState.Attack))
  1237. {
  1238. break;
  1239. }
  1240. }
  1241. break;
  1242. case CharacterState.KeepAttack:
  1243. if ((btnRushPress) && mp >= rushCostMp)
  1244. {
  1245. ChangeState(CharacterState.Rush);
  1246. break;
  1247. }
  1248. if (btnJumpPress && canJumpTime > 0)
  1249. {
  1250. Jump();
  1251. break;
  1252. }
  1253. if (!btnNorthKeep)
  1254. {
  1255. if (CheckPlayerChangeState(CharacterState.KeepAttack))
  1256. {
  1257. break;
  1258. }
  1259. }
  1260. switch (attackState)
  1261. {
  1262. case PlayerAttackState.Idle:
  1263. if (bodyTrans.localScale.x > 0)
  1264. {
  1265. if (leftDir.x > 0.3f)
  1266. {
  1267. SetAttackState(PlayerAttackState.WalkBack);
  1268. velocity.x = attackMoveSpeed;
  1269. rb.velocity = velocity;
  1270. break;
  1271. }
  1272. else if (leftDir.x < -0.3f)
  1273. {
  1274. SetAttackState(PlayerAttackState.WalkForward);
  1275. velocity.x = -attackMoveSpeed;
  1276. rb.velocity = velocity;
  1277. break;
  1278. }
  1279. }
  1280. else
  1281. {
  1282. if (leftDir.x > 0.3f)
  1283. {
  1284. SetAttackState(PlayerAttackState.WalkForward);
  1285. velocity.x = attackMoveSpeed;
  1286. rb.velocity = velocity;
  1287. break;
  1288. }
  1289. else if (leftDir.x < -0.3f)
  1290. {
  1291. SetAttackState(PlayerAttackState.WalkBack);
  1292. velocity.x = -attackMoveSpeed;
  1293. rb.velocity = velocity;
  1294. break;
  1295. }
  1296. }
  1297. velocity.x = 0;
  1298. rb.velocity = velocity;
  1299. break;
  1300. case PlayerAttackState.WalkForward:
  1301. if (bodyTrans.localScale.x > 0)
  1302. {
  1303. if (leftDir.x > 0.3f)
  1304. {
  1305. SetAttackState(PlayerAttackState.WalkBack);
  1306. velocity.x = attackMoveSpeed;
  1307. rb.velocity = velocity;
  1308. break;
  1309. }
  1310. else if (leftDir.x > -0.3f && leftDir.x < 0.3f)
  1311. {
  1312. SetAttackState(PlayerAttackState.Idle);
  1313. velocity.x = 0;
  1314. rb.velocity = velocity;
  1315. break;
  1316. }
  1317. else
  1318. {
  1319. velocity.x = -attackMoveSpeed;
  1320. rb.velocity = velocity;
  1321. }
  1322. }
  1323. else
  1324. {
  1325. if (leftDir.x < -0.3f)
  1326. {
  1327. SetAttackState(PlayerAttackState.WalkBack);
  1328. velocity.x = -attackMoveSpeed;
  1329. rb.velocity = velocity;
  1330. break;
  1331. }
  1332. else if (leftDir.x > -0.3f && leftDir.x < 0.3f)
  1333. {
  1334. SetAttackState(PlayerAttackState.Idle);
  1335. velocity.x = 0;
  1336. rb.velocity = velocity;
  1337. break;
  1338. }
  1339. else
  1340. {
  1341. velocity.x = attackMoveSpeed;
  1342. rb.velocity = velocity;
  1343. }
  1344. }
  1345. break;
  1346. case PlayerAttackState.WalkBack:
  1347. if (bodyTrans.localScale.x > 0)
  1348. {
  1349. if (leftDir.x < -0.3f)
  1350. {
  1351. SetAttackState(PlayerAttackState.WalkForward);
  1352. velocity.x = -attackMoveSpeed;
  1353. rb.velocity = velocity;
  1354. break;
  1355. }
  1356. else if (leftDir.x > -0.3f && leftDir.x < 0.3f)
  1357. {
  1358. SetAttackState(PlayerAttackState.Idle);
  1359. velocity.x = 0;
  1360. rb.velocity = velocity;
  1361. break;
  1362. }
  1363. else
  1364. {
  1365. velocity.x = attackMoveSpeed;
  1366. rb.velocity = velocity;
  1367. }
  1368. }
  1369. else
  1370. {
  1371. if (leftDir.x > 0.3f)
  1372. {
  1373. SetAttackState(PlayerAttackState.WalkForward);
  1374. velocity.x = attackMoveSpeed;
  1375. rb.velocity = velocity;
  1376. break;
  1377. }
  1378. else if (leftDir.x > -0.3f && leftDir.x > 0.3f)
  1379. {
  1380. SetAttackState(PlayerAttackState.Idle);
  1381. velocity.x = 0;
  1382. rb.velocity = velocity;
  1383. break;
  1384. }
  1385. else
  1386. {
  1387. velocity.x = -attackMoveSpeed;
  1388. rb.velocity = velocity;
  1389. }
  1390. }
  1391. break;
  1392. default:
  1393. break;
  1394. }
  1395. break;
  1396. case CharacterState.Summon:
  1397. if (leftDir.x > 0.3f || leftDir.x < -0.3f)
  1398. {
  1399. cacheDir = leftDir.x;
  1400. }
  1401. if (LBisHold)
  1402. {
  1403. cacheRush = true;
  1404. }
  1405. if (summonTime <= 0)
  1406. {
  1407. if (CheckPlayerChangeState(CharacterState.Summon))
  1408. {
  1409. break;
  1410. }
  1411. }
  1412. rb.velocity = Vector3.right * velocityAddition;
  1413. break;
  1414. case CharacterState.Rush:
  1415. if (rushTime <= 0)
  1416. {
  1417. if (btnRushKeep)
  1418. {
  1419. ChangeState(CharacterState.Sprint);
  1420. break;
  1421. }
  1422. if (CheckPlayerChangeState(CharacterState.Rush))
  1423. {
  1424. break;
  1425. }
  1426. }
  1427. //if (leftDir.magnitude < 0.3f)
  1428. //{
  1429. // if (bodyTrans.localScale.x > 0)
  1430. // {
  1431. // rushDir = Vector3.left;
  1432. // }
  1433. // else
  1434. // {
  1435. // rushDir = Vector3.right;
  1436. // }
  1437. //}
  1438. //else
  1439. //{
  1440. // rushDir = leftDir.normalized;
  1441. //}
  1442. rb.velocity = rushDir * rushSpeed;
  1443. break;
  1444. case CharacterState.Sprint:
  1445. if (!btnRushKeep)
  1446. {
  1447. if (CheckPlayerChangeState(CharacterState.Sprint))
  1448. {
  1449. break;
  1450. }
  1451. }
  1452. if (mp < sprintCostMp * Time.deltaTime)
  1453. {
  1454. if (CheckPlayerChangeState(CharacterState.Sprint))
  1455. {
  1456. break;
  1457. }
  1458. }
  1459. mp -= sprintCostMp * Time.deltaTime;
  1460. uiMp.Show(mp, totalMp);
  1461. //CheckTurn();
  1462. //if (leftDir.magnitude < 0.3f)
  1463. //{
  1464. // if (bodyTrans.localScale.x > 0)
  1465. // {
  1466. // rushDir = Vector3.left;
  1467. // }
  1468. // else
  1469. // {
  1470. // rushDir = Vector3.right;
  1471. // }
  1472. //}
  1473. //else
  1474. //{
  1475. // rushDir = leftDir.normalized;
  1476. //}
  1477. rb.velocity = rushDir * rushSpeed;
  1478. break;
  1479. case CharacterState.Die:
  1480. if (dieKeepTime <= 0)
  1481. {
  1482. if (isRevive)
  1483. {
  1484. reviveTime += Time.deltaTime;
  1485. if (reviveTime >= totalReviveTime)
  1486. {
  1487. PlayerRevive();
  1488. }
  1489. }
  1490. else
  1491. {
  1492. PlayerDie();
  1493. }
  1494. }
  1495. break;
  1496. case CharacterState.Conduct:
  1497. if (CheckConduct())
  1498. {
  1499. ChangeState(CharacterState.Idle);
  1500. }
  1501. break;
  1502. default:
  1503. break;
  1504. }
  1505. if (!foot.TrigGround && !canFly)
  1506. {
  1507. if (rb.velocity.y > 0)
  1508. {
  1509. rb.velocity += Vector3.up * extraRiseGravity * Time.deltaTime;
  1510. }
  1511. else
  1512. {
  1513. rb.velocity += Vector3.up * extraFallGravity * Time.deltaTime;
  1514. }
  1515. }
  1516. isClickBtnRush = false;
  1517. isKeepBtnRush = false;
  1518. isClickBtnJump = false;
  1519. isClickBtnSouth = false;
  1520. isClickBtnEast = false;
  1521. isClickBtnNorth = false;
  1522. isClickBtnWest = false;
  1523. isBtnSouthUp = false;
  1524. isBtnEastUp = false;
  1525. isBtnNorthUp = false;
  1526. isBtnWestUp = false;
  1527. isSpiritSummon = false;
  1528. isSpiritSummon1 = false;
  1529. isSpiritSummon2 = false;
  1530. isSpiritSummon3 = false;
  1531. isClickBtnTransfigurate = false;
  1532. keyTransfigurateRelease = false;
  1533. if (foot.TrigGround)
  1534. {
  1535. canJumpTime = leaveGroundCanJumpTime;
  1536. }
  1537. //SearchTarget();
  1538. //attackTarget = targetCharacter;
  1539. if (isMpRepel && floatState == 0)
  1540. {
  1541. if (mp < totalMp)
  1542. {
  1543. if (!isRapedReply)
  1544. {
  1545. mp += mpReplySpeed * Time.deltaTime;
  1546. }
  1547. else
  1548. {
  1549. mp += rapidReplySpeed * Time.deltaTime;
  1550. }
  1551. }
  1552. }
  1553. if (floatState != 0)
  1554. {
  1555. if (mp > 0)
  1556. {
  1557. lostMp += mpReplySpeed * Time.deltaTime;
  1558. mp -= mpReplySpeed * Time.deltaTime;
  1559. }
  1560. if (lostMp >= addMp)
  1561. {
  1562. Instantiate(soul, transform.position, new Quaternion(0, 0, 0, 0), null);
  1563. lostMp = 0;
  1564. }
  1565. }
  1566. if (mp > totalMp)
  1567. {
  1568. mp = totalMp;
  1569. }
  1570. if (mp < 0)
  1571. {
  1572. mp = 0;
  1573. }
  1574. uiMp.Show(mp, totalMp);
  1575. }
  1576. public void PlayerDie()
  1577. {
  1578. switch (playerId)
  1579. {
  1580. case 0:
  1581. SpiritSystem.isP1In = true;
  1582. SpiritSystem.isP1Out = false;
  1583. break;
  1584. case 1:
  1585. SpiritSystem.isP2In = true;
  1586. SpiritSystem.isP2Out = false;
  1587. break;
  1588. default:
  1589. break;
  1590. }
  1591. foot.trigGroundList.Clear();
  1592. bodyTrans.gameObject.SetActive(false);
  1593. uiHp.transform.parent.gameObject.SetActive(false);
  1594. rb.constraints = RigidbodyConstraints.FreezeAll;
  1595. isRevive = true;
  1596. reviveTime = 0;
  1597. }
  1598. public void PlayerRevive()
  1599. {
  1600. isRevive = false;
  1601. isBaseBtnOut = false;
  1602. bodyTrans.gameObject.SetActive(true);
  1603. uiHp.transform.parent.gameObject.SetActive(true);
  1604. rb.constraints = RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezeRotation;
  1605. transform.position = new Vector3(142 + 4 * playerId, 0, 0);
  1606. switch (playerId)
  1607. {
  1608. case 0:
  1609. SpiritSystem.isP1In = false;
  1610. SpiritSystem.isP1Out = true;
  1611. SpiritSystem.player1 = gameObject;
  1612. SpiritSystem.p1Spirits = GetComponent<Spirits>();
  1613. break;
  1614. case 1:
  1615. SpiritSystem.isP2In = false;
  1616. SpiritSystem.isP2Out = true;
  1617. SpiritSystem.player2 = gameObject;
  1618. SpiritSystem.p2Spirits = GetComponent<Spirits>();
  1619. break;
  1620. default:
  1621. break;
  1622. }
  1623. Init();
  1624. }
  1625. public void RapidReplyMp()
  1626. {
  1627. isRapedReply = true;
  1628. rapidReplyEffect.SetActive(true);
  1629. }
  1630. public void NormalReplyMp()
  1631. {
  1632. isRapedReply = false;
  1633. rapidReplyEffect.SetActive(false);
  1634. }
  1635. public override void ChangeState(CharacterState newState)
  1636. {
  1637. if (state == newState)
  1638. {
  1639. return;
  1640. }
  1641. Vector3 velocity = rb.velocity;
  1642. switch (state)
  1643. {
  1644. case CharacterState.Idle:
  1645. break;
  1646. case CharacterState.Run:
  1647. velocity.x = 0;
  1648. break;
  1649. case CharacterState.Rise:
  1650. bodyCollider.SetActive(true);
  1651. break;
  1652. case CharacterState.Fall:
  1653. break;
  1654. //case CharacterState.Hurt:
  1655. // break;
  1656. case CharacterState.Coma:
  1657. canMove = true;
  1658. break;
  1659. case CharacterState.Attack:
  1660. aniCollider.Play("NotAttack", 1, 0);
  1661. break;
  1662. case CharacterState.KeepAttack:
  1663. aniCollider.Play("NotAttack", 1, 0);
  1664. break;
  1665. case CharacterState.Summon:
  1666. rb.isKinematic = false;
  1667. if (cacheDir != 0)
  1668. {
  1669. if (cacheDir > 0.3f && bodyTrans.localScale.x > 0)
  1670. {
  1671. Turn();
  1672. }
  1673. else if (cacheDir < -0.3f && bodyTrans.localScale.x < 0)
  1674. {
  1675. Turn();
  1676. }
  1677. cacheDir = 0;
  1678. }
  1679. break;
  1680. case CharacterState.Rush:
  1681. velocity = Vector3.zero;
  1682. break;
  1683. case CharacterState.Sprint:
  1684. velocity = Vector3.zero;
  1685. break;
  1686. case CharacterState.Die:
  1687. if (isRevive)
  1688. {
  1689. return;
  1690. }
  1691. isDie = false;
  1692. break;
  1693. case CharacterState.Conduct:
  1694. rb.isKinematic = false;
  1695. Time.timeScale = 1;
  1696. Time.fixedDeltaTime = fixedDeltaTime * Time.timeScale;
  1697. conductReadyTip.activeFalse();
  1698. break;
  1699. default:
  1700. break;
  1701. }
  1702. CharacterState oldState = state;
  1703. state = newState;
  1704. switch (newState)
  1705. {
  1706. case CharacterState.Idle:
  1707. aniCollider.Play("Idle", 0, 0);
  1708. if (oldState == CharacterState.Fall)
  1709. {
  1710. ani.Play("fall_end", 0, 0);
  1711. }
  1712. else
  1713. {
  1714. ani.Play("idle", 0, 0);
  1715. }
  1716. velocity = Vector3.right * velocityAddition;
  1717. //animalAni.SetInteger("state", (int)PlayerState.Idle);
  1718. break;
  1719. case CharacterState.Run:
  1720. aniCollider.Play("Run", 0, 0);
  1721. ani.Play("run_start", 0, 0);
  1722. //animalAni.SetInteger("state", (int)PlayerState.Walk);
  1723. break;
  1724. case CharacterState.Rise:
  1725. aniCollider.Play("Rise", 0, 0);
  1726. canJumpTime = 0;
  1727. break;
  1728. case CharacterState.Fall:
  1729. aniCollider.Play("Fall", 0, 0);
  1730. ani.Play("fall", 0, 0);
  1731. //animalAni.SetInteger("state", (int)PlayerState.Fall);
  1732. break;
  1733. //case CharacterState.Hurt:
  1734. // aniCollider.Play("Hurt", 0, 0);
  1735. // ani.Play("hitted", 0, 0);
  1736. // invincibleTime = totalInvincibleTime;
  1737. // hurtKeepTime = minHurtKeepTime;
  1738. // //ani.Play("Invincible", 2, 0);
  1739. // break;
  1740. case CharacterState.Coma:
  1741. //ani.Play("Coma", 0, 0);
  1742. ani.Play("idle", 0, 0);
  1743. aniCollider.Play("Idle", 0, 0);
  1744. rb.velocity = Vector3.zero;
  1745. break;
  1746. case CharacterState.Attack:
  1747. attackController.attackTime = totalAttack_summonTime;
  1748. break;
  1749. case CharacterState.KeepAttack:
  1750. aniCollider.Play("Attack_summonKeep", 1, 0);
  1751. break;
  1752. case CharacterState.Summon:
  1753. aniCollider.Play("Summon", 0, 0);
  1754. ani.Play("summon", 0, 0);
  1755. velocity = Vector3.right * velocityAddition;
  1756. rb.isKinematic = true;
  1757. cacheDir = 0;
  1758. cacheRush = false;
  1759. break;
  1760. case CharacterState.Rush:
  1761. aniCollider.Play("Rush", 0, 0);
  1762. ani.Play("rush_loop", 0, 0);
  1763. rushTime = totalRushTime;
  1764. invincibleTime = rushInvincibleTime;
  1765. //if (leftDir.magnitude < 0.3f)
  1766. //{
  1767. // if (bodyTrans.localScale.x > 0)
  1768. // {
  1769. // rushDir = Vector3.left;
  1770. // }
  1771. // else
  1772. // {
  1773. // rushDir = Vector3.right;
  1774. // }
  1775. //}
  1776. //else
  1777. //{
  1778. // rushDir = leftDir.normalized;
  1779. //}
  1780. if (bodyTrans.localScale.x > 0)
  1781. {
  1782. rushDir = Vector3.left;
  1783. }
  1784. else
  1785. {
  1786. rushDir = Vector3.right;
  1787. }
  1788. velocity = rushDir * rushSpeed;
  1789. mp -= rushCostMp;
  1790. uiMp.Show(mp, totalMp);
  1791. break;
  1792. case CharacterState.Sprint:
  1793. aniCollider.Play("Sprint", 0, 0);
  1794. //ani.Play("rush_loop", 0, 0);
  1795. velocity = rushDir * rushSpeed;
  1796. break;
  1797. case CharacterState.Die:
  1798. aniCollider.Play("Die", 0, 0);
  1799. ani.Play("die", 0, 0);
  1800. isDie = true;
  1801. dieKeepTime = totalDieKeepTime;
  1802. break;
  1803. case CharacterState.Conduct:
  1804. conductTime = 0;
  1805. rb.velocity = Vector3.zero;
  1806. rb.isKinematic = true;
  1807. aniCollider.Play("Summon", 0, 0);
  1808. ani.Play("summon", 0, 0);
  1809. break;
  1810. default:
  1811. break;
  1812. }
  1813. rb.velocity = velocity;
  1814. }
  1815. public void CheckTurn()
  1816. {
  1817. if (leftDir.x > 0.3f && bodyTrans.localScale.x > 0)
  1818. {
  1819. if (state == CharacterState.Run)
  1820. {
  1821. ani.Play("run_start", 0, 0);
  1822. }
  1823. Turn();
  1824. }
  1825. else if (leftDir.x < -0.3f && bodyTrans.localScale.x < 0)
  1826. {
  1827. if (state == CharacterState.Run)
  1828. {
  1829. ani.Play("run_start", 0, 0);
  1830. }
  1831. Turn();
  1832. }
  1833. }
  1834. public Vector3 AirMove(Vector3 velocity)
  1835. {
  1836. CheckTurn();
  1837. if (canFly)
  1838. {
  1839. velocity = leftDir.normalized * flySpeed;
  1840. if (transform.position.y > maxFlyHeight && velocity.y > 0)
  1841. {
  1842. velocity.y = 0;
  1843. }
  1844. }
  1845. else
  1846. {
  1847. if (leftDir.x > 0.3f)
  1848. {
  1849. velocity = new Vector3(moveSpeed, velocity.y, velocity.z);
  1850. }
  1851. else if (leftDir.x < -0.3f)
  1852. {
  1853. velocity = new Vector3(-moveSpeed, velocity.y, velocity.z);
  1854. }
  1855. else
  1856. {
  1857. velocity = new Vector3(0, velocity.y, velocity.z);
  1858. }
  1859. }
  1860. return velocity;
  1861. }
  1862. public void Summon(int id)
  1863. {
  1864. if (id >= demonicPrefabs.Count)
  1865. {
  1866. Debug.LogError("未配置" + id + "号使魔");
  1867. return;
  1868. }
  1869. if (id >= demonicSummonPos.Count)
  1870. {
  1871. Debug.LogError("未配置" + id + "号使魔召唤位置");
  1872. return;
  1873. }
  1874. GameObject prefab;
  1875. if (id == 1)
  1876. {
  1877. prefab = chooseYinYang.SelectPrefab(playerId);
  1878. }
  1879. else
  1880. {
  1881. prefab = demonicPrefabs[id];
  1882. }
  1883. if (!CheckCanSummon(id))
  1884. {
  1885. return;
  1886. }
  1887. ChangeState(CharacterState.Summon);
  1888. summonTime = prefab.GetComponent<Demonic>().totalSummonTime;
  1889. float costMp = prefab.GetComponent<Demonic>().costMp;
  1890. mp -= costMp;
  1891. uiMp.Show(mp, totalMp);
  1892. GameObject demonicObj = PoolManager.Instantiate(prefab);
  1893. Demonic demonic = demonicObj.GetComponent<Demonic>();
  1894. demonic.id = id;
  1895. demonic.playerID = playerId;
  1896. if (!demonicDic.ContainsKey(id))
  1897. {
  1898. demonicDic.Add(id, new List<Demonic>());
  1899. }
  1900. demonicDic[id].Add(demonic);
  1901. if (id <= 2)
  1902. {
  1903. demonicNums[id].text = demonicDic[id].Count.ToString();
  1904. }
  1905. demonicObj.transform.parent = null;
  1906. demonicObj.transform.localEulerAngles = Vector3.zero;
  1907. demonicObj.transform.localScale = new Vector3(1, 1, 1);
  1908. Vector3 offset = demonicSummonPos[id];
  1909. if (bodyTrans.localScale.x > 0)
  1910. {
  1911. demonicObj.transform.position = transform.position + offset;
  1912. if (demonic.bodyTrans.localScale.x < 0)
  1913. {
  1914. demonic.Turn();
  1915. }
  1916. }
  1917. else
  1918. {
  1919. demonicObj.transform.position = transform.position + new Vector3(-offset.x, offset.y, offset.z);
  1920. if (demonic.bodyTrans.localScale.x > 0)
  1921. {
  1922. demonic.Turn();
  1923. }
  1924. }
  1925. if (demonic.canFly)
  1926. {
  1927. demonic.flyHeight = demonic.transform.position.y;
  1928. }
  1929. demonic.player = this;
  1930. demonic.Init();
  1931. int order = prefab.GetComponent<Demonic>().baseSortingOrder + demonicDic[demonic.id].Count;
  1932. demonic.SetSortingOrder(order);
  1933. if (id != 4)
  1934. {
  1935. demonic.Attack_summon();
  1936. }
  1937. //id 3~6 为四个英灵
  1938. if (id >= 3 && id <= 6)
  1939. {
  1940. spirits.ultimateTimes[spirits.nowSpirit] -= 1;
  1941. }
  1942. spiritSystem.RefreshPlayerUI();
  1943. if (isInSoulTower)
  1944. {
  1945. ls.AddDenomic(demonic);
  1946. }
  1947. }
  1948. public void OnDemonicRecycle(Demonic demonic)
  1949. {
  1950. if (!demonicDic.ContainsKey(demonic.id))
  1951. {
  1952. return;
  1953. }
  1954. demonicDic[demonic.id].Remove(demonic);
  1955. if (demonic.id <= 2)
  1956. {
  1957. demonicNums[demonic.id].text = demonicDic[demonic.id].Count.ToString();
  1958. }
  1959. for (int i = 0; i < demonicDic[demonic.id].Count; i++)
  1960. {
  1961. int order = demonicDic[demonic.id][i].baseSortingOrder + i;
  1962. demonicDic[demonic.id][i].SetSortingOrder(order);
  1963. }
  1964. }
  1965. public bool CheckCanSummon(int id)
  1966. {
  1967. GameObject prefab;
  1968. if (id == 1)
  1969. {
  1970. prefab = chooseYinYang.SelectPrefab(playerId);
  1971. }
  1972. else
  1973. {
  1974. prefab = demonicPrefabs[id];
  1975. }
  1976. float costMp = prefab.GetComponent<Demonic>().costMp;
  1977. if (id < 3)
  1978. {
  1979. costMp += addCostMp[id] * demonicDic[id].Count;
  1980. }
  1981. if (mp < costMp)
  1982. {
  1983. Debug.Log("mp不足召唤失败, 还得加个动画或者音效啥的");
  1984. return false;
  1985. }
  1986. return true;
  1987. }
  1988. public void Attack_summon()
  1989. {
  1990. attackController.Attack_summon();
  1991. if (leftDir.x > 0.3f)
  1992. {
  1993. if (bodyTrans.localScale.x > 0)
  1994. {
  1995. Turn();
  1996. }
  1997. SetAttackState(PlayerAttackState.WalkForward);
  1998. }
  1999. else if (leftDir.x < -0.3f)
  2000. {
  2001. if (bodyTrans.localScale.x < 0)
  2002. {
  2003. Turn();
  2004. }
  2005. SetAttackState(PlayerAttackState.WalkForward);
  2006. }
  2007. else
  2008. {
  2009. SetAttackState(PlayerAttackState.Idle);
  2010. }
  2011. }
  2012. public void SetAttackState(PlayerAttackState value)
  2013. {
  2014. attackState = value;
  2015. ani.SetInteger("attackState", (int)value);
  2016. aniCollider.Play("Attack_summonKeep", 1, 0);
  2017. }
  2018. /*
  2019. public void SearchTarget()
  2020. {
  2021. targetCharacter = searchTrigger.GetMinDisTarget(attackController.targetTypes, attackController.canHitFly);
  2022. }*/
  2023. public void ChangeSpirit()
  2024. {
  2025. if ((playerId == 0 && SpiritSystem.canP1CardChange) || (playerId == 1 && SpiritSystem.canP2CardChange))
  2026. {
  2027. if (rightDir.x >= 0.5)
  2028. {
  2029. switch (playerId)
  2030. {
  2031. case 0:
  2032. SpiritSystem.P1CardChangeTime = 0;
  2033. SpiritSystem.canP1CardChange = false;
  2034. SpiritSystem.isP1CardChangeR = true;
  2035. break;
  2036. case 1:
  2037. SpiritSystem.P2CardChangeTime = 0;
  2038. SpiritSystem.canP2CardChange = false;
  2039. SpiritSystem.isP2CardChangeR = true;
  2040. break;
  2041. default:
  2042. break;
  2043. }
  2044. }
  2045. else if (rightDir.x <= -0.5)
  2046. {
  2047. switch (playerId)
  2048. {
  2049. case 0:
  2050. SpiritSystem.P1CardChangeTime = 0;
  2051. SpiritSystem.canP1CardChange = false;
  2052. SpiritSystem.isP1CardChangeL = true;
  2053. break;
  2054. case 1:
  2055. SpiritSystem.P2CardChangeTime = 0;
  2056. SpiritSystem.canP2CardChange = false;
  2057. SpiritSystem.isP2CardChangeL = true;
  2058. break;
  2059. default:
  2060. break;
  2061. }
  2062. }
  2063. }
  2064. }
  2065. }