private void OnTempMechanicStateChanged(TempMechanicState oldState, TempMechanicState newState, TempMechanicInfo info ) { if (isInitialized) { if (TempMechanic != null && (TempMechanic.Id == info.Id)) { UpdateState(newState); } } }
private void OnTempMechanicStateChanged(TempMechanicState oldState, TempMechanicState newState, TempMechanicInfo mechanic) { if (generator != null && (generator.GeneratorId == mechanic.GeneratorId)) { UpdateViews(); if (newState == TempMechanicState.Completed) { RemoveTempMechanicView(mechanic); } } }
private void UpdateState(TempMechanicState state) { switch (state) { case TempMechanicState.MoveToLoad: { //progressParent.Deactivate(); progressParent.Activate(); progressFill.fillAmount = 0; //countText.Deactivate(); countText.Activate(); rectTransform.localScale = Vector3.one; countText.GetComponent<RectTransform>().localScale = Vector3.one; animator.SetTrigger(animNames[Direction.Right]); //progressParent.Deactivate(); //countText.Deactivate(); rectTransform.anchoredPosition = Vector2.Lerp(leftPosition, rightPosition, TempMechanic.NormalizedTimer); } break; case TempMechanicState.Loading: { animator.SetTrigger(animNames[Direction.StayRight]); progressParent.Activate(); countText.Activate(); rectTransform.anchoredPosition = rightPosition; } break; case TempMechanicState.MoveToUnload: { progressParent.Activate(); countText.Activate(); rectTransform.localScale = new Vector3(-1, 1, 1); countText.GetComponent<RectTransform>().localScale = new Vector3(-1, 1, 1); animator.SetTrigger(animNames[Direction.Left]); rectTransform.anchoredPosition = Vector2.Lerp(rightPosition, leftPosition, TempMechanic.NormalizedTimer); } break; case TempMechanicState.Unloading: { progressParent.Activate(); countText.Activate(); animator.SetTrigger(animNames[Direction.StayLeft]); rectTransform.anchoredPosition = leftPosition; rectTransform.localScale = Vector3.one; countText.GetComponent<RectTransform>().localScale = Vector3.one; } break; default: { rectTransform.localScale = Vector3.one; countText.GetComponent<RectTransform>().localScale = Vector3.one; animator.SetTrigger(animNames[Direction.StayRight]); progressParent.Deactivate(); countText.Deactivate(); rectTransform.anchoredPosition = leftPosition; } break; } }
private void ChangeState(TempMechanicState newState) { TempMechanicState oldState = State; if (State != newState) { if (newState == TempMechanicState.MoveToLoad) { timer = 0f; State = TempMechanicState.MoveToLoad; GameEvents.OnTempMechanicInfoStateChanged(oldState, State, this); } else if (newState == TempMechanicState.Loading) { timer -= MoveInterval; State = TempMechanicState.Loading; GameEvents.OnTempMechanicInfoStateChanged(oldState, State, this); if (timer >= LoadInterval) { ChangeState(TempMechanicState.MoveToUnload); } } else if (newState == TempMechanicState.MoveToUnload) { timer -= LoadInterval; State = TempMechanicState.MoveToUnload; GameEvents.OnTempMechanicInfoStateChanged(oldState, State, this); if (timer >= MoveInterval) { ChangeState(TempMechanicState.Unloading); } } else if (newState == TempMechanicState.Unloading) { timer -= MoveInterval; State = TempMechanicState.Unloading; GameEvents.OnTempMechanicInfoStateChanged(oldState, State, this); if (timer > UnloadInterval) { //ChangeState(TempMechanicState.Completed); ChangeState(TempMechanicState.MoveToLoad); } } else if (newState == TempMechanicState.Completed) { State = TempMechanicState.Completed; GameEvents.OnTempMechanicInfoStateChanged(oldState, State, this); } } }
public static void OnTempMechanicInfoStateChanged(TempMechanicState oldState, TempMechanicState newState, TempMechanicInfo info) => TempMechanicInfoStateChanged?.Invoke(oldState, newState, info);