public T GetValueByType <T>(int type) where T : ConfigVo { T t = null; ConfigVo vo = null; if (rideMapping.TryGetValue(type, out vo) && vo is T) { return(t = vo as T); } if (levelMapping.TryGetValue(type, out vo) && vo is T) { return(t = vo as T); } if (rideGiftMapping.TryGetValue(type, out vo) && vo is T) { return(t = vo as T); } //if ( rideMaxGiftMapping.TryGetValue( type , out vo ) && vo is T ) //{ // return t = vo as T; //} return(t); }
/// <summary> /// UI进场动画 /// </summary> private void UiAnimation(ConfigVo configVo) { //标题 Transform title = UIRoot.Find("Title"); title.Find("Text").GetComponent <Text>().text = configVo.name; RectTransform titleRectTransform = title.GetComponent <RectTransform>(); titleRectTransform.DOAnchorPosY(-25F, 0.5F).SetEase(Ease.Linear); //信息面板 Transform leftInfo = UIRoot.Find("LeftInfo"); Transform panel = leftInfo.Find("Panel"); foreach (PropertyInfo p in configVo.GetType().GetProperties()) { Transform find = panel.Find(p.Name); if (find == null) { continue; } find.Find("Text").GetComponent <Text>().text = p.GetValue(configVo, null) + ""; } leftInfo.GetComponent <RectTransform>().DOAnchorPosX(180F, 0.5F).SetEase(Ease.Linear); UIRoot.Find("RightInfo").GetComponent <RectTransform>().DOAnchorPosX(-180F, 0.5F).SetEase(Ease.Linear); //按钮组 RectTransform buttonGroup = UIRoot.Find("ButtonGroup").GetComponent <RectTransform>(); buttonGroup.DOAnchorPosY(25F, 0.5F).SetEase(Ease.Linear); }
private void AddMapping(int type, Dictionary <int, ConfigVo> mapping, ConfigVo value) { if (mapping.ContainsKey(type)) { mapping[type] = value; } else { mapping.Add(type, value); } }