public void Initialize( string staminaNamespaceName, EzStaminaModel staminaModel, Func <IEnumerator, Coroutine> startCoroutine, Action <Coroutine> stopCoroutine, GetStaminaEvent onGetStamina, RecoverStaminaEvent onRecoverStamina, ConsumeStaminaEvent onConsumeStamina, ErrorEvent onError ) { _staminaNamespaceName = staminaNamespaceName; _staminaModel = staminaModel; _startCoroutine = startCoroutine; _stopCoroutine = stopCoroutine; _onGetStamina = onGetStamina; _onRecoverStamina = onRecoverStamina; _onConsumeStamina = onConsumeStamina; _onError = onError; }
public static IEnumerator ConsumeStamina( Client client, GameSession session, string staminaNamespaceName, EzStaminaModel staminaModel, int consumeValue, ConsumeStaminaEvent onConsumeStamina, GetStaminaEvent onGetStamina, ErrorEvent onError ) { AsyncResult <EzConsumeResult> result = null; yield return(client.Stamina.Consume( r => { result = r; }, session, staminaNamespaceName, staminaModel.Name, consumeValue )); if (result.Error != null) { onError.Invoke( result.Error ); yield break; } var stamina = result.Result.Item; onConsumeStamina.Invoke(staminaModel, stamina, consumeValue); onGetStamina.Invoke(staminaModel, stamina); }