public override bool Execute() { SM.SceneRoom room = SM.RandomRoomLevel.Singleton.LookupRoom(RoomGUID); Actor eventActor = BattleArena.Singleton.m_blackBoard.GetBlackBoardActor("DropItemActor"); foreach (var dropItemData in mDropItemDataList) { //掉落Func if ((ID)dropItemData.mDropItemId == ID.key) { DropItemPerformanceType itemType = new DropItemPerformanceType(); itemType.m_intParam = (int)dropItemData.mDropItemId; itemType.m_deadPos = new Vector3(eventActor.MainObj.transform.position.x, eventActor.MainObj.transform.position.y, eventActor.MainObj.transform.position.z); itemType.m_eulerAngles = new Vector3(eventActor.MainObj.transform.localEulerAngles.x, eventActor.MainObj.transform.localEulerAngles.y, eventActor.MainObj.transform.localEulerAngles.z); MainGame.Singleton.StartCoroutine(DropItemPerformance.Singleton.LoadDropItem(itemType)); BattleArena.Singleton.KeyCount += 1; } else { // dropItemData.mTrapData.position = new Vector3(eventActor.MainObj.transform.position.x, eventActor.MainObj.transform.position.y, eventActor.MainObj.transform.position.z); // SM.TrapRefresh.SpawnMe(room, dropItemData.mTrapData); } } return(true); }
// 掉落前 的 记录整理 public void Start(NPC npc) { // 掉落卡牌 if (npc.IsHaveDropItem()) { // 掉落卡牌 DropItemPerformanceCard itemType = new DropItemPerformanceCard(); itemType.m_type = DropItemPerformanceType.Type.enCard; itemType.m_cardList.Clear(); itemType.m_deadPos = new Vector3(npc.MainObj.transform.position.x, npc.MainObj.transform.position.y, npc.MainObj.transform.position.z); itemType.m_eulerAngles = new Vector3(npc.MainObj.transform.localEulerAngles.x, npc.MainObj.transform.localEulerAngles.y, npc.MainObj.transform.localEulerAngles.z); // 更新掉落列表 if (null != npc.roomElement) { foreach (int cardId in npc.roomElement.MonsterData.dropList) { itemType.m_cardList.Add(cardId); } } MainGame.Singleton.StartCoroutine(LoadDropItem(itemType)); } // 掉落金钱 if ((npc.GetNpcType() == ENNpcType.enBoxNPC && npc.GetNpcInterSubType() == ENNpcInterSubType.enTreasureBox)) { // 掉落金钱 DropItemPerformanceType itemType = new DropItemPerformanceType(); itemType.m_type = DropItemPerformanceType.Type.enGold; itemType.m_intParam = 100; itemType.m_deadPos = new Vector3(npc.MainObj.transform.position.x, npc.MainObj.transform.position.y, npc.MainObj.transform.position.z); itemType.m_eulerAngles = new Vector3(npc.MainObj.transform.localEulerAngles.x, npc.MainObj.transform.localEulerAngles.y, npc.MainObj.transform.localEulerAngles.z); MainGame.Singleton.StartCoroutine(LoadDropItem(itemType)); } }
public IEnumerator LoadDropItem(DropItemPerformanceType item) { yield return(new WaitForSeconds(0.2f)); GameResPackage.AsyncLoadPackageData loadData = new GameResPackage.AsyncLoadPackageData(); IEnumerator e = null; EventItemInfo eventInfo = GameTable.eventItemAsset.LookUp(item.m_intParam); DropItemPerformanceType.Type type = item.m_type; if (eventInfo != null) { type = (DropItemPerformanceType.Type)eventInfo.dropType; } switch (type) { // 卡牌 case DropItemPerformanceType.Type.enCard: { DropItemPerformanceCard cardItem = (DropItemPerformanceCard)item; foreach (int cardId in cardItem.m_cardList) { e = NewDropItem(loadData, item, cardId); while (true) { e.MoveNext(); if (loadData.m_isFinish) { break; } yield return(e.Current); } Debug.Log("....cardId:" + cardId); yield return(new WaitForSeconds(0.1f)); } // 卡牌的增长数目 Reward.Singleton.m_cardDesNum = Reward.Singleton.m_cardNum + cardItem.m_cardList.Count; break; } // 金钱 case DropItemPerformanceType.Type.enGold: { // 如果有钱则掉落金币 效果 if (item.m_intParam > 0) { int min = 15; int max = 30; WorldParamInfo worldInfo = GameTable.WorldParamTableAsset.Lookup((int)ENWorldParamIndex.enDropGoldMinMax); if (null != worldInfo) { List <int> cardList = ConvertorTool.StringToList_Int(worldInfo.StringTypeValue); if (null != cardList && cardList.Count >= 2) { min = cardList[0]; max = cardList[1]; } } // 金币增长的数目 int randomGold = UnityEngine.Random.Range(100, 1000); Reward.Singleton.m_goldDesNum = Reward.Singleton.m_goldNum + randomGold; int dropNum = UnityEngine.Random.Range(min, max); for (int i = 0; i < dropNum; i++) { e = NewDropItem(loadData, item); while (true) { e.MoveNext(); if (loadData.m_isFinish) { break; } yield return(e.Current); } yield return(new WaitForSeconds(0.01f)); } } break; } // 钥匙 case DropItemPerformanceType.Type.enKey: { e = NewDropItem(loadData, item, item.m_intParam); while (true) { e.MoveNext(); if (loadData.m_isFinish) { break; } yield return(e.Current); } break; } } }
// IEnumerator NewDropItem(GameResPackage.AsyncLoadPackageData loadData, DropItemPerformanceType item, int intParam = 0) { EventItemInfo eventInfo = GameTable.eventItemAsset.LookUp(item.m_intParam); DropItemPerformanceType.Type type = item.m_type; if (eventInfo != null) { type = (DropItemPerformanceType.Type)eventInfo.dropType; } // string objName = ""; switch (type) { case DropItemPerformanceType.Type.enGold: { objName = "Balk/p-b-gold"; break; } case DropItemPerformanceType.Type.enCard: { objName = "Balk/p-b-contract"; //DropItemPerformanceCard cardItem = (DropItemPerformanceCard)item; // 根据不同星级掉落不同 模型 HeroInfo heroInfo = GameTable.HeroInfoTableAsset.Lookup(intParam); if (null != heroInfo) { RarityRelativeInfo rarityInfo = GameTable.RarityRelativeAsset.LookUp(heroInfo.Rarity); if (null != rarityInfo) { ModelInfo modelInfo = GameTable.ModelInfoTableAsset.Lookup(rarityInfo.m_dropItemModelID); if (null != modelInfo) { objName = modelInfo.ModelFile; } } } break; } case DropItemPerformanceType.Type.enKey: { // 钥匙模型 objName = "Balk/p-b-gold"; EventItemInfo eventItemInfo = GameTable.eventItemAsset.LookUp(intParam); if (null != eventItemInfo) { ModelInfo modelInfo = GameTable.ModelInfoTableAsset.Lookup(eventItemInfo.modelId); if (null != modelInfo) { objName = modelInfo.ModelFile; } } break; } } float rotation = 30f; rotation = UnityEngine.Random.Range(0f, 360f); GameResPackage.AsyncLoadObjectData data = new GameResPackage.AsyncLoadObjectData(); IEnumerator e = PoolManager.Singleton.Coroutine_Load(GameData.GetPrefabPath(objName), data); while (true) { e.MoveNext(); if (data.m_isFinish) { break; } yield return(e.Current); } GameObject goldObj = data.m_obj as GameObject; goldObj.transform.parent = MainGame.Singleton.MainObject.transform; goldObj.transform.position = item.m_deadPos; goldObj.SetActive(true); goldObj.transform.localEulerAngles = new Vector3(item.m_eulerAngles.x, item.m_eulerAngles.y + rotation, item.m_eulerAngles.z); int dropIndex = AddDropItem(goldObj); Animation anim = goldObj.transform.Find("gold_body").GetComponent <Animation>(); PickUpCallback pickUpCallback = goldObj.transform.Find("gold_body").GetComponent <PickUpCallback>(); if (null != pickUpCallback) { pickUpCallback.Clear(); pickUpCallback.m_index = dropIndex; } // 随机动画 int animationCount = anim.GetComponent <Animation>().GetClipCount(); int animationIndex = UnityEngine.Random.Range(1, animationCount); int index = 1; foreach (AnimationState state in anim.GetComponent <Animation>()) { if (index == animationIndex) { anim.CrossFade(state.name); break; } index++; } loadData.m_isFinish = true; }