Advertisement
Darkhitori

CF_control

Jan 20th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.42 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/Player")]
  10.     [Tooltip("Control player. ")]
  11.     public class CF_control : FsmStateAction
  12.     {
  13.         [RequiredField]
  14.         [CheckForComponent(typeof(Player))]
  15.         public FsmOwnerDefault gameObject;
  16.        
  17.         public enum Control
  18.         {
  19.             horiz_vert_speed_jump_dive_crouch_bodyLookDirection_diveDirection_side,
  20.             move_speed_jump_dive_crouch_bodyLookDirection_diveDirection_side
  21.         }
  22.        
  23.         public Control methods;
  24.        
  25.         public FsmFloat horiz;
  26.         public FsmFloat vert;
  27.         public FsmVector3 move;
  28.         public FsmFloat speed;
  29.         public FsmBool jump;
  30.         public FsmBool dive;
  31.         public FsmBool crouch;
  32.         public FsmVector3 bodyLookDirection;
  33.         public FsmVector3 diveDirection;
  34.         public FsmFloat side;
  35.        
  36.         public FsmBool everyFrame;
  37.  
  38.         Player theScript;
  39.  
  40.         public override void Reset()
  41.         {
  42.             gameObject = null;
  43.             methods =  Control.horiz_vert_speed_jump_dive_crouch_bodyLookDirection_diveDirection_side;
  44.             horiz = null;
  45.             vert = null;
  46.             move = new Vector3(0,0,0);
  47.             speed = null;
  48.             jump = false;
  49.             dive = false;
  50.             crouch = false;
  51.             bodyLookDirection = new Vector3(0,0,0);
  52.             diveDirection = new Vector3(0,0,0);
  53.             side = null;
  54.             everyFrame = true;
  55.         }
  56.        
  57.         public override void OnEnter()
  58.         {
  59.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  60.  
  61.             theScript = go.GetComponent<Player>();
  62.  
  63.  
  64.             if (!everyFrame.Value)
  65.             {
  66.                 DoTheMethod();
  67.                 Finish();
  68.             }
  69.  
  70.         }
  71.  
  72.         public override void OnUpdate()
  73.         {
  74.             if (everyFrame.Value)
  75.             {
  76.                 DoTheMethod();
  77.             }
  78.         }
  79.  
  80.         void DoTheMethod()
  81.         {
  82.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  83.             if (go == null)
  84.             {
  85.                 return;
  86.             }
  87.            
  88.             switch(methods)
  89.             {
  90.             case  Control.horiz_vert_speed_jump_dive_crouch_bodyLookDirection_diveDirection_side:
  91.                 theScript.control(horiz.Value,
  92.                     vert.Value,
  93.                     speed.Value,
  94.                     jump.Value,
  95.                     dive.Value,
  96.                     crouch.Value,
  97.                     bodyLookDirection.Value,
  98.                     diveDirection.Value,
  99.                     side.Value);
  100.                 break;
  101.             case  Control.move_speed_jump_dive_crouch_bodyLookDirection_diveDirection_side:
  102.                 theScript.control(move.Value,
  103.                     speed.Value,
  104.                     jump.Value,
  105.                     dive.Value,
  106.                     crouch.Value,
  107.                     bodyLookDirection.Value,
  108.                     diveDirection.Value,
  109.                     side.Value);
  110.                 break;
  111.             }
  112.  
  113.                        
  114.         }
  115.  
  116.     }
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement