protected override void OnPress(bool pressed) { base.OnPress(pressed); if (GetMPress()) { } else { if (gameObject.transform.localPosition.y >= finshed_y) { if (OnCardDragFished != null) { current = this; EventDelegate.Execute(OnCardDragFished); current = null; } } transform.localPosition = startPos; } }
static void SetSkillCardPos(bool isCoexist) { int count = 0; if (isCoexist) { count = skillList.Count + cardWidget.childCount; } else { count = skillList.Count; } if (count == 0) { cardWidget.DestroyChildren(); return; } for (int i = 0; i < skillList.Count; i++) { GameObject go = GameObject.Instantiate(skillList[i].cardPrefab); go.transform.SetParent(cardWidget, false); go.name = skillList[i].data.Name; DragSkillCard cardDrag = go.GetComponent <DragSkillCard>(); cardDrag.OnCardDragFished.Clear(); cardDrag.OnCardDragFished.Add(new EventDelegate(OnCardDragFished)); cardDrag.finshed_y = -1.5f; go.tag = "SkillCard"; } GridCard(count); }
static void OnCardDragFished() { arrowState = ArrowState.moveToDown; OnUpArrowBtnClick(); DragSkillCard current = DragSkillCard.current; string name = current.gameObject.name; Skill skill = null; for (int i = 0; i < allSkillList.Count; i++) { if (name == allSkillList[i].data.Name) { skill = allSkillList[i]; } } curSkill = skill; List <string> targetNameList = new List <string>(); foreach (string item in skill.TargetWithHanderDic.Keys) { targetNameList.Add(item); } int count = targetWidget.transform.childCount; for (int i = 0; i < targetNameList.Count; i++) { GameObject go = null; if (i < count) { go = targetWidget.transform.GetChild(i).gameObject; UISprite sprite = go.transform.FindRecursively("Sprite").GetComponent <UISprite>(); sprite.spriteName = targetNameList[i]; } else { go = GameObject.Instantiate(infoItem); go.transform.SetParent(targetWidget.transform, false); } UIButton button = go.GetComponent <UIButton>(); button.onClick.Clear(); button.onClick.Add(skill.TargetWithHanderDic[targetNameList[i]]); button.onClick.Add(new EventDelegate(OnTargetBtnClick)); UILabel nameLabel = go.transform.FindRecursively("nameLabel").GetComponent <UILabel>(); if (targetNameList[i] == "myself") { nameLabel.text = "自己"; } else if (targetNameList[i] == "scene") { nameLabel.text = "环境"; } go.name = targetNameList[i]; go.SetActive(true); } for (int i = targetWidget.transform.childCount - 1; i >= targetNameList.Count; i--) { GameObject go = targetWidget.transform.GetChild(i).gameObject; go.SetActive(false); } targetWidget.gameObject.SetActive(true); targetWidget.Reposition(); }