예제 #1
0
        public static RawNode GetRawNode(IContext context, string path, IRandom random)
        {
            var     parts   = GetParts(path);
            RawNode current = context.repositoryNode;

            for (int i = 0; i < parts.Count; i++)
            {
                current = current.GetNode(parts[i][0]);

                if (SelectPathUtil.IsSimple(parts[i][1]))
                {
                    current = current.GetNode(parts[i][1]);
                }
                else
                {
                    var allKeys = new List <string>();
                    allKeys.AddRange(current.GetSortedKeys());
                    var affectedKeys = SelectPathUtil.GetAffectedKeys(parts[i][1], allKeys);
                    if (affectedKeys.Count == 0)
                    {
                        return(null);
                    }

                    var selectedKey = affectedKeys[random.Range(0, affectedKeys.Count)];
                    current = current.GetNode(selectedKey);
                }
            }

            return(current);
        }
예제 #2
0
        public Player(RawNode initNode, RawNode repositoryNode)
        {
            this.repositoryNode = repositoryNode;

            dataSources = new DataSources();

            var simpleResources = new SimpleResourceCollection(initNode.GetNode("simple-resources"), new SimpleResourceCategories(), this, new SimpleResourceDataSource(repositoryNode.GetNode("simple-resources"), this));
            var objects         = new SomeModelCollection(initNode.GetNode("objects"), new SomeModelCategories(), this, new SomeModelDataSource(repositoryNode.GetNode("objects"), this));
            var random          = new RandomCollection(initNode.GetNode("random"), new RandomCategories(), this, new RandomDataSource(repositoryNode.GetNode("random"), this));
            var cities          = new CityCollection(initNode.GetNode("cities"), new CityCategories(), this, new CityDescriptionDataSource(repositoryNode.GetNode("cities"), this));

            AddChild(random);
            AddChild(simpleResources);
            AddChild(objects);
            AddChild(cities);
        }
예제 #3
0
        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"));
                }
            }
        }
예제 #4
0
        private KnifeDef GetKnifeFullDef(string knife, KnifeMode mode)
        {
            RawNode node = null;

            string modeKey = KnifeUtils.GetKnifeModeKey(mode);

            var knifeNode = m_knivesSettings.GetNode(knife);
            var modesNode = knifeNode.GetNode("modes");

            if (modesNode.CheckKey(modeKey))
            {
                var modeNode = modesNode.GetNode(modeKey);
                node = modeNode.WithFallback(knifeNode);
            }
            else
            {
                throw new InvalidOperationException("Knife " + knife + " not support " + mode + " mode");
            }

            var modesSettings = m_settings.GetNode("modes");

            if (modesSettings.CheckKey(modeKey))
            {
                node = node.WithFallback(modesSettings.GetNode(modeKey));
            }

            if (modesSettings.CheckKey("default"))
            {
                node = node.WithFallback(modesSettings.GetNode("default"));
            }

            return(new KnifeDef(knife, mode, node));
        }
예제 #5
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);
        }
예제 #6
0
        public override TModel this[string collectionKey]
        {
            get
            {
                TModel model = base[collectionKey];

                if (model != null)
                {
                    return(model);
                }

                var description = (TDescription)dataSource.GetChild(collectionKey);
                model = Factory(_initNode.GetNode(collectionKey), description);
                AddChild(model);
                model.Initialization();

                return(model);
            }
        }
예제 #7
0
        public KnivesRepoDef(RawNode config)
        {
            var dict = config.dictionary;

            knives = new KnifeDef[dict.Count];

            int index = 0;

            foreach (var item in dict)
            {
                knives[index++] = new KnifeDef(item.Key, KnifeMode.Medium, config.GetNode(item.Key));
            }
        }
예제 #8
0
        public RleSetPathChoice(RawNode node, IContext context)
            : base(node, context)
        {
            var rows = node.GetNode("elements").array;

            foreach (var obj in rows)
            {
                var l   = (List <object>)obj;
                var arr = new [] { l[0], Convert.ToInt32(l[1]) };
                _list.Add(arr);
            }

            foreach (var pair in _list)
            {
                _length += (int)pair[1];
            }
        }
        public RleSetAmount(RawNode node, IContext context)
            : base(node, context)
        {
            _random = PathUtil.GetModelPath(GetContext(), node.GetString("random"), null).GetSelf <Random>();
            var rows = node.GetNode("elements").array;

            foreach (var obj in rows)
            {
                var pair = (List <object>)obj;
                var arr  = new [] { Convert.ToInt32(pair[0]), Convert.ToInt32(pair[1]) };
                _list.Add(arr);
            }

            foreach (var pair in _list)
            {
                _length += pair[1];
            }
        }
예제 #10
0
        public static KnifeMode[] GetSupportedModes(RawNode knifeNode)
        {
            var modesNode      = knifeNode.GetNode("modes");
            var supportedModes = new KnifeMode[AllKnifeModes.Length];

            int count = 0;

            foreach (var mode in AllKnifeModes)
            {
                var key = GetKnifeModeKey(mode);
                if (modesNode.CheckKey(key))
                {
                    supportedModes[count++] = mode;
                }
            }

            Array.Resize(ref supportedModes, count);
            return(supportedModes);
        }
예제 #11
0
 protected CompositeTrigger(RawNode initNode, TriggerCategories categories, TriggerDescription description, IContext context)
     : base(initNode, categories, description, context)
 {
     triggers = new TriggerCollection(initNode.GetNode("triggers"), categories, context, new TriggerDataSource(description.GetNode().GetNode("triggers"), context));
 }
예제 #12
0
 protected WrappedPrice(RawNode node, IContext context) : base(node, context)
 {
     innerPrice = FactoryManager.Build <Price>(node.GetNode("price"), context);
 }
 public DynamicCompositeReward(RawNode node, IContext context) : base(node, context)
 {
     rewards = new LazyArray <DynamicReward>(node.GetNode("rewards"), context);
 }
예제 #14
0
 public CompositeReward(RawNode rawNode, IContext context)
     : base(rawNode, context)
 {
     rewards = new LazyArray <Reward>(rawNode.GetNode("rewards"), context);
 }
예제 #15
0
 protected WrappedReward(RawNode rawNode, IContext context)
     : base(rawNode, context)
 {
     innerReward = FactoryManager.Build <Reward>(rawNode.GetNode("reward"), context);
 }
예제 #16
0
 public RenewableResourceReward(RawNode node, IContext context)
     : base(node, context)
 {
     _amount = FactoryManager.Build <Amount>(node.GetNode("amount"), context);
 }
예제 #17
0
 public SimpleResourceReward(RawNode node, IContext context = null) : base(node, context)
 {
     amount = FactoryManager.Build <Amount>(node.GetNode("amount"), context);
 }
예제 #18
0
 public WrappedRewardResult(RawNode node, IContext context) : base(node, context)
 {
     rewardResult = FactoryManager.Build <RewardResult>(node.GetNode("result"), context);
 }
 protected DynamicWrappedReward(RawNode node, IContext context) : base(node, context)
 {
     innerReward = FactoryManager.Build <DynamicReward>(node.GetNode("reward"), context);
 }
예제 #20
0
 public CompositePrice(RawNode rawNode, IContext context)
     : base(rawNode, context)
 {
     prices = new LazyArray <Price>(rawNode.GetNode("prices"), context);
 }
예제 #21
0
 protected CompositeRequirement(RawNode node, IContext context)
     : base(node, context)
 {
     requirements = new LazyArray <Requirement>(node.GetNode("requirements"), context);
 }
예제 #22
0
 protected WrappedRequirement(RawNode node, IContext context) : base(node, context)
 {
     innerRequirement = FactoryManager.Build <Requirement>(node.GetNode("requirement"), context);
 }
예제 #23
0
 public DynamicCompositePrice(RawNode node, IContext context) : base(node, context)
 {
     prices = new LazyArray <DynamicPrice>(node.GetNode("prices"), context);
 }