Advertisement
Guest User

Untitled

a guest
Mar 25th, 2024
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. using UnityEngine;
  2. using AC;
  3. using System.Collections.Generic;
  4.  
  5. public class CheckCards : MonoBehaviour
  6. {
  7. public ActionList playerWinsCutscene;
  8. public ActionList setCutscene;
  9. private int cardNumber;
  10. private int tempVariable;
  11. private InvItem selectedItem;
  12.  
  13. public void CheckCard()
  14. {
  15. // Step 1: Check selected inventory item
  16. selectedItem = AC.KickStarter.runtimeInventory.SelectedItem;
  17. List<string> itemsToRemove = new List<string>(); // Temporary list to hold items to remove
  18. if (selectedItem != null)
  19. {
  20. for (int i = 1; i <= 10; i++)
  21. {
  22. if (selectedItem.label == "KCards/Card" + i)
  23. {
  24. cardNumber = i;
  25. break;
  26. }
  27. }
  28. }
  29.  
  30. // Step 2: Check local variable and perform actions
  31. GVar variable = AC.LocalVariables.GetVariable("Card" + cardNumber);
  32. if (cardNumber > 0 && AC.LocalVariables.GetIntegerValue(variable.id) > 2)
  33. {
  34. // Add "KCards/CardNumber" to the list of items to remove
  35. itemsToRemove.Add("KCards/Card" + cardNumber);
  36. Debug.Log("Card is Card " + selectedItem.label);
  37. }
  38.  
  39. // Remove items after iterating through the collection
  40. foreach (string itemLabel in itemsToRemove)
  41. {
  42. KickStarter.runtimeInventory.Remove(itemLabel, 3);
  43. }
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement