Exemplo n.º 1
0
 // default update
 public override UnitStatModifierConfig GetUpdatedUSMC(UnitStatModifierConfig unitStatModifierConfig, System.Object context)
 {
     // get city from gameObject
     //City city = context.GetComponent<City>();
     // verify if party unit is not null
     //if (city != null)
     // verify if context match
     if (DoesContextMatch(context))
     {
         // init city from context
         City city = (City)context;
         // copy current USM config (to not make changes on default one)
         UnitStatModifierConfig newUSMConfig = Instantiate(unitStatModifierConfig);
         // verify if city level config has been defined
         if (powerPerCityLevel.Length - 1 >= city.CityLevelCurrent)
         {
             // update to current USM config power based on the city current level
             newUSMConfig.modifierPower = powerPerCityLevel[city.CityLevelCurrent];
         }
         else
         {
             Debug.LogError("Config for city with [" + city.CityLevelCurrent + "] level has not been defined");
         }
         // return new USM config
         return(newUSMConfig);
     }
     else
     {
         Debug.Log("Context doesn't match");
         //Debug.LogError("City reference is null");
     }
     return(unitStatModifierConfig);
 }
 // default update
 public override UnitStatModifierConfig GetUpdatedUSMC(UnitStatModifierConfig unitStatModifierConfig, System.Object context)
 {
     // get party unit from gameObject
     //PartyUnit partyUnit = context.GetComponent<PartyUnit>();
     // verify if party unit is not null
     //if (partyUnit != null)
     // verify if context match
     if (DoesContextMatch(context))
     {
         // init PartyUnit from context
         PartyUnit partyUnit = (PartyUnit)context;
         // copy current USM config (to not make changes on default one)
         UnitStatModifierConfig newUSMConfig = Instantiate(unitStatModifierConfig);
         // get party unit stats upgrade count
         int statsUpgradeCount = partyUnit.StatsUpgradesCount;
         // update to current USM config power
         newUSMConfig.modifierPower += powerIncrementOnStatsUpgrade * statsUpgradeCount;
         // return new USM config
         return(newUSMConfig);
     }
     else
     {
         // Debug.LogError("Party Unit reference is null");
         Debug.LogError("Context doesn't match");
     }
     return(unitStatModifierConfig);
 }
 // default update
 public override UnitStatModifierConfig GetUpdatedUSMC(UnitStatModifierConfig unitStatModifierConfig, System.Object context)
 {
     // get party unit from gameObject
     //PartyUnit partyUnit = context.GetComponent<PartyUnit>();
     // verify if party unit is not null
     //if (partyUnit != null)
     if (DoesContextMatch(context))
     {
         // init PartyUnit from context
         PartyUnit partyUnit = (PartyUnit)context;
         // copy current USM config (to not make changes on default one)
         UnitStatModifierConfig newUSMConfig = Instantiate(unitStatModifierConfig);
         // get party unit stats upgrade count
         int skillLevel = partyUnit.GetUnitSkillData(associatedUnitSkillID).currentSkillLevel;
         // update to current USM config power based on calculation type
         newUSMConfig.modifierPower = Mathf.RoundToInt(newUSMConfig.modifierPower + newUSMConfig.modifierPower * skillLevel * percentToBase / 100f);
         // return new USM config
         return(newUSMConfig);
     }
     else
     {
         //Debug.LogError("Party Unit reference is null");
         Debug.LogError("Context doesn't match");
     }
     return(unitStatModifierConfig);
 }
 // default update
 public virtual UnitStatModifierConfig GetUpdatedUSMC(UnitStatModifierConfig unitStatModifierConfig, System.Object context)
 {
     if (DoesContextMatch(context))
     {
         // do changes
         // return updated UnitStatModifierConfig
     }
     // by default do not do any changes
     return(unitStatModifierConfig);
 }
Exemplo n.º 5
0
    //public string GetLimiterMessageInContextOf(System.Object srcContext, System.Object dstContext)
    //{
    //    string message = "";
    //    // loop through all limiters
    //    foreach (ModifierLimiter modifierLimiter in modifierLimiters)
    //    {
    //        // verify is modifier power is limited
    //        //if (modifierLimiter.DoDiscardModifierInContextOf(srcContext, dstContext))
    //        {
    //            Debug.Log(".. Verify and adjust message size. Idea: show full message with pop-up on mouse over.");
    //            // at least one requirement is not met
    //            return modifierLimiter.OnLimitMessage;
    //        }
    //    }
    //    // return resulting message
    //    return message;
    //}

    UnitStatModifierConfig GetUpdatedUnitStatModifierConfig(System.Object context)
    {
        // init updated usmc with the copy of default usmc (note: avoid modification of default usmc)
        UnitStatModifierConfig updatedUSMC = Instantiate(unitStatModifierConfig);

        // update usmc
        foreach (ModifierConfigUpdater modifierConfigUpdater in modifierConfigUpdaters)
        {
            updatedUSMC = modifierConfigUpdater.GetUpdatedUSMC(updatedUSMC, context);
        }
        Debug.LogWarning("Updated USMConfig power " + updatedUSMC.modifierPower);
        // return result
        return(updatedUSMC);
    }
 // default get quantitive bonus of the updater
 public virtual int GetDifference(UnitStatModifierConfig unitStatModifierConfig, System.Object context)
 {
     // return difference between updated modifier power and default power
     return(GetUpdatedUSMC(unitStatModifierConfig, context).modifierPower - unitStatModifierConfig.modifierPower);
 }