+Playmaker

This commit is contained in:
2015-12-13 14:35:35 +06:00
parent cc8138a942
commit c6cad2e0bc
1483 changed files with 67081 additions and 0 deletions

View File

@@ -0,0 +1,63 @@
// (c) Copyright HutongGames, LLC 2010-2014. All rights reserved.
using UnityEngine;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Array)]
[Tooltip("Get a Random item from an Array.")]
public class ArrayGetRandom : FsmStateAction
{
[RequiredField]
[UIHint(UIHint.Variable)]
[Tooltip("The Array to use.")]
public FsmArray array;
[RequiredField]
[UIHint(UIHint.Variable)]
[Tooltip("Store the value in a variable.")]
[MatchElementType("array")]
public FsmVar storeValue;
[Tooltip("Repeat every frame while the state is active.")]
public bool everyFrame;
public override void Reset()
{
array = null;
storeValue =null;
everyFrame = false;
}
// Code that runs on entering the state.
public override void OnEnter()
{
DoGetRandomValue();
if (!everyFrame)
{
Finish();
}
}
public override void OnUpdate()
{
DoGetRandomValue();
}
private void DoGetRandomValue()
{
if (storeValue.IsNone)
{
return;
}
storeValue.SetValue(array.Get(Random.Range(0,array.Length)));
}
}
}