ExpManager.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. using DG.Tweening;
  2. using GameFramework.Event;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using UnityEngine;
  6. using UnityGameFramework.Runtime;
  7. public class ExpManager : MonoBehaviour
  8. {
  9. private GameObject eff = null;
  10. private static ExpManager mInst = null;
  11. public static void Init()
  12. {
  13. if (null == mInst)
  14. {
  15. GameObject obj = new GameObject(typeof(ExpManager).ToString());
  16. mInst = obj.AddComponent<ExpManager>();
  17. }
  18. }
  19. private void OnEnable()
  20. {
  21. EventComponent eventCmpt = GameEntry.GetComponent<EventComponent>();
  22. eventCmpt.Subscribe(HeroLvlUpEvent.EventId, HeroLevelUpProcessor);
  23. eventCmpt.Subscribe(GetExpEvent.EventId, HeroAddProcessor);
  24. }
  25. private void OnDisable()
  26. {
  27. EventComponent eventCmpt = GameEntry.GetComponent<EventComponent>();
  28. if (eventCmpt.Check(HeroLvlUpEvent.EventId, HeroLevelUpProcessor))
  29. {
  30. eventCmpt.Unsubscribe(HeroLvlUpEvent.EventId, HeroLevelUpProcessor);
  31. }
  32. if (eventCmpt.Check(GetExpEvent.EventId, HeroAddProcessor))
  33. {
  34. eventCmpt.Unsubscribe(GetExpEvent.EventId, HeroAddProcessor);
  35. }
  36. }
  37. /// <summary>
  38. /// 唤灵师等级提升事件
  39. /// </summary>
  40. /// <param name="e"></param>
  41. public void HeroLevelUpProcessor(object sender, GameEventArgs e)
  42. {
  43. var evt = e as HeroLvlUpEvent;
  44. if (null != evt)
  45. {
  46. //// 队列显示唤灵师升级
  47. //PopupEffectQueueHelper.Instance.ShowEffect(ePopupEffectType.HuanLingShiLvUp, "");
  48. //int power = evt.HeroVo.GetPower() - evt.PowerAdded;
  49. //int added = evt.PowerAdded;
  50. //string powerStr = "<color=#F6CF00>" + power.ToString() + "</color>";
  51. //string add = "<color=#ffffff> + </color>";
  52. //string addedStr = "<color=#00ff00>" + added.ToString() + "</color>";
  53. //// 队列显示战力提升
  54. //PopupEffectQueueHelper.Instance.ShowEffect(ePopupEffectType.PowerAdd, powerStr + add + addedStr);
  55. }
  56. }
  57. /// <summary>
  58. /// 唤灵师加经验提升事件
  59. /// </summary>
  60. /// <param name="e"></param>
  61. public void HeroAddProcessor(object sender, GameEventArgs e)
  62. {
  63. var evt = e as GetExpEvent;
  64. if (null != evt)
  65. {
  66. // Debug.Log("获取经验:" + evt.ExpNum);
  67. UI_TipsWindow.ShowHeroAddExpEffect(evt.ExpNum);
  68. }
  69. }
  70. private void ExpEffect()
  71. {
  72. // 增加拾取特效
  73. ResourceHelper.Instance.LoadAssetBundle("shiqu_tuowei", (ab) =>
  74. {
  75. if (ab != null)
  76. {
  77. eff = (GameObject)Instantiate(ab.LoadAsset("shiqu_tuowei"));
  78. eff.transform.localPosition = this.transform.position;
  79. //CmptAutoDestory des = eff.AddComponent<CmptAutoDestory>();
  80. //des.LiveTime = 2.0f;
  81. eff.transform.DOMove(this.transform.position + Vector3.up * 4, 0.7f).OnComplete(() =>
  82. {
  83. DropItemFollow follow = eff.AddComponent<DropItemFollow>();
  84. follow.target = HeroPlayerController.Instance.m_Hero.gameObject;
  85. });
  86. //mtweener = eff.transform.DOMove(this.transform.position + Vector3.up * 5, 1.0f);
  87. //mtweener.OnComplete(()=>
  88. //{
  89. // tweenFly = true;
  90. //});
  91. }
  92. });
  93. }
  94. }