MoveCharacter.cs 23 KB

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