public override void OnHeartBeat() { base.OnHeartBeat(); if (IsHealthBarVisibleWholeTime) { if (_uiEnemyStateView == null) { _uiEnemyStateView = ObjectManager.GetInstance.GetObject <UIEnemyStateView>(ObjectManager.PoolTag.General, HUDManager.GetInstance.EnemyHealthBarPrefab, null, GameManager.GetInstance.UIRootTransform); if (MaxLifeSpanCount != 0) { _uiEnemyStateView.SetType(UIEnemyStateView.GaugeType.LifeCount); } _uiEnemyStateView.SetTrigger(this); } _uiEnemyStateView.UpdateState(); } if (State == UnitState.Dead) { if (DecayTimeLeft <= 0) { MaterialApplier.RevertTrigger(); ObjectManager.RemoveObject(this); } return; } if (UnitActivity == Activity.Hunt && IsInAttackRange) { TryPushNextPattern(); } PatternGroup.ForEach(pattern => { pattern.PatternCooldown = Math.Max(0, pattern.PatternCooldown - 1); }); Delay = Math.Max(0, Delay - 1); }
protected void SwitchActivity(Activity activity) { if (UnitActivity == activity && State == UnitState.Lives) { return; } switch (activity) { case Activity.Hunt: if (IsHealthBarVisibleOnlyHunt && !IsHealthBarVisibleWholeTime) { if (_uiEnemyStateView == null) { _uiEnemyStateView = ObjectManager.GetInstance.GetObject <UIEnemyStateView>(ObjectManager.PoolTag.General, HUDManager.GetInstance.EnemyHealthBarPrefab, null, GameManager.GetInstance.UIRootTransform); if (MaxLifeSpanCount != 0) { _uiEnemyStateView.SetType(UIEnemyStateView.GaugeType.LifeCount); } _uiEnemyStateView.SetTrigger(this); } } if (!IsAnyObstacleBetweenFocus) { UpdateTension(); } break; case Activity.Rest: if (IsHealthBarVisibleOnlyHunt && !IsHealthBarVisibleWholeTime) { if (_uiEnemyStateView != null) { ObjectManager.RemoveObject(_uiEnemyStateView); _uiEnemyStateView = null; } } UnitBoneAnimator.SetTrigger(BoneAnimator.AnimationState.Idle); _navMeshAgent.enabled = false; break; case Activity.Returntocamp: if (IsHealthBarVisibleOnlyHunt && !IsHealthBarVisibleWholeTime) { if (_uiEnemyStateView != null) { ObjectManager.RemoveObject(_uiEnemyStateView); _uiEnemyStateView = null; } } _ignoreFocusTime = IgnoreFocusUpdateTime; break; default: throw new ArgumentOutOfRangeException(nameof(activity), activity, null); } UnitActivity = activity; }