NSFW Fap Hero project
unknown
csharp
4 years ago
2.8 kB
9
Indexable
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class Tempo : MonoBehaviour
{
[System.Serializable]
public class Stroke
{
[Header("Wait this long before starting")]
public float waitTime;
[Header("How many strokes")]
public int strokeCount;
[Header("How fast we do strokes")]
public float speed;
[Header("Character's messages")]
[TextArea]
public string message;
[Header("What animation we play while stroking")]
public string animation;
[Header("How fast we play animation")]
public float animationSpeed = 1;
}
public TextMeshProUGUI textDisplay;
public ParticleSystem MoneyShot;
[Header("Audio for beat")]
public AudioSource audioSource;
public List<Stroke> Strokes = new List<Stroke>();
public int index;
private int strokeCounter;
[Header("Character with Animator control")]
public Animator animator;
private string currentState;
private void Start()
{
StartCoroutine(Stroking(index, Strokes[index].speed, Strokes[index].strokeCount, Strokes[index].waitTime));
}
IEnumerator Stroking(int id, float speed, int count, float breakDelay)
{
while (breakDelay > 0)
{
breakDelay -= Time.deltaTime;
yield return null;
}
if (breakDelay <= 0)
{
for (int i = count; i > 0; i--)
{
audioSource.Play();
if (textDisplay)
{ textDisplay.text = "Minzy:" + Strokes[index].message; }
if (Strokes[index].animation != "")
{
ChangeAnimationState(Strokes[index].animation);
}
animator.speed = Strokes[index].animationSpeed;
strokeCounter++;
yield return new WaitForSeconds(speed);
}
if (index < Strokes.Count - 1)
{
index++;
StartCoroutine(Stroking(index, Strokes[index].speed, Strokes[index].strokeCount, Strokes[index].waitTime));
}
}
//Cum
if (index == Strokes.Count -1)
{
if (MoneyShot)
{
MoneyShot.Play();
}
}
}
void ChangeAnimationState(string newState)
{
//stop same animation from interrupting itself
if (currentState == newState) return;
//play animation
//animator.Play(newState);
animator.CrossFade(newState, 0.15f);
//reassign current state
currentState = newState;
}
}
Editor is loading...