Advertisement
Darkhitori

CF_decreaseHealth

Jan 20th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.09 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("Decrease health by input value. ")]
  11.     public class CF_decreaseHealth : FsmStateAction
  12.     {
  13.         [RequiredField]
  14.         [CheckForComponent(typeof(Stats))]
  15.         public FsmOwnerDefault gameObject;
  16.        
  17.         public FsmInt byVal;
  18.        
  19.         public FsmBool everyFrame;
  20.  
  21.         Stats theScript;
  22.  
  23.         public override void Reset()
  24.         {
  25.             gameObject = null;
  26.             byVal = null;
  27.             everyFrame = true;
  28.         }
  29.        
  30.         public override void OnEnter()
  31.         {
  32.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  33.  
  34.             theScript = go.GetComponent<Stats>();
  35.  
  36.  
  37.             if (!everyFrame.Value)
  38.             {
  39.                 DoTheMethod();
  40.                 Finish();
  41.             }
  42.  
  43.         }
  44.  
  45.         public override void OnUpdate()
  46.         {
  47.             if (everyFrame.Value)
  48.             {
  49.                 DoTheMethod();
  50.             }
  51.         }
  52.  
  53.         void DoTheMethod()
  54.         {
  55.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  56.             if (go == null)
  57.             {
  58.                 return;
  59.             }
  60.            
  61.             theScript.decreaseHealth(byVal.Value);
  62.         }
  63.  
  64.     }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement