nbarber20

clickableObject.cs

Dec 20th, 2018
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.63 KB | None | 0 0
  1. public List Required;
  2.     private bool HasRequired = false;
  3.     public Action[] SuccessActions;
  4.     public Action[] FailActions;
  5.  
  6.  public void OnPointerClick(PointerEventData eventData)
  7.  {
  8.        
  9.   if (eventData.button == PointerEventData.InputButton.Left)
  10.   {
  11.             HasRequired = true;
  12.             foreach(Requirements r in Required)
  13.             {
  14.                 switch (r.Type)//check to see if the player is doing it wrong
  15.                 {
  16.                     case Requirements.RequirementType.PickedUpItem:
  17.                         if (!GlobalGameVars.PickedUpItems[r.id].Active) HasRequired = false;
  18.                         break;
  19.                     case Requirements.RequirementType.ItemInHand:
  20.                         if (Inventory.IteminHand != r.id) HasRequired = false;
  21.                         break;
  22.                     case Requirements.RequirementType.GlobalVariableIsTrue:
  23.                         if (!GlobalGameVars.OtherVars[r.id].Active) HasRequired = false;
  24.                         break;
  25.                     case Requirements.RequirementType.HoldingJournalPages:
  26.                         if (GlobalGameVars.HeldPages < r.id) HasRequired = false;
  27.                         break;
  28.                 }
  29.  
  30.             }
  31.             if (HasRequired) {
  32.                 for (int i = 0; i < SuccessActions.Length; i++)
  33.                 {
  34.                     SuccessActions[i].ClickedObject();
  35.                 }
  36.    } else if (FailActions.Length!=0) {
  37.                 for (int i = 0; i < FailActions.Length; i++)
  38.                 {
  39.                     FailActions[i].ClickedObject();
  40.                 }
  41.    }
  42.   }
  43.  }
Advertisement
Add Comment
Please, Sign In to add comment