Пример #1
0
        public Tileset(TilesetLayer data)
        {
            hasTransitions = data.HasTransitions;
            flavorDensity  = data.FlavorDensity;
            groundTiles    = new WeightList <Drawable>();
            flavorObjects  = new WeightList <ISprite>();

            if (hasTransitions)
            {
                crossTransitions  = new WeightList <Drawable> [15];
                borderTransitions = new WeightList <Drawable> [15];
                for (int i = 0; i < 15; i++)
                {
                    crossTransitions[i]  = new WeightList <Drawable>();
                    borderTransitions[i] = new WeightList <Drawable>();
                }
            }

            if (data.FlavorObjects != null)
            {
                foreach (var flavor in data.FlavorObjects)
                {
                    var sprite = App.Resources.GetSprite(flavor.ResName);
                    flavorObjects.Add(sprite, flavor.Weight);
                }
            }
        }
Пример #2
0
    public UniqueBase GetRandomUniqueBase(int ilvl, GroupType?group = null, EquipSlotType?slot = null)
    {
        if (uniqueList == null)
        {
            LoadUniques();
        }

        WeightList <UniqueBase> possibleUniqueList = new WeightList <UniqueBase>();

        foreach (UniqueBase unique in uniqueList.Values)
        {
            if (group != null && unique.group != group)
            {
                continue;
            }

            if (slot != null && unique.equipSlot != slot)
            {
                continue;
            }

            if (unique.dropLevel <= ilvl)
            {
                possibleUniqueList.Add(unique, unique.spawnWeight);
            }
        }
        if (possibleUniqueList.Count == 0)
        {
            return(null);
        }
        return(possibleUniqueList.ReturnWeightedRandom());
    }
Пример #3
0
 public TreasureClassItem(string name, int group, int level, int picks,
                          int uniqueBonus, int setBonus, int rareBonus, int magicBonus, int noDrop,
                          string item1, int prob1,
                          string item2, int prob2,
                          string item3, int prob3,
                          string item4, int prob4,
                          string item5, int prob5,
                          string item6, int prob6,
                          string item7, int prob7,
                          string item8, int prob8,
                          string item9, int prob9,
                          string item10, int prob10)
 {
     Name        = name;
     Picks       = picks;
     Group       = group;
     Level       = level;
     UniqueBonus = uniqueBonus;
     SetBonus    = setBonus;
     RareBonus   = rareBonus;
     MagicBonus  = magicBonus;
     NoDrop      = noDrop;
     ItemProbs   = new List <KeyValuePair <string, int> >(10);
     WeightList  = new WeightList <string>();
     AddItem(item1, prob1);
     AddItem(item2, prob2);
     AddItem(item3, prob3);
     AddItem(item4, prob4);
     AddItem(item5, prob5);
     AddItem(item6, prob6);
     AddItem(item7, prob7);
     AddItem(item8, prob8);
     AddItem(item9, prob9);
     AddItem(item10, prob10);
 }
Пример #4
0
    private void AddEquipmentDrops(BattleEndWindow battleEndWindow)
    {
        //Get Equipment
        int   additionalDrops   = (int)(survivalLoopCount / 5);
        float rarityBoost       = 1 + (0.25f * survivalLoopCount);
        float nonStageEpicBoost = 1 + (0.4f * survivalLoopCount);
        float stageEpicBoost    = 1 + (0.25f * survivalLoopCount * 5);
        float affixLevelSkew    = 1.2f + (survivalLoopCount * 0.1f);
        int   equipmentDrops    = Random.Range(stageInfo.equipmentDropCountMin + additionalDrops, stageInfo.equipmentDropCountMax + 1 + additionalDrops);

        WeightList <RarityType> nonStageDropRarity = new WeightList <RarityType>();

        nonStageDropRarity.Add(RarityType.UNCOMMON, (int)(BASE_UNCOMMON_DROP_WEIGHT / rarityBoost));
        nonStageDropRarity.Add(RarityType.RARE, (int)(BASE_RARE_DROP_WEIGHT * rarityBoost));
        nonStageDropRarity.Add(RarityType.EPIC, (int)(BASE_EPIC_DROP_WEIGHT * nonStageEpicBoost));
        nonStageDropRarity.Add(RarityType.UNIQUE, (int)(BASE_UNIQUE_DROP_WEIGHT * nonStageEpicBoost));

        WeightList <RarityType> stageDropRarity = new WeightList <RarityType>();

        stageDropRarity.Add(RarityType.UNCOMMON, (int)(BASE_UNCOMMON_DROP_WEIGHT_STAGE_DROP / rarityBoost));
        stageDropRarity.Add(RarityType.RARE, (int)(BASE_RARE_DROP_WEIGHT_STAGE_DROP * rarityBoost));
        stageDropRarity.Add(RarityType.EPIC, (int)(BASE_EPIC_DROP_WEIGHT_STAGE_DROP * stageEpicBoost));

        if (stageInfo.equipmentDropList.Count == 0)
        {
            int boostedRarityDrops = System.Math.Max(equipmentDrops / 2, 1);
            for (int i = 0; i < equipmentDrops; i++)
            {
                RarityType rarity;
                if (i < boostedRarityDrops)
                {
                    rarity = stageDropRarity.ReturnWeightedRandom();
                }
                else
                {
                    rarity = nonStageDropRarity.ReturnWeightedRandom();
                }
                AddNonStagePoolDrop(affixLevelSkew, rarity);
            }
        }
        else
        {
            WeightList <string> weightList = Helpers.CreateWeightListFromWeightBases(stageInfo.equipmentDropList);
            int dropsFromStagePool         = System.Math.Max(equipmentDrops / 2, 1);
            for (int i = 0; i < dropsFromStagePool; i++)
            {
                string baseId = weightList.ReturnWeightedRandom();
                var    equip  = Equipment.CreateEquipmentFromBase(ResourceManager.Instance.GetEquipmentBase(baseId), stageLevel + survivalLoopCount);
                RollEquipmentRarity(equip, stageDropRarity.ReturnWeightedRandom(), affixLevelSkew);
                gainedEquipment.Add(equip);
            }

            for (int i = 0; i < equipmentDrops - dropsFromStagePool; i++)
            {
                RarityType rarity = nonStageDropRarity.ReturnWeightedRandom();
                AddNonStagePoolDrop(affixLevelSkew, rarity);
            }
        }
    }
Пример #5
0
 /// <summary>
 /// Adds an item and its prob.
 /// </summary>
 /// <param name="item">Item code</param>
 /// <param name="prob">Item prob</param>
 public void AddItem(string item, int prob)
 {
     if (!string.IsNullOrEmpty(item) && prob > 0)
     {
         ItemProbs.Add(new KeyValuePair <string, int>(item, prob));
         TotalProb += prob;
         WeightList.Add(item, (uint)prob);
     }
 }
Пример #6
0
    public static WeightList <string> CreateWeightListFromWeightBases(List <WeightBase> weightBases)
    {
        WeightList <string> ret = new WeightList <string>();

        foreach (WeightBase weightBase in weightBases)
        {
            ret.Add(weightBase.idName, weightBase.weight);
        }
        return(ret);
    }
Пример #7
0
 public TreasureClassItem(string name, int autoTCMinLevel, int autoTCMaxLevel)
 {
     Name           = name;
     Picks          = 1;
     ItemProbs      = new List <KeyValuePair <string, int> >(10);
     WeightList     = new WeightList <string>();
     AutoTCMinLevel = autoTCMinLevel;
     AutoTCMaxLevel = autoTCMaxLevel;
     IsAutoTC       = true;
 }
Пример #8
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="type">Affix Category to Generate</param>
    /// <param name="ilvl">Level of Target</param>
    /// <param name="targetTypeTags">List of target's tags to determine base spawn weights</param>
    /// <param name="affixBonusTypeStrings">List of strings to determine which affixes have already been applied to target</param>
    /// <param name="weightModifiers">Values to multiply base spawn weight by if they match the group tags</param>
    /// <returns></returns>
    public AffixBase GetRandomAffixBase(AffixType type, int ilvl, HashSet <GroupType> targetTypeTags, List <string> affixBonusTypeStrings, Dictionary <GroupType, float> weightModifiers = null, float affixLevelSkewFactor = 1f)
    {
        WeightList <AffixBase> possibleAffixList = GetPossibleAffixes(type, ilvl, targetTypeTags, affixBonusTypeStrings, weightModifiers, affixLevelSkewFactor);

        if (possibleAffixList.Count == 0)
        {
            return(null);
        }
        return(possibleAffixList.ReturnWeightedRandom());
    }
Пример #9
0
 public ConsumableType GetRandomConsumable()
 {
     if (consumableWeightList == null)
     {
         consumableWeightList = new WeightList <ConsumableType>();
         consumableWeightList.Add(ConsumableType.AFFIX_REROLLER, 3000);
         consumableWeightList.Add(ConsumableType.AFFIX_CRAFTER, 900);
     }
     return(consumableWeightList.ReturnWeightedRandom());
 }
    private void SetBoneWeights(ref List <Vector3> uniqueParticlePositions, ref List <int> uniqueParticleIndices)
    {
        SkinnedMeshRenderer skinnedMeshRenderer = skin;

        // Cache used values rather than accessing straight from the mesh on the loop below
        Vector3[] cachedVertices = skinnedMeshRenderer.sharedMesh.vertices;

        Matrix4x4[]  cachedBindposes   = skinnedMeshRenderer.sharedMesh.bindposes;
        BoneWeight[] cachedBoneWeights = skinnedMeshRenderer.sharedMesh.boneWeights;

        // Make a CWeightList for each bone in the skinned mesh
        WeightList[] nodeWeights = new WeightList[skinnedMeshRenderer.bones.Length];
        for (int i = 0; i < skinnedMeshRenderer.bones.Length; i++)
        {
            nodeWeights[i]           = new WeightList();
            nodeWeights[i].boneIndex = i;
            nodeWeights[i].transform = skinnedMeshRenderer.bones[i];
        }

        for (int uniqueIndex = 0; uniqueIndex < uniqueParticleIndices.Count; uniqueIndex++)
        {
            Vector3 particlePos = uniqueParticlePositions[uniqueIndex];
            int     i           = GetNearestVertIndex(particlePos, ref cachedVertices);
            //Debug.Log(i);
            vertMapAsset.nearestVertIndex.Add(i);
            vertMapAsset.uniqueIndex.Add(uniqueIndex);
            BoneWeight bw = cachedBoneWeights[i];

            if (bw.weight0 != 0.0f)
            {
                Vector3 localPt = cachedBindposes[bw.boneIndex0].MultiplyPoint3x4(particlePos);// cachedVertices[i]);
                nodeWeights[bw.boneIndex0].weights.Add(new VertexWeight(uniqueIndex, localPt, bw.weight0));
            }
            if (bw.weight1 != 0.0f)
            {
                Vector3 localPt = cachedBindposes[bw.boneIndex1].MultiplyPoint3x4(particlePos);//cachedVertices[i]);
                nodeWeights[bw.boneIndex1].weights.Add(new VertexWeight(uniqueIndex, localPt, bw.weight1));
            }
            if (bw.weight2 != 0.0f)
            {
                Vector3 localPt = cachedBindposes[bw.boneIndex2].MultiplyPoint3x4(particlePos);//cachedVertices[i]);
                nodeWeights[bw.boneIndex2].weights.Add(new VertexWeight(uniqueIndex, localPt, bw.weight2));
            }
            if (bw.weight3 != 0.0f)
            {
                Vector3 localPt = cachedBindposes[bw.boneIndex3].MultiplyPoint3x4(particlePos);//cachedVertices[i]);
                nodeWeights[bw.boneIndex3].weights.Add(new VertexWeight(uniqueIndex, localPt, bw.weight3));
            }
        }

        vertMapAsset.particleNodeWeights = nodeWeights;
        //Debug.Log(nodeWeights.Length);
    }
Пример #11
0
        public void CalculateWeight(string term)
        {
            if (string.IsNullOrWhiteSpace(term))
            {
                return;
            }

            var sourceArray = term.Split(new char[] { ' ' });

            foreach (var text in sourceArray)
            {
                if (string.IsNullOrWhiteSpace(text))
                {
                    continue;
                }

                if (Name.IsMatch(text))
                {
                    SumWeight += WeightList.Where(w => w.Name == "name").Select(w => w.W).FirstOrDefault();
                }

                if (Type.IsMatch(text))
                {
                    SumWeight += WeightList.Where(w => w.Name == "type").Select(w => w.W).FirstOrDefault();
                }

                if (SerialNumber.IsMatch(text))
                {
                    SumWeight += WeightList.Where(w => w.Name == "serialNumber").Select(w => w.W).FirstOrDefault();
                }

                if (Floor.IsMatch(text))
                {
                    SumWeight += WeightList.Where(w => w.Name == "floor").Select(w => w.W).FirstOrDefault();
                }

                if (RoomNumber.IsMatch(text))
                {
                    SumWeight += WeightList.Where(w => w.Name == "roomNumber").Select(w => w.W).FirstOrDefault();
                }

                if (Description.IsMatch(text))
                {
                    SumWeight += WeightList.Where(w => w.Name == "description").Select(w => w.W).FirstOrDefault();
                }
            }
        }
        public IActionResult Get()
        {
            // Arrange

            // Act
            var bizResult = _bizLogic.Read();

            // Response
            if (bizResult.Outcome == MetrikOutcome.Ok)
            {
                WeightList responseResult = WeightList.MapFrom(bizResult.Artifact);

                return(Ok(responseResult));
            }

            return(ParseMetrikResultIntoActionResult(bizResult));
        }
        public void BasicTest()
        {
            WeightList wl = new WeightList(items, new DateTime(2019, 1, 8));

            List <TodoItem> expected = new List <TodoItem>(
                new TodoItem[] {
                new TodoItem(90, 4000, new DateTime(2019, 1, 1)),
                new TodoItem(91, 4000, new DateTime(2019, 1, 2)),
                new TodoItem(92, 4000, new DateTime(2019, 1, 3)),
                new TodoItem(93, 4000, new DateTime(2019, 1, 4)),
                new TodoItem(94, 4000, new DateTime(2019, 1, 5)),
                new TodoItem(95, 4000, new DateTime(2019, 1, 6)),
                new TodoItem(96, 4000, new DateTime(2019, 1, 7)),
            });

            wl.List.Should().BeEquivalentTo(expected);
        }
Пример #14
0
        public void CalculateWeight(string term, IEnumerable <Lock> locks)
        {
            LockCount = locks.Count(l => l.BuildingId.Equals(Id));

            if (string.IsNullOrWhiteSpace(term))
            {
                return;
            }

            var sourceArray = term.Split(new char[] { ' ' });

            foreach (var text in sourceArray)
            {
                if (string.IsNullOrWhiteSpace(text))
                {
                    continue;
                }

                if (Name.IsMatch(text))
                {
                    SumWeight += WeightList.Where(w => w.Name == "name").Select(w => w.W).FirstOrDefault();
                    if (LockCount > 0)
                    {
                        SumWeight += WeightList.Where(w => w.Name == "name").Select(w => w.WT).FirstOrDefault();
                    }
                }

                if (ShortCut.IsMatch(text))
                {
                    SumWeight += WeightList.Where(w => w.Name == "shortCut").Select(w => w.W).FirstOrDefault();
                    if (LockCount > 0)
                    {
                        SumWeight += WeightList.Where(w => w.Name == "shortCut").Select(w => w.WT).FirstOrDefault();
                    }
                }

                if (Description.IsMatch(text))
                {
                    SumWeight += WeightList.Where(w => w.Name == "description").Select(w => w.W).FirstOrDefault();
                    if (LockCount > 0)
                    {
                        SumWeight += WeightList.Where(w => w.Name == "description").Select(w => w.WT).FirstOrDefault();
                    }
                }
            }
        }
Пример #15
0
    private void AddArchetypeDrops(BattleEndWindow battleEndWindow)
    {
        //Get Archetype
        int archetypeDrops = 1 + survivalLoopCount / 3;
        int i = 0;

        if (stageInfo.archetypeDropList.Count != 0)
        {
            WeightList <string> stageDropList = Helpers.CreateWeightListFromWeightBases(stageInfo.archetypeDropList);
            string        baseId        = stageDropList.ReturnWeightedRandom();
            ArchetypeBase archetypeBase = ResourceManager.Instance.GetArchetypeBase(baseId);
            ArchetypeItem item          = ArchetypeItem.CreateArchetypeItem(archetypeBase, stageLevel);
            gainedArchetypeItems.Add(item);
            i = 1;
        }

        for (; i < archetypeDrops; i++)
        {
            ArchetypeItem item = ArchetypeItem.CreateArchetypeItem(ResourceManager.Instance.GetRandomArchetypeBase(stageLevel + survivalLoopCount), stageLevel + survivalLoopCount);
            gainedArchetypeItems.Add(item);
        }
    }
Пример #16
0
    public ArchetypeBase GetRandomArchetypeBase(int ilvl)
    {
        if (archetypeList == null)
        {
            LoadArchetypes();
        }

        WeightList <ArchetypeBase> possibleArchetypeList = new WeightList <ArchetypeBase>();

        foreach (ArchetypeBase archetype in archetypeList.Values)
        {
            if (archetype.dropLevel <= ilvl)
            {
                possibleArchetypeList.Add(archetype, archetype.spawnWeight);
            }
        }
        if (possibleArchetypeList.Count == 0)
        {
            return(null);
        }
        return(possibleArchetypeList.ReturnWeightedRandom());
    }
Пример #17
0
    public EquipmentBase GetRandomEquipmentBase(int ilvl, GroupType?group = null, EquipSlotType?slot = null, float baseLevelSkew = 1f)
    {
        if (equipmentList == null)
        {
            LoadEquipment();
        }

        WeightList <EquipmentBase> possibleEquipList = new WeightList <EquipmentBase>();

        foreach (EquipmentBase equipment in equipmentList.Values)
        {
            if (group != null && equipment.group != group)
            {
                continue;
            }

            if (slot != null && equipment.equipSlot != slot)
            {
                continue;
            }

            if (equipment.dropLevel <= ilvl)
            {
                float weight = 1f;
                if (baseLevelSkew != 1f)
                {
                    weight *= Mathf.Lerp(1 / baseLevelSkew, baseLevelSkew, (float)equipment.dropLevel / ilvl);
                }

                possibleEquipList.Add(equipment, (int)(equipment.spawnWeight * weight));
            }
        }
        if (possibleEquipList.Count == 0)
        {
            return(null);
        }
        return(possibleEquipList.ReturnWeightedRandom());
    }
        public void SevenDayAvgTest()
        {
            WeightList wl = new WeightList(items);

            Assert.AreEqual(93.42857142, wl.SevenDayAvg(), 0.01);

            List <TodoItem> item1 = new List <TodoItem>(
                new TodoItem[] {
                new TodoItem(90, 4000, new DateTime(2019, 1, 1)),
                new TodoItem(92, 4000, new DateTime(2019, 1, 3)),
                new TodoItem(95, 4000, new DateTime(2019, 1, 6)),
                new TodoItem(96, 4000, new DateTime(2019, 1, 7)),
                // week
                new TodoItem(97, 4000, new DateTime(2019, 1, 8)),
                new TodoItem(99, 4000, new DateTime(2019, 1, 10)),
                new TodoItem(90, 4000, new DateTime(2019, 1, 11)),
                new TodoItem(90, 4000, new DateTime(2019, 1, 12)),
            });

            wl = new WeightList(item1);

            Assert.AreEqual(94.5, wl.SevenDayAvg(), 0.01);
        }
        private async void BtnSubmitExercise_Clicked(object sender, EventArgs e)
        {
            try
            {
                _objAddExerciseWorkoutRequest.UserId    = Convert.ToInt32(Settings.UserID);
                _objAddExerciseWorkoutRequest.WorkOutId = Convert.ToInt32(Workoutid);
                _objAddExerciseWorkoutRequest.mainList  = new List <MainList>();
                _objHeaderModel.TokenCode = Settings.TokenCode;
                RapList    rl = new RapList();
                MainList   ml = new MainList();
                WeightList wl = new WeightList();
                LevelList  ll = new LevelList();
                TimedList  tl = new TimedList();


                ml.SetsNumber     = NumberofSets;
                ml.ExerciseName   = XFTxtboxExerciseName.Text;
                ml.ExerciseTypeId = WorkOutType;
                if (Settings.WeightName != null)
                {
                    ml.ImperialType = "Weight";
                }
                else
                {
                    ml.ImperialType = "Distance";
                }

                foreach (StackLayout child in GridSets.Children)
                {
                    Entry  entryWeight = (Entry)((Frame)child.Children[0]).Content;
                    string valueWeight = entryWeight.Text;

                    Entry  rep      = (Entry)((Frame)child.Children[3]).Content;
                    string valueRep = rep.Text;
                    if (WorkOutType == Convert.ToInt32(WorkoutSets.Sets_x_Reps_with_weight))
                    {
                        wl.TotalRaps    = Convert.ToInt32(valueRep);
                        wl.TotalWeight  = Convert.ToInt32(valueWeight);
                        wl.ImperialType = Settings.WeightName;
                        ml.weightList.Add(wl);
                        _objAddExerciseWorkoutRequest.mainList.Add(ml);
                    }
                    else if (WorkOutType == Convert.ToInt32(WorkoutSets.Sets_x_Reps_with_Level))
                    {
                        ll.TotalRaps    = Convert.ToInt32(valueRep);
                        ll.TotalWeight  = Convert.ToInt32(valueWeight);
                        ll.ImperialType = Settings.DistanceName;
                        ml.levelList.Add(ll);
                        _objAddExerciseWorkoutRequest.mainList.Add(ml);
                    }

                    else if (WorkOutType == Convert.ToInt32(WorkoutSets.Timed_Sets_seconds))
                    {
                        tl.TimedSet = Convert.ToInt32(valueRep);
                        ml.timedList.Add(tl);
                        _objAddExerciseWorkoutRequest.mainList.Add(ml);
                    }

                    else if (WorkOutType == Convert.ToInt32(WorkoutSets.Sets_x_Reps))
                    {
                        rl.RepsSets = Convert.ToInt32(valueRep);
                        ml.rapList.Add(rl);
                        _objAddExerciseWorkoutRequest.mainList.Add(ml);
                    }

                    else if (WorkOutType == Convert.ToInt32(WorkoutSets.Distance_x_Time))
                    {
                        ml.distance.RepsSetsTime = Convert.ToInt32(valueRep);
                        ml.DistanceInKm          = Convert.ToInt32(valueWeight);
                        _objAddExerciseWorkoutRequest.mainList.Add(ml);
                    }

                    else if (WorkOutType == Convert.ToInt32(WorkoutSets.Free_Text))
                    {
                        ml.textList.Text = (valueWeight);
                        ml.Text          = valueWeight;
                        _objAddExerciseWorkoutRequest.mainList.Add(ml);
                    }
                }

                _objAddExerciseWorkoutResponse = await _apiService.AddExerciseWorkoutPostAsync(new Get_API_Url().CommonBaseApi(_baseUrl), true, _objHeaderModel, _objAddExerciseWorkoutRequest);

                if (_objAddExerciseWorkoutResponse.StatusCode == 200)
                {
                    await Navigation.PopAsync(true);

                    //await Navigation.PopAsync(true);
                    DependencyService.Get <IToast>().Show(_objAddExerciseWorkoutResponse.Message);
                }
                else
                {
                    DependencyService.Get <IToast>().Show(_objAddExerciseWorkoutResponse.Message);
                }

                //if (_objAddWorkoutResponse.StatusCode == 200)
                //{
                //    DependencyService.Get<IToast>().Show(_objAddWorkoutResponse.Message);
                //    WorkoutId = _objAddWorkoutResponse.WorkoutId;
                //}
                //else
                //{
                //    DependencyService.Get<IToast>().Show(_objAddWorkoutResponse.Message);
                //}
            }
            catch (Exception ex)
            {
                var msg = ex.Message;
            }
        }
Пример #20
0
    public WeightList <AffixBase> GetPossibleAffixes(AffixType type, int ilvl, HashSet <GroupType> targetTypeTags, List <string> affixBonusTypeStrings, Dictionary <GroupType, float> weightModifiers, float affixLevelSkewFactor)
    {
        if (targetTypeTags == null)
        {
            targetTypeTags = new HashSet <GroupType>()
            {
                GroupType.NO_GROUP
            };
        }
        if (weightModifiers == null)
        {
            weightModifiers = new Dictionary <GroupType, float>();
        }

        Dictionary <string, AffixBase> affixList;

        switch (type)
        {
        case AffixType.PREFIX:
            affixList = prefixList;
            break;

        case AffixType.SUFFIX:
            affixList = suffixList;
            break;

        case AffixType.INNATE:
            affixList = innateList;
            break;

        case AffixType.ENCHANTMENT:
            affixList = enchantmentList;
            break;

        case AffixType.MONSTERMOD:
            affixList = monsterModList;
            break;

        default:
            affixList = null;
            break;
        }

        WeightList <AffixBase> possibleAffixList = new WeightList <AffixBase>();

        foreach (AffixBase affixBase in affixList.Values)
        {
            // check if affix type has already been applied to target
            if (affixBonusTypeStrings != null && affixBonusTypeStrings.Count > 0)
            {
                if (affixBonusTypeStrings.Contains(affixBase.AffixBonusTypeString))
                {
                    continue;
                }
            }

            //check if affix is drop only
            if (affixBase.groupTypes.Contains(GroupType.DROP_ONLY) && !targetTypeTags.Contains(GroupType.DROP_ONLY))
            {
                continue;
            }

            float weightMultiplier = 1.0f;
            int   baseWeight       = 0;

            if (affixBase.spawnLevel <= ilvl)
            {
                foreach (AffixWeight affixWeight in affixBase.spawnWeight)
                {
                    if (targetTypeTags.Contains(affixWeight.type) || affixWeight.type == GroupType.NO_GROUP)
                    {
                        baseWeight = affixWeight.weight;
                        break;
                    }
                }
                if (baseWeight > 0)
                {
                    foreach (GroupType groupTag in affixBase.groupTypes)
                    {
                        if (weightModifiers.ContainsKey(groupTag))
                        {
                            weightMultiplier *= weightModifiers[groupTag];
                        }
                    }

                    if (affixLevelSkewFactor != 1f)
                    {
                        weightMultiplier *= Mathf.Lerp(1 / affixLevelSkewFactor, affixLevelSkewFactor, (float)affixBase.spawnLevel / ilvl);
                    }

                    if (weightMultiplier == 0)
                    {
                        continue;
                    }
                    possibleAffixList.Add(affixBase, (int)(baseWeight * weightMultiplier));
                }
            }
        }

        return(possibleAffixList);
    }
Пример #21
0
    private void SetBoneWeights(List <Vector3> uniqueParticlePositions, List <int> uniqueParticleIndices)
    {
        SkinnedMeshRenderer skinnedMeshRenderer = Skin;

        // Cache used values rather than accessing straight from the mesh on the loop below
        Vector3[]    _cachedVertices    = skinnedMeshRenderer.sharedMesh.vertices;
        Matrix4x4[]  _cachedBindposes   = skinnedMeshRenderer.sharedMesh.bindposes;
        BoneWeight[] _cachedBoneWeights = skinnedMeshRenderer.sharedMesh.boneWeights;

        // Make an array of WeightLists for each bone in the skinned mesh
        // return bone index for mesh and associated weights for each bone and associated vertex weights
        WeightList[] nodeWeights = new WeightList[skinnedMeshRenderer.bones.Length];
        for (int i = 0; i < skinnedMeshRenderer.bones.Length; i++)
        {
            nodeWeights[i]           = new WeightList();
            nodeWeights[i].boneIndex = i;
            nodeWeights[i].transform = skinnedMeshRenderer.bones[i];
        }

        //Go thru all mesh vertex indices which are now unique vertex indices
        for (int uniqueIndex = 0; uniqueIndex < uniqueParticleIndices.Count; uniqueIndex++)
        {
            //assign a Vector3 temp to unique vertex positions
            //store the index temporarily of the unique vertex index
            int     i       = uniqueParticleIndices[uniqueIndex];
            Vector3 vertPos = uniqueParticlePositions[i];
            //print(i);
            //nearestVertIndex.Add(i);
            //unique_Index.Add(uniqueIndex);
            //get the bone weight of the associated unique mesh vertex
            BoneWeight bw = _cachedBoneWeights[i];

            //Set bone weights for each of the mesh vertices
            if (bw.weight0 != 0.0f)
            {
                Vector3 localPt = _cachedBindposes[bw.boneIndex0].MultiplyPoint3x4(vertPos);// cachedVertices[i]);
                nodeWeights[bw.boneIndex0].weights.Add(new VertexWeight(uniqueIndex, localPt, bw.weight0));
            }
            if (bw.weight1 != 0.0f)
            {
                Vector3 localPt = _cachedBindposes[bw.boneIndex1].MultiplyPoint3x4(vertPos);//cachedVertices[i]);
                nodeWeights[bw.boneIndex1].weights.Add(new VertexWeight(uniqueIndex, localPt, bw.weight1));
            }
            if (bw.weight2 != 0.0f)
            {
                Vector3 localPt = _cachedBindposes[bw.boneIndex2].MultiplyPoint3x4(vertPos);//cachedVertices[i]);
                nodeWeights[bw.boneIndex2].weights.Add(new VertexWeight(uniqueIndex, localPt, bw.weight2));
            }
            if (bw.weight3 != 0.0f)
            {
                Vector3 localPt = _cachedBindposes[bw.boneIndex3].MultiplyPoint3x4(vertPos);//cachedVertices[i]);
                nodeWeights[bw.boneIndex3].weights.Add(new VertexWeight(uniqueIndex, localPt, bw.weight3));
            }
        }

        //Reassign the nodeweights to Weightlist[] of particleNodeweights
        particleNodeWeights = nodeWeights;
        //print(nodeWeights.Length);
        //foreach (var i in particleNodeWeights)
        //{
        //    print(i.ToString());
        //}
    }