public static List <ABInfo> GetABInfoList(ABType type) { if (string.IsNullOrEmpty(abSearchString)) { if (type == ABType.All) { return(s_ABInfoDic.Values.ToList()); } s_TempABList.Clear(); foreach (var kv in s_ABInfoDic) { if (kv.Value.type == type) { s_TempABList.Add(kv.Value); } } } else { s_TempABList.Clear(); foreach (var kv in s_ABInfoDic) { if ((kv.Value.type == type || type == ABType.All) && kv.Value.name.Contains(abSearchString)) { s_TempABList.Add(kv.Value); } } } return(s_TempABList); }
// Création si c'est une feuille public PredictionTree(Prediction prediction, Color color) { isLeaf = true; type = ABType.MAX; this.prediction = prediction; value = prediction.board.getRank(color); sons = new List <PredictionTree>(); }
//Creation si c'est un max ou un min public PredictionTree(ABType t, Prediction prediction) { isLeaf = false; type = t; this.prediction = prediction; value = 0; sons = new List <PredictionTree>(); }
private void UpdateAB(Vector3 targetPos, ABType type) { if (InView(targetPos)) { var selfPlayer = adapter.GetPlayerEntity(); var playerTrans = selfPlayer.characterContoller.Value.transform; var distance = Mathf.FloorToInt(Vector3.Distance(targetPos, playerTrans.position)); var mi = "m"; var camera = selfPlayer.cameraObj.MainCamera; var result = UIUtils.WorldPosToRect(targetPos, camera, rootRect); switch (type) { case ABType.A: _viewModel.AactiveSelf = true; _viewModel.AtitleText = distance + mi; _viewModel.AUIPos = new Vector3(result.x, result.y, 0); break; case ABType.B: _viewModel.BactiveSelf = true; _viewModel.BtitleText = distance + mi; _viewModel.BUIPos = new Vector3(result.x, result.y, 0); break; case ABType.C4: _viewModel.C4activeSelf = true; _viewModel.C4titleText = distance + mi; _viewModel.C4UIPos = new Vector3(result.x, result.y, 0); break; default: break; } } else { switch (type) { case ABType.A: _viewModel.AactiveSelf = false; break; case ABType.B: _viewModel.BactiveSelf = false; break; case ABType.C4: _viewModel.C4activeSelf = false; break; default: break; } } }
private void UpdateAB(Vector3 targetPos, ABType type) { if (InView(targetPos)) { var selfPlayer = adapter.GetPlayerEntity(); var playerTrans = selfPlayer.characterContoller.Value.transform; var distance = Mathf.FloorToInt(Vector3.Distance(targetPos, playerTrans.position)); var mi = "m"; var camera = Camera.main; var result = UIUtils.WorldPosToRect(targetPos, camera, rootRect); switch (type) { case ABType.A: _viewModel.subrootA.gameObject.SetActive(true); AView.tittle.text = distance + mi; AView.rect.anchoredPosition = new Vector3(result.x, result.y, 0); break; case ABType.B: _viewModel.subrootB.gameObject.SetActive(true); BView.tittle.text = distance + mi; BView.rect.anchoredPosition = new Vector3(result.x, result.y, 0); break; case ABType.C4: _viewModel.subrootC4.gameObject.SetActive(true); C4View.tittle.text = distance + mi; C4View.rect.anchoredPosition = new Vector3(result.x, result.y, 0); break; default: break; } } else { switch (type) { case ABType.A: _viewModel.subrootA.gameObject.SetActive(false); break; case ABType.B: _viewModel.subrootB.gameObject.SetActive(false); break; case ABType.C4: _viewModel.subrootC4.gameObject.SetActive(false); break; default: break; } } }
private Res getCachedAbRes(ABType abType, string name) { //Debug.LogError("getCachedAbRes:" + name); if (ResCacheDic[abType].ContainsKey(name)) { return(ResCacheDic[abType][name]); } //Debug.LogError("get cachedABRes fail," + name); return(null); }
public void RemoveRes(ABType abType, string name) { if (!ResCacheDic.ContainsKey(abType)) { return; } if (ResCacheDic[abType].ContainsKey(name)) { ResCacheDic[abType].Remove(name); } }
private void GUIButton() { GUILayout.BeginHorizontal(); if (GUILayout.Button(m_SettingsTexture, GUILayout.Width(k_ABToolbarHeight), GUILayout.Height(k_ABToolbarHeight))) { GUISettingsPanel(); } var clicked = GUILayout.Button(m_RefreshTexture, GUILayout.Width(k_ABToolbarHeight), GUILayout.Height(k_ABToolbarHeight)); if (clicked) { RefreshAB(); } var platform = GUILayout.SelectionGrid(m_SelectedPlatformIndex, m_PlatformTextures, 3, GUILayout.Width(k_ABToolbarHeight * 3.3f), GUILayout.Height(k_ABToolbarHeight)); if (platform != m_SelectedPlatformIndex) { m_SelectedPlatformIndex = platform; switch (m_SelectedPlatformIndex) { case 0: m_SelectedPlatform = BuildTarget.StandaloneWindows64; break; case 1: m_SelectedPlatform = BuildTarget.iOS; break; case 2: m_SelectedPlatform = BuildTarget.Android; break; } RefreshAB(); } var tabLabels = new string[] { "All\n" + ABDatabase.GetABTypeSizeStr(ABType.All), "Model\n" + ABDatabase.GetABTypeSizeStr(ABType.Model), "Scene\n" + ABDatabase.GetABTypeSizeStr(ABType.Scene), "UI\n" + ABDatabase.GetABTypeSizeStr(ABType.UI), "Other\n" + ABDatabase.GetABTypeSizeStr(ABType.Other), "Dep\n" + ABDatabase.GetABTypeSizeStr(ABType.Dep) }; var barWidth = position.width - 5 * k_ABToolbarHeight + 7.4f; var selected = (ABType)GUILayout.Toolbar((int)m_SelectedABType, tabLabels, GUILayout.Height(k_ABToolbarHeight), GUILayout.Width(barWidth)); if (selected != m_SelectedABType) { m_SelectedABType = selected; m_ABTree.UpdateInfoList(ABDatabase.GetABInfoList(m_SelectedABType)); } GUILayout.EndHorizontal(); }
public static string GetABTypeSizeStr(ABType type) { if (s_ABTypeStat.ContainsKey(type)) { if (type == ABType.All) { return(s_ABTypeStat[type].StrInfo(s_TotalABs)); } else { return(s_ABTypeStat[type].StrInfo()); } } else { return(""); } }
public static string GetPreFix(ABType t) { FieldInfo[] fields = t.GetType().GetFields(); foreach (FieldInfo field in fields) { if (field.Name.Equals(t.ToString())) { object[] objs = field.GetCustomAttributes(typeof(ABTypeDes), true); if (objs != null && objs.Length > 0) { return(((ABTypeDes)objs[0]).PreFix); } else { Debug.LogError(t.GetType().Name + ",没有添加ABTypeDes"); return(""); } } } Debug.LogError("no such field:" + t.GetType().Name); return(""); }
/// <summary> /// name不带后缀,不带前缀 /// </summary> /// <param name="name">name为2D场景对应的预制件名称</param> /// <returns></returns> public static GameObject Load(string name, ABType abType) { if (abType != ABType.Effect && abType != ABType.Window && abType != ABType.OtherPrefab) { Debug.LogError("ABPrefab do not support load " + abType.ToString()); } GameObject obj = null; AssetBundle ab = LoadAB(name, abType); obj = ab.LoadAsset(name) as GameObject; ab.Unload(false); obj = GameObject.Instantiate(obj);//由于上面获得的 obj,实质是预制件,故这里需要Instantiate PrefabRes res = null; if (abType == ABType.Effect) { res = new EffectRes(name, obj); } else if (abType == ABType.Window) { res = new WindowRes(name, obj); } else if (abType == ABType.OtherPrefab) { res = new OtherPrefabRes(name, obj); } else { Debug.LogError("TODO:"); } EventDispatcher.Instance.DispatchEvent(EventID.OnABResLoaded, res); return(obj); }
void onRootObjDestroy(string evtId, object[] paras) { GameObject obj = paras[0] as GameObject; MatTextureHolder holder = obj.GetComponent <MatTextureHolder>(); if (holder != null) { ABType abType = holder.abType; if (abType == ABType.Window) { for (int i = 0; i < ABManagerMono.Instance.windowResList.Count; i++) { if (ABManagerMono.Instance.windowResList[i].resObj == obj) { ABManagerMono.Instance.windowResList.Remove(ABManagerMono.Instance.windowResList[i]); return; } } } else if (abType == ABType.Effect) { for (int i = 0; i < ABManagerMono.Instance.effectResList.Count; i++) { if (ABManagerMono.Instance.effectResList[i].resObj == obj) { ABManagerMono.Instance.effectResList.Remove(ABManagerMono.Instance.effectResList[i]); return; } } } else { Debug.LogError("TODO:::"); } } }
/// <summary> /// name不带后缀,不带前缀 /// </summary> /// <param name="name"></param> /// <returns></returns> static AssetBundle LoadAB(string name, ABType abType) { string nameNew = ABTypeUtil.GetPreFix(abType) + name; return(AB.Load(nameNew)); }