123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 |
- using System.Collections.Generic;
- using CombatLibrary.CombatLibrary.CombatCore.Utility;
- using Common.Utility.CombatEvent;
- using Core.Audio;
- using Fort23.Core;
- using Fort23.Mono;
- using Fort23.UTool;
- using GameLogic.Bag;
- using GameLogic.Combat.CombatTool;
- using GameLogic.Combat.CombatType;
- using UnityEngine;
- using UnityEngine.UI;
- using Utility.UITool;
- namespace GameUI.Combat
- {
- /// <summary>
- /// 战斗和mono层的桥接
- /// </summary>
- public class CombatMonoBaisc
- {
- private CombatController combatController;
- private ShowItemMoveToTargetPanel _showItemMoveToTargetPanel;
-
- public async CTask Init(CombatController combatController)
- {
- this.combatController = combatController;
- _showItemMoveToTargetPanel = await ShowItemMoveToTargetPanel.OpenShowItemMoveToTargetPanel();
- AddEvent();
- }
- protected void AddEvent()
- {
- EventManager.Instance.AddEventListener(CustomEventType.Combat_ItemShow, Combat_ItemShow);
-
- CombatEventManager.Instance.AddEventListener(CombatEventType.HeroDieFinish, HeroDie);
- }
- protected void HeroDie(IEventData iEventData)
- {
- HeroDieEventData heroDieEventData= iEventData as HeroDieEventData;
- if (heroDieEventData.combatHeroEntity.IsEnemy)
- {
- return;
- }
- BetterList<CombatHeroEntity> myHero = combatController.CombatHeroController.GetHeroList(false);
- if (myHero.Count <= 0)
- {
- CombatHeroDiePanel.OpenCombatHeroDiePanel();
- }
- }
- protected void Combat_ItemShow(IEventData iEventData)
- {
- Vector2 target = _showItemMoveToTargetPanel.moveTarget.GetComponent<RectTransform>().anchoredPosition;
- CombatItemShowEventData combatItemShowEventData = iEventData as CombatItemShowEventData;
- CombatItemShowEventData.ShowType showType = combatItemShowEventData.showType;
- if (showType == CombatItemShowEventData.ShowType.LevelExp)
- {
- MainUIPanel mainUIPanel = UIManager.Instance.GetComponent<MainUIPanel>();
- Vector3 pos = mainUIPanel.expPoint.position;
- target = _showItemMoveToTargetPanel.transform.worldToLocalMatrix * pos;
- }
- else if (showType == CombatItemShowEventData.ShowType.HeroExp)
- {
- MainUIPanel mainUIPanel = UIManager.Instance.GetComponent<MainUIPanel>();
- Vector3 pos = mainUIPanel.Icon_HeroExp.transform.position;
- target = _showItemMoveToTargetPanel.transform.worldToLocalMatrix * pos;
- } else if (showType == CombatItemShowEventData.ShowType.MonsterGold)
- {
- MainUIPanel mainUIPanel = UIManager.Instance.GetComponent<MainUIPanel>();
- Vector3 pos = mainUIPanel.Icon_Coin.transform.position;
- target = _showItemMoveToTargetPanel.transform.worldToLocalMatrix * pos;
- }
- Vector3 p = UIManager.Instance.CurrCustomCameraStack.camera.WorldToScreenPoint(
- combatItemShowEventData.startPos_WorldPos);
- Vector3 p2 = UIManager.Instance.UICamera.ScreenToWorldPoint(p);
- Vector3 startPos = _showItemMoveToTargetPanel.transform.worldToLocalMatrix * p2;
- int maxCount = combatItemShowEventData.count;
- int addValue = combatItemShowEventData.addValue / maxCount;
- int finishVale = combatItemShowEventData.addValue % maxCount;
- _showItemMoveToTargetPanel.ShowPanel(startPos, target, maxCount, combatItemShowEventData.showName,
- delegate(ImageMove imageMove)
- {
- MainUIPanel mainUIPanel = UIManager.Instance.GetComponent<MainUIPanel>();
- if (mainUIPanel == null)
- {
- return;
- }
- int currAddValue = addValue;
- if (imageMove.GroupIndex == maxCount - 1)
- {
- currAddValue += finishVale;
- }
- if ((CombatItemShowEventData.ShowType)imageMove.data == CombatItemShowEventData.ShowType.LevelExp)
- {
- if (mainUIPanel != null)
- {
- ParticleSystemPool particleSystemPool =
- GObjectPool.Instance.FetchAsyncForGameObject<ParticleSystemPool>(mainUIPanel.fx_ui_exp,
- "fx_ui_exp");
- particleSystemPool.transform.SetParent(mainUIPanel.expPoint.transform);
- particleSystemPool.transform.localPosition = Vector3.zero;
- particleSystemPool.transform.localScale = Vector3.one;
- LevelBattleCombatType levelBattleCombatType =
- CombatController.currActiveCombat.CombatTypeBasic as LevelBattleCombatType;
- if (levelBattleCombatType != null)
- {
- levelBattleCombatType.exp += currAddValue;
- }
- }
- }
- else if ((CombatItemShowEventData.ShowType)imageMove.data ==
- CombatItemShowEventData.ShowType.HeroExp)
- {
- if (mainUIPanel != null)
- {
- ParticleSystemPool particleSystemPool =
- GObjectPool.Instance.FetchAsyncForGameObject<ParticleSystemPool>(mainUIPanel.fx_ui_coin,
- "fx_ui_coin");
- particleSystemPool.transform.SetParent(mainUIPanel.Icon_HeroExp.transform);
- particleSystemPool.transform.localPosition = Vector3.zero;
- particleSystemPool.transform.localScale = Vector3.one;
- BagController.Instance.AddHeroExp(currAddValue);
- // particleSystemPool.transform.
- }
- } else if ((CombatItemShowEventData.ShowType)imageMove.data ==
- CombatItemShowEventData.ShowType.MonsterGold)
- {
- if (mainUIPanel != null)
- {
- ParticleSystemPool particleSystemPool =
- GObjectPool.Instance.FetchAsyncForGameObject<ParticleSystemPool>(mainUIPanel.fx_ui_coin,
- "fx_ui_coin");
- particleSystemPool.transform.SetParent(mainUIPanel.Icon_Coin.transform);
- particleSystemPool.transform.localPosition = Vector3.zero;
- particleSystemPool.transform.localScale = Vector3.one;
- BagController.Instance.AddCoin(currAddValue);
- // AudioManager.Instance.PlayAudio("jingbi.wav");
- // particleSystemPool.transform.
- }
- }
- }, SetTargetPoint, showType);
- }
- private void SetTargetPoint(ImageMove imageMove)
- {
- if ((CombatItemShowEventData.ShowType)imageMove.data == CombatItemShowEventData.ShowType.LevelExp)
- {
- MainUIPanel mainUIPanel = UIManager.Instance.GetComponent<MainUIPanel>();
- Vector3 pos = mainUIPanel.expPoint.position;
- Vector3 target = _showItemMoveToTargetPanel.transform.worldToLocalMatrix * pos;
- CurveInfo curveInfo = imageMove.currAcur.CurveInfos[1];
- curveInfo.t = target.x;
- curveInfo.v = target.y;
- imageMove.currAcur.CurveInfos[1] = curveInfo;
- }
- }
- public void Update(float t)
- {
- }
- }
- }
|