public void add(int stage, string[] data_soldiers, string[] data_bosss) { WeightRandom <Stage_Level_stagechapterModel.EquipExpDropDataOne> random = new WeightRandom <Stage_Level_stagechapterModel.EquipExpDropDataOne>(); int index = 0; int length = data_soldiers.Length; while (index < length) { Stage_Level_stagechapterModel.EquipExpDropDataOne t = this.get(data_soldiers[index]); random.Add(t, t.weight); index++; } this.soldiers.Add(stage, random); WeightRandom <Stage_Level_stagechapterModel.EquipExpDropDataOne> random2 = new WeightRandom <Stage_Level_stagechapterModel.EquipExpDropDataOne>(); int num3 = 0; int num4 = data_bosss.Length; while (num3 < num4) { Stage_Level_stagechapterModel.EquipExpDropDataOne t = this.get(data_bosss[num3]); random2.Add(t, t.weight); num3++; } this.bosss.Add(stage, random2); }
static public List <float3> SampleMeshSurface(Mesh mesh, int sampleNum = 1024) { var ret = new List <float3>(); if (mesh == null || mesh.GetTopology(0) != MeshTopology.Triangles) { LogTool.Log("Invalid mesh", LogLevel.Warning); return(ret); } var triangles = mesh.triangles; var area = new List <float>(); var minArea = float.MaxValue; foreach (var idx in Enumerable.Range(0, triangles.Length / 3)) { var pa = mesh.vertices[triangles[idx * 3]]; var pb = mesh.vertices[triangles[idx * 3 + 1]]; var pc = mesh.vertices[triangles[idx * 3 + 2]]; var A = pa - pc; var B = pb - pc; var a = 0.5f * math.length(math.cross(A, B)); area.Add(a); minArea = math.min(minArea, a); } foreach (var i in Enumerable.Range(0, area.Count)) { area[i] /= minArea; } var weights = area.Select(v => Mathf.CeilToInt(v)).ToList(); var rand = new WeightRandom(weights); while (sampleNum-- > 0) { var idx = rand.Random(); var pa = mesh.vertices[triangles[idx * 3]]; var pb = mesh.vertices[triangles[idx * 3 + 1]]; var pc = mesh.vertices[triangles[idx * 3 + 2]]; var u = UnityEngine.Random.value; var v = UnityEngine.Random.value; if (u + v > 1) { u = 1 - u; v = 1 - v; } var p = u * pa + v * pb + (1 - (u + v)) * pc; ret.Add(p); } return(ret); }
public int GetRandomShopType() { int key = GameLogic.Hold.BattleData.Level_CurrentStage; WeightRandom random = null; if (this.mCountList.TryGetValue(key, out random)) { return(random.GetRandom()); } object[] args = new object[] { key }; SdkManager.Bugly_Report("Shop_MysticShopModel_Extra", Utils.FormatString("stage ��{0} is not in mCountList!", args)); return(0); }
public void Init() { this.init_show_prop_weight(); this.mMysticShopData = LocalSave.Instance.mSaveData.mMysticShopData; IList <Shop_MysticShop> allBeans = base.GetAllBeans(); int num = 0; int count = allBeans.Count; while (num < count) { Shop_MysticShop shop = allBeans[num]; int index = 0; int length = shop.Stage.Length; while (index < length) { if (!this.mEquipList.TryGetValue(shop.Stage[index], out ShopData data)) { data = new ShopData { stageid = shop.Stage[index] }; this.mEquipList.Add(shop.Stage[index], data); } data.Add(shop); index++; } num++; } IList <Shop_MysticShopShow> list2 = LocalModelManager.Instance.Shop_MysticShopShow.GetAllBeans(); int num5 = 0; int num6 = list2.Count; while (num5 < num6) { Shop_MysticShopShow show = list2[num5]; WeightRandom random = new WeightRandom(); int index = 0; int length = show.ShopTypeProb.Length; while (index < length) { random.Add(index + 1, show.ShopTypeProb[index]); index++; } this.mCountList.Add(show.ID, random); num5++; } }
private void init_show_prop_weight() { IEnumerator <Shop_MysticShopShow> enumerator = LocalModelManager.Instance.Shop_MysticShopShow.GetAllBeans().GetEnumerator(); while (enumerator.MoveNext()) { int[] shopTypeProb = enumerator.Current.ShopTypeProb; if (shopTypeProb.Length == 2) { WeightRandom random = new WeightRandom(); for (int i = 0; i < shopTypeProb.Length; i++) { if (shopTypeProb[i] > 0) { random.Add(i, shopTypeProb[i]); } } } } }
public void Add(Shop_MysticShop data) { Dictionary <int, WeightRandom> dictionary = null; WeightRandom random = null; int index = 0; int length = data.Position.Length; while (index < length) { if (!this.mList.TryGetValue(data.Position[index], out dictionary)) { dictionary = new Dictionary <int, WeightRandom>(); this.mList.Add(data.Position[index], dictionary); } if (!dictionary.TryGetValue(data.ShopType, out random)) { random = new WeightRandom(); dictionary.Add(data.ShopType, random); } random.Add(data.ID, data.Weights); index++; } }