Advertisement
Darkhitori

CF_activate

Jan 20th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.02 KB | None | 0 0
  1. //Darkhitori v1.0
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using MLSpace;
  6.  
  7. namespace HutongGames.PlayMaker.Actions
  8. {
  9.     [ActionCategory("CombatFramework/Stats")]
  10.     [Tooltip("Activate UIs ")]
  11.     public class CF_activate : FsmStateAction
  12.     {
  13.         [RequiredField]
  14.         [CheckForComponent(typeof(Stats))]
  15.         public FsmOwnerDefault gameObject;
  16.        
  17.         public FsmBool everyFrame;
  18.  
  19.         Stats theScript;
  20.  
  21.         public override void Reset()
  22.         {
  23.             gameObject = null;
  24.             everyFrame = true;
  25.         }
  26.        
  27.         public override void OnEnter()
  28.         {
  29.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  30.  
  31.             theScript = go.GetComponent<Stats>();
  32.  
  33.  
  34.             if (!everyFrame.Value)
  35.             {
  36.                 DoTheMethod();
  37.                 Finish();
  38.             }
  39.  
  40.         }
  41.  
  42.         public override void OnUpdate()
  43.         {
  44.             if (everyFrame.Value)
  45.             {
  46.                 DoTheMethod();
  47.             }
  48.         }
  49.  
  50.         void DoTheMethod()
  51.         {
  52.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  53.             if (go == null)
  54.             {
  55.                 return;
  56.             }
  57.            
  58.             theScript.activate();
  59.  
  60.                        
  61.         }
  62.  
  63.     }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement