/tronshoot/Assets/PlayMaker/Actions/iTween/iTweenFsmAction.cs

https://bitbucket.org/gregpat90/tronshoot · C# · 77 lines · 50 code · 10 blank · 17 comment · 6 complexity · a6063477ee4ca018f5b90136c4264274 MD5 · raw file

  1. // (c) Copyright HutongGames, LLC 2010-2011. All rights reserved.
  2. using UnityEngine;
  3. using System.Collections.Generic;
  4. namespace HutongGames.PlayMaker.Actions
  5. {
  6. // base type for GUI actions that need a Rect
  7. [Tooltip("iTween base action - don't use!")]
  8. public abstract class iTweenFsmAction : FsmStateAction
  9. {
  10. /*
  11. iTween does not allow to run simultaneous iTween of the same type. Please, have this in your mind. That means you can not perform MoveTo and MoveAdd at the same time on one object
  12. */
  13. public enum AxisRestriction{
  14. none,x,y,z,xy,xz,yz
  15. }
  16. [ActionSection("Events")]
  17. public FsmEvent startEvent;
  18. public FsmEvent finishEvent;
  19. [Tooltip("Setting this to true will allow the animation to continue independent of the current time which is helpful for animating menus after a game has been paused by setting Time.timeScale=0.")]
  20. public FsmBool realTime;
  21. public FsmBool stopOnExit;
  22. public FsmBool loopDontFinish;
  23. internal iTweenFSMEvents itweenEvents;
  24. //Don't forget to asign this value in descendatns in order to stop iTween when stopOnExit is true
  25. protected string itweenType = "";
  26. protected int itweenID = -1;
  27. //Since all iTween gets param delay, this variable is set automatically in order to help descedants to pass this param
  28. public override void Reset()
  29. {
  30. startEvent = null;
  31. finishEvent = null;
  32. realTime = new FsmBool { Value = false };
  33. stopOnExit = new FsmBool { Value = true };
  34. loopDontFinish = new FsmBool { Value = true };
  35. itweenType = "";
  36. }
  37. protected void OnEnteriTween(FsmOwnerDefault anOwner)
  38. {
  39. GameObject go = Fsm.GetOwnerDefaultTarget(anOwner);
  40. itweenEvents = (iTweenFSMEvents)go.AddComponent("iTweenFSMEvents");
  41. itweenEvents.itweenFSMAction = this;
  42. iTweenFSMEvents.itweenIDCount++;
  43. itweenID = iTweenFSMEvents.itweenIDCount;
  44. itweenEvents.itweenID = iTweenFSMEvents.itweenIDCount;
  45. itweenEvents.donotfinish = loopDontFinish.IsNone ? false : loopDontFinish.Value;
  46. }
  47. protected void IsLoop(bool aValue){
  48. if(itweenEvents != null) itweenEvents.islooping = aValue;
  49. }
  50. protected void OnExitiTween(FsmOwnerDefault anOwner){
  51. GameObject go = Fsm.GetOwnerDefaultTarget(anOwner);
  52. if(itweenEvents) GameObject.Destroy(itweenEvents);
  53. if(stopOnExit.IsNone) iTween.Stop(go, itweenType);
  54. else if(stopOnExit.Value) iTween.Stop(go, itweenType);
  55. // if(!stopOnExit.IsNone && stopOnExit.Value == true) {
  56. // Component[] itweens = go.GetComponents<iTween>();
  57. // for(int i = 0; i<itweens.Length;i++){
  58. // iTween itween = (iTween)itweens[i];
  59. // if(itween.type.ToLower().Contains(itweenType)){
  60. // GameObject.Destroy(itween);
  61. // }
  62. // }
  63. // }
  64. }
  65. }
  66. }