MoveCharacter.cs 23 KB

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