Exemplo n.º 1
0
    // Update is called once per frame
    private void Update()
    {
        if (IsActioning)
        {
            if (!CurrentAction.IsActionActive)
            {
                IsActioning = false;
                CurrentTime = 0;
                StopAction();
                ExternalActionWhenFailed?.Invoke();
            }

            CurrentTime           += Time.deltaTime;
            ProgressBar.fillAmount = CurrentTime / TotalTime;
            ProgressBar.transform.parent.position = Camera.main.WorldToScreenPoint(ProcessBarWorldPosition.position) /*+ new Vector3(0, UIOffset)*/;

            if (CurrentTime >= TotalTime)
            {
                PlayParticleEffects(CurrentAction.GetActionableParameters().ActionSuccessParticles, CurrentAction.transform);

                CurrentTime = 0;
                StopAction();
                ActionAfterFinishing?.Invoke(gameObject);
                ExternalActionWhenSuccessful?.Invoke();
                CurrentAction.PlayFinishedActionSFX();
            }
        }
    }