123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- using Common.Utility.CombatEvent;
- using GameLogic.Combat.Hero;
- using UnityEngine;
- namespace Fort23.Mono
- {
- [UIBinding(prefab = "DuiPingWidget")]
- public partial class DuiPingWidget : UIComponent
- {
- public CombatMagicWeaponEntity combatMagicWeaponEntity;
- private RectTransform rectTransform;
- private void Init()
- {
- }
- public override void AddEvent()
- {
- }
- public override void DelEvent()
- {
- }
- public override void AddButtonEvent()
- {
- rectTransform = icon.GetComponent<RectTransform>();
- rectTransform.sizeDelta = new Vector2(100, 9);
- }
- public void ShowWidget(CombatMagicWeaponEntity combatMagicWeaponEntity)
- {
- this.combatMagicWeaponEntity = combatMagicWeaponEntity;
- Vector3 offPos = new Vector3(0, 0);
- if (this.combatMagicWeaponEntity.IsEnemy)
- {
- offPos = new Vector3(0, 2);
- }
- else
- {
- offPos = new Vector3(0, -2);
- }
-
- Vector3 worldPos = combatMagicWeaponEntity.GameObject.transform.position + offPos;
- Vector3 p = UIManager.Instance.CurrCustomCameraStack.camera.WorldToScreenPoint(worldPos);
- Vector3 p2 = UIManager.Instance.UICamera.ScreenToWorldPoint(p);
- transform.position = p2;
- }
- public void UpdateHp()
- {
- float bl = combatMagicWeaponEntity.HpBl / combatMagicWeaponEntity.MaxHp;
- rectTransform.sizeDelta = new Vector2(100 * bl, 9);
- }
- }
- }
|