Advertisement
Darkhitori

CF_attack_end_notify

Jan 20th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.38 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/PlayerControlBase")]
  10.     [Tooltip("Notify game character on attack end. ")]
  11.     public class CF_attack_end_notify : FsmStateAction
  12.     {
  13.         [RequiredField]
  14.         [CheckForComponent(typeof(PlayerControlBase))]
  15.         public FsmOwnerDefault gameObject;
  16.        
  17.         [ObjectType(typeof(IGameCharacter))]
  18.         public FsmObject attacker;
  19.         public FsmInt attackType;
  20.        
  21.         public FsmBool everyFrame;
  22.  
  23.         PlayerControlBase theScript;
  24.  
  25.         public override void Reset()
  26.         {
  27.             gameObject = null;
  28.             attacker = null;
  29.             attackType = null;
  30.             everyFrame = true;
  31.         }
  32.        
  33.         public override void OnEnter()
  34.         {
  35.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  36.  
  37.             theScript = go.GetComponent<PlayerControlBase>();
  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 cAttacker = attacker.Value as IGameCharacter;
  64.             if (cAttacker == null)
  65.             {
  66.                 return;
  67.             }
  68.            
  69.             theScript.attack_end_notify(cAttacker, attackType.Value);
  70.  
  71.                        
  72.         }
  73.  
  74.     }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement