private bool CheckIfCostTypeIsItem(CostTypeIndex costType)
 {
     return(costType == CostTypeIndex.WhiteItem ||
            costType == CostTypeIndex.GreenItem ||
            costType == CostTypeIndex.RedItem ||
            costType == CostTypeIndex.BossItem);
 }
Ejemplo n.º 2
0
 // Token: 0x060004C4 RID: 1220 RVA: 0x00012D45 File Offset: 0x00010F45
 private static void Register(CostTypeIndex costType, CostTypeDef costTypeDef)
 {
     if (costType < CostTypeIndex.Count)
     {
         costTypeDef.name = costType.ToString();
     }
     CostTypeCatalog.costTypeDefs[(int)costType] = costTypeDef;
 }
Ejemplo n.º 3
0
        // Token: 0x06001CDE RID: 7390 RVA: 0x0007B9E8 File Offset: 0x00079BE8
        public static void OnPurchase <T>(CharacterBody characterBody, CostTypeIndex costType, T statDefsToIncrement) where T : IEnumerable <StatDef>
        {
            StatSheet statSheet = PlayerStatsComponent.FindBodyStatSheet(characterBody);

            if (statSheet == null)
            {
                return;
            }
            StatDef statDef  = null;
            StatDef statDef2 = null;

            switch (costType)
            {
            case CostTypeIndex.Money:
                statDef  = StatDef.totalGoldPurchases;
                statDef2 = StatDef.highestGoldPurchases;
                break;

            case CostTypeIndex.PercentHealth:
                statDef  = StatDef.totalBloodPurchases;
                statDef2 = StatDef.highestBloodPurchases;
                break;

            case CostTypeIndex.LunarCoin:
                statDef  = StatDef.totalLunarPurchases;
                statDef2 = StatDef.highestLunarPurchases;
                break;

            case CostTypeIndex.WhiteItem:
                statDef  = StatDef.totalTier1Purchases;
                statDef2 = StatDef.highestTier1Purchases;
                break;

            case CostTypeIndex.GreenItem:
                statDef  = StatDef.totalTier2Purchases;
                statDef2 = StatDef.highestTier2Purchases;
                break;

            case CostTypeIndex.RedItem:
                statDef  = StatDef.totalTier3Purchases;
                statDef2 = StatDef.highestTier3Purchases;
                break;
            }
            statSheet.PushStatValue(StatDef.totalPurchases, 1UL);
            statSheet.PushStatValue(StatDef.highestPurchases, statSheet.GetStatValueULong(StatDef.totalPurchases));
            if (statDef != null)
            {
                statSheet.PushStatValue(statDef, 1UL);
                if (statDef2 != null)
                {
                    statSheet.PushStatValue(statDef2, statSheet.GetStatValueULong(statDef));
                }
            }
            if (statDefsToIncrement != null)
            {
                foreach (StatDef statDef3 in statDefsToIncrement)
                {
                    if (statDef3 != null)
                    {
                        statSheet.PushStatValue(statDef3, 1UL);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        private static void Init()
        {
            CostTypeCatalog.costTypeDefs = new CostTypeDef[11];
            CostTypeIndex costType     = CostTypeIndex.None;
            CostTypeDef   costTypeDef7 = new CostTypeDef();

            costTypeDef7.buildCostString = delegate(CostTypeDef costTypeDef, CostTypeDef.BuildCostStringContext context)
            {
                context.stringBuilder.Append("");
            };
            costTypeDef7.isAffordable = ((CostTypeDef costTypeDef, CostTypeDef.IsAffordableContext context) => true);
            costTypeDef7.payCost      = delegate(CostTypeDef costTypeDef, CostTypeDef.PayCostContext context)
            {
            };
            CostTypeCatalog.Register(costType, costTypeDef7);
            CostTypeIndex costType2    = CostTypeIndex.Money;
            CostTypeDef   costTypeDef2 = new CostTypeDef();

            costTypeDef2.costStringFormatToken = "COST_MONEY_FORMAT";
            costTypeDef2.isAffordable          = delegate(CostTypeDef costTypeDef, CostTypeDef.IsAffordableContext context)
            {
                CharacterBody component = context.activator.GetComponent <CharacterBody>();
                if (component)
                {
                    CharacterMaster master = component.master;
                    if (master)
                    {
                        return((ulong)master.money >= (ulong)((long)context.cost));
                    }
                }
                return(false);
            };
            costTypeDef2.payCost = delegate(CostTypeDef costTypeDef, CostTypeDef.PayCostContext context)
            {
                if (context.activatorMaster)
                {
                    context.activatorMaster.money -= (uint)context.cost;
                }
            };
            costTypeDef2.colorIndex = ColorCatalog.ColorIndex.Money;
            CostTypeCatalog.Register(costType2, costTypeDef2);
            CostTypeIndex costType3    = CostTypeIndex.PercentHealth;
            CostTypeDef   costTypeDef3 = new CostTypeDef();

            costTypeDef3.costStringFormatToken         = "COST_PERCENTHEALTH_FORMAT";
            costTypeDef3.saturateWorldStyledCostString = false;
            costTypeDef3.darkenWorldStyledCostString   = true;
            costTypeDef3.isAffordable = delegate(CostTypeDef costTypeDef, CostTypeDef.IsAffordableContext context)
            {
                HealthComponent component = context.activator.GetComponent <HealthComponent>();
                return(component && component.combinedHealth / component.fullCombinedHealth * 100f >= (float)context.cost);
            };
            costTypeDef3.payCost = delegate(CostTypeDef costTypeDef, CostTypeDef.PayCostContext context)
            {
                HealthComponent component = context.activator.GetComponent <HealthComponent>();
                if (component)
                {
                    float combinedHealth = component.combinedHealth;
                    float num            = component.fullCombinedHealth * (float)context.cost / 100f;
                    if (combinedHealth > num)
                    {
                        component.TakeDamage(new DamageInfo
                        {
                            damage     = num,
                            attacker   = context.purchasedObject,
                            position   = context.purchasedObject.transform.position,
                            damageType = (DamageType.NonLethal | DamageType.BypassArmor)
                        });
                    }
                }
            };
            costTypeDef3.colorIndex = ColorCatalog.ColorIndex.Blood;
            CostTypeCatalog.Register(costType3, costTypeDef3);
            CostTypeIndex costType4    = CostTypeIndex.LunarCoin;
            CostTypeDef   costTypeDef4 = new CostTypeDef();

            costTypeDef4.costStringFormatToken         = "COST_LUNARCOIN_FORMAT";
            costTypeDef4.saturateWorldStyledCostString = false;
            costTypeDef4.darkenWorldStyledCostString   = true;
            costTypeDef4.isAffordable = delegate(CostTypeDef costTypeDef, CostTypeDef.IsAffordableContext context)
            {
                NetworkUser networkUser = Util.LookUpBodyNetworkUser(context.activator.gameObject);
                return(networkUser && (ulong)networkUser.lunarCoins >= (ulong)((long)context.cost));
            };
            costTypeDef4.payCost = delegate(CostTypeDef costTypeDef, CostTypeDef.PayCostContext context)
            {
                NetworkUser networkUser = Util.LookUpBodyNetworkUser(context.activator.gameObject);
                if (networkUser)
                {
                    networkUser.DeductLunarCoins((uint)context.cost);
                }
            };
            costTypeDef4.colorIndex = ColorCatalog.ColorIndex.LunarCoin;
            CostTypeCatalog.Register(costType4, costTypeDef4);
            CostTypeCatalog.Register(CostTypeIndex.WhiteItem, new CostTypeDef
            {
                costStringFormatToken = "COST_ITEM_FORMAT",
                isAffordable          = new CostTypeDef.IsAffordableDelegate(CostTypeCatalog.< > c.< > 9. < Init > g__IsAffordableItem | 5_0),
                payCost    = new CostTypeDef.PayCostDelegate(CostTypeCatalog.< > c.< > 9. < Init > g__PayCostItems | 5_1),
                colorIndex = ColorCatalog.ColorIndex.Tier1Item,
                itemTier   = ItemTier.Tier1
            });