void Start() { mTargetPrefab = Resources.Load(WUJIANG_TARGET) as GameObject; mTargetParent = new GameObject("TargetParent"); mTargetParent.transform.position = new Vector3(0, 0, 0); // 第一级菜单监听,显示第二级菜单位置 for (int i = 0; i < mMenuFirstBtns.Length; i++) { int index = i; mMenuFirstBtns[index].GetComponent <Button>().onClick.AddListener(delegate() { if (index == 0) { // 隐藏整个菜单(一级菜单) gameObject.SetActive(false); // 待机(目前为移动) mWujiang.Move(BattleGameManager.GetInstance().GetWujiangTransparent().transform.position); mWujiang.Seclet(false); BattleGameManager.GetInstance().GetWujiangTransparent().SetActive(false); } else if (index == 3) { // 显示技能菜单(二级菜单) Vector3 scale = mMenuFirstBtns[index].transform.lossyScale; Vector2 sizeDelta = mMenuFirstBtns[index].GetComponent <RectTransform>().sizeDelta; mSecondMenu.transform.position = mMenuFirstBtns[index].transform.position + new Vector3(sizeDelta.x * scale.x / 2, sizeDelta.y * scale.y / 2, 0); // 根据武将适性显示技能个数 for (int j = 0; j < mMenuSecondBtns.Length; j++) { if (j < mWujiang.mSkills.mSkillNames.Count) { mMenuSecondBtns[j].SetActive(true); mMenuSecondBtns[j].GetComponentInChildren <Text>().text = mWujiang.mSkills.mSkillNames[j]; // 根据是否可以释放技能来决定是否只用按钮 if (mWujiang.mSkills.mAllTargets[j].Count > 0) { EnabelBtn(mMenuSecondBtns[j]); } else { DisabelBtn(mMenuSecondBtns[j]); } } else { mMenuSecondBtns[j].SetActive(false); } } } else { // 隐藏二级菜单 mSecondMenu.GetComponent <RectTransform>().anchoredPosition = new Vector2(1000, 1000); } }); } // 第二级菜单监听 for (int i = 0; i < mMenuSecondBtns.Length; i++) { int index = i; mMenuSecondBtns[i].GetComponent <Button>().onClick.AddListener(delegate() { // 显示技能能攻击的目标集合 mSkillIndex = index; mTargets = mWujiang.mSkills.mAllTargets[index]; mWujiang.SetWujiangState(WujiangState.WujiangState_Prepare_Attack); ShowSkillTarget(mTargets); gameObject.SetActive(false); }); } mSecondMenu.GetComponent <RectTransform>().anchoredPosition = new Vector2(1000, 1000); }
public static void SetCurrentWujiang(Wujiang wujiang) { msCurrentWujiang = wujiang; msCurrentWujiang.Seclet(true); }