public void Test1() { if (Input.GetMouseButtonDown(1)) { ActionController player = ObjectManager.Instance.GetMyActionController(); LootObjData lootData = new LootObjData(); float y = 3; if (Time.realtimeSinceStartup % 2 > 1) { lootData._lootId = "money"; y = 0; } else { lootData._lootId = "all_helm_1_white_defense"; //armor y = 3; } //lootData._lootId = "mage_weapon_0_white_initial"; //weapon //lootData._lootId = "gemstone_0_0"; //gem lootData._lootCount = 1; float x = UnityEngine.Random.Range(-3, 3); float z = UnityEngine.Random.Range(-3, 3); LootOneForCheatDrop(lootData, player.transform.position, new Vector3(x, y, z)); } }
private void LootWithScore(List <LootObjData> dataList, LootData lootData, float score) { int count = 0; while (score > 0) { LootWeight lootWeight = GetRandomLootWeight(lootData._lootList); if (lootWeight != null) { int lootCount = UnityEngine.Random.Range(lootWeight._countMin, lootWeight._countMax); float lootScore = 0; if (lootWeight._itemId == "money") { lootScore = lootCount; } else { ItemData data = getItemData(lootWeight._itemId); lootScore = lootCount * (data == null ? 0 : 0); } //Debug.Log("score: "+ score + " :" + lootWeight._itemId + " "+ lootCount + " " +lootScore +" " + (lootScore < score * 2)); if (lootScore < score * 2) { score -= lootScore; LootObjData lootObj = new LootObjData(); lootObj._lootId = lootWeight._itemId; lootObj._lootCount = lootCount; dataList.Add(lootObj); } } count++; if (count >= _lootMax) { //Debug.LogWarning("CalLootWithScore:["+count+"] totalScore:" + totalScore + " remainScore:"+ score); break; } } /* * string result = "result : "; * foreach(LootObjData tmp in dataList) * { * result += tmp._lootId + " "; * } * Debug.Log(result); */ }
private void GetOneLoot(List <LootObjData> dataList, LootData lootData) { LootWeight lootWeight = GetRandomLootWeight(lootData._lootList); if (lootWeight != null) { LootObjData lootObj = new LootObjData(); lootObj._lootId = lootWeight._itemId; lootObj._lootCount = UnityEngine.Random.Range(lootWeight._countMin, lootWeight._countMax);; dataList.Add(lootObj); } }
public void StartLootOneMove(LootObjData lootObjData, Vector3 pos, Vector3 offset) { Assertion.Check(lootObjData._lootObject != null); //active the move object lootObjData._lootObject.SetActive(true); //set transfrom and start move LootMove move = lootObjData._lootObject.GetComponent <LootMove>(); move.transform.localPosition = pos; move.StartMove(offset, _time); }
public static List <LootObjData> ParseLootList(BinaryReader reader) { int count = reader.ReadByte(); List <LootObjData> list = new List <LootObjData>(); for (int i = 0; i < count; i++) { LootObjData data = new LootObjData(); data._lootId = FaustComm.NetResponse.ReadString(reader); data._lootCount = reader.ReadInt32(); list.Add(data); } return(list); }
//WARNING!!!!!!!!!!! only use for cheat drop!!! public void LootOneForCheatDrop(LootObjData lootObjData, Vector3 pos, Vector3 offset) { GameObject moveObj = new GameObject("Loot[" + lootObjData._lootId + "]"); LootMove move = moveObj.AddComponent <LootMove>(); move.transform.parent = _lootRoot; move.transform.localPosition = pos; GameObject lootMovePrefab = null; GameObject lootObjPrefab = null; GameObject lootParticlePrefab = null; int particleIndex = 0; if (lootObjData._lootId == "money") { lootMovePrefab = _lootMoveParticlePrefab; if (lootObjData._lootCount <= _smallScMax) { lootObjPrefab = _lootSmallScPrefab; particleIndex = 0; } else if (lootObjData._lootCount <= _middleScMax) { lootObjPrefab = _lootMiddleScPrefab; particleIndex = 1; } else { lootObjPrefab = _lootLargeScPrefab; particleIndex = 2; } } else { lootMovePrefab = _lootMoveMathfPrefab; ItemData itemData = getItemData(lootObjData._lootId); if (itemData.subType == ItemSubType.weapon) { // get entity. int role = (int)PlayerInfo.Instance.Role; string entityPath = itemData.instance; GameObject entity = InJoy.AssetBundles.AssetBundles.Load(entityPath) as GameObject; FCEquipmentsBase eb = entity.GetComponent <FCEquipmentsBase>(); Assertion.Check(eb != null); // get model. Assertion.Check(eb._equipmentSlots.Length > 0); GameObject model = InJoy.AssetBundles.AssetBundles.Load(eb._equipmentSlots[0]._modelPath) as GameObject; if (model == null) { Debug.LogError("[Loot Manager] Can not find asset " + eb._equipmentSlots[0]._modelPath); } lootObjPrefab = model; } else { string path = _lootArmors[(int)itemData.subType]; int level = itemData.rareLevel; string [] levelsuffix = new string[] { "0", "0", "1", "2", "2", "2", "2", "2" }; path = path.Replace(".prefab", levelsuffix[level] + ".prefab"); GameObject model = InJoy.AssetBundles.AssetBundles.Load(path) as GameObject; if (model == null) { Debug.LogError("[Loot Manager] Can not find asset " + path); } lootObjPrefab = model; } particleIndex = itemData.rareLevel; } if (particleIndex > _lootParticlePath.Count - 1) { particleIndex = _lootParticlePath.Count - 1; } lootParticlePrefab = _lootParticlePrefab[particleIndex]; move.SetData(lootMovePrefab, lootObjPrefab, lootParticlePrefab, lootObjData._lootId, lootObjData._lootCount, _liftTime); move.StartMoveForCheatDrop(offset, _time); }
public void PrepareOneLootPrefab(LootObjData lootObjData) { GameObject lootMovePrefab = null; //move trace GameObject lootObjPrefab = null; //loot obj GameObject lootParticlePrefab = null; //particle //creata move object GameObject moveObj = new GameObject("Loot[" + lootObjData._lootId + "]"); lootObjData._lootObject = moveObj; LootMove move = moveObj.AddComponent <LootMove>(); //add move obj to root move.transform.parent = _lootRoot; Debug.Log("prepare loot object " + lootObjData._lootId + ":" + lootObjData._lootObject.name); //determine the 3 prefabs int particleIndex = 0; if (lootObjData._lootId == "money") { lootMovePrefab = _lootMoveParticlePrefab; if (lootObjData._lootCount <= _smallScMax) { lootObjPrefab = _lootSmallScPrefab; particleIndex = 0; } else if (lootObjData._lootCount <= _middleScMax) { lootObjPrefab = _lootMiddleScPrefab; particleIndex = 1; } else { lootObjPrefab = _lootLargeScPrefab; particleIndex = 2; } } else { ItemData itemData = getItemData(lootObjData._lootId); if (itemData == null) { Destroy(moveObj); Debug.LogError("Loot id (" + lootObjData._lootId + ") not found."); return; } lootMovePrefab = _lootMoveMathfPrefab; if (itemData.subType == ItemSubType.weapon) { // get entity. int role = (int)PlayerInfo.Instance.Role; string entityPath = itemData.instance; GameObject entity = InJoy.AssetBundles.AssetBundles.Load(entityPath) as GameObject; FCEquipmentsBase eb = entity.GetComponent <FCEquipmentsBase>(); Assertion.Check(eb != null); eb = EquipmentAssembler.Singleton.CheckEquipmentResource(eb); // get model. Assertion.Check(eb._equipmentSlots.Length > 0); GameObject model = InJoy.AssetBundles.AssetBundles.Load(eb._equipmentSlots[0]._modelPath) as GameObject; if (model == null) { Debug.LogError("[Loot Manager] Can not find asset " + eb._equipmentSlots[0]._modelPath); } lootObjPrefab = model; } else { string path; if (itemData.subType == ItemSubType.none) { path = _lootArmors[(int)ItemSubType.weapon]; } else { path = _lootArmors[(int)itemData.subType]; } int level = itemData.rareLevel; string [] levelsuffix = new string[] { "0", "0", "1", "2", "2", "2", "2", "2" }; path = path.Replace(".prefab", levelsuffix[level] + ".prefab"); GameObject model = InJoy.AssetBundles.AssetBundles.Load(path) as GameObject; if (model == null) { Debug.LogError("[Loot Manager] Can not find asset " + path); } lootObjPrefab = model; } particleIndex = itemData.rareLevel; } if (particleIndex > _lootParticlePath.Count - 1) { particleIndex = _lootParticlePath.Count - 1; } lootParticlePrefab = _lootParticlePrefab[particleIndex]; move.SetData(lootMovePrefab, lootObjPrefab, lootParticlePrefab, lootObjData._lootId, lootObjData._lootCount, _liftTime); move.PrepareMovePrefabs(); moveObj.SetActive(false); }