Darkhitori

ThirdPersonCamera/ChangeState

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