Darkhitori

vShooterWeapon/ShootEffect

Jan 14th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.60 KB | None | 0 0
  1. //Darkhitori v1.0
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using Invector;
  6. using Invector.ItemManager;
  7.  
  8. namespace HutongGames.PlayMaker.Actions
  9. {
  10.     [ActionCategory("Invector/vShooterWeapon")]
  11.     [Tooltip(" ")]
  12.     public class vSW_ShootEffect : FsmStateAction
  13.     {
  14.         [RequiredField]
  15.         [CheckForComponent(typeof(vShooterWeapon))]
  16.         public FsmOwnerDefault gameObject;
  17.        
  18.         public enum ShootEffect
  19.         {
  20.             sender,
  21.             aimPosition_sender
  22.         }
  23.        
  24.         public ShootEffect methods;
  25.        
  26.         public FsmVector3 aimPosition;
  27.        
  28.         [ObjectType(typeof(Transform))]
  29.         public FsmObject sender;
  30.        
  31.         public FsmBool everyFrame;
  32.  
  33.         vShooterWeapon theScript;
  34.  
  35.         public override void Reset()
  36.         {
  37.             gameObject = null;
  38.             aimPosition = new Vector3(0,0,0);
  39.             sender = null;
  40.             everyFrame = true;
  41.         }
  42.        
  43.         public override void OnEnter()
  44.         {
  45.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  46.  
  47.             theScript = go.GetComponent<vShooterWeapon>();
  48.  
  49.  
  50.             if (!everyFrame.Value)
  51.             {
  52.                 DoTheMagic();
  53.                 Finish();
  54.             }
  55.  
  56.         }
  57.  
  58.         public override void OnUpdate()
  59.         {
  60.             if (everyFrame.Value)
  61.             {
  62.                 DoTheMagic();
  63.             }
  64.         }
  65.  
  66.         void DoTheMagic()
  67.         {
  68.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  69.             if (go == null)
  70.             {
  71.                 return;
  72.             }
  73.             var vSend = sender.Value as Transform;
  74.             if (vSend == null)
  75.             {
  76.                 return;
  77.             }
  78.            
  79.             switch(methods)
  80.             {
  81.             case ShootEffect.sender:
  82.                 theScript.ShootEffect(vSend);
  83.                 break;
  84.             case ShootEffect.aimPosition_sender:
  85.                 theScript.ShootEffect(aimPosition.Value, vSend);
  86.                 break;
  87.             }
  88.              
  89.            
  90.         }
  91.  
  92.     }
  93. }
Advertisement
Add Comment
Please, Sign In to add comment