public void UpdateFoodAndActivity() { foreach (var activity in m_listActivities) { if (activity.nLevel != m_nLevel) { continue; } GameObject tmpActivityGO = GameObject.Instantiate <GameObject>(ActivityPrefabGO); //show the activity if (tmpActivityGO == null) { Debug.Log("Null Image "); break; } tmpActivityGO.GetComponent <Image>().sprite = CAssetMgr.Load <Sprite>(activity.szImgName); ListActivitiesDisplay.Add(tmpActivityGO); tmpActivityGO.GetComponent <Button>().onClick.AddListener(() => { unDisplay(); CaclulateResult(); UpdateFoodAndActivity(); ShowMiddleCenter(m_nCatType, m_nLevel, m_nCurrentLevelResult); //display the midddle cuenter }); } foreach (var food in m_listFood) { if (food.nLevel != m_nLevel) { continue; } GameObject tmpFoodGO = GameObject.Instantiate <GameObject>(FoodPrefabGO); //show the food if (tmpFoodGO == null) { Debug.Log("Null Image "); break; } tmpFoodGO.GetComponent <Image>().sprite = CAssetMgr.Load <Sprite>(food.szImgName); listFoodDisplay.Add(tmpFoodGO); tmpFoodGO.GetComponent <Button>().onClick.AddListener(() => { unDisplay(); CaclulateResult(); UpdateFoodAndActivity(); ShowMiddleCenter(m_nCatType, m_nLevel, m_nCurrentLevelResult); //display the midddle cuenter }); } Display(); }
private void Start() { this.m_listCatType = UI_OverViewMgr.Instance.listCCatTypes; Btn_NextPage.onClick.AddListener(OnClickCallBack); // 初始化对象 foreach (var catTyp in m_listCatType) //数据加载, 设置基本按钮东西 { if (catTyp.nLevel != 1) { continue; } GameObject prefab = GameObject.Instantiate <GameObject>(Prefab_CatDisplay); // intantiate the prefab prefab.transform.SetParent(GP_CatTypes.transform); Sprite img_CatImg = CAssetMgr.Load <Sprite>(catTyp.szImgName); // Load the resource , Load the Img and the text if (img_CatImg == null) { throw new NullReferenceException(); } if (prefab.GetComponent <Image> () != null) //换相片 { prefab.GetComponent <Image> ().sprite = img_CatImg; } else { throw new NullReferenceException(); } if (prefab.GetComponent <Button>() != null) { prefab.GetComponent <Button>().onClick.AddListener(() => { UI_OverViewMgr.Instance.PlayerChoiceIndex = int.Parse(catTyp.key); Sequence mySequence = DOTween.Sequence(); mySequence.Append(prefab.transform.DOLocalMoveY(100f, 0.5f).SetEase(Ease.OutQuad)); mySequence.Append(prefab.transform.DOLocalMoveY(0, 0.5f).SetEase(Ease.OutBounce)); }); } else { throw new NullReferenceException(); } prefab.SetActive(false); //先隐藏 m_ListCats.Add(prefab); //对点击时间添加回调函数, } ShowGamePreView(); }
public void ShowMiddleCenter(int In_nCatTypeIndex, int In_nLevel, int In_nCurLevelResult) { if (MiddleCenterGO == null) { Debug.LogError("The middle Center can't been null "); } if (In_nCatTypeIndex == -1 || In_nLevel == -1 || In_nCurLevelResult == -1) { Debug.LogError("The something is -1 "); } foreach (CCatType cat in UI_OverViewMgr.Instance.listCCatTypes) { if (In_nCatTypeIndex != cat.type || In_nLevel != cat.nLevel) { continue; } // Debug.Log("Update the middle center "); // Debug.Log("Index : " + In_nCatTypeIndex + "Level :" + In_nLevel + "Result : " + In_nCurLevelResult); // Debug.Log("Cat key :" +(int.Parse(cat.key)%3) + "cat level " + cat.nLevel + "reslut " + cat.nCurrentLevelResult ); // Debug.Log("cat imag" + cat.szImgName + "cat key" + cat.key); MiddleCenterGO.GetComponent <Image>().sprite = CAssetMgr.Load <Sprite>(cat.szImgName); //Replace Image } }
private void InitCAssetMgr() { this.m_instance = new CAssetMgr(); }
// Start is called before the first frame update void Start() { Sprite sImg = GameObject.Instantiate <Sprite>(CAssetMgr.Load <Sprite>("Timer_解析2")); }