void ClickInBag(GameObject go, object parameter) { Parameter.Box p = (Parameter.Box)parameter; CharBag.Goods goods = (CharBag.Goods)p.obj; #if _Debug Debug.Log("ok!!" + " Name:" + goods.Name + " ID:" + p.ID); #endif SlotBox slotbox = new SlotBox(); if (SlotList.ContainsKey(p.ID)) { slotbox = SlotList[p.ID]; slotbox.button.transform.Find("Text").GetComponent <Text>().text = goods.Name; slotbox.button.transform.Find("Bottom/Image").GetComponent <Image>().sprite = Materiral.GetMaterialIcon(goods.MateriralType, goods.ID); slotbox.button.transform.Find("Bottom/Image").GetComponent <Image>().color = new Color(1, 1, 1, 1f); //把物品添加到合成系统的slotlist中 slotbox.slot = goods; SlotList[p.ID] = slotbox; //CloseBag _bagInstance.CloseBagMenu(gameObject); } }
void AddFristPropertyUIEft() { CharBag.Goods _fristGoods = new CharBag.Goods(); string[] mt = recipe.Target.Split(','); _fristGoods.Property = Materiral.GetMaterialProperty(int.Parse(mt[0]), int.Parse(mt[1])); AddPropertyUIEft(_fristGoods); }
CharBag.Goods CreateGoods() { CharBag.Goods goods = new CharBag.Goods(); goods.Property = new int[4]; for (int i = 0; i < PropertyBox.Count; i++) { //如果大于最大个数则忽略 if (i >= 4) { break; } PropertyElementBase p = (PropertyElementBase)PropertyBox[i]; goods.Property[i] = p.Property.ID; } goods.Quality = Quality; goods.Number = 1; goods.Name = recipe.Name; string target = recipe.Target; if (target[0] == char.Parse("0")) { string mat_str = target.Substring(target.IndexOf(",") + 1); goods.MateriralType = 0; goods.ID = int.Parse(mat_str); } else if (target[0] == char.Parse("1")) { string mat_str = target.Substring(target.IndexOf(",") + 1); goods.MateriralType = 1; goods.ID = int.Parse(mat_str); } goods.Type = Materiral.GetTypeByMaterialID(goods.MateriralType, goods.ID); goods.MaterialEffet = QualityEffectID; //计算价格 goods.Price = Materiral.GetMaterialPrice(goods.MateriralType, goods.ID); goods = CharBag.SetPrice(goods); //添加道具 goods.UID = CharBag.AddGoods(goods); questManager.CheckQuestListWithGoods(QuestManager.QuestTypeList.ComposeGoods, goods, 0); //更新物品信息 PlayerInfo.AddGoodsInfo(goods.MateriralType, goods.ID, PlayerInfo.GoodsInfoType.RecipeCount); //删除道具 foreach (SlotBox slot in SlotList.Values) { CharBag.RemoveGoods(slot.slot.UID); } return(goods); }
void ShowMateriralInfo(GameObject go, object parameter) { CharBag.Goods goods = (CharBag.Goods)parameter; ItemInfoUI info = Instantiate(iteminfo).GetComponent <ItemInfoUI>(); info.Ini(); info.OpenItemInfo(goods); }
public void SetGoodsName(int MaterialType) { //创建物品列表 for (int i = 0; i < _bagList.Count; i++) { CharBag.Goods _map = (CharBag.Goods)_bagList[i]; //筛选物品,特殊物品不显示 if (MaterialType != -1) { if (_map.MateriralType != MaterialType) { continue; } if (_map.MateriralType == 2 && _map.Type == 0) { continue; } } GameObject button = Instantiate(btn_menu); button.transform.SetParent(_fitter.transform, false); button.name = _map.ID.ToString(); button.transform.Find("Text").GetComponent <Text>().text = _map.Name; button.transform.Find("Image").GetComponent <Image>().sprite = Materiral.GetMaterialIcon(_map.MateriralType, _map.ID); //显示数量 button.transform.Find("num").gameObject.SetActive(true); button.transform.Find("num/Text").GetComponent <Text>().text = _map.Number.ToString(); //显示价格 button.transform.Find("PriceBoard").gameObject.SetActive(true); button.transform.Find("PriceBoard/Text").GetComponent <Text>().text = _map.Price.ToString(); //设置参数容器中的参数 Parameter.Box _p = new Parameter.Box(); _p.obj = _map; //设置点击事件 OnClickInScorll.Get(button.transform).parameter = _p; OnClickInScorll.Get(button.transform).onHoldByParameter = ShowMateriralInfo; //添加背包进入筛选背包列表 f_BagList.Add(_map); } //调整列表为置顶 if (f_BagList.Count > 5) { setGird(); } StartCoroutine(SetListToTop()); }
void ShowMaterialIcon(CharBag.Goods goods, RectTransform rect) { //显示采集到的素材图标 GameObject materiralicon = new GameObject(); Image sr = materiralicon.AddComponent <Image>(); sr.sprite = Materiral.GetMaterialIcon(goods.MateriralType, goods.ID); materiralicon.transform.position = rect.position; materiralicon.transform.SetParent(MateriralList.Find("ListBox"), false); materiralicon.transform.localScale = new Vector3(1, 1, 1); materiralicon.GetComponent <RectTransform>().sizeDelta = new Vector2(50, 50); //由路点落到list处 RectTransform er = MateriralList.Find("ListBox").GetComponent <RectTransform>(); LeanTween.moveLocal(materiralicon, new Vector3(er.localPosition.x, er.rect.height, 0), 1f); LeanTween.scale(materiralicon, new Vector3(0, 0, 0), 0.4f).setEase(LeanTweenType.easeInBack).setDestroyOnComplete(true).setOnComplete(() => { StartCoroutine(ShowMateriralInList(goods)); }); }
//上架商品 void ClickInBag(GameObject go, object parameter) { Parameter.Box p = (Parameter.Box)parameter; CharBag.Goods goods = (CharBag.Goods)p.obj; //如果货架上有商品,则添加道具到背包 if (goodslist[p.ID - 1].Name != null && goodslist[p.ID - 1].ID != 0) { CharBag.AddGoods(goodslist[p.ID - 1]); } //添加选中的商品到商品列 goodslist[p.ID - 1] = goods; string path = p.ID.ToString() + "/itemIcon"; transform.Find(path).GetComponent <SpriteRenderer>().sprite = Materiral.GetMaterialIcon(goods.MateriralType, goods.ID); //显示商品价格 string priceiconpath = p.ID.ToString() + "/price/icon"; string pricepath = p.ID.ToString() + "/price/text"; transform.Find(priceiconpath).gameObject.SetActive(true); transform.Find(pricepath).gameObject.SetActive(true); transform.Find(pricepath).GetComponent <TextMesh>().text = goods.Price.ToString(); //移除背包中的商品 CharBag.RemoveGoods(goods.UID); _bagInstance.CloseBagMenu(gameObject); ChangeRecipeUiState(); PlayerData.ShopGoodsData.SaveShopGoods(goodslist); CharBag.SaveBagGoods(); questManager.CheckQuestListWithGoods(QuestManager.QuestTypeList.PutGoods, goods, 0); //更新物品信息 PlayerInfo.AddGoodsInfo(goods.MateriralType, goods.ID, PlayerInfo.GoodsInfoType.PutCount); }
/// <summary> /// 用于检查是否触发事件,物品判断的条件不管使用哪个EventType都一样,point是玩家所在的位置 /// </summary> /// <param name="EventType"></param> /// <returns></returns> public bool CheckQuestListWithGoods(QuestTypeList EventType, CharBag.Goods goods, int point) { bool ishit = false; //事件判断 foreach (QuestBase _event in NowQuestInfoList) { switch (_event.QuestComplete.QuestType) { //给物品相关的判断,统一处理 case QuestTypeList.PutGoods: case QuestTypeList.SellGoods: case QuestTypeList.ComposeGoods: case QuestTypeList.CollectGoods: case QuestTypeList.ComposeProperty: if (_event.QuestComplete.Parameter == null || _event.QuestComplete.Parameter.Length <= 0) { Debug.LogWarning("任务配置表Parameter出错! questID:" + _event.ID); } if (_event.QuestComplete.QuestType == QuestTypeList.ComposeProperty) { foreach (int p in goods.Property) { if (p == _event.QuestComplete.Parameter[0] && _event.QuestComplete.Num > PlayerInfo.GetQuestProgress(_event.ID) && PlayerInfo.GetQuestStatus(_event.ID) == PlayerInfo.QuestInfo.QuestInfoType.Todo) { PlayerInfo.AddQuestProgress(_event.ID, 1, _event.QuestComplete.Num); UIInstance.UpdateQuestUI(_event.ID, point); ishit = true; } } } else { if (_event.QuestComplete.Parameter[0] == 0) { if (goods.ID == _event.QuestComplete.Parameter[1] && _event.QuestComplete.Num > PlayerInfo.GetQuestProgress(_event.ID) && PlayerInfo.GetQuestStatus(_event.ID) == PlayerInfo.QuestInfo.QuestInfoType.Todo) { if (_event.QuestComplete.QuestType == QuestTypeList.PutGoods && _event.QuestComplete.QuestType == EventType) { PlayerInfo.AddQuestProgress(_event.ID, 1, _event.QuestComplete.Num); UIInstance.UpdateQuestUI(_event.ID, point); ishit = true; } else if (_event.QuestComplete.QuestType == QuestTypeList.SellGoods && _event.QuestComplete.QuestType == EventType) { PlayerInfo.AddQuestProgress(_event.ID, 1, _event.QuestComplete.Num); UIInstance.UpdateQuestUI(_event.ID, point); ishit = true; } else if (_event.QuestComplete.QuestType == QuestTypeList.ComposeGoods && _event.QuestComplete.QuestType == EventType) { PlayerInfo.AddQuestProgress(_event.ID, 1, _event.QuestComplete.Num); UIInstance.UpdateQuestUI(_event.ID, point); ishit = true; } else if (_event.QuestComplete.QuestType == QuestTypeList.CollectGoods && _event.QuestComplete.QuestType == EventType) { PlayerInfo.AddQuestProgress(_event.ID, 1, _event.QuestComplete.Num); UIInstance.UpdateQuestUI(_event.ID, point); ishit = true; } } } //item } break; } } if (ishit == true) { PlayerData.PlayerInfoData.Save(PlayerInfo.GetPlayerInfo()); } return(ishit); }
public void OpenItemInfo(CharBag.Goods good) { //名称 goodsUIBase.nameText.text = good.Name; //图片icon goodsUIBase.goodsIMG.sprite = Materiral.GetMaterialIcon(good.MateriralType, good.ID); //物品类型 if (good.MateriralType == 0) { goodsUIBase.MaterialtypeText.text = "类型:物品"; } else if (good.MateriralType == 1) { goodsUIBase.MaterialtypeText.text = "类型:概念"; } else { goodsUIBase.MaterialtypeText.text = "类型:未知"; } //数量 goodsUIBase.numText.text = "数量:" + good.Number.ToString(); //品质 goodsUIBase.qualityText.text = "品质:" + good.Quality.ToString(); //价格 goodsUIBase.priceText.text = "价格:" + good.Price.ToString(); //物品效果 if (good.MaterialEffet != 0) { Materiral.Effect _effect = Materiral.FindMaterialEffectByID(good.MaterialEffet); goodsUIBase.effect.text = _effect.Name; effect = _effect; } //物品属性 if (good.Property != null) { for (int i = 0; i < good.Property.Length; i++) { if (good.Property[i] == 0) { break; } Materiral.Property _p = Materiral.GetProNameByProID(good.Property[i]); GameObject p_obj = goodsUIBase.propertys[i]; p_obj.SetActive(true); p_obj.transform.GetChild(0).GetComponent <Text>().text = _p.Name; p_obj.transform.GetChild(1).GetComponent <Image>().sprite = Materiral.GetPropertyIcon(_p.ID); Propertys.Add(_p); } } //类型 goodsUIBase.typeText.text = Materiral.FindTypeNameByID(good.Type).Name; string str = Materiral.GetDesByMaterialID(good.MateriralType, good.ID); //描述 goodsUIBase.des.text = System.Text.RegularExpressions.Regex.Unescape(str); }
void SetRecipeNameInShop(object parameter) { Parameter.Box p = (Parameter.Box)parameter; //显示当前上架的物品 if (p.obj != null) { CharBag.Goods currentGoods = (CharBag.Goods)p.obj; Image _image = shopGoods.transform.Find("Image").GetComponent <Image>(); Text _text = shopGoods.transform.Find("Text").GetComponent <Text>(); Button _button = shopGoods.transform.Find("Button").GetComponent <Button>(); _text.text = "当前上架的商品:"; _text.transform.localPosition = new Vector3(_text.transform.position.x, 50, _text.transform.position.z); _image.gameObject.SetActive(true); _image.sprite = Materiral.GetMaterialIcon(currentGoods.MateriralType, currentGoods.ID); EventTriggerListener.Get(_image.gameObject).parameter = p; EventTriggerListener.Get(_image.gameObject).onClickByParameter = ShowMateriralInfo; _button.gameObject.SetActive(true); EventTriggerListener.Get(_button.gameObject).parameter = p; EventTriggerListener.Get(_button.gameObject).onClickByParameter = p.callbackByEvent; } //创建物品列表 for (int i = 0; i < _bagList.Count; i++) { CharBag.Goods _map = (CharBag.Goods)_bagList[i]; //筛选物品,特殊物品不显示 if (_map.MateriralType > 1) { continue; } GameObject button = Instantiate(btn_menu); button.transform.SetParent(_fitter.transform, false); button.name = _map.ID.ToString(); button.transform.Find("Text").GetComponent <Text>().text = _map.Name; button.transform.Find("Image").GetComponent <Image>().sprite = Materiral.GetMaterialIcon(_map.MateriralType, _map.ID); //显示数量 button.transform.Find("num").gameObject.SetActive(true); button.transform.Find("num/Text").GetComponent <Text>().text = _map.Number.ToString(); //显示价格 button.transform.Find("PriceBoard").gameObject.SetActive(true); button.transform.Find("PriceBoard/Text").GetComponent <Text>().text = _map.Price.ToString(); //设置参数容器中的参数 Parameter.Box _p = new Parameter.Box(); _p.ID = p.ID; _p.obj = _map; //设置点击事件 OnClickInScorll.Get(button.transform).parameter = _p; OnClickInScorll.Get(button.transform).onClickByParameter = p.callback; OnClickInScorll.Get(button.transform).onHoldByParameter = ShowMateriralInfo; //添加背包进入筛选背包列表 f_BagList.Add(_map); } //调整列表为置顶 if (f_BagList.Count > 5) { setGird(); } StartCoroutine(SetListToTop()); }
//TODO:add type mode void SetRecipeNameFilter(object parameter) { Parameter.Box p = (Parameter.Box)parameter; Recipe.Slot slot = (Recipe.Slot)p.obj; Dictionary <int, RecipeUI.SlotBox> slotList = (Dictionary <int, RecipeUI.SlotBox>)p.subobj; for (int i = 0; i < _bagList.Count; i++) { CharBag.Goods _map = new CharBag.Goods(); CharBag.Goods m_map = (CharBag.Goods)_bagList[i]; ////////筛选 if (slot.SlotType == Recipe.SlotTypeList.Material) { //固定材料 if (slot.MatType == 0 && slot.MatType == m_map.MateriralType) //Item { if (m_map.ID == slot.MatId) { _map = m_map; } } else if (slot.MatType == 1 && slot.MatType == m_map.MateriralType) //Mind { if (m_map.ID == slot.MatId) { _map = m_map; } } } else if (slot.SlotType == Recipe.SlotTypeList.MaterialType) { if (m_map.Type == slot.MatType) { _map = m_map; } } //添加进入背包列表,并且创建按钮 if (_map.Name != null) { //添加背包进入筛选背包列表 f_BagList.Add(_map); //创建按钮 GameObject button = Instantiate(btn_menu); button.transform.SetParent(_fitter.transform, false); button.name = _map.ID.ToString(); button.transform.Find("Text").GetComponent <Text>().text = _map.Name; button.transform.Find("Image").GetComponent <Image>().sprite = Materiral.GetMaterialIcon(_map.MateriralType, _map.ID); //显示数量 button.transform.Find("num").gameObject.SetActive(true); ; button.transform.Find("num/Text").GetComponent <Text>().text = _map.Number.ToString(); //设置参数容器中的参数 Parameter.Box _p = new Parameter.Box(); _p.ID = p.ID; _p.obj = _map; //设置点击事件 OnClickInScorll.Get(button.transform).parameter = _p; OnClickInScorll.Get(button.transform).onClickByParameter = p.callback; OnClickInScorll.Get(button.transform).onHoldByParameter = ShowMateriralInfo; //如果是已经的选中的则不能点击 foreach (RecipeUI.SlotBox _slot in slotList.Values) { if (_map.UID == _slot.slot.UID) { button.name = _map.ID.ToString(); button.transform.Find("Text").GetComponent <Text>().text = _map.Name + " <color=red>(E)</color>"; button.transform.GetComponent <Image>().color = Color.gray; OnClickInScorll.Get(button.transform).onClickByParameter = null; } } } } //调整列表为置顶 if (f_BagList.Count > 5) { setGird(); } StartCoroutine(SetListToTop()); }
//属性效果UI效果 void AddPropertyUIEft(CharBag.Goods _slot) { float actionTime = 0.5f; for (int i = 0; i < _slot.Property.Length; i++) { if (_slot.Property[i] == 0) { continue; } int proID = _slot.Property[i]; RectTransform _property = Instantiate(PropertyListElement).GetComponent <RectTransform>(); _property.transform.SetParent(PropertyListGrid.transform, false); _property.localPosition = GetPropertyPos(PropertyBox.Count + 1); _property.sizeDelta = GetPropertySize(PropertyBox.Count + 1); //获取materiral的颜色 Color _color_image = _property.GetComponent <Image>().color; Color _color_text = _property.transform.Find("Text").GetComponent <Text>().color; Color from = new Color(_color_image.r, _color_image.g, _color_image.b, 0); _property.GetComponent <Image>().color = from; _property.transform.Find("Image").GetComponent <Image>().color = from; _property.transform.Find("Text").GetComponent <Text>().color = from; //渐现效果 LeanTween.value(_property.gameObject, from, _color_image, 0.25f).setDelay(actionTime).setOnUpdate( (Color col) => { _property.GetComponent <Image>().color = col; } ); LeanTween.value(_property.gameObject, from, _color_text, 0.25f).setDelay(actionTime).setOnUpdate( (Color col) => { _property.transform.Find("Text").GetComponent <Text>().color = col; } ); LeanTween.value(_property.gameObject, from, new Color(1, 1, 1, 1), 0.25f).setDelay(actionTime).setOnUpdate( (Color col) => { _property.transform.Find("Image").GetComponent <Image>().color = col; } ); //TODO:点击效果 //EndTODO Materiral.Property _p = Materiral.GetProNameByProID(proID); _property.transform.Find("Text").GetComponent <Text>().text = _p.Name; _property.transform.Find("Image").GetComponent <Image>().sprite = Materiral.GetIconByName(_p.IMG); PropertyElementBase _proBase = new PropertyElementBase(); _proBase.ID = PropertyBox.Count + 1; _proBase.Property = _p; _proBase.Button = _property; PropertyBox.Add(_proBase); } }
void StartCompose(GameObject go) { for (int i = 0; i < recipeSlotsList.transform.childCount; i++) { if (recipeSlotsList.transform.GetChild(i).gameObject.name == "Compose") { continue; } GameObject slot = recipeSlotsList.transform.GetChild(i).gameObject; slot.transform.Find("Bottom/Image").GetComponent <Image>().color = Color.white; slot.transform.Find("Bottom").GetComponent <Image>().enabled = false; slot.transform.Find("Text").GetComponent <Text>().text = ""; slot.transform.Find("Count").gameObject.SetActive(false); } float actionTime = 3f; LeanTween.scale(btn_Compose.gameObject, new Vector3(0.1f, 0.1f, 0.1f), 0.1f).setEase(LeanTweenType.easeInBack).setOnComplete( () => { btn_Compose.gameObject.SetActive(false); }); ComposeMask.SetActive(true); Color c = recipeSlotsList.GetComponent <Image>().color; recipeSlotsList.GetComponent <Image>().color = new Color(c.r, c.g, c.b, 0); Color m = ComposeMask.GetComponent <Image>().color; //渐现效果 LeanTween.value(ComposeMask.gameObject, c, new Color(m.r, m.g, m.b, 0.7f), actionTime * 0.1f).setOnUpdate( (Color col) => { ComposeMask.GetComponent <Image>().color = col; } ); LeanTween.value(recipeSlotsList.gameObject, c, new Color(c.r, c.g, c.b, 0), actionTime * 0.1f).setOnUpdate( (Color col) => { recipeSlotsList.GetComponent <Image>().color = col; } ); //上升效果 LeanTween.moveY(recipeSlotsList.gameObject, Screen.height / 2, actionTime * 0.5f).setEase(LeanTweenType.easeOutQuad); //旋转效果 LeanTween.rotateZ(recipeSlotsList.gameObject, 360 * 10, actionTime).setEase(LeanTweenType.easeInOutQuad); LeanTween.scale(recipeSlotsList.gameObject, new Vector3(1.3f, 1.3f, 1.3f), actionTime * 0.7f).setEase(LeanTweenType.easeOutQuad).setOnComplete( () => { LeanTween.scale(recipeSlotsList.gameObject, new Vector3(0.1f, 0.1f, 0.1f), actionTime * 0.3f).setEase(LeanTweenType.easeInBack).setOnComplete( () => { CharBag.Goods goods = CreateGoods(); btn_startRecipe.gameObject.SetActive(true); btn_startRecipe.transform.Find("Text").GetComponent <Text>().text = "收取"; recipeSlotsList.gameObject.SetActive(false); EventTriggerListener.Get(btn_startRecipe.gameObject).onClick = CloseRecipe; targetgoods = Instantiate(btn_recipeSlot); targetgoods.transform.SetParent(recipeUI.transform, false); targetgoods.transform.SetAsLastSibling(); targetgoods.transform.position = recipeSlotsList.transform.position; targetgoods.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f); LeanTween.scale(targetgoods, new Vector3(1.5f, 1.5f, 1.5f), 1f).setEase(LeanTweenType.easeOutBack); targetgoods.transform.Find("Text").GetComponent <Text>().text = goods.Name; targetgoods.transform.Find("Bottom/Image").GetComponent <Image>().sprite = Materiral.GetMaterialIcon(goods.MateriralType, goods.ID); GameObject _targetButton = targetgoods.transform.Find("Bottom/Image").gameObject; EventTriggerListener.Get(_targetButton).parameter = goods; EventTriggerListener.Get(_targetButton).onClickByParameter = ShowMateriralInfo; }); } ); }
//通过进入地图的id筛选出道具,然后通过权重选出拾取的东西。 //如果以后会有专门进入地图的设定的话,则可以吧判断地图id筛选道具列表的方法单独移出。 public void CollectionAction(int ap, RectTransform rect) { Debug.Log("mine:" + ap); //筛选出可以掉落的道具 int mapid = ap; ArrayList List = new ArrayList(); int max = 0; foreach (CollectionMap materiral in CollectionList) { if (materiral.Map == mapid) { List.Add(materiral); //获取随机范围 max += materiral.Weight; } } //随机权重,选出拾取哪个道具 CharBag.Goods dropMa = new CharBag.Goods(); dropMa.Property = new int[4]; int point = Random.Range(1, max); int check = 0; foreach (CollectionMap materiral in List) { check += materiral.Weight; if (check >= point) { //指定掉落的材料 dropMa.MateriralType = materiral.MateriralType; dropMa.ID = materiral.ID; //指定数量,后期会修改为需要指定数量 dropMa.Number = 1; //随机品质 dropMa.Quality = Random.Range(materiral.RandomQuality[0], materiral.RandomQuality[1]); //随机属性;随机4个属性 int random_max = 0; int propcount = 0; for (int i = 0; i < materiral.RandomProperty.Length / 2; i++) { random_max += materiral.RandomProperty[i, 1]; } for (int index = 0; index < 4; index++) { if (materiral.PropertyProbability < Random.Range(1, 100)) { continue; } int _point = Random.Range(1, random_max); int _check = 0; //指定随机属性 for (int i = 0; i < materiral.RandomProperty.Length / 2; i++) { _check += materiral.RandomProperty[i, 1]; if (_check >= _point) { dropMa.Property[propcount] = materiral.RandomProperty[i, 0]; propcount++; break; } } } break; } //endif } //endforech //获取名称 if (dropMa.MateriralType == 0) { Materiral.Items dorp_item = Materiral.FindItemByID(dropMa.ID); dropMa.Name = dorp_item.Name; //设定基础价格,之后还需要计算 dropMa.Price = dorp_item.Price; //获取type dropMa.Type = Materiral.GetTypeByMaterialID(dropMa.MateriralType, dropMa.ID); } //item else if (dropMa.MateriralType == 1) { Materiral.Minds drop_mind = Materiral.FindMindByID(dropMa.ID); dropMa.Name = drop_mind.Name; //设定基础价格,之后还需要计算 dropMa.Price = drop_mind.Price; //获取type dropMa.Type = Materiral.GetTypeByMaterialID(dropMa.MateriralType, dropMa.ID); } //mind //计算价格 dropMa = CharBag.SetPrice(dropMa); //添加物品 dropMa.UID = CharBag.AddGoods(dropMa); questManager.CheckQuestListWithGoods(QuestManager.QuestTypeList.CollectGoods, dropMa, ap); //更新物品信息 PlayerInfo.AddGoodsInfo(dropMa.MateriralType, dropMa.ID, PlayerInfo.GoodsInfoType.CollectCount); eventmanager.PreCheckEventList(1); ShowMaterialIcon(dropMa, rect); }
IEnumerator ShowMateriralInList(CharBag.Goods goods) { yield return(null); float listHeight = MateriralList.Find("ListBox").GetComponent <RectTransform>().rect.height; float listWidth = MateriralList.Find("ListBox").GetComponent <RectTransform>().rect.width; GameObject materiral = Instantiate(bt_materiral); //获取materiral的颜色 Color _color_image = materiral.GetComponent <Image>().color; Color _color_text = materiral.transform.Find("Text").GetComponent <Text>().color; Color from = new Color(0, 0, 0, 0); materiral.GetComponent <Image>().color = from; materiral.transform.Find("Text").GetComponent <Text>().color = from; //获取materiral的大小 RectTransform rec_mat = bt_materiral.GetComponent <RectTransform>(); //添加进入列表中 materiral.transform.SetParent(MateriralList.Find("ListBox"), false); //materiral.transform.SetAsFirstSibling(); //如果显示数目超过顶部,则对齐顶部 if (MateriralList.Find("ListBox").transform.childCount *rec_mat.rect.height > listHeight) { GameObject materiallist = MateriralList.Find("ListBox").gameObject; LeanTween.moveLocalY(materiallist, MateriralList.Find("ListBox").transform.localPosition.y - rec_mat.rect.height, 0.15f); } float dis = MateriralList.Find("ListBox").GetComponent <RectTransform>().rect.height / 2; //dis为中心点;抵消local的偏差,使用local0点为中心点 float button_pos = -dis + (rec_mat.rect.height / 2) + (MateriralList.Find("ListBox").transform.childCount - 1) * rec_mat.rect.height; materiral.GetComponent <RectTransform>().localPosition = new Vector3(0, dis + button_pos); //由上落下的效果 LeanTween.moveLocalY(materiral, button_pos, 0.5f).setEase(LeanTweenType.easeOutBounce); //渐现效果 LeanTween.value(materiral, from, _color_image, 0.25f).setOnUpdate( (Color col) => { materiral.GetComponent <Image>().color = col; } ); LeanTween.value(materiral, from, _color_text, 0.25f).setOnUpdate( (Color col) => { materiral.transform.Find("Text").GetComponent <Text>().color = col; } ); //显示名称 materiral.transform.Find("Text").GetComponent <Text>().text = goods.Name; materiral.transform.Find("Image").GetComponent <Image>().sprite = Materiral.GetMaterialIcon(goods.MateriralType, goods.ID); EventTriggerListener.Get(materiral).parameter = goods; EventTriggerListener.Get(materiral).onClickByParameter = ShowMateriralInfo; }