Beispiel #1
0
        protected override Task Act(ActParameters Parameters)
        {
            AudioSource AudioSource = Parameters.Object.GetComponent <AudioSource>();

            if (AudioSource != null)
            {
                if (AudioClips != null && AudioClips.Length > 0)
                {
                    if (PlayRandomAudioClip)
                    {
                        CurrentIndex = Random.Range(0, AudioClips.Length);
                    }
                    else
                    {
                        CurrentIndex = (CurrentIndex + 1) % AudioClips.Length;
                    }
                    AudioSource.PlayOneShot(AudioClips[CurrentIndex]);
                }
                else
                {
                    AudioSource.Play();
                }
            }
            else
            {
                Debug.LogWarning("No AudioSource.", this);
            }

            return(Task.CompletedTask);
        }
Beispiel #2
0
        protected override async Task Act(ActParameters Parameters)
        {
            // To prevent loops that make Unity unresponsive
            await Parameters.Yield();

            await Action?.Act();
        }
Beispiel #3
0
        protected override async Task Act(ActParameters Parameters)
        {
            bool Success = true;
            var  context = InitializeContext(Parameters, ref Success);

            if (!Success)
            {
                Debug.LogWarning("Animation initialization failed.", this);
                return;
            }

            var target = ConvertData(Target);

            if (Duration <= 0)
            {
                Set(ref context, target);
                return;
            }
            float Speed = 1 / Duration;

            var start = EvaluateStartPoint(ref context);

            for (float t = 0; t < 1; t += Time.deltaTime * Speed)
            {
                Set(ref context, Lerp(
                        start,
                        target,
                        Interpolators.Interpolate(InterpolationType, t)
                        ));
                await Parameters.Yield();
            }
            Set(ref context, target);
        }
Beispiel #4
0
        protected override async Task Act(ActParameters Parameters)
        {
            float initial_time = Time.time;

            while (Time.time - initial_time < Duration)
            {
                await Parameters.Yield();
            }
        }
        protected override async Task Act(ActParameters Parameters)
        {
            List <Task> Tasks = new List <Task>();

            foreach (var action in Actions(Parameters.Object))
            {
                if (action.gameObject != gameObject)
                {
                    await Parameters.Await(action.Act());
                }
            }
        }
        protected override Task Act(ActParameters Parameters)
        {
            var particle_system = Parameters.Object.GetComponent <ParticleSystem>();

            if (particle_system != null)
            {
                particle_system.Play();
            }
            else
            {
                Debug.LogWarning("No ParticleSystem found.", this);
            }
            return(Task.CompletedTask);
        }
        protected sealed override Material InitializeContext(ActParameters Parameters, ref bool Success)
        {
            var renderer = Parameters.Object.GetComponent <Renderer>();

            if (renderer != null)
            {
                return(renderer.material);
            }

            var graphic = Parameters.Object.GetComponent <Graphic>();

            if (graphic != null)
            {
                return(graphic.material);
            }

            Debug.LogWarning("No Renderer or Graphic component found on the object", this);
            Success = false;
            return(null);
        }
 protected override Task Act(ActParameters Parameters)
 {
     Parameters.Object.SetActive(ActivationState);
     return(Task.CompletedTask);
 }
Beispiel #9
0
 protected override Task Act(ActParameters Parameters)
 {
     Parameters.Object.SetActive(!Parameters.Object.activeSelf);
     return(Task.CompletedTask);
 }
Beispiel #10
0
 protected override Transform InitializeContext(ActParameters Parameters, ref bool Success)
 {
     return(Parameters.Object.transform);
 }
 protected override Task Act(ActParameters Parameters)
 {
     SceneManager.LoadScene(SceneName);
     return(Task.CompletedTask);
 }
Beispiel #12
0
 protected abstract ContextType InitializeContext(ActParameters Parameters, ref bool Success);