void Start() { gameObject.Play(AnimateAction.Create(sprites, frameRate)); // Self-destroy Destroy(this); }
public static int Add(float startTime, float fullTime, AnimateAction animateAction, ResultAction resultAction = null) { if (instance == null) { Timer timer = GameObject.FindObjectOfType <Timer>(); if (timer != null) { instance = timer; } else { GameObject timerObject = new GameObject("GlobalTimer"); DontDestroyOnLoad(timerObject); instance = timerObject.AddComponent <Timer>(); } } return(instance.AddTimer(startTime, fullTime, animateAction, resultAction)); }
int AddTimer(float startTime, float actionTime, AnimateAction animAction, ResultAction resultAction) { for (int i = 0; i < timers.Length; i++) { if (timers[i] <= 0 && endAction[i] == null && animateAction[i] == null) { timers[i] = actionTime - startTime; animationTime[i] = actionTime; animateAction[i] = animAction; endAction[i] = resultAction; return(i); } } // need more timers - add to Arrays int tempNum = timers.Length; // increase arr size float[] newTimers = new float[tempNum + 5]; float[] newAnimationTime = new float[tempNum + 5]; AnimateAction[] newAnimateAction = new AnimateAction[tempNum + 5]; ResultAction[] newEndAction = new ResultAction[tempNum + 5]; // replace old values in new Array for (int i = 0; i < timers.Length; i++) { newTimers[i] = timers[i]; newAnimationTime[i] = animationTime[i]; newAnimateAction[i] = animateAction[i]; newEndAction[i] = endAction[i]; } timers = newTimers; animationTime = newAnimationTime; animateAction = newAnimateAction; endAction = newEndAction; // Add new timer timers[tempNum] = actionTime - startTime; animationTime[tempNum] = actionTime; animateAction[tempNum] = animAction; endAction[tempNum] = resultAction; return(tempNum); }
public static GameObject Instantiate(ENTITY e) { GameObject entityObject; switch (e.Classname) { case "action_animate": { entityObject = AnimateAction.Instantiate(e); break; } case "action_move": { entityObject = MoveAction.Instantiate(e); break; } case "action_rotate": { entityObject = RotateAction.Instantiate(e); break; } case "action_sequence": { entityObject = ActionSequence.Instantiate(e); break; } case "action_sound": { entityObject = SoundAction.Instantiate(e); break; } case "action_wait": { entityObject = WaitAction.Instantiate(e); break; } case "audio_source": { entityObject = AudioSourceObject.Instantiate(e); break; } case "dream_environment": { entityObject = DreamEnvironment.Instantiate(e); break; } case "!map": { entityObject = MapObject.Instantiate(e); break; } case "!model": { entityObject = ModelObject.Instantiate(e); break; } case "music_controller": { entityObject = MusicController.Instantiate(e); break; } case "player_spawn": { entityObject = PlayerSpawn.Instantiate(e); break; } case "target": { entityObject = Target.Instantiate(e); break; } case "trigger_link": { entityObject = TriggerLink.Instantiate(e); break; } case "trigger_sequence": { entityObject = TriggerSequence.Instantiate(e); break; } case "trigger_sound": { entityObject = TriggerSound.Instantiate(e); break; } case "trigger_teleport": { entityObject = TriggerTeleport.Instantiate(e); break; } default: { Debug.LogWarning("Could not instantiate entity with classname " + e.Classname); entityObject = new GameObject(e.Classname); break; } } return(entityObject); }
public static int Add(float fullTime, AnimateAction animateAction, ResultAction resultAction = null) { return(Add(0, fullTime, animateAction, resultAction)); }