Advertisement
Darkhitori

CF_add2DestroyList

Jan 20th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.29 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("Add npc to destory list. Npc will be destroyed in next turn LateUpdate method ")]
  12.     public class CF_add2DestroyList : FsmStateAction
  13.     {
  14.         [RequiredField]
  15.         [CheckForComponent(typeof(NPCManager))]
  16.         public FsmOwnerDefault gameObject;
  17.        
  18.         [ObjectType(typeof(NPCScript))]
  19.         public FsmObject npc;
  20.        
  21.         public FsmBool everyFrame;
  22.  
  23.         NPCManager theScript;
  24.  
  25.  
  26.         public override void Reset()
  27.         {
  28.             gameObject = null;
  29.             npc = null;
  30.             everyFrame = true;
  31.         }
  32.        
  33.         public override void OnEnter()
  34.         {
  35.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  36.  
  37.             theScript = go.GetComponent<NPCManager>();
  38.  
  39.  
  40.             if (!everyFrame.Value)
  41.             {
  42.                 DoTheMethod();
  43.                 Finish();
  44.             }
  45.  
  46.         }
  47.  
  48.         public override void OnUpdate()
  49.         {
  50.             if (everyFrame.Value)
  51.             {
  52.                 DoTheMethod();
  53.             }
  54.         }
  55.  
  56.         void DoTheMethod()
  57.         {
  58.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  59.             if (go == null)
  60.             {
  61.                 return;
  62.             }
  63.             var cNpc = npc.Value as NPCScript;
  64.             if (cNpc == null)
  65.             {
  66.                 return;
  67.             }
  68.            
  69.             theScript.add2DestroyList(cNpc);            
  70.         }
  71.  
  72.     }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement