mirror of
https://github.com/BlackMATov/unity-flash-tools.git
synced 2025-12-16 22:19:31 +07:00
move project to root depo directory
This commit is contained in:
42
Assets/FlashTools/Example/Scripts/PurpleFlowerLogic.cs
Normal file
42
Assets/FlashTools/Example/Scripts/PurpleFlowerLogic.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
using FTRuntime;
|
||||
using FTRuntime.Yields;
|
||||
|
||||
namespace FlashTools.Examples {
|
||||
[RequireComponent(typeof(SwfClipController))]
|
||||
public class PurpleFlowerLogic : MonoBehaviour {
|
||||
static string[] _idleSequences = {"talk", "idle0", "idle1", "idle2"};
|
||||
static string _fadeInSequence = "fadeIn";
|
||||
static string _fadeOutSequence = "fadeOut";
|
||||
|
||||
void Start() {
|
||||
var ctrl = GetComponent<SwfClipController>();
|
||||
StartCoroutine(StartCoro(ctrl));
|
||||
}
|
||||
|
||||
IEnumerator StartCoro(SwfClipController ctrl) {
|
||||
while ( true ) {
|
||||
yield return ctrl.PlayAndWaitStopOrRewind(_fadeInSequence);
|
||||
for ( var i = 0; i < 3; ++i ) {
|
||||
var idle_seq = GetRandomIdleSequence(ctrl);
|
||||
yield return ctrl.PlayAndWaitStopOrRewind(idle_seq);
|
||||
}
|
||||
yield return ctrl.PlayAndWaitStopOrRewind(_fadeOutSequence);
|
||||
yield return new WaitForSeconds(2.0f);
|
||||
}
|
||||
}
|
||||
|
||||
string GetRandomIdleSequence(SwfClipController ctrl) {
|
||||
var cur_seq = ctrl.clip.sequence;
|
||||
do {
|
||||
var seq_index = Random.Range(0, _idleSequences.Length);
|
||||
var new_sequence = _idleSequences[seq_index];
|
||||
if ( new_sequence != cur_seq ) {
|
||||
return new_sequence;
|
||||
}
|
||||
} while ( true );
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user