// Token: 0x060004A6 RID: 1190 RVA: 0x00012B14 File Offset: 0x00010D14
        public static void BuildCostStringStyledDefault(CostTypeDef costTypeDef, CostTypeDef.BuildCostStringStyledContext context)
        {
            StringBuilder stringBuilder = context.stringBuilder;

            stringBuilder.Append("<nobr>");
            if (costTypeDef.costStringStyle != null)
            {
                stringBuilder.Append("<style=");
                stringBuilder.Append(costTypeDef.costStringStyle);
                stringBuilder.Append(">");
            }
            if (context.includeColor)
            {
                Color32 costColor = costTypeDef.GetCostColor(context.forWorldDisplay);
                stringBuilder.Append("<color=#");
                stringBuilder.AppendColor32RGBHexValues(costColor);
                stringBuilder.Append(">");
            }
            costTypeDef.BuildCostString(context.cost, context.stringBuilder);
            if (context.includeColor)
            {
                stringBuilder.Append("</color>");
            }
            if (costTypeDef.costStringStyle != null)
            {
                stringBuilder.Append("</style>");
            }
            stringBuilder.Append("</nobr>");
        }
 // Token: 0x0600049E RID: 1182 RVA: 0x000129EE File Offset: 0x00010BEE
 public static void BuildCostStringDefault(CostTypeDef costTypeDef, CostTypeDef.BuildCostStringContext context)
 {
     context.stringBuilder.Append(Language.GetStringFormatted(costTypeDef.costStringFormatToken, new object[]
     {
         context.cost
     }));
 }
예제 #3
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;
 }
 // Token: 0x060009DE RID: 2526 RVA: 0x0002B010 File Offset: 0x00029210
 private void FixedUpdate()
 {
     if (this.targetTextMesh)
     {
         CostHologramContent.sharedStringBuilder.Clear();
         Color       color       = Color.white;
         CostTypeDef costTypeDef = CostTypeCatalog.GetCostTypeDef(this.costType);
         if (costTypeDef != null)
         {
             costTypeDef.BuildCostStringStyled(this.displayValue, CostHologramContent.sharedStringBuilder, true, false);
             color = costTypeDef.GetCostColor(true);
         }
         this.targetTextMesh.SetText(CostHologramContent.sharedStringBuilder);
         this.targetTextMesh.color = color;
     }
 }
        // Token: 0x060010B3 RID: 4275 RVA: 0x00049330 File Offset: 0x00047530
        public void OnInteractionBegin(Interactor activator)
        {
            if (!this.CanBeAffordedByInteractor(activator))
            {
                return;
            }
            CharacterBody        component   = activator.GetComponent <CharacterBody>();
            CostTypeDef          costTypeDef = CostTypeCatalog.GetCostTypeDef(this.costType);
            ItemIndex            itemIndex   = ItemIndex.None;
            ShopTerminalBehavior component2  = base.GetComponent <ShopTerminalBehavior>();

            if (component2)
            {
                itemIndex = component2.CurrentPickupIndex().itemIndex;
            }
            CostTypeDef.PayCostResults payCostResults = costTypeDef.PayCost(this.cost, activator, base.gameObject, this.rng, itemIndex);
            foreach (ItemIndex itemIndex2 in payCostResults.itemsTaken)
            {
                PurchaseInteraction.CreateItemTakenOrb(component.corePosition, base.gameObject, itemIndex2);
                if (itemIndex2 != itemIndex)
                {
                    Action <PurchaseInteraction, Interactor> action = PurchaseInteraction.onItemSpentOnPurchase;
                    if (action != null)
                    {
                        action(this, activator);
                    }
                }
            }
            foreach (EquipmentIndex arg in payCostResults.equipmentTaken)
            {
                Action <PurchaseInteraction, Interactor, EquipmentIndex> action2 = PurchaseInteraction.onEquipmentSpentOnPurchase;
                if (action2 != null)
                {
                    action2(this, activator, arg);
                }
            }
            IEnumerable <StatDef> statDefsToIncrement = this.purchaseStatNames.Select(new Func <string, StatDef>(StatDef.Find));

            StatManager.OnPurchase <IEnumerable <StatDef> >(component, this.costType, statDefsToIncrement);
            this.onPurchase.Invoke(activator);
            this.lastActivator = activator;
        }
        // Token: 0x060004A2 RID: 1186 RVA: 0x00012A58 File Offset: 0x00010C58
        public static Color32 GetCostColorDefault(CostTypeDef costTypeDef, CostTypeDef.GetCostColorContext context)
        {
            Color32 color = ColorCatalog.GetColor(costTypeDef.colorIndex);

            if (context.forWorldDisplay)
            {
                float h;
                float num;
                float num2;
                Color.RGBToHSV(color, out h, out num, out num2);
                if (costTypeDef.saturateWorldStyledCostString && num > 0f)
                {
                    num = 1f;
                }
                if (costTypeDef.darkenWorldStyledCostString)
                {
                    num2 *= 0.5f;
                }
                color = Color.HSVToRGB(h, num, num2);
            }
            return(color);
        }
예제 #7
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
            });