public override void OnInspectorGUI() { base.OnInspectorGUI(); SC_CardGrabber cardGrabber = (target as SC_CardSearcher).GetComponent <SC_CardGrabber> (); if (GUILayout.Button("Search")) { foreach (SC_BaseCard c in Resources.LoadAll <SC_BaseCard> ("")) { if (cardGrabber.Matching(c)) { Debug.Log(c.name); } } } }
public void GrabPerform() { activeCard = this; ApplyingEffects = true; SC_CardGrabber grabber = GetComponent <SC_CardGrabber> (); bool[] where = new bool[] { grabber.deck, grabber.discard, grabber.otherDiscard }; List <SC_BaseCard>[] lists = new List <SC_BaseCard>[] { effectTarget.Deck.cards, effectTarget.Graveyard.Cards, (effectTarget == Caller ? Receiver : Caller).Graveyard.Cards }; Vector2 size = Resources.Load <RectTransform> ("Prefabs/Cards/P_Grab_Card").sizeDelta; foreach (Transform t in UI.grabUI.container) { Destroy(t.gameObject); } float margin = (UI.grabUI.container.rect.width - (size.x * 5)) / 6f; int x = 0; int y = 0; List <SC_GrabCard> grabbable = new List <SC_GrabCard> (); for (int i = 0; i < 3; i++) { if (where [i]) { foreach (SC_BaseCard c in lists[i]) { if (grabber.Matching(c)) { if (effectTarget.IsLocalPlayer) { SC_GrabCard g = Instantiate(Resources.Load <GameObject> ("Prefabs/Cards/P_Grab_Card"), UI.grabUI.container).GetComponentInChildren <SC_GrabCard> (); g.Setup(c, i); (g.transform.parent as RectTransform).anchoredPosition = new Vector2(x * size.x + (x + 1) * margin, -y * size.y - (y + 1) * margin); if (effectTarget.AI) { grabbable.Add(g); } } x = x == 4 ? 0 : x + 1; y = x == 0 ? y + 1 : y; } } } } effectTarget.IntChoices["Grab"] = -1; GrabsRemaining = Mathf.Min(Mathf.Max(CurrentEffect.effectValue, 1), y * 5 + x); if (GrabsRemaining == 0) { StartCoroutine(NoGrabbing()); } else { May(() => { StartCoroutine(Grabbing()); if (effectTarget.IsLocalPlayer) { y += (x == 0 ? -1 : 0) + 1; UI.grabUI.container.sizeDelta = new Vector2(UI.grabUI.container.sizeDelta.x, Mathf.Max(960, size.y * y + margin * (y + 1))); SC_GrabCard.selectedCards = new List <SC_BaseCard> (); UI.ShowGrabPanel(); } else if (effectTarget.AI) { List <int> indexes = new List <int> (); while (GrabsRemaining > 0) { int r = UnityEngine.Random.Range(0, grabbable.Count); if (!indexes.Contains(r) && SC_GrabCard.canGrab(grabbable[r].card)) { effectTarget.IntChoices["Grab" + GrabsRemaining] = grabbable[r].origin; effectTarget.StringChoices["Grab" + GrabsRemaining] = grabbable[r].name; GrabsRemaining--; } } effectTarget.IntChoices["Grab"] = 0; } }); } }