protected override int ConstructButtons() { int i = 0; //Debug.Log("_grp.GroupMembersCharacterData.Count:" + _grp.GroupMembersCharacterData.Count); for (i = 0; i < _grp.GroupMembersGameObjects.Count; i++) { GameObject targetButton = Instantiate(_Button); targetButton.transform.SetParent(this.gameObject.transform, false); _Buttons.Add(targetButton); Button but = targetButton.GetComponent <Button>(); RectTransform butTrans = targetButton.GetComponent <RectTransform>(); butTrans.anchoredPosition3D = new Vector3(ButtonWidth / 2.0f, -(i * ButtonHeight) - (ButtonHeight / 2.0f), 0); TargetButtonInfo info = targetButton.GetComponent <TargetButtonInfo>(); info.DisplayString = _grp.GroupMembersCharacterData[i].Name; info.Data = _grp.GroupMembersCharacterData[i]; info.TargetNum = i; info.Button = but; AddEvents(targetButton); } return(i); }
public void AddEffectToButtons(string eff) { int i; for (i = 0; i < _Buttons.Count; i++) { TargetButtonInfo info = _Buttons[i].GetComponent <TargetButtonInfo>(); info.Effect = eff; } }
public void ButtonCallback(BaseEventData eventData) { if (numMoves < numMovesAllowed) { GameObject but = eventData.selectedObject; //Debug.Log(but.ToString() +", "+ but.GetType()); TargetButtonInfo info = but.GetComponent <TargetButtonInfo>(); GameObject turnsBtn = GameObject.FindGameObjectWithTag("TurnButton"); //Debug.Log("info.TargetNum:" + info.TargetNum); turns t = turnsBtn.GetComponent <turns>(); System.Random rand = new System.Random(); int tmp = GlobalGameInfo.PlayerGroupData.GroupMembersCharacterData.Count - 1; int r = rand.Next(tmp); t.AddAction(info.Effect, GlobalGameInfo.PlayerGroupData.GroupMembersCharacterData[r], _grp.GroupMembersCharacterData[info.TargetNum]); numMoves++; } else { Debug.Log("Max moves allowed performed"); } }