public static void ApplyRewards(ProgressionInfo progressionInfo) { if (CanApplyRewards(progressionInfo)) { DoApplyRewards(progressionInfo); } }
void GetGoal(long money) { for (int len = goals.Length; goalIndex < len; ++goalIndex) { ProgressionInfo goal = goals[goalIndex]; if (goal.moneyCondition > money && !ProgressionStore.instance.GetProgressionComplete(goal)) { break; } } }
public void Configure() { ProgressionInfo[] progressionInfos = ScriptableObjects.instance.progressionInfos; machineConditions.Clear(); Dictionary <long, List <ProgressionInfo> > moneyConditions = new Dictionary <long, List <ProgressionInfo> >(); Dictionary <long, List <ProgressionInfo> > levelConditions = new Dictionary <long, List <ProgressionInfo> >(); for (int i = 0, len = progressionInfos.Length; i < len; ++i) { ProgressionInfo progression = progressionInfos[i]; // Machine Conditions MachineInfo[] machineUnlockConditions = progression.machineUnlockConditions; for (int j = 0, jlen = machineUnlockConditions.Length; j < jlen; ++j) { MachineInfo machineUnlock = machineUnlockConditions[j]; if (!machineConditions.TryGetValue(machineUnlock, out List <ProgressionInfo> conditions)) { conditions = new List <ProgressionInfo>(); machineConditions.Add(machineUnlock, conditions); } conditions.Add(progression); } // Money Conditions if (progression.moneyCondition != 0) { if (!moneyConditions.TryGetValue(progression.moneyCondition, out List <ProgressionInfo> conditions)) { conditions = new List <ProgressionInfo>(); moneyConditions.Add(progression.moneyCondition, conditions); } conditions.Add(progression); } // Level Conditions if (progression.levelCondition != 0) { if (!levelConditions.TryGetValue(progression.levelCondition, out List <ProgressionInfo> conditions)) { conditions = new List <ProgressionInfo>(); levelConditions.Add(progression.levelCondition, conditions); } conditions.Add(progression); } } this.moneyConditions = new OpenSortedList <long, List <ProgressionInfo> >(moneyConditions); this.levelConditions = new OpenSortedList <long, List <ProgressionInfo> >(levelConditions); }
public static bool AreConditionsMet(ProgressionInfo progressionInfo) { if (MachineUnlockConditionsMet(progressionInfo.machineUnlockConditions)) { long levelCondition = progressionInfo.levelCondition; CurrencySystem currencySystem = CurrencySystem.instance; if (levelCondition == 0 || currencySystem.save.level >= levelCondition) { long moneyCondition = progressionInfo.moneyCondition; if (moneyCondition == 0 || currencySystem.save.money >= moneyCondition) { return(true); } } } return(false); }
public static void DoApplyRewards(ProgressionInfo progressionInfo) { ProgressionStore.instance.SetProgressionComplete(progressionInfo, true); CurrencySystem.instance.ProgressionReward(progressionInfo); MachineInfo[] machineRewards = progressionInfo.machineRewards; for (int i = 0, len = machineRewards.Length; i < len; ++i) { MachineInfo machineReward = machineRewards[i]; MachineUnlockSystem.instance.Unlock(machineReward); } MachineGroupInfo[] machineGroupRewards = progressionInfo.machineGroupRewards; for (int i = 0, len = machineGroupRewards.Length; i < len; ++i) { MachineInfo[] machineGroupReward = machineGroupRewards[i].members; for (int j = 0, jlen = machineGroupReward.Length; j < jlen; ++j) { MachineUnlockSystem.instance.Unlock(machineGroupReward[j]); } } }
public void ProgressionReward(ProgressionInfo progressionInfo) { if (progressionInfo.moneyReward > 0) { long value = progressionInfo.moneyReward; save.money += value; CurrencyEvent currencyEvent = new CurrencyEvent(GAResourceFlowType.Source, CurrencyType.Money, CurrencyEventType.ProgressionReward, progressionInfo); Analytics.instance.NewCurrencyEvent(currencyEvent, value); moneyChanged.Invoke(); } if (progressionInfo.xpReward > 0) { long value = progressionInfo.xpReward; save.xp += value; CurrencyEvent currencyEvent = new CurrencyEvent(GAResourceFlowType.Source, CurrencyType.Xp, CurrencyEventType.ProgressionReward, progressionInfo); Analytics.instance.NewCurrencyEvent(currencyEvent, value); xpChanged.Invoke(); } }
public static bool CanApplyRewards(ProgressionInfo progressionInfo) { return(!ProgressionStore.instance.GetProgressionComplete(progressionInfo) && AreConditionsMet(progressionInfo)); }
public CurrencyEvent(GAResourceFlowType flowType, CurrencyType currencyType, CurrencyEventType currencyEventType, ProgressionInfo progressionInfo) { Assert.IsNotNull(progressionInfo); Assert.IsTrue(flowType != GAResourceFlowType.Undefined); this.flowType = flowType; this.currencyType = currencyType; this.currencyEventType = currencyEventType; eventItemId = progressionInfo.progressionName; }