/// <summary>
 /// On step update
 /// </summary>
 /// <param name="step"></param>
 public override void OnStep(float step)
 {
     if (ParentEntity != null)
     {
         ParentEntity.transform.position = ScreenPositionUtility.GetClampedPosition(Vector2.Lerp(ParentEntity.transform.position, TargetPoint, GetDeltaTime()), positionOffset);
     }
 }
 /// <summary>
 /// Mono update
 /// </summary>
 void Update()
 {
     if (!ScreenPositionUtility.InScreen(transform.position, Vector2.one * 2))
     {
         if (enteredScreen)
         {
             Destroy(gameObject);
         }
     }
     else
     {
         enteredScreen = true;
     }
 }
예제 #3
0
    /// <summary>
    /// Take damage metho
    /// </summary>
    /// <param name="damage"></param>
    public void TakeDamage(float damage)
    {
        if (CanTakeDamage && ScreenPositionUtility.InScreen(transform.position, Vector2.one * 0.25f) && DependencyHolder.MainStateController.CurrentState.StateID == StateController.States.Game)
        {
            if (totalHealth < 0)
            {
                totalHealth = Health;
            }
            Health -= damage;

            HealthUpdated?.Invoke(Health / totalHealth);
        }

        if (Health <= 0)
        {
            SignalOnDeath();
            OnDeath();
        }
    }