MoveCharacter.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689
  1. using Spine.Unity;
  2. using Spine;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using UnityEngine;
  6. using TMPro;
  7. using Sirenix.OdinInspector;
  8. public enum CharacterTag
  9. {
  10. Common,
  11. Tank
  12. }
  13. public class MoveCharacter : Character
  14. {
  15. [Space(30)]
  16. [Title("MoveCharacter属性")]
  17. public CharacterTag charactertag;
  18. [LabelText("角色抗击打值")] public int hitResistance;
  19. [LabelText("Buff控制器")] public BuffController bc;
  20. [FoldoutGroup("组件")] public Foot foot;
  21. [HideInInspector] public AttributeStatus attributeStatus;
  22. [HideInInspector] public HitFeedbackSystem hitFeedbackSystem;
  23. [HideInInspector] public SpineEvent spineEvent;
  24. [FoldoutGroup("额外重力",order:-1)] [LabelText("上升")] public float extraRiseGravity = -28.8f; //上升时额外重力加速度
  25. [FoldoutGroup("额外重力")] [LabelText("下落")] public float extraFallGravity = -14.4f; //下落时额外重力加速度
  26. [FoldoutGroup("额外重力")] [LabelText("近地")] public float extraGroundGravity = -28.8f;
  27. [FoldoutGroup("平台", order: -1)] [LabelText("移速增量")]public float velocityAddition;
  28. [FoldoutGroup("平台")] [DisplayOnly] public float platformPosY;
  29. [FoldoutGroup("平台")] [DisplayOnly] public float platformRotZ;
  30. [FoldoutGroup("平台")] public float RotLerpSpeed = 0.6f;
  31. [FoldoutGroup("平台")] [DisplayOnly] public float RotLerpTime;
  32. [FoldoutGroup("飞行兵落地后回升")] [LabelText("是否需要判定回升")] public bool needToAdjustFlyHeight;
  33. [FoldoutGroup("飞行兵落地后回升", order: -1)] [DisplayOnly] public float flyHeight;
  34. [FoldoutGroup("飞行兵落地后回升")] [LabelText("最大高度")] public float maxFlyHeight;
  35. [FoldoutGroup("飞行兵落地后回升")] [LabelText("最低高度")] public float minFlyHeight;
  36. float refspeed = 1;
  37. [FoldoutGroup("飞行兵落地后回升")] [LabelText("速度")] [Range(0, 1)] public float flyUpTime;
  38. [HideInInspector]
  39. public int isAdjustHeight;
  40. [Header("材质")]
  41. public float matState = 1;
  42. public GameObject spinee;
  43. public MeshRenderer mesh;
  44. public Material[] mats;
  45. public Material[] outlineMats;
  46. public Material[] outline1Mats;
  47. [Header("属性")]
  48. public float moveSpeed = 5;
  49. public float moveSpeedScale = 1;
  50. [Header("减伤")]
  51. public bool isDamageReduction;
  52. public float reductionDegree;
  53. public GameObject reductionEffect;
  54. //技能类,后面移到其他脚本
  55. [Header("临时血量")]
  56. public GameObject effect;
  57. private int temptHP;
  58. private int curHP;
  59. private float continueTime;
  60. private bool isTempt;
  61. [Header("魂")]
  62. public GameObject soulPrefab;
  63. public float soulStartSpeed = 1f;
  64. [Header("隐身")]
  65. public bool isInvisible;
  66. public float invisibleTime;
  67. [Header("传送门")]
  68. public bool haveTransmit;
  69. [HideInInspector]
  70. public float transmitTime;
  71. public PortalsController portalsController;
  72. [Header("受到持续伤害")]
  73. public bool isSustainedInjury; //是否正在受到持续伤害
  74. [HideInInspector] public float sustainedInjuryTime; //存储持续伤害经过的时间
  75. public float sustainedInjury_IntervalTime; //每次伤害的间隔时间
  76. public int sustainedInjury_damage; //每次造成的伤害
  77. [Header("受到重伤")]
  78. public float heavyDamage;
  79. [Header("被谁击杀")]
  80. [DisplayOnly]
  81. public Character killer;
  82. [Header("冰冻效果")]
  83. public bool isFrozen = false;
  84. private float frozenTimer;
  85. [Header("感电效果")]
  86. public bool isElectrify = false;
  87. private float electrifyTimer;
  88. public GameObject electrifyEffect;
  89. [Header("灼烧效果")]
  90. public bool isOnFire = false;
  91. public int fireStacks;
  92. private float fireTimer;
  93. private float fireBuffTimer;
  94. private GameObject fireEffect;
  95. public virtual void Awake()
  96. {
  97. spinee = bodyTrans.GetChild(0).gameObject;
  98. mesh = spinee.GetComponent<MeshRenderer>();
  99. mats = mesh.materials;
  100. attributeStatus = GetComponentInChildren<AttributeStatus>();
  101. hitFeedbackSystem = beHitTrigger.GetComponent<HitFeedbackSystem>();
  102. }
  103. private void Start()
  104. {
  105. }
  106. public override void Init()
  107. {
  108. base.Init();
  109. attributeStatus.Init();
  110. transform.localScale = Vector3.one;
  111. mecanim.transform.localPosition = Vector3.zero;
  112. mecanim.transform.localRotation = Quaternion.Euler(Vector3.zero);
  113. platformRotZ = 0;
  114. }
  115. //0:漂浮 1:正常 2:无敌
  116. public void ChangeMat(int state)
  117. {
  118. if((state == 0 && matState == 2) || (state == 2 && matState == 0))
  119. {
  120. return;
  121. }
  122. if (outline1Mats.Length == 0)
  123. {
  124. return;
  125. }
  126. if (spinee == null || mesh == null || mats == null)
  127. {
  128. spinee = transform.GetChild(0).GetChild(0).gameObject;
  129. mesh = spinee.GetComponent<MeshRenderer>();
  130. mats = mesh.materials;
  131. }
  132. switch (state)
  133. {
  134. case 0:
  135. mesh.materials = outlineMats;
  136. break;
  137. case 1:
  138. mesh.materials = mats;
  139. break;
  140. case 2:
  141. mesh.materials = outline1Mats;
  142. break;
  143. }
  144. matState = state;
  145. }
  146. public void GetTemptHP(int addTemptHP, float time)
  147. {
  148. isTempt = true;
  149. effect.SetActive(true);
  150. curHP = hp;
  151. totalHp += addTemptHP;
  152. hp += addTemptHP;
  153. temptHP = addTemptHP;
  154. continueTime = time;
  155. }
  156. private void LoseTemptHP()
  157. {
  158. isTempt = false;
  159. effect.SetActive(false);
  160. totalHp -= temptHP;
  161. if (hp > curHP)
  162. {
  163. hp = curHP;
  164. }
  165. }
  166. public virtual void Update()
  167. {
  168. CheckElectrify();
  169. CheckFrozen();
  170. CheckFire();
  171. if (isTempt)
  172. {
  173. continueTime -= Time.deltaTime;
  174. if (continueTime <= 0 || hp <= curHP)
  175. {
  176. LoseTemptHP();
  177. }
  178. }
  179. if (beLarger)
  180. {
  181. Enlarge();
  182. }/*
  183. if (isInvisible)
  184. {
  185. invisibleTime -= Time.deltaTime;
  186. if(invisibleTime <= 0)
  187. {
  188. isInvisible = false;
  189. ChangeMat(1);
  190. }
  191. }
  192. if (haveTransmit)
  193. {
  194. transmitTime -= Time.deltaTime;
  195. if(transmitTime <=0)
  196. {
  197. haveTransmit = false;
  198. portalsController.rbs.Remove(rb);
  199. }
  200. }*/
  201. //受到持续伤害
  202. if (isSustainedInjury)
  203. {
  204. SustainedInjury();
  205. }
  206. }
  207. //伤害减免状态开启(减免程度,减免时长)
  208. public void DamageReductionStateOn(float degree, GameObject effect)
  209. {
  210. if (reductionEffect == null)
  211. {
  212. reductionEffect = PoolManager.Instantiate(effect, transform.position, new Quaternion(0, 0, 0, 0), transform);
  213. }
  214. reductionEffect.SetActive(true);
  215. isDamageReduction = true;
  216. reductionDegree = degree;
  217. canNotChangeHurt = true;
  218. }
  219. public void DamageReductionStateToOff(float onTime)
  220. {
  221. Invoke("DamageReductionStateOff", onTime);
  222. }
  223. private void DamageReductionStateOff()
  224. {
  225. isDamageReduction = false;
  226. reductionEffect.SetActive(false);
  227. canNotChangeHurt = false;
  228. }
  229. //仅造成伤害
  230. public override void BeHit(int damage)
  231. {
  232. if (invincibleTime > 0)
  233. {
  234. //attributeStatus.AddSpecialState(attackInfo, attackFrom);
  235. return;
  236. }
  237. if (Random.Range(0, 100) < attributeStatus.resistances.dodge)
  238. {
  239. return;
  240. }
  241. int armorRate = attributeStatus.resistances.armor;
  242. //计算护甲减免
  243. damage = (int)(damage * (100f / (100 + armorRate)) + 0.5f);
  244. damage = (int)(damage * (1 + attributeStatus.vulnerableRate) + 0.5f);
  245. //伤害跳字
  246. if (showInjuryNum && damage > 0)
  247. {
  248. GameObject injuryNum;
  249. injuryNum = PoolManager.Instantiate(injuryNumTextSummon);
  250. injuryNum.transform.position = new Vector3(
  251. transform.position.x + injuryNumPos_summon.x + Random.Range(-injuryNumRandom_summon.x / 2f, injuryNumRandom_summon.x / 2f),
  252. transform.position.y + injuryNumPos_summon.y + Random.Range(-injuryNumRandom_summon.y / 2f, injuryNumRandom_summon.y / 2f),
  253. transform.position.z);
  254. TextMeshProUGUI text = injuryNum.GetComponentInChildren<TextMeshProUGUI>();
  255. text.text = damage.ToString();
  256. }
  257. hp -= damage;
  258. uiHp.Show(hp, totalHp);
  259. if (hp <= 0)
  260. {
  261. hitFeedbackSystem.curCharacterState = CharacterState.None;
  262. ChangeState(CharacterState.Die);
  263. }
  264. }
  265. //造成伤害附加其他效果,最好都用这个新版本的
  266. //damage 有传参的话会忽略attackinfo 中的damage值
  267. public override void BeHit(AttackController.AttackMethod attackMethod, Character attackFrom, int damage = -1)
  268. {
  269. if (invincibleTime > 0)
  270. {
  271. //attributeStatus.AddSpecialState(attackInfo, attackFrom);
  272. return;
  273. }
  274. if (Random.Range(0, 100) < attributeStatus.resistances.dodge && CompareTag("Demonic"))
  275. {
  276. GameObject missTxt = PoolManager.Instantiate(injuryNumTextSummon);
  277. missTxt.transform.position = new Vector3(
  278. transform.position.x + injuryNumPos_summon.x + Random.Range(-injuryNumRandom_summon.x / 2f, injuryNumRandom_summon.x / 2f),
  279. transform.position.y + injuryNumPos_summon.y + Random.Range(-injuryNumRandom_summon.y / 2f, injuryNumRandom_summon.y / 2f),
  280. transform.position.z);
  281. TextMeshProUGUI text = missTxt.GetComponentInChildren<TextMeshProUGUI>();
  282. text.text = "Miss";
  283. return;
  284. }
  285. AttackInfo attackInfo = attackMethod.attackInfo;
  286. ScreenReflectPresets.instance.ScreenReflect(hitFeedbackSystem, attackInfo.attackValue - hitResistance);
  287. int damageData;
  288. if(damage == -1)
  289. {
  290. damageData = attackInfo.damage;
  291. }
  292. else
  293. {
  294. damageData = damage;
  295. }
  296. if (attackFrom.CompareTag("Demonic") || attackFrom.CompareTag("Player"))
  297. {
  298. damageData = CalculateFinalDamage(damageData, attackFrom);
  299. }
  300. int armorRate = attributeStatus.resistances.armor;
  301. bool haveStackingWords = false;
  302. if (attackInfo.attackEffect != null && attackInfo.attackEffect.Count > 0)
  303. {
  304. foreach (AttackEffect ae in attackInfo.attackEffect)
  305. {
  306. switch (ae)
  307. {
  308. /*非控制*/
  309. //穿甲
  310. case AttackEffect.ArmorPiercing:
  311. armorRate = attributeStatus.AddArmorPiercing(attackMethod);
  312. break;
  313. //易伤
  314. case AttackEffect.Vulnerable:
  315. attributeStatus.AddVulnerable(attackMethod.attackInfo.vulnerable.rate, attackMethod.attackInfo.vulnerable.time);
  316. break;
  317. case AttackEffect.StackingWounds:
  318. haveStackingWords = true;
  319. attributeStatus.AddStackingWouds(attackMethod);
  320. break;
  321. }
  322. }
  323. }
  324. //计算累伤
  325. if (haveStackingWords)
  326. {
  327. damageData = (int)(damageData + attributeStatus.stackingWords + 0.5f);
  328. }
  329. //计算护甲减免
  330. damageData = (int)(damageData * (100f / (100 + armorRate)) + 0.5f);
  331. //计算易伤
  332. damageData = (int)(damageData * (1 + attributeStatus.vulnerableRate) + 0.5f);
  333. //伤害减免,先注释,用到的时候再改
  334. //if (isDamageReduction)
  335. //{
  336. // damage = (int)((1 - reductionDegree) * damage);
  337. //}
  338. if (Random.Range(0, 100) < attackInfo.criticalChance)
  339. {
  340. damageData = (int)((2 + attackInfo.criticalStrikeEffect/100f) * damageData);
  341. }
  342. hp -= damageData;
  343. if(Random.Range(0,100) < attackInfo.lifesteal)
  344. {
  345. attackFrom.hp = Mathf.Clamp(attackFrom.hp + attackFrom.attackController.lifesteal, 0, attackFrom.totalHp);
  346. }
  347. //敌方士兵受起手式伤害/我方士兵受伤 闪白
  348. if (!isFrozen)
  349. {
  350. if ((attackFrom.CompareTag("Demonic")||attackFrom.CompareTag("Player")) && attackInfo.attackMethod_Type == AttackMethod_Type.Attack_Summon)
  351. {
  352. beHitTrigger.JudgeTurnWhite(true, this);
  353. }
  354. else
  355. {
  356. beHitTrigger.JudgeTurnWhite(false, this);
  357. }
  358. }
  359. //击中特效(如果有的话)
  360. if (attackInfo.effect)
  361. {
  362. Vector3 effectPos = beHitTrigger.GetComponent<Collider>().bounds.center;
  363. PoolManager.Instantiate(attackInfo.effect, effectPos);
  364. }
  365. //伤害跳字
  366. if (showInjuryNum && damageData > 0)
  367. {
  368. GameObject injuryNum;
  369. //是起手式
  370. if ((attackFrom.CompareTag("Demonic") || attackFrom.CompareTag("Player") )&& attackInfo.attackMethod_Type == AttackMethod_Type.Attack_Summon)
  371. {
  372. injuryNum = PoolManager.Instantiate(injuryNumTextSummon);
  373. injuryNum.transform.position = new Vector3(
  374. transform.position.x + injuryNumPos_summon.x + Random.Range(-injuryNumRandom_summon.x / 2f, injuryNumRandom_summon.x / 2f),
  375. transform.position.y + injuryNumPos_summon.y + Random.Range(-injuryNumRandom_summon.y / 2f, injuryNumRandom_summon.y / 2f),
  376. transform.position.z);
  377. if (isElectrify && GameManager.instance.isWindThunderEnable)
  378. {
  379. int randomInt = Random.Range(0, 100);
  380. if (randomInt < GameManager.instance.windThunderProbability)
  381. {
  382. LightningStrike();
  383. }
  384. }
  385. }
  386. //不是起手式
  387. else
  388. {
  389. injuryNum = PoolManager.Instantiate(injuryNumText);
  390. injuryNum.transform.position = new Vector3(
  391. transform.position.x + injuryNumPos_march.x + Random.Range(-injuryNumRandom_march.x / 2f, injuryNumRandom_march.x / 2f),
  392. transform.position.y + injuryNumPos_march.y + Random.Range(-injuryNumRandom_march.y / 2f, injuryNumRandom_march.y / 2f),
  393. transform.position.z);
  394. }
  395. TextMeshProUGUI text = injuryNum.GetComponentInChildren<TextMeshProUGUI>();
  396. text.text = damageData.ToString();
  397. }
  398. //if ((attackMethod.additionalEffects & AttackAdditionalEffects.Wind) == AttackAdditionalEffects.Wind)
  399. //{
  400. // rb.mass -= rb.mass * GameManager.instance.weightReductionratio;
  401. // BeHit(GameManager.instance.windDamage);
  402. //}
  403. uiHp.Show(hp, totalHp);
  404. if (hp <= 0)
  405. {
  406. killer = attackFrom;
  407. hitFeedbackSystem.curCharacterState = CharacterState.None;
  408. ChangeState(CharacterState.Die);
  409. return;
  410. }
  411. //顿帧
  412. if(damage == -1)
  413. {
  414. hitFeedbackSystem.FreezeFrame(attackMethod, attackFrom);
  415. }
  416. if ((attackMethod.additionalEffects & AttackAdditionalEffects.Fire) == AttackAdditionalEffects.Fire)
  417. {
  418. AddFireBuff();
  419. }
  420. if ((attackMethod.additionalEffects & AttackAdditionalEffects.Ice) == AttackAdditionalEffects.Ice)
  421. {
  422. BeFrozen();
  423. }
  424. }
  425. //受到持续伤害
  426. public void SustainedInjury()
  427. {
  428. sustainedInjuryTime += Time.deltaTime;
  429. if(sustainedInjuryTime >= sustainedInjury_IntervalTime)
  430. {
  431. sustainedInjuryTime = 0;
  432. BeHit(sustainedInjury_damage);
  433. }
  434. }
  435. public override bool AdjustHeight()
  436. {
  437. if (canFly)
  438. {
  439. if (transform.position.y - flyHeight > 0.1f)
  440. {
  441. Vector3 pos = transform.position;
  442. pos.y = Mathf.Lerp(pos.y, flyHeight, flyUpTime);
  443. transform.position = pos;
  444. return false;
  445. }
  446. else if (transform.position.y - flyHeight < -0.1f)
  447. {
  448. Vector3 pos = transform.position;
  449. pos.y = Mathf.Lerp(pos.y, flyHeight, flyUpTime);
  450. transform.position = pos;
  451. return false;
  452. }
  453. else
  454. {
  455. Vector3 pos = transform.position;
  456. pos.y = flyHeight;
  457. transform.position = pos;
  458. }
  459. }
  460. isAdjustHeight = 2;
  461. return true;
  462. }
  463. #region 冰冻效果
  464. public void CheckFrozen()
  465. {
  466. if (isFrozen)
  467. {
  468. if(Time.time - frozenTimer > GameManager.instance.frozenTime + GameManager.instance.myTreasuresTag[2] * GameManager.instance.iceLabelEffectRatio)
  469. {
  470. isFrozen = false;
  471. beHitTrigger.ChangeRenderState(RenderState.Normal);
  472. if (canFly)
  473. {
  474. rb.useGravity = false;
  475. //rb.velocity = Vector3.zero;
  476. isAdjustHeight = 1;
  477. }
  478. }
  479. else
  480. {
  481. if(state != CharacterState.SpecialStatus_BlowUp && state != CharacterState.SpecialStatus_ShotDown)
  482. {
  483. if(state != CharacterState.FramePause && state != CharacterState.HitStun && state != CharacterState.SpecialStatus_Weak)
  484. {
  485. attributeStatus.AddWeak(GameManager.instance.frozenTime + GameManager.instance.myTreasuresTag[2] * GameManager.instance.iceLabelEffectRatio + frozenTimer - Time.time);
  486. }
  487. if (!foot.TrigGround) rb.velocity -= Vector3.down * extraFallGravity * Time.deltaTime;
  488. else nowCanFly = false;
  489. rb.constraints &= ~RigidbodyConstraints.FreezePositionY;
  490. }
  491. }
  492. }
  493. }
  494. public void BeFrozen()
  495. {
  496. if (!isFrozen)
  497. {
  498. beHitTrigger.ChangeRenderState(RenderState.Frozen);
  499. if (GameManager.instance.isFireIceEnable)
  500. {
  501. int randomInt = Random.Range(0, 100);
  502. if (randomInt < GameManager.instance.fireIceProbability)
  503. {
  504. FireExplosion();
  505. }
  506. }
  507. }
  508. isFrozen = true;
  509. frozenTimer = Time.time;
  510. rb.useGravity = true;
  511. rb.constraints &= ~RigidbodyConstraints.FreezePositionY;
  512. }
  513. #endregion
  514. #region 感电效果
  515. private void CheckElectrify()
  516. {
  517. if (isElectrify)
  518. {
  519. if(Time.time - electrifyTimer > GameManager.instance.electrifyTime)
  520. {
  521. isElectrify = false;
  522. ani.speed = 1;
  523. moveSpeedScale = 1f;
  524. electrifyEffect.SetActive(false);
  525. }
  526. }
  527. }
  528. public void BeElectrify()
  529. {
  530. if (!isElectrify)
  531. {
  532. isElectrify = true;
  533. ani.speed = GameManager.instance.attackSpeedScale;
  534. moveSpeedScale = GameManager.instance.moveSpeedScale;
  535. attributeStatus.AddVulnerable(GameManager.instance.vulnerableRate + GameManager.instance.myTreasuresTag[5] * GameManager.instance.thunderLabelEffectRatio, GameManager.instance.electrifyTime);
  536. if (electrifyEffect == null)
  537. {
  538. electrifyEffect = Instantiate(Resources.Load<GameObject>("Prefab/FX/ElectrifyEffect"), transform.position + Vector3.up, Quaternion.identity, transform);
  539. electrifyEffect.transform.localPosition = new Vector3(0, 0.8f, 0);
  540. }
  541. else electrifyEffect.SetActive(true);
  542. }
  543. electrifyTimer = Time.time;
  544. //BeHit(CalculateFinalDamage(GameManager.instance.thunderDamage + GameManager.instance.thunderAttributeDamage));
  545. }
  546. private void LightningStrike()
  547. {
  548. CountDownDestory countDownDestory = PoolManager.Instantiate(Resources.Load<GameObject>("Prefab/FX/Effc_Fall_thunder"), transform.position, Quaternion.identity, transform).AddComponent<CountDownDestory>();
  549. countDownDestory.StartCountDown(1f);
  550. BeHit(GameManager.instance.thunderboltDamage + (int)((GameManager.instance.myTreasuresTag[1] + GameManager.instance.myTreasuresTag[5]) * GameManager.instance.windThunderLabelEffectRatio));
  551. attributeStatus.AddWeak(1f);
  552. }
  553. #endregion
  554. #region 灼烧效果
  555. public void AddFireBuff()
  556. {
  557. fireStacks++;
  558. fireBuffTimer = Time.time;
  559. if (isFrozen && GameManager.instance.isFireIceEnable)
  560. {
  561. int randomInt = Random.Range(0, 100);
  562. if (randomInt < GameManager.instance.fireIceProbability)
  563. {
  564. FireExplosion();
  565. isFrozen = false;
  566. beHitTrigger.ChangeRenderState(RenderState.Normal);
  567. if (canFly)
  568. {
  569. rb.useGravity = false;
  570. isAdjustHeight = 1;
  571. }
  572. }
  573. }
  574. if(fireStacks > 0 && !isOnFire)
  575. {
  576. isOnFire = true;
  577. if (fireEffect == null)
  578. {
  579. fireEffect = Instantiate(Resources.Load<GameObject>("Prefab/FX/FireEffect"), transform.position, Quaternion.identity, transform);
  580. fireEffect.transform.localPosition = new Vector3(0, 0.8f, 0);
  581. }
  582. else fireEffect.SetActive(true);
  583. }
  584. fireTimer = Time.time;
  585. }
  586. public void CheckFire()
  587. {
  588. if (isOnFire)
  589. {
  590. if(Time.time - fireTimer > GameManager.instance.fireInterval)
  591. {
  592. BeHit(CalculateFinalDamage((GameManager.instance.fireDamage + (int)(GameManager.instance.myTreasuresTag[7] * GameManager.instance.fireLabelEffectRatio)) * fireStacks));
  593. Debug.Log(GameManager.instance.myTreasuresTag[7] * GameManager.instance.fireLabelEffectRatio);
  594. fireTimer = Time.time;
  595. }
  596. if (Time.time - fireBuffTimer > GameManager.instance.fireBuffTime)
  597. {
  598. fireStacks = 0;
  599. isOnFire = false;
  600. fireEffect.SetActive(false);
  601. }
  602. }
  603. }
  604. private void FireExplosion()
  605. {
  606. GameObject explosionObj = PoolManager.Instantiate(Resources.Load<GameObject>("Prefab/FX/Explosion"),transform.position);
  607. Explosion explosion = explosionObj.GetComponent<Explosion>();
  608. explosion.Init(this,CalculateFinalDamage(GameManager.instance.explosionDamage + (int)((GameManager.instance.myTreasuresTag[6] + GameManager.instance.myTreasuresTag[2]) * GameManager.instance.fireIceLabelEffectRatio)), 4f,1f);
  609. fireStacks = 0;
  610. isOnFire = false;
  611. if(fireEffect != null) fireEffect.SetActive(false);
  612. Debug.Log("爆炸");
  613. }
  614. #endregion
  615. protected virtual void OnDisable()
  616. {
  617. isOnFire = false;
  618. fireStacks = 0;
  619. if (fireEffect != null) fireEffect.SetActive(false);
  620. isFrozen = false;
  621. isElectrify = false;
  622. if (electrifyEffect != null) electrifyEffect.SetActive(false);
  623. ani.speed = 1;
  624. moveSpeedScale = 1f;
  625. }
  626. }