2022-06-29 05:37:14 +00:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
public class WhiteLines : MonoBehaviour
|
|
|
|
{
|
|
|
|
float speed;
|
|
|
|
float startAt = 4.80f;
|
|
|
|
float endAt = -3.1f;
|
|
|
|
[SerializeField] SpriteRenderer line;
|
|
|
|
public int rngEarlyGone, rngMiddleLine;
|
|
|
|
[SerializeField] bool isRandomLineMiddle;
|
|
|
|
bool checkAnother, checkOnce;
|
|
|
|
|
|
|
|
void Start()
|
|
|
|
{
|
|
|
|
//speed = Random.Range(0.005f, 0.007f);
|
|
|
|
speed = Random.Range(0.005f, 0.009f);
|
|
|
|
rngEarlyGone = Random.Range(0, 5);
|
|
|
|
if (isRandomLineMiddle)
|
|
|
|
{
|
|
|
|
rngMiddleLine = Random.Range(0, 101);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-08 05:27:10 +00:00
|
|
|
void FixedUpdate()
|
2022-06-29 05:37:14 +00:00
|
|
|
{
|
2023-03-27 03:09:55 +00:00
|
|
|
if (transform.position.y > endAt && !isRandomLineMiddle)
|
2022-06-29 05:37:14 +00:00
|
|
|
{
|
|
|
|
transform.position += new Vector3(0, -speed * 1f, 0);
|
|
|
|
}
|
2023-03-27 03:09:55 +00:00
|
|
|
else if (transform.position.y <= endAt && !isRandomLineMiddle)
|
2022-06-29 05:37:14 +00:00
|
|
|
{
|
|
|
|
speed = Random.Range(0.005f, 0.009f);
|
|
|
|
transform.position = new Vector3(0, startAt, 0);
|
|
|
|
rngEarlyGone = Random.Range(0, 5);
|
|
|
|
}
|
|
|
|
|
2023-03-27 03:09:55 +00:00
|
|
|
if (rngEarlyGone > 0 && !isRandomLineMiddle)
|
2022-06-29 05:37:14 +00:00
|
|
|
{
|
|
|
|
line.color += new Color(1f, 1f, 1f, -0.01f);
|
2023-03-27 03:09:55 +00:00
|
|
|
if (line.color.a <= 0)
|
2022-06-29 05:37:14 +00:00
|
|
|
{
|
|
|
|
rngEarlyGone = Random.Range(0, 5);
|
|
|
|
line.color = new Color(1f, 1f, 1f, .10f);
|
2023-03-27 03:09:55 +00:00
|
|
|
transform.position = new Vector3(0, startAt, 0);
|
2022-06-29 05:37:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isRandomLineMiddle)
|
2023-03-27 03:09:55 +00:00
|
|
|
{
|
|
|
|
if (rngMiddleLine > 1 && !checkAnother)
|
2022-06-29 05:37:14 +00:00
|
|
|
{
|
|
|
|
rngMiddleLine = Random.Range(0, 101);
|
|
|
|
}
|
2023-03-27 03:09:55 +00:00
|
|
|
if (rngMiddleLine <= 1)
|
2022-06-29 05:37:14 +00:00
|
|
|
{
|
|
|
|
line.color += new Color(1f, 1f, 1f, 0.01f);
|
|
|
|
checkAnother = true;
|
|
|
|
|
2023-03-27 03:09:55 +00:00
|
|
|
if (!checkOnce && line.color.a > .5f)
|
2022-06-29 05:37:14 +00:00
|
|
|
{
|
|
|
|
checkOnce = true;
|
|
|
|
}
|
|
|
|
}
|
2023-03-27 03:09:55 +00:00
|
|
|
if (checkOnce)
|
2022-06-29 05:37:14 +00:00
|
|
|
{
|
|
|
|
line.color -= new Color(1f, 1f, 1f, 0.02f);
|
|
|
|
if (line.color.a <= 0)
|
|
|
|
{
|
|
|
|
line.color = new Color(1f, 1f, 1f, 0f);
|
|
|
|
rngMiddleLine = Random.Range(0, 101);
|
|
|
|
transform.position = new Vector3(0, Random.Range(-1, 5));
|
|
|
|
checkAnother = false;
|
|
|
|
checkOnce = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|