예제 #1
0
 private void OnSecretaryStateChanged(SecretaryState oldState, SecretaryState newState, SecretaryInfo secretary)
 {
     if (isInitialized)
     {
         if ((Secretary != null) && (Secretary.GeneratorId == secretary.GeneratorId))
         {
             UpdateState(newState);
         }
     }
 }
예제 #2
0
        private void ChangeState(SecretaryState newState)
        {
            SecretaryState oldState = State;

            if (State != newState)
            {
                if (newState == SecretaryState.MoveToLoad)
                {
                    timer = 0;
                    State = SecretaryState.MoveToLoad;
                    GameEvents.OnSecretaryStateChanged(oldState, newState, this);
                }
                else if (newState == SecretaryState.Loading)
                {
                    timer -= MoveInterval;
                    State  = SecretaryState.Loading;
                    GameEvents.OnSecretaryStateChanged(oldState, newState, this);
                    if (timer >= LoadInterval)
                    {
                        ChangeState(SecretaryState.MoveToUnload);
                    }
                }
                else if (newState == SecretaryState.MoveToUnload)
                {
                    timer -= LoadInterval;
                    State  = SecretaryState.MoveToUnload;
                    GameEvents.OnSecretaryStateChanged(oldState, newState, this);
                    if (timer >= MoveInterval)
                    {
                        ChangeState(SecretaryState.Unloading);
                    }
                }
                else if (newState == SecretaryState.Unloading)
                {
                    timer -= MoveInterval;
                    State  = SecretaryState.Unloading;
                    GameEvents.OnSecretaryStateChanged(oldState, newState, this);
                    if (timer > UnloadInterval)
                    {
                        ChangeState(SecretaryState.Completed);
                    }
                }
                else if (newState == SecretaryState.Completed)
                {
                    State = SecretaryState.Completed;
                    timer = 0;
                    GameEvents.OnSecretaryStateChanged(oldState, newState, this);
                    GameEvents.OnSecretaryWorkCircleCompleted(this, 1);
                }
            }
        }
예제 #3
0
        private void UpdateState(SecretaryState state)
        {
            print($"update state => {state}");
            switch (state)
            {
            case SecretaryState.MoveToLoad: {
                progressParent.Deactivate();
                rectTransform.localScale = new Vector3(-1, 1, 1);
                animator.SetTrigger(animNames[Direction.Left]);
                rectTransform.anchoredPosition = Vector2.Lerp(rightPosition, leftPosition, Secretary.NormalizedTimer);
            }
            break;

            case SecretaryState.Loading: {
                animator.SetTrigger(animNames[Direction.StayLeft]);
                rectTransform.anchoredPosition = leftPosition;
                progressParent.Activate();
            }
            break;

            case SecretaryState.MoveToUnload: {
                progressParent.Activate();
                rectTransform.localScale = Vector3.one;
                animator.SetTrigger(animNames[Direction.Right]);
                rectTransform.anchoredPosition = Vector2.Lerp(leftPosition, rightPosition, Secretary.NormalizedTimer);
            }
            break;

            case SecretaryState.Unloading: {
                rectTransform.localScale = Vector3.one;
                progressParent.Activate();
                animator.SetTrigger(animNames[Direction.StayRight]);
                rectTransform.anchoredPosition = rightPosition;
            }
            break;
            }
        }
예제 #4
0
 public static void OnSecretaryStateChanged(SecretaryState oldState, SecretaryState newState, SecretaryInfo secretary)
 => SecretaryStateChanged?.Invoke(oldState, newState, secretary);