Darkhitori

CF_destroyNpcs

Jan 20th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.06 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.  
  8. namespace HutongGames.PlayMaker.Actions
  9. {
  10.     [ActionCategory("CombatFramework/NPCManager")]
  11.     [Tooltip("Destroy npcs in destory queue ")]
  12.     public class CF_destroyNpcs : FsmStateAction
  13.     {
  14.         [RequiredField]
  15.         [CheckForComponent(typeof(NPCManager))]
  16.         public FsmOwnerDefault gameObject;
  17.        
  18.         public FsmBool everyFrame;
  19.  
  20.         NPCManager theScript;
  21.  
  22.  
  23.         public override void Reset()
  24.         {
  25.             gameObject = null;
  26.             everyFrame = true;
  27.         }
  28.        
  29.         public override void OnEnter()
  30.         {
  31.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  32.  
  33.             theScript = go.GetComponent<NPCManager>();
  34.  
  35.  
  36.             if (!everyFrame.Value)
  37.             {
  38.                 DoTheMethod();
  39.                 Finish();
  40.             }
  41.  
  42.         }
  43.  
  44.         public override void OnUpdate()
  45.         {
  46.             if (everyFrame.Value)
  47.             {
  48.                 DoTheMethod();
  49.             }
  50.         }
  51.  
  52.         void DoTheMethod()
  53.         {
  54.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  55.             if (go == null)
  56.             {
  57.                 return;
  58.             }
  59.            
  60.             theScript.destroyNpcs();            
  61.         }
  62.  
  63.     }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment