Esempio n. 1
0
 protected void FinishTrigger(EnergyTrigger trigger, NPNFError error)
 {
     if (trigger != null)
     {
         trigger.FinishTriggeredAction(this, trigger, error);
     }
 }
Esempio n. 2
0
        private void HandleUninitializedEnergy(EnergyTrigger trigger, Action <Energy, EnergyTrigger, NPNFError> callback)
        {
            NPNFError error = NPNFError.GetGameError(NPNFError.GameCode.ENERGY_NOT_INITIALIZED);

            if (callback != null)
            {
                callback(this, trigger, error);
            }
            FinishTrigger(trigger, error);
        }
Esempio n. 3
0
 private void TriggerHandler(EnergyTrigger trigger)
 {
     if (trigger.action == EnergyTrigger.Action.Debit)
     {
         Debit(trigger.amount, trigger);
     }
     else if (trigger.action == EnergyTrigger.Action.Credit)
     {
         Credit(trigger.amount, trigger);
     }
 }
Esempio n. 4
0
        private void Credit(int amount, EnergyTrigger trigger)
        {
            if (!IsInitialized)
            {
                HandleUninitializedEnergy(trigger, OnCreditError);
                return;
            }

            Model.Credit(energyName, amount, (EnergyStatus status, NPNFError error) => {
                if (error != null && OnCreditError != null)
                {
                    OnCreditError(this, trigger, error);
                }
                FinishTrigger(trigger, error);
            });
        }
Esempio n. 5
0
 protected abstract void DebitErrorHandler(Energy energy, EnergyTrigger trigger, NPNFError error);