public static int GetBoxAmount(int boxId) { RandomItemBoxInfo bibi = RandomItemBoxInfo.GetBoxInfoById(boxId); if (bibi != null) { return(bibi.boxAmount); } return(0); }
public static List <ItemIdCount> GenItemDicByBoxId(int boxId, out string path, System.Random rand = null) { //test return 1,1 List <ItemIdCount> items = new List <ItemIdCount>(); items.Add(new ItemIdCount(1, 1)); //--to do //1.getbox path = testPath; RandomItemBoxInfo ribi = RandomItemBoxInfo.GetBoxInfoById(boxId); if (ribi == null) { return(null); } path = ribi.boxModelPath; //2.getrule RandomItemRulesInfo riri = RandomItemRulesInfo.GetRuleInfoById(ribi.rulesId); if (riri == null) { return(null); } //3.random items if (rand == null) { rand = new System.Random((int)System.DateTime.UtcNow.Ticks); } int itemAmount = rand.Next(ribi.boxItemAmountMin, ribi.boxItemAmountMax + 1); items = riri.RandomItemDict(itemAmount, rand); return(items); }
public bool IsTerrainAvailable(IntVector2 GenPos, out Vector3 pos, out int boxId) { //--to do: 1.random the data int height = VFDataRTGen.GetPosHeight(GenPos.x, GenPos.y, true); bool inWater = VFDataRTGen.IsSea(height); bool inCave = false; pos = new Vector3(GenPos.x, height - 2, GenPos.y); RaycastHit hitTest; if (Physics.Raycast(pos, Vector3.down, out hitTest, 512, 1 << Pathea.Layer.VFVoxelTerrain)) { inCave = true; } RandomMapType type = VFDataRTGen.GetXZMapType(GenPos.x, GenPos.x); IntVector2 tileIndex = new IntVector2(GenPos.x >> VoxelTerrainConstants._shift, GenPos.y >> VoxelTerrainConstants._shift); VArtifactTown vaTown = null; if (VArtifactTownManager.Instance != null) { for (int i = -4; i < 5; i++) { for (int j = -4; j < 5; j++) { vaTown = VArtifactTownManager.Instance.GetTileTown(new IntVector2(tileIndex.x + i, tileIndex.y + j)); if (vaTown != null) { break; } } if (vaTown != null) { break; } } } List <int> genCondition = new List <int>(); if (vaTown != null) { if (vaTown.type == VArtifactType.NpcTown) { genCondition.Add(BoxMapTypeInt.NEAR_TOWN); } else { genCondition.Add(BoxMapTypeInt.NEAR_CAMP); } } switch (type) { case RandomMapType.Desert: genCondition.Add(BoxMapTypeInt.DESERT); break; case RandomMapType.Redstone: genCondition.Add(BoxMapTypeInt.REDSTONE); break; default: genCondition.Add(BoxMapTypeInt.GRASSLAND); break; } if (inWater) { genCondition.Add(BoxMapTypeInt.IN_WATER); } if (inCave) { genCondition.Add(BoxMapTypeInt.IN_CAVE); } boxId = -1; List <RandomItemBoxInfo> boxInfoList = RandomItemDataMgr.GetBoxIdByCondition(genCondition, height); if (boxInfoList == null || boxInfoList.Count == 0) { return(false); } List <RandomItemBoxInfo> boxInfoAvailable = new List <RandomItemBoxInfo> (); foreach (RandomItemBoxInfo rib in boxInfoList) { if (IsBoxNumAvailable(rib.boxId, rib.boxAmount)) { boxInfoAvailable.Add(rib); } } if (boxInfoAvailable.Count == 0) { return(false); } RandomItemBoxInfo boxInfo = boxInfoAvailable[new System.Random((int)System.DateTime.UtcNow.Ticks).Next(boxInfoAvailable.Count)]; boxId = boxInfo.boxId; float deep = boxInfo.boxDepth; //2.check with boxId if (deep <= 0) { deep = -3; } else if (deep < 2) { deep = 2; } pos = new Vector3(GenPos.x, height - deep, GenPos.y); if (pos.y < 0) { pos.y = 0; } else { RaycastHit hit; if (Physics.Raycast(pos, Vector3.down, out hit, 512, 1 << Pathea.Layer.VFVoxelTerrain)) { pos.y = hit.point.y - boxInfo.boxDepth; } } if (pos.y < 0) { return(false); } return(true); }
public static void LoadData() { RandomItemBoxInfo.LoadData(); RandomItemRulesInfo.LoadData(); RandomItemTypeInfo.LoadData(); }
public static List <RandomItemBoxInfo> GetBoxIdByCondition(List <int> conditionList, int height) { List <RandomItemBoxInfo> ribi = RandomItemBoxInfo.RandomBoxMatchCondition(conditionList, height); return(ribi); }