void Update() { bool updateHotEntity = !PlayerController.instance.FixedSelection(); loots.Clear(); if (highlightLoot) { FindVisibleLoots(); } _lootHighlighter.Show(loots, updateHotEntity); if (updateHotEntity) { if (Ui.Hover) { HotEntity = null; } else if (_lootHighlighter.Hot != null) { HotEntity = _lootHighlighter.Hot; } else { HotEntity = CalcHotEntity(); } } if (HotEntity != null && !highlightLoot) { var unit = HotEntity.GetComponent <Unit>(); if (unit && unit.monStat != null) { if (unit.monStat.interact) { ShowLabel(HotEntity); } else if (unit.monStat.killable) { ShowEnemyBar(unit); } else { ShowNothing(); } } else { ShowLabel(HotEntity); } } else { ShowNothing(); } }
void Update() { bool updateHotEntity = !PlayerController.instance.FixedSelection(); pickups.Clear(); if (highlightPickups) { FindVisiblePickups(); } pickupHighlighter.Show(pickups, updateHotEntity); if (updateHotEntity) { if (Ui.Hover) { HotEntity = null; } else if (pickupHighlighter.Hot != null) { HotEntity = pickupHighlighter.Hot; } else { HotEntity = CalcHotEntity(); } } if (HotEntity != null && !highlightPickups) { var character = HotEntity.GetComponent <Character>(); if (character && character.monStat != null) { if (character.monStat.interact) { ShowLabel(HotEntity); } else if (character.monStat.killable) { ShowEnemyBar(character); } else { ShowNothing(); } } else { ShowLabel(HotEntity); } } else { ShowNothing(); } }
void Update() { bool updateHotEntity = !PlayerController.instance.FixedSelection(); if (!highlightPickups) { pickups.Clear(); } pickupHighlighter.Show(pickups, updateHotEntity); pickups.Clear(); if (updateHotEntity) { if (highlightPickups && pickupHighlighter.Hot != null) { HotEntity = pickupHighlighter.Hot; } else { HotEntity = newHotEntity; } } newHotEntity = null; if (HotEntity != null && !highlightPickups) { var character = HotEntity.GetComponent <Character>(); if (character && character.monStat != null) { if (character.monStat.interact) { ShowLabel(HotEntity); } else if (character.monStat.killable) { ShowEnemyBar(character); } else { ShowNothing(); } } else { ShowLabel(HotEntity); } } else { ShowNothing(); } mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition); mousePos.z = 0; }
/// <summary> /// 根据实体id获取实体 /// </summary> /// <param name="entityComponent">实体组件</param> /// <param name="entityId">实体编号</param> /// <returns>逻辑实体</returns> public static EntityLogicBase GetGameEntity(this EntityComponent entityComponent, int entityId) { UnityGameFrame.Runtime.Entity entity = entityComponent.GetEntity(entityId); HotEntity hotEntity = entity.Logic as HotEntity; if (hotEntity == null) { return(null); } return(hotEntity.HotLogicInstance as EntityLogicBase); }
//触发检测 public override void OnTriggerEnter(HotEntity other) { if (other == null) { return; } EntityLogicBase otherTarget = other.HotLogicInstance as EntityLogicBase; if (otherTarget != null && other.Id >= RuntimeEntity.Id) { // 碰撞事件由 Id 小的一方处理,避免重复处理 return; } AIUtility.PerformCollision(this, otherTarget); }
//获取实体之间的距离 public static float GetDistance(HotEntity fromEntity, HotEntity toEntity) { return((toEntity.Position - fromEntity.CachedTransform.position).magnitude); }
/// <summary> /// 实体初始化 /// </summary> public virtual void OnInit(HotEntity entity, object userData) { m_Entity = entity; }
public override void OnInit(HotEntity entity, object userData) { base.OnInit(entity, userData); m_Animator = entity.gameObject.GetOrAddComponent <Animator>(); }
/// <summary> /// 实体初始化 /// </summary> /// <param name="userData">用户自定义数据</param> public virtual void OnInit(object userData) { RuntimeEntity = userData as HotEntity; }
//触发器离开的回调 public virtual void OnTriggerExit(HotEntity collider) { }