Advertisement
Darkhitori

vEquipAreaControl/OnPickUpItemCallBack

Jan 14th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.57 KB | None | 0 0
  1. //Darkhitori v1.0
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using Invector.ItemManager;
  6.  
  7. namespace HutongGames.PlayMaker.Actions
  8. {
  9.     [ActionCategory("Invector/vEquipAreaControl")]
  10.     [Tooltip(" ")]
  11.     public class vEA_OnPickUpItemCallBack : FsmStateAction
  12.     {
  13.         [RequiredField]
  14.         [CheckForComponent(typeof(vEquipAreaControl))]
  15.         public FsmOwnerDefault gameObject;
  16.        
  17.         [ObjectType(typeof(vEquipArea))]
  18.         public FsmObject area;
  19.        
  20.         [ObjectType(typeof(vItemSlot))]
  21.         public FsmObject slot;
  22.        
  23.         public FsmEvent sendEvent;
  24.        
  25.         public FsmBool everyFrame;
  26.  
  27.         vEquipAreaControl theScript;
  28.  
  29.  
  30.         public override void Reset()
  31.         {
  32.             gameObject = null;
  33.             area = null;
  34.             slot = null;
  35.             sendEvent = null;
  36.             everyFrame = true;
  37.         }
  38.        
  39.         public override void OnEnter()
  40.         {
  41.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  42.  
  43.             theScript = go.GetComponent<vEquipAreaControl>();
  44.  
  45.  
  46.             if (!everyFrame.Value)
  47.             {
  48.                 DoTheMagic();
  49.                 Finish();
  50.             }
  51.  
  52.         }
  53.  
  54.         public override void OnUpdate()
  55.         {
  56.             if (everyFrame.Value)
  57.             {
  58.                 DoTheMagic();
  59.             }
  60.         }
  61.  
  62.         void DoTheMagic()
  63.         {
  64.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  65.             if (go == null)
  66.             {
  67.                 return;
  68.             }
  69.             var vArea = area.Value as vEquipArea;
  70.             if (vArea == null)
  71.             {
  72.                 return;
  73.             }
  74.             var vSlot = slot.Value as vItemSlot;
  75.             if (vSlot == null)
  76.             {
  77.                 return;
  78.             }
  79.            
  80.             theScript.OnPickUpItemCallBack(vArea, vSlot);
  81.             if (sendEvent == null)
  82.             {
  83.                 return;
  84.             }
  85.             else
  86.             {
  87.                 Fsm.Event(sendEvent);
  88.             }
  89.         }
  90.  
  91.     }
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement