Advertisement
Darkhitori

Emerald AI/CombatType

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