Example #1
0
        public KnifeDef(string key, KnifeMode mode, RawNode config)
        {
            this.key  = key;
            this.mode = mode;

            name             = config.GetString("name");
            rarity           = KnifeUtils.GetRarity(config.GetString("rarity", "common"));
            modes            = KnifeUtils.GetSupportedModes(config);
            timeScale        = config.GetFloat("time_scale");
            minForce         = config.GetFloat("knife_min_force");
            maxForce         = config.GetFloat("knife_max_force");
            gravity          = config.GetFloat("gravity");
            bounceMultiplier = config.GetFloat("knife_bounce_multiplier");
            heightMultiplier = config.GetFloat("height_multiplier");
            rotationSpeed    = config.GetFloat("rotation_speed");
            rotationDecrease = config.GetFloat("rotation_decrease");
            rotationMinSpeed = config.GetFloat("rotation_min_speed");

            prefab = config.GetString("prefab");
            scale  = config.GetFloat("scale");
            sides  = config.GetInt("sides", 1);
            size   = config.GetFloat("size");

            price = config.CheckKey("price") ? new PriceDef(config.GetNode("price")) : PriceDef.NewNone();

            visibleInCollection   = config.GetBool("collection_visible", true);
            visibleInRoulette     = config.GetBool("roulette_visible", true);
            droppableFromRoulette = config.GetBool("roulette_drop", true);

            ReadDeflection(config, "success_deflection", out successDeflectionLeft, out successDeflectionRight);
            ReadDeflection(config, "perfect_success_deflection", out perfectDeflectionLeft, out perfectDeflectionRight);

            hasSkillSuccessDeflection = HasDeflection(config, "skill_success_deflection");
            if (hasSkillSuccessDeflection)
            {
                ReadDeflection(config, "skill_success_deflection", out skillSuccessDeflectionLeft, out skillSuccessDeflectionRight);
            }

            hasSkillPerfectDeflection = HasDeflection(config, "skill_perfect_deflection");
            if (hasSkillPerfectDeflection)
            {
                ReadDeflection(config, "skill_perfect_deflection", out skillPerfectDeflectionLeft, out skillPerfectDeflectionRight);
            }

            if (config.CheckKey("skill_pefect_flip_gold_probability"))
            {
                skillPefectFlipGoldProbability = config.GetFloat("skill_pefect_flip_gold_probability");
                skillPefectFlipGoldMin         = config.GetInt("skill_pefect_flip_gold_min", 0);
                skillPefectFlipGoldMax         = config.GetInt("skill_pefect_flip_gold_max", 0);
            }

            if (config.CheckKey("skill_ads_multiplier"))
            {
                skillAdsMultiplier = config.GetFloat("skill_ads_multiplier", 1);
            }

            skillTooltip = config.GetString("skill_tooltip", null);
            skillIcon    = config.GetString("skill_icon", null);
            skillAdsIcon = config.GetString("skill_ads_icon", null);
        }
        public Reward(RawNode node, IContext context) : base(node, context)
        {
            type = node.GetString("type");

            if (node.CheckKey("choice"))
            {
                choice = FactoryManager.Build <PathChoice>(node.GetNode("choice"), context);
            }
            else
            {
                if (node.CheckKey("path"))
                {
                    path = PathUtil.GetModelPath(GetContext(), node.GetNode("path"));
                }
            }
        }
 public PathChoice(RawNode node, IContext context) : base(node, context)
 {
     if (node.CheckKey("random"))
     {
         random = PathUtil.GetModelPath(context, node.GetString("random"), null).GetSelf <Random>();
     }
 }
        public DynamicRandomReward(RawNode node, IContext context) : base(node, context)
        {
            if (node.CheckKey("random"))
            {
                _random = PathUtil.GetModelPath(GetContext(), node.GetString("random"), null).GetSelf <Random>();
            }

            probability = node.GetDouble("probability");
        }
        public static TRet Build <TRet>(RawNode rawNode, IContext context)
        {
            Type baseType = typeof(TRet);

            if (rawNode.CheckKey("type"))
            {
                return(Build <TRet>(rawNode.GetString("type"), rawNode, context));
            }

            return((TRet)_defaultFactory.Build(baseType, rawNode, context));
        }
        public static ModelsPath GetModelPath(IContext context, RawNode node)
        {
            string path;
            Random random = null;

            if (node.IsDictionary() && node.CheckKey("path"))
            {
                path = node.GetString("path");

                if (node.CheckKey("random"))
                {
                    random = GetModelPath(context, node.GetString("random"), null).GetSelf <Random>();
                }
            }
            else
            {
                path = node.ToString();
            }

            return(GetResult(context, path, random));
        }
Example #7
0
 private static bool HasDeflection(RawNode config, string name)
 {
     return(config.CheckKey(name) || config.CheckKey(name + "_left") || config.CheckKey(name + "_right"));
 }