Life is Slow: Scripts

Für mein interaktives Kunstwerk «Life is Slow» schreibe ich insgesamt neunundzwanzig ausführliche Scripts in der Programmiersprache C#. Scripts sind sozusagen Befehle, die miteinander interagieren und den Computer berechnen lassen, was in welchem Fall passieren soll. Sie ermöglichen eine Symbiose zwischen der betrachtenden Person und dem Werk und sind einer der zeitaufwändigsten Elemente beim Kreieren einer Applikation.


Bei etwaigem Interesse habe ich alle meine Scripts hier aufgelistet:

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

using UnityEngine.Rendering.Universal;


public class SunScript : MonoBehaviour

{

//public Animator myAnimator;

public Camera mainCamera;


public publicVariables worldVars;

public bool sunVisible = true;


public Light2D myIntensity;


public float desiredFalloff;

public float desiredRadius;


float yVelocity = 0.0f;


public float customIntensityBoost;


void Start()

{

myIntensity = gameObject.GetComponent<Light2D>();

}


void Update()

{

if (System.DateTime.Now.Hour <= 12)

{

myIntensity.intensity = Mathf.SmoothDamp(myIntensity.intensity, customIntensityBoost + (((float)System.DateTime.Now.Hour) / 10) - 0.2f, ref yVelocity, 3f);


}


if (System.DateTime.Now.Hour > 12)

{

myIntensity.intensity = Mathf.SmoothDamp(myIntensity.intensity, customIntensityBoost + (24 - ((float)System.DateTime.Now.Hour)) / 10, ref yVelocity, 3f);

}


if(System.DateTime.Now.Hour > 19 || System.DateTime.Now.Hour < 6)

{

myIntensity.intensity = Mathf.SmoothDamp(myIntensity.intensity, 0, ref yVelocity, 3f);

}


}


}

using System.Collections;

using System.Collections.Generic;

using UnityEngine;


public class seedlingScript : MonoBehaviour

{

public Rigidbody2D rigidbuddy;

public publicVariables worldVar;

public GameObject myPlant;

public GameObject lightScript;

public Camera mainCamera;


public Animator myAnimator;

public Animator myLampinator;


public AnimationState idleFlap;

// public ParticleSystem myParticleSystem;




bool firstTimeGround = false;


bool firstTouch;

// Start is called before the first frame update

void Start()

{

firstTouch = false;

//myParticleSystem.enableEmission = false;


}


// Update is called once per frame

void Update()

{

if(!firstTimeGround)

{

if (!firstTouch)

{

rigidbuddy.gravityScale = 0;

}


if (firstTouch)

{

if (transform.position.y < mainCamera.transform.position.y - 2)

{

rigidbuddy.gravityScale = 0.25f;

//rigidbuddy.velocity = new Vector2(rigidbuddy.velocity.x, 0);


}


else if (transform.position.y > mainCamera.transform.position.y - 1)

{

rigidbuddy.gravityScale = 0.7f;

}

}



if (Input.GetMouseButtonDown(0) && transform.position.y < mainCamera.transform.position.y + mainCamera.orthographicSize && transform.position.y < 10)

{


firstTouch = true;



myAnimator.SetTrigger("Jump");


rigidbuddy.angularVelocity = 0;


rigidbuddy.velocity = new Vector2(0, 8f);


Quaternion target = Quaternion.Euler(0, 0, (Input.mousePosition.x - (Screen.width / 2)) / (Screen.width / 150));

transform.rotation = Quaternion.Slerp(transform.rotation, target, Time.deltaTime * 0.1f);

}


if (Input.GetMouseButton(0))

{

rigidbuddy.drag += 20 * Time.deltaTime;

}


if (Input.GetMouseButtonUp(0))

{

rigidbuddy.drag = 15;

}

}


if(firstTimeGround)

{

transform.position = new Vector2(0, transform.position.y);

}

}


private void OnCollisionEnter2D(Collision2D collision)

{



if(collision.gameObject.tag == "Ground" && !firstTimeGround)

{

myAnimator.SetTrigger("SeedlingFadeOut");


firstTimeGround = true;

rigidbuddy.drag = 5;

//myParticleSystem.enableEmission = true;

StartCoroutine(waitABit());

}

}


IEnumerator waitABit()

{

yield return new WaitForSecondsRealtime(6);


myLampinator.SetTrigger("FadeOut");



rigidbuddy.bodyType = RigidbodyType2D.Static;

gameObject.GetComponent<PolygonCollider2D>().enabled = false;



worldVar.startUpMainGame();


PlayerPrefs.SetInt("BeginningScene", 1);

yield return new WaitForSecondsRealtime(400);

gameObject.SetActive(false);

this.enabled = false;


}



}


using System.Collections;

using System.Collections.Generic;

using UnityEngine;


public class cloudMoving : MonoBehaviour

{

public publicVariables myWorld;




public float direction;

public float randomY;


public float randomCustomSpeed;


public ParticleSystem myParticles;




// Start is called before the first frame update

void Start()

{

myWorld.cloudClicked = false;

direction = myWorld.cloudDirection;


randomY = Random.Range(-0.1f, 0.1f);

randomCustomSpeed = Random.Range(0.8f, 1.2f);

StartCoroutine(changeDirection());

}


// Update is called once per frame

void Update()

{

direction = myWorld.cloudDirection;


if(myWorld.cloudClicked == false)

{

if (transform.position.x > -14 && direction < 0)

{

transform.position = new Vector2(transform.position.x + randomCustomSpeed*(myWorld.cloudDirection * Time.deltaTime), transform.position.y + (randomY * Time.deltaTime));

}


if (transform.position.x < 14 && direction > 0)

{

transform.position = new Vector2(transform.position.x + randomCustomSpeed*(myWorld.cloudDirection * Time.deltaTime), transform.position.y + (randomY * Time.deltaTime));

}


if (transform.position.y <= 0.1f)

{

randomY = Random.Range(0.01f, 0.1f);

}


if (transform.position.y >= 4f)

{

randomY = Random.Range(-0.1f, -0.01f);

}

}


if (Input.GetMouseButton(0) && myWorld.cloudClicked == true)

{

if(myParticles != null)

{

myParticles.Play();

}


transform.position = Vector2.MoveTowards(new Vector2(transform.position.x, transform.position.y), Camera.main.ScreenToWorldPoint(new Vector2(Input.mousePosition.x, Input.mousePosition.y)), 0.5f * Time.deltaTime);

}


if(Input.GetMouseButtonUp(0))

{

myWorld.cloudClicked = false;

}

}



IEnumerator changeDirection()

{

yield return new WaitForSecondsRealtime(Random.Range(40, 120));


randomY = Random.Range(-0.1f, 0.1f);


StartCoroutine(changeDirection());


}


private void OnMouseDown()

{

myWorld.cloudClicked = true;


}

}


using System.Collections;

using System.Collections.Generic;

using UnityEngine;


public class cameraScript : MonoBehaviour

{

public publicVariables myVariables;

public lifeGrowing myLife;

public Camera meCamera;

public GameObject seedling;

public Vector3 velocity = Vector3.zero;


public float targetPosX;



float yVelocity = 0.0f;


// Start is called before the first frame update

void Start()

{


}


// Update is called once per frame

void Update()

{


if (PlayerPrefs.GetInt("BeginningScene") == 0)

{

if (myVariables.beginningScene == true && seedling.transform.position.y < 7)

{

transform.position = Vector3.SmoothDamp(transform.position, new Vector3(targetPosX, seedling.transform.position.y + 0.4f, transform.position.z), ref velocity, 5f);

}


if (Input.GetMouseButton(0) && myVariables.beginningScene == true)

{

targetPosX = seedling.transform.position.x + (Input.mousePosition.x - (Screen.width / 2)) / (Screen.width / 4);

}


if (myVariables.beginningScene == false)

{

transform.position = Vector3.SmoothDamp(transform.position, new Vector3(0, -0.3f, transform.position.z), ref velocity, 5f);

}


meCamera.orthographicSize = Mathf.SmoothDamp(meCamera.orthographicSize, 1.2f, ref yVelocity, 0.3f);


}


if (PlayerPrefs.GetInt("BeginningScene") != 0)

{

if (myVariables.beginningScene == true && seedling.transform.position.y < 7)

{

transform.position = Vector3.SmoothDamp(transform.position, new Vector3(targetPosX, seedling.transform.position.y + 0.25f, transform.position.z), ref velocity, 5f);

}


if (Input.GetMouseButton(0) && myVariables.beginningScene == true)

{

targetPosX = seedling.transform.position.x + (Input.mousePosition.x - (Screen.width / 2)) / (Screen.width / 4);

}


if (myVariables.beginningScene == false)

{

transform.position = Vector3.SmoothDamp(transform.position, new Vector3(0, -0.5f, transform.position.z), ref velocity, 5f);

}


meCamera.fieldOfView = Mathf.SmoothDamp(meCamera.fieldOfView, 1.2f + myLife.plantStage, ref yVelocity, 0.3f);

}



}

}


using System.Collections;

using System.Collections.Generic;

using UnityEngine;

using ModernProgramming;


public class SmallFlowerScript : MonoBehaviour

{

public Sprite[] allFlowers;

public GameObject flowerPrefab;

public GameObject currentFlower;


public Collider2D groundCollider;

public Collider2D frontHillCollider;

public Collider2D backHillCollider;




// Start is called before the first frame update

void Start()

{

StartCoroutine(plantSmallFlower());




//for (var i = 0; i < 80; i++)

//{

// if(PlayerPrefsExtended.HasKey("SmallFlowerPos " + i))

// {

// currentFlower = Instantiate(flowerPrefab, PlayerPrefsExtended.GetVector3("SmallFlowerPos " + i, transform.position), Quaternion.identity);

// currentFlower.GetComponent<imSmallFlower>().myIndex = i;

// }


// else

// {

// currentFlower = Instantiate(flowerPrefab, new Vector2(Random.Range(-5.000f, 7.000f), Random.Range(-3.000f, -1.500f)), Quaternion.identity);

// currentFlower.GetComponent<imSmallFlower>().myIndex = i;

// }


// //yield return new WaitForSecondsRealtime(Random.Range(1f, 10.0f));



//}

}



// Update is called once per frame

void Update()

{


}


IEnumerator plantSmallFlower()

{



for (var i = 0; i < 180; i++)

{


if (PlayerPrefsExtended.HasKey("SmallFlowerPos " + i))

{

currentFlower = Instantiate(flowerPrefab, PlayerPrefsExtended.GetVector3("SmallFlowerPos " + i, transform.position), Quaternion.identity);

currentFlower.GetComponent<imSmallFlower>().myIndex = i;

}


else

{

yield return new WaitForSecondsRealtime(Random.Range(0.4f, 10f));


currentFlower = Instantiate(flowerPrefab, new Vector2(Random.Range(-5.000f, 7.000f), Random.Range(-3.000f, -1.3f)), Quaternion.identity);

currentFlower.GetComponent<imSmallFlower>().myIndex = i;


i++;


yield return new WaitForSecondsRealtime(Random.Range(0.4f, 10f));


Vector2 randomPos = new Vector2(Random.Range(-10.000f, 10.000f), Random.Range(-5.000f, 1.3f));

currentFlower = Instantiate(flowerPrefab, groundCollider.ClosestPoint(randomPos), Quaternion.identity);

currentFlower.GetComponent<imSmallFlower>().myIndex = i;


i++;


yield return new WaitForSecondsRealtime(Random.Range(0.4f, 10f));


Vector2 randomPos4 = new Vector2(Random.Range(-4.000f, 4.000f), Random.Range(-3.000f, 1.3f));

currentFlower = Instantiate(flowerPrefab, groundCollider.ClosestPoint(randomPos4), Quaternion.identity);

currentFlower.GetComponent<imSmallFlower>().myIndex = i;


i++;


yield return new WaitForSecondsRealtime(Random.Range(0.4f, 10f));


Vector2 randomPos5 = new Vector2(Random.Range(-3.000f, 3.000f), Random.Range(-2.000f, 1.3f));

currentFlower = Instantiate(flowerPrefab, groundCollider.ClosestPoint(randomPos5), Quaternion.identity);

currentFlower.GetComponent<imSmallFlower>().myIndex = i;


i++;


yield return new WaitForSecondsRealtime(Random.Range(0.4f, 10f));


currentFlower = Instantiate(flowerPrefab, new Vector2(Random.Range(-5.000f, 7.000f), Random.Range(-3.000f, -1.3f)), Quaternion.identity);

currentFlower.GetComponent<imSmallFlower>().myIndex = i;


i++;


yield return new WaitForSecondsRealtime(Random.Range(0.4f, 10f));


Vector2 randomPos2 = new Vector2(Random.Range(-10.000f, 10.000f), Random.Range(-5.000f, 1.3f));

currentFlower = Instantiate(flowerPrefab, backHillCollider.ClosestPoint(randomPos2), Quaternion.identity);

currentFlower.GetComponent<imSmallFlower>().myIndex = i;


i++;


yield return new WaitForSecondsRealtime(Random.Range(0.4f, 10f));


currentFlower = Instantiate(flowerPrefab, new Vector2(Random.Range(-5.000f, 7.000f), Random.Range(-3.000f, -1.3f)), Quaternion.identity);

currentFlower.GetComponent<imSmallFlower>().myIndex = i;


i++;


yield return new WaitForSecondsRealtime(Random.Range(0.4f, 10f));


Vector2 randomPos3 = new Vector2(Random.Range(-10.000f, 10.000f), Random.Range(-5.000f, 1.3f));

currentFlower = Instantiate(flowerPrefab, frontHillCollider.ClosestPoint(randomPos3), Quaternion.identity);

currentFlower.GetComponent<imSmallFlower>().myIndex = i;


}

}

}

}


using System.Collections;

using System.Collections.Generic;

using UnityEngine;

using UnityEngine.Rendering.Universal;


public class publicVariables : MonoBehaviour

{

public bool beginningScene = false;


public GameObject moon;

public GameObject sun;

public GameObject sunsetLight;

public GameObject myGlobalLight;

public GameObject introductoryText;

public GameObject leadText;

public GameObject life;

public GameObject seedling;

public GameObject lightingSystem;


public Animator sunAnimator;

public Animator moonAnimator;

//public Animator lifeAnimator;

public Animator globalLightAnimator;


public float sunDesiredIntensity;

public float moonDesiredIntensity;


public float cloudDirection;


public int taskStage;


public List<string> taskTexts = new List<string>();


public lifeGrowing lifeGrow;

//bool sunFadingIn = false;


public Camera mainCamera;


public bool cloudClicked;



// Start is called before the first frame update

void Start()

{


if (PlayerPrefs.GetInt("BeginningScene") == 0)

{

beginningScene = true;

seedling.SetActive(true);

life.SetActive(false);

introductoryText.SetActive(true);

moon.SetActive(false);

sun.SetActive(false);

sunsetLight.SetActive(false);

myGlobalLight.SetActive(false);

leadText.SetActive(false);

mainCamera.transform.position = new Vector3(0, 2.9f, mainCamera.transform.position.z);

//lifeAnimator.enabled = true;

lightingSystem.SetActive(false);




}


if (PlayerPrefs.GetInt("BeginningScene") != 0)

{

seedling.SetActive(false);

beginningScene = false;

//introductoryText.SetActive(false);

moon.SetActive(true);

sun.SetActive(true);

myGlobalLight.SetActive(true);

life.SetActive(true);

leadText.SetActive(true);

sunsetLight.SetActive(true);

//lifeAnimator.enabled = false;

lightingSystem.SetActive(true);

cloudDirection = Random.Range(0.4f, -0.4f);

StartCoroutine(changeDirection());

}


taskStage = PlayerPrefs.GetInt("TaskStagePref");




}


// Update is called once per frame

void Update()

{



}


public void startUpMainGame()

{

//seedling.SetActive(false);



string growDateString = System.DateTime.Now.ToString();

PlayerPrefs.SetString("LastGrowDate", growDateString);


beginningScene = false;

//introductoryText.SetActive(false);

moon.SetActive(true);

sunsetLight.SetActive(true);


sun.SetActive(true);

//sunAnimator.enabled = false;

sun.GetComponent<Light2D>().intensity = 0;

leadText.SetActive(true);

life.SetActive(true);

//Debug.Log(sun.GetComponent<Light2D>().intensity);

//sunFadingIn = true;


myGlobalLight.SetActive(true);

myGlobalLight.GetComponent<Light2D>().intensity = 0;


lightingSystem.SetActive(false);


//sunAnimator.SetTrigger("OnSunVisible");

moonAnimator.SetTrigger("OnMoonAppear");

globalLightAnimator.SetTrigger("StartUpScene");

lifeGrow.plantStage = 0;





}


IEnumerator changeDirection()

{

yield return new WaitForSecondsRealtime(Random.Range(150, 400));

cloudDirection = Random.Range(-1.00f, 1.00f);



StartCoroutine(changeDirection());


}





}


using System.Collections;

using System.Collections.Generic;

using UnityEngine;


public class ButterflyScript : MonoBehaviour

{

public GameObject nextFlower;

public float todaysSpeed;

public Animator myAnimator;

GameObject[] flowers;


public Vector2 targetPos;


// Start is called before the first frame update

void Start()

{

todaysSpeed = Random.Range(0.3f, 0.4f);


myAnimator.speed = 1 + (todaysSpeed / 1000);


float todaysScale = Random.Range(0.045f, 0.065f);

transform.localScale = (new Vector2(todaysScale, todaysScale));


flowers = GameObject.FindGameObjectsWithTag("Flower");

int rand = Random.Range(0, flowers.Length);

nextFlower = flowers[rand];


StartCoroutine(choosePosition());

}


// Update is called once per frame

void Update()

{

transform.position = Vector2.MoveTowards(transform.position, targetPos, todaysSpeed * Time.deltaTime);

//transform.up = new Vector2(targetPos.x - transform.position.x, targetPos.y - transform.position.y);



if (transform.position.x == nextFlower.transform.position.x && transform.position.y == (nextFlower.transform.position.y + nextFlower.GetComponent<SpriteRenderer>().bounds.size.y))

{

flowers = GameObject.FindGameObjectsWithTag("Flower");

int rand = Random.Range(0, flowers.Length);

nextFlower = flowers[rand];

}


if(transform.position.x == targetPos.x && transform.position.y == targetPos.y)

{

targetPos = new Vector2(transform.position.x + (nextFlower.transform.position.x - transform.position.x) / Random.Range(1.0f, 5.0f), transform.position.y + (nextFlower.transform.position.y + nextFlower.GetComponent<SpriteRenderer>().bounds.size.y - transform.position.y) / (Random.Range(1.0f, 5.0f)));

}


if(transform.position.x < targetPos.x)

{

gameObject.transform.localScale = new Vector2(Mathf.Abs(gameObject.transform.localScale.x), gameObject.transform.localScale.y);

}


if (transform.position.x >targetPos.x)

{

gameObject.transform.localScale = new Vector2(-Mathf.Abs(gameObject.transform.localScale.x), gameObject.transform.localScale.y);

}


//gameObject.transform.localScale = new Vector2(gameObject.transform.localScale.x * (Mathf.Abs(transform.position.y)), gameObject.transform.localScale.y * (Mathf.Abs(transform.position.y)));

}


IEnumerator choosePosition()

{

yield return new WaitForSecondsRealtime(Random.Range(0.1f, 4f));


todaysSpeed = Random.Range(0.3f, 0.5f);

myAnimator.speed = 1 + Random.Range(0.0f, 0.5f);

targetPos = new Vector2(transform.position.x + (nextFlower.transform.position.x - transform.position.x) / Random.Range(1.0f, 5.0f), transform.position.y + Random.Range(0.0f, 0.3f) + (nextFlower.transform.position.y + nextFlower.GetComponent<SpriteRenderer>().bounds.size.y - transform.position.y) / (Random.Range(1.0f, 5.0f)));


StartCoroutine(choosePosition());


}

}


using System.Collections;

using System.Collections.Generic;

using UnityEngine;


public class beeScript : MonoBehaviour

{


public GameObject nextFlower;

public Animator myAnimator;

public float todaysSpeed;

GameObject[] flowers;


public Vector2 targetPos;


// Start is called before the first frame update

void Start()

{

todaysSpeed = Random.Range(0.0008f, 0.0012f);


myAnimator.speed = 1 + (80 * todaysSpeed);


float todaysScale = Random.Range(0.03f, 0.04f);

transform.localScale = (new Vector2(todaysScale, todaysScale));


flowers = GameObject.FindGameObjectsWithTag("Flower");

int rand = Random.Range(0, flowers.Length);

nextFlower = flowers[rand];

}


// Update is called once per frame

void Update()

{

transform.position = Vector2.MoveTowards(transform.position, targetPos, todaysSpeed);



if (transform.position.x == targetPos.x && transform.position.y == targetPos.y)

{


flowers = GameObject.FindGameObjectsWithTag("Flower");

int rand = Random.Range(0, flowers.Length);

nextFlower = flowers[rand];


targetPos = new Vector2(nextFlower.transform.position.x, nextFlower.transform.position.y + nextFlower.GetComponent<SpriteRenderer>().bounds.size.y);

}


if (transform.position.x < targetPos.x)

{

gameObject.transform.localScale = new Vector2(Mathf.Abs(gameObject.transform.localScale.x), gameObject.transform.localScale.y);

transform.right = new Vector2(targetPos.x - transform.position.x, targetPos.y - transform.position.y);

}


if (transform.position.x > targetPos.x)

{

gameObject.transform.localScale = new Vector2(-Mathf.Abs(gameObject.transform.localScale.x), gameObject.transform.localScale.y);

transform.right = new Vector2(targetPos.x - transform.position.x, targetPos.y - transform.position.y) * -1;

}


}

}


using System.Collections;

using System.Collections.Generic;

using UnityEngine;



public class treeHighlightScript : MonoBehaviour

{

public lifeGrowing myPlant;


public int highlightStage;

public Sprite[] highlightStages;

// Start is called before the first frame update

void Start()

{

gameObject.GetComponent<SpriteRenderer>().sprite = highlightStages[highlightStage];


}


// Update is called once per frame

void Update()

{



}


public void HighlightGrow()

{

gameObject.GetComponent<SpriteRenderer>().sprite = highlightStages[highlightStage];

}

}


using System.Collections;

using System.Collections.Generic;

using UnityEngine;


using ModernProgramming;


public class lifeGrowing : MonoBehaviour

{

public Camera mainCamera;


public treeHighlightScript treeHighlightScript;


public Sprite[] plantStages;

public int plantStage = 0;

public int lastPlantStage =0;

public float lastMinuteGrow;

public Time timeOfGrowing;


public System.DateTime firstStartTime;

public System.DateTime lastGrow;

public System.DateTime lastMidnight;




// Start is called before the first frame update

void Start()

{

if (PlayerPrefs.GetInt("BeginningScene") == 0)

{

plantStage = 0;

lastPlantStage = 0;



}


plantStage = PlayerPrefs.GetInt("PlantStage");

lastMinuteGrow = PlayerPrefs.GetFloat("lastGrowInMinutes");


System.DateTime current = System.DateTime.Now;

lastMidnight = current.AddDays(0).Date;

gameObject.GetComponent<SpriteRenderer>().sprite = plantStages[plantStage];


System.DateTime.TryParse(PlayerPrefs.GetString("LastGrowDate"), out lastGrow);


treeHighlightScript.highlightStage = plantStage;

treeHighlightScript.HighlightGrow();

}


// Update is called once per frame

void Update()

{




if (System.DateTime.Now.Date != lastGrow.Date)

{

ForceGrow();

}


//Debug.Log(System.DateTime.Now.Minute + "now");

//Debug.Log(lastGrow.Minute + "lastTime");


if((System.DateTime.Now.Hour * (60) + System.DateTime.Now.Minute) - ((lastGrow.Hour * 60) + lastGrow.Minute) > 30)

{

ForceGrow();

Debug.Log("More than 30 min");

}


if(plantStage != lastPlantStage)

{

lastPlantStage = plantStage;

PlayerPrefs.SetInt("PlantStage", plantStage);

gameObject.GetComponent<SpriteRenderer>().sprite = plantStages[plantStage];

treeHighlightScript.highlightStage = plantStage;

treeHighlightScript.HighlightGrow();


}


//System.DateTime current = System.DateTime.Now;

//double minutesSinceMidnight = (current - lastMidnight).TotalMinutes;


//if (minutesSinceMidnight - lastMinuteGrow >= 30)

//{


// plantStage += 1;

// lastGrow = System.DateTime.Now;


// PlayerPrefs.SetFloat("lastGrowInMinutes", ((float)minutesSinceMidnight));

// lastMinuteGrow = ((float)minutesSinceMidnight);


// string growDateString = System.DateTime.Now.ToString();

// PlayerPrefs.SetString("LastGrowDate", growDateString);

//}



}


public void ForceGrow()

{

System.DateTime current = System.DateTime.Now;

double minutesSinceMidnight = (current - lastMidnight).TotalMinutes;


plantStage += 1;

lastGrow = System.DateTime.Now;


PlayerPrefs.SetFloat("lastGrowInMinutes", ((float)minutesSinceMidnight));

lastMinuteGrow = ((float)minutesSinceMidnight);


string growDateString = System.DateTime.Now.ToString();

PlayerPrefs.SetString("LastGrowDate", growDateString);


treeHighlightScript.highlightStage = plantStage;

treeHighlightScript.HighlightGrow();

}

}


using System.Collections;

using System.Collections.Generic;

using UnityEngine;

using ModernProgramming;


[System.Serializable]


//public class SerializableList<T>

//{

// public List<Transform> myList;

//}




public class bigPlantWorldScript : MonoBehaviour

{


//[SerializeField] public SerializableList<Transform> bigPlantsTransformList;


public List<Transform> bigPlantsTransformList;

public GameObject[] seedPrefabs;

public int totalFlowers;


public GameObject currentFlower;


// Start is called before the first frame update

void Start()

{


totalFlowers = PlayerPrefs.GetInt("TotalFlowers");


for (var i = 0; i < totalFlowers; i++)

{


currentFlower = Instantiate(seedPrefabs[PlayerPrefs.GetInt("Chosen Flower " + i)], PlayerPrefsExtended.GetVector3("FlowerPos " + i, transform.position), Quaternion.identity);

currentFlower.GetComponent<bigPlantScript>().myFlowerIndex = i;

}


StartCoroutine(spawnSeeds());


//string json = JsonUtility.ToJson(bigPlantsTransformList);

//Debug.Log(json);


}


// Update is called once per frame

void Update()

{


}


IEnumerator spawnSeeds()

{

yield return new WaitForSecondsRealtime(Random.Range(10, 40));


int chosenFlower = Random.Range(0, seedPrefabs.Length);


if(Random.Range(0,2) == 0)

{

currentFlower = Instantiate(seedPrefabs[chosenFlower], new Vector3(Random.Range(-11.000f, -4.000f), Random.Range(6.000f, 9.500f), 1), Quaternion.identity);

}

else

{

currentFlower = Instantiate(seedPrefabs[chosenFlower], new Vector3(Random.Range(11.000f, 4.000f), Random.Range(6.000f, 9.500f), 1), Quaternion.identity);

}


bigPlantsTransformList.Add(currentFlower.transform);

totalFlowers += 1;

PlayerPrefs.SetInt("TotalFlowers", totalFlowers);

PlayerPrefs.SetInt("Chosen Flower " + totalFlowers, chosenFlower);


//string json = JsonUtility.ToJson(bigPlantsTransformList);

//Debug.Log(json);

currentFlower.GetComponent<bigPlantScript>().myFlowerIndex = totalFlowers;


StartCoroutine(spawnSeeds());

}

}


using System.Collections;

using System.Collections.Generic;

using UnityEngine;

using ModernProgramming;


public class bigPlantScript : MonoBehaviour

{

public bool flying;

public GameObject myDandelion;

public GameObject myShadow;

public GameObject particlePlop;


public int myFlowerIndex;


public Sprite[] myGrowthStages;

public int myGrowthStage;


public Rigidbody2D rigidbuddy;


public Camera mainCamera;


public bool clicked;


public Collider2D groundCollider;

public Collider2D frontHillCollider;

public Collider2D backHillCollider;


//public GameObject myShadow;



// Start is called before the first frame update

void Start()

{

groundCollider = GameObject.Find("MainGround").GetComponent<Collider2D>();

frontHillCollider = GameObject.Find("FrontGround").GetComponent<Collider2D>();

backHillCollider = GameObject.Find("BGHillGreen").GetComponent<Collider2D>();

mainCamera = Camera.main;

//mainCamera.usePhysicalProperties = enabled;


if (PlayerPrefs.GetInt("Plant has settled " + myFlowerIndex) == 1)

{

myDandelion.SetActive(false);

rigidbuddy.simulated = false;

particlePlop.SetActive(true);

StartCoroutine(growMe());

}


if (PlayerPrefs.HasKey("Growth Stage of " + myFlowerIndex))

{

myGrowthStage = PlayerPrefs.GetInt("Growth Stage of " + myFlowerIndex);

gameObject.GetComponent<SpriteRenderer>().sprite = myGrowthStages[myGrowthStage];

}


else

{

gameObject.GetComponent<SpriteRenderer>().sprite = myGrowthStages[0];

}


if(PlayerPrefs.HasKey("Seed Flying " + myFlowerIndex))

{

flying = false;

}


else

{

flying = true;

rigidbuddy.AddForce(new Vector2(Random.Range(-3.0f, 3.0f), Random.Range(-0.40f, 0.40f)));

PlayerPrefs.SetInt("Seed Flying " + myFlowerIndex, 1);

}


if(PlayerPrefs.GetInt("Seed Flying " + myFlowerIndex) != 0)

{

StartCoroutine(windBlows());

}



}


// Update is called once per frame

void Update()

{



//if (Input.GetMouseButtonDown(0))

//{

// Vector2 mousePosition = Input.mousePosition;


// Ray2D ray = Camera.main.


// if (Physics2D.Raycast(ray, out RaycastHit2D hit)) //(Physics.Raycast(ray, out RaycastHit hit))

// {

// Debug.Log("clickedSomewhere");

// if (hit.collider.gameObject.name == gameObject.name)

// {

// Debug.Log("clicked");

// Vector2.MoveTowards(transform.position, mousePosition, 30f * Time.deltaTime);

// }

// }

//}


if (Input.GetMouseButton(0) && clicked == true)

{


Vector2 mousePosition = Input.mousePosition;


transform.position = Vector2.MoveTowards(new Vector2(transform.position.x, transform.position.y), mainCamera.ScreenToWorldPoint(new Vector2(Input.mousePosition.x, Input.mousePosition.y)), 3f * Time.deltaTime);

}



if(Input.GetMouseButtonUp(0) && clicked == true)

{


if(PlayerPrefs.GetInt("Plant has settled " + myFlowerIndex) == 0)

{

if (gameObject.GetComponent<Collider2D>().IsTouching(groundCollider) || gameObject.GetComponent<Collider2D>().IsTouching(backHillCollider) || gameObject.GetComponent<Collider2D>().IsTouching(frontHillCollider))

{

flying = false;

PlayerPrefs.SetInt("Seed Flying " + myFlowerIndex, 0);

particlePlop.SetActive(true);

PlayerPrefs.SetInt("Plant has settled " + myFlowerIndex, 1);

myDandelion.GetComponent<Animator>().SetTrigger("FadeOut");

rigidbuddy.simulated = false;

StartCoroutine(growMe());

}

}


}


if (Input.GetMouseButtonUp(0))

{

clicked = false;

}



if (flying != true)

{

myDandelion.SetActive(false);


// myShadow.SetActive(true);

}


if (flying == true)

{

myDandelion.SetActive(true);

myDandelion.GetComponent<Animator>().SetTrigger("SetActive");

myShadow.SetActive(false);




// myShadow.SetActive(true);

}


if (transform.position.x < -12f || transform.position.x > 12f || transform.position.y < -10f || transform.position.y > 12f)

{

flying = true;

rigidbuddy.AddForce(new Vector2(Random.Range(-3.0f, 3.0f), Random.Range(-0.40f, 0.40f)));

PlayerPrefs.DeleteKey("SeedFlying " + myFlowerIndex);


if (Random.Range(0, 2) == 0)

{

transform.position = new Vector3(Random.Range(-11.000f, -9.000f), Random.Range(1.000f, 9.500f), 1);

}

else

{

transform.position = new Vector3(Random.Range(11.000f, 9.000f), Random.Range(1.000f, 9.500f), 1);

}


}

}


IEnumerator growMe()

{

yield return new WaitForSecondsRealtime(Random.Range(1, 10));


if(myGrowthStage < myGrowthStages.Length -1)

{

myGrowthStage += 1;

PlayerPrefs.SetInt("Growth Stage of " + myFlowerIndex, myGrowthStage);

gameObject.GetComponent<SpriteRenderer>().sprite = myGrowthStages[PlayerPrefs.GetInt("Growth Stage of " + myFlowerIndex)];

}


if (PlayerPrefs.GetInt("Seed Flying " + myFlowerIndex) == 0)

{

StartCoroutine(growMe());

}


}


IEnumerator windBlows()

{

yield return new WaitForSecondsRealtime(Random.Range(0.1f, 8.0f));


rigidbuddy.AddForce(new Vector2(Random.Range(-1.0f, 1.0f), Random.Range(-0.40f, 0.40f)));


if(PlayerPrefs.GetInt("Seed Flying " + myFlowerIndex) != 0)

{

StartCoroutine(windBlows());

}


}


IEnumerator setInactive()

{

yield return new WaitForSecondsRealtime(Random.Range(0.1f, 8.0f));


flying = false;


myShadow.SetActive(true);

PlayerPrefs.SetInt("Seed Flying " + myFlowerIndex, 0);

StartCoroutine(growMe());


if (!Input.GetMouseButton(0) && !clicked)

{

rigidbuddy.simulated = false;

}

}


private void OnCollisionEnter2D(Collision2D collision)

{

if(collision.gameObject.tag == "Ground")

{


StartCoroutine(setInactive());

}

}


void OnApplicationQuit()

{

PlayerPrefsExtended.SetVector3("FlowerPos " + myFlowerIndex, transform.position);

PlayerPrefs.SetInt("Growth Stage of " + myFlowerIndex, myGrowthStage);


}


private void OnMouseDown()

{

if(PlayerPrefs.GetInt("Plant has settled " + myFlowerIndex) == 0)

{

clicked = true;

}



}

}


using System.Collections;

using System.Collections.Generic;

using UnityEngine;

using ModernProgramming;


public class imSmallFlower : MonoBehaviour

{

public GameObject worldVars;


public int myIndex;

public int mySprite;


// Start is called before the first frame update

void Start()

{

worldVars = GameObject.Find("WorldScripts");


if(PlayerPrefs.HasKey("MySprite " + myIndex))

{

mySprite = PlayerPrefs.GetInt("MySprite " + myIndex);

gameObject.GetComponent<SpriteRenderer>().sprite = worldVars.GetComponent<SmallFlowerScript>().allFlowers[mySprite];

}

else

{

mySprite = Random.Range(0, 47);

gameObject.GetComponent<SpriteRenderer>().sprite = worldVars.GetComponent<SmallFlowerScript>().allFlowers[mySprite];

}


if(Random.Range(1, 2) != 1)

{

gameObject.GetComponent<SpriteRenderer>().flipX = true;


}


PlayerPrefs.SetInt("MySprite " + myIndex, mySprite);

PlayerPrefsExtended.SetVector3("SmallFlowerPos " + myIndex, transform.position);


}




// Update is called once per frame

void Update()

{


}

}


using System.Collections;

using System.Collections.Generic;

using UnityEngine;


public class turnClouds : MonoBehaviour

{

// Start is called before the first frame update

void Start()

{


}


// Update is called once per frame

void Update()

{

transform.eulerAngles = new Vector3(0, 0, transform.eulerAngles.z + 1 * Time.deltaTime);

}

}

using System.Collections;

using System.Collections.Generic;

using UnityEngine;


public class lightRaysScript : MonoBehaviour

{

public LightRays2D myLightrays;

public float yVelocity = 0.00f;


// Start is called before the first frame update

void Start()

{


}


// Update is called once per frame

void Update()

{

if (System.DateTime.Now.Hour <= 12)

{

myLightrays.contrast = Mathf.SmoothDamp(myLightrays.contrast, (((float)System.DateTime.Now.Hour) / 10) + 1.4f, ref yVelocity, 3f);


}


if (System.DateTime.Now.Hour > 12)

{

myLightrays.contrast = Mathf.SmoothDamp(myLightrays.contrast, ((24 -((float)System.DateTime.Now.Hour)) / 10) + 1.4f, ref yVelocity, 3f);

}

}

}


using System.Collections;

using System.Collections.Generic;

using UnityEngine;

using UnityEngine.Rendering.Universal;


public class highlightColorScript : MonoBehaviour

{

public float hue;

public float saturationDivisor;


//public Color myColor = gameObject.GetComponent<Light2D>().color;


public Light2D thisLight;


// Start is called before the first frame update

void Start()

{


}


// Update is called once per frame

void Update()

{

System.DateTime current = System.DateTime.Now;

System.DateTime lastMidnight = current.AddDays(0).Date;


double secondsSinceMidnight = (current - lastMidnight).TotalSeconds;


double secondsInADay = (current.AddDays(1).Date - lastMidnight).TotalSeconds;




//transform.eulerAngles = new Vector3(0, 0, 360 / (360 / ((float)secondsSinceMidnight) * ((float)secondsInADay) / 360));

thisLight.color = new Color(255, 243, (255 / 255 / ((float)secondsSinceMidnight) * ((float)secondsInADay)) / 255, 255);



//if (System.DateTime.Now.Hour >= 18 || System.DateTime.Now.Hour < 6)

//{

// if(saturationDivisor<800)

// {

// saturationDivisor += 1 * Time.deltaTime;

// }

//}


//if (System.DateTime.Now.Hour >= 6 && System.DateTime.Now.Hour < 18)

//{

// if (saturationDivisor > 1)

// {

// saturationDivisor -= 1 * Time.deltaTime;

// }

//}

}

}

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

using UnityEngine.UI;


public class myTextScript : MonoBehaviour

{

public publicVariables myVariables;


public Animator myAnimator;


public Text thisLeadText;


public bool taskDone = false;


public List<string> rewardText = new List<string>();


public List<string> welcomeMorning = new List<string>();

public List<string> welcomeNoon = new List<string>();

public List<string> welcomeEvening = new List<string>();

public List<string> welcomeNight = new List<string>();


// Start is called before the first frame update

void Start()

{


StartCoroutine(startWait());

}


// Update is called once per frame

void Update()

{


if (taskDone == true)

{

taskDone = false;

myAnimator.SetTrigger("FadeOutTrigger");

StartCoroutine(giveRewardText());

}


}


IEnumerator waitABit()

{

yield return new WaitForSecondsRealtime(5);

thisLeadText.text = myVariables.taskTexts[PlayerPrefs.GetInt("TaskStagePref")];

myAnimator.SetTrigger("FadeInTrigger");


}


IEnumerator giveRewardText()

{

yield return new WaitForSecondsRealtime(1);


thisLeadText.text = rewardText[PlayerPrefs.GetInt("TaskStagePref")];

myAnimator.SetTrigger("FadeInTrigger");


myVariables.taskStage += 1;

PlayerPrefs.SetInt("TaskStagePref", myVariables.taskStage);


yield return new WaitForSecondsRealtime(20);

myAnimator.SetTrigger("FadeOutTrigger");


yield return new WaitForSecondsRealtime(Random.Range(40, 100));

StartCoroutine(waitABit());



}


IEnumerator startWait()

{


//myAnimator.SetTrigger("FadeInTrigger");

if (System.DateTime.Now.Hour >= 6 && System.DateTime.Now.Hour < 8)

{

thisLeadText.text = welcomeMorning[Random.Range(0, welcomeMorning.Count)];


}


if (System.DateTime.Now.Hour >= 8 && System.DateTime.Now.Hour < 18)

{

thisLeadText.text = welcomeNoon[Random.Range(0, welcomeNoon.Count)];


}


if (System.DateTime.Now.Hour >= 18 && System.DateTime.Now.Hour < 20)

{

thisLeadText.text = welcomeEvening[Random.Range(0, welcomeEvening.Count)];


}


if (System.DateTime.Now.Hour >= 20 || System.DateTime.Now.Hour < 6)

{

thisLeadText.text = welcomeNight[Random.Range(0, welcomeNight.Count)];


}

yield return new WaitForSecondsRealtime(15);


myAnimator.SetTrigger("FadeOutTrigger");

StartCoroutine(waitABit());



}

}


using System.Collections;

using System.Collections.Generic;

using UnityEngine;


public class seedHighlightScript : MonoBehaviour

{

public SpriteRenderer parentRenderer;

public SpriteRenderer myRenderer;


public Sprite lastSprite;

// Start is called before the first frame update

void Start()

{


}


// Update is called once per frame

void Update()

{

if(lastSprite != parentRenderer.sprite)

{

myRenderer.sprite = parentRenderer.sprite;

lastSprite = parentRenderer.sprite;

}


}

}


using System.Collections;

using System.Collections.Generic;

using UnityEngine;


public class seedHighlightScript : MonoBehaviour

{

public SpriteRenderer parentRenderer;

public SpriteRenderer myRenderer;


public Sprite lastSprite;

// Start is called before the first frame update

void Start()

{


}


// Update is called once per frame

void Update()

{

if(lastSprite != parentRenderer.sprite)

{

myRenderer.sprite = parentRenderer.sprite;

lastSprite = parentRenderer.sprite;

}


}

}


using System.Collections;

using System.Collections.Generic;

using UnityEngine;

using UnityEngine.Rendering.Universal;


public class moonScript : MonoBehaviour

{

//public Animator myAnimator;

public Camera mainCamera;

public publicVariables worldVars;

public bool moonVisible = false;

public Light2D myIntensity;


public float desiredFalloff;

public float desiredRadius;


float yVelocity = 0.0f;



void Start()

{

myIntensity = gameObject.GetComponent<Light2D>();

}


void Update()

{

//if (System.DateTime.Now.Hour >= 6 && System.DateTime.Now.Hour < 18)

//{


// if (myIntensity.intensity > 0)

// {


// myIntensity.intensity -= 0.5f * Time.deltaTime;

// }


// if (myIntensity.falloffIntensity < 1)

// {

// myIntensity.falloffIntensity += 0.1f * Time.deltaTime;

// }


// if (myIntensity.pointLightOuterRadius > 4)

// {

// myIntensity.pointLightOuterRadius -= 0.8f * Time.deltaTime;

// }






//}


//if (System.DateTime.Now.Hour >= 18 || System.DateTime.Now.Hour < 6)

//{


// if (myIntensity.intensity < worldVars.sunDesiredIntensity)

// {

// myIntensity.intensity += 0.5f * Time.deltaTime;

// }


// if (myIntensity.falloffIntensity > desiredFalloff)

// {

// myIntensity.falloffIntensity -= 0.1f * Time.deltaTime;

// }


// if (myIntensity.pointLightOuterRadius < desiredRadius)

// {

// myIntensity.pointLightOuterRadius += 0.8f * Time.deltaTime;

// }


//}


if (myIntensity.intensity < 1 && System.DateTime.Now.Hour < 7)

{

myIntensity.intensity = Mathf.SmoothDamp(myIntensity.intensity, ((12 - ((float)System.DateTime.Now.Hour)) / 10) - 0.2f, ref yVelocity, 0.03f);



}


if (myIntensity.intensity < 1 && System.DateTime.Now.Hour > 19)

{

myIntensity.intensity = Mathf.SmoothDamp(myIntensity.intensity, (((float)System.DateTime.Now.Hour) - 12) / 10, ref yVelocity, 0.03f);

}


if (System.DateTime.Now.Hour >= 7 && System.DateTime.Now.Hour < 18)

{

myIntensity.intensity = Mathf.SmoothDamp(myIntensity.intensity, 0, ref yVelocity, 0.03f);


}


}

}


using System.Collections;

using System.Collections.Generic;

using UnityEngine;


public class turningScript : MonoBehaviour

{

// Start is called before the first frame update

void Start()

{


}


// Update is called once per frame

void Update()

{

System.DateTime current = System.DateTime.Now;

System.DateTime lastMidnight = current.AddDays(0).Date;


double secondsSinceMidnight = (current - lastMidnight).TotalSeconds;


double secondsInADay = (current.AddDays(1).Date - lastMidnight).TotalSeconds;


transform.eulerAngles = new Vector3(0, 0, 360 / (360 / ((float)secondsSinceMidnight) * ((float)secondsInADay) / 360));

}

}


using System.Collections;

using System.Collections.Generic;

using UnityEngine;


public class musicScript : MonoBehaviour

{


public AudioSource sunriseMusic;

public AudioSource daylightMusic;

public AudioSource nightfallMusic;

public AudioSource midnightMusic;


// Start is called before the first frame update

void Start()

{


}


// Update is called once per frame

void Update()

{

if(!sunriseMusic.isPlaying && !daylightMusic.isPlaying && !nightfallMusic.isPlaying && !midnightMusic.isPlaying)

{

if (System.DateTime.Now.Hour >= 6 && System.DateTime.Now.Hour < 8 && !sunriseMusic.isPlaying)

{

sunriseMusic.Play();


}


if (System.DateTime.Now.Hour >= 8 && System.DateTime.Now.Hour < 18 && !daylightMusic.isPlaying)

{

daylightMusic.Play();


}


if (System.DateTime.Now.Hour >= 18 && System.DateTime.Now.Hour < 20 && !nightfallMusic.isPlaying)

{

nightfallMusic.Play();


}


if (System.DateTime.Now.Hour >= 20 || System.DateTime.Now.Hour < 6 && !midnightMusic.isPlaying)

{

midnightMusic.Play();


}

}





}

}


using System.Collections;

using System.Collections.Generic;

using UnityEngine;


public class moonTurning : MonoBehaviour

{

// Start is called before the first frame update

void Start()

{


}


// Update is called once per frame

void Update()

{

System.DateTime current = System.DateTime.Now;

System.DateTime lastMidnight = current.AddDays(0).Date;


double secondsSinceMidnight = (current - lastMidnight).TotalSeconds;


double secondsInADay = (current.AddDays(1).Date - lastMidnight).TotalSeconds;



transform.eulerAngles = new Vector3(0, 0, 360 / (360 / ((float)secondsSinceMidnight) * ((float)secondsInADay) / 360));

}



}


using System.Collections;

using System.Collections.Generic;

using UnityEngine;


public class moonTurning : MonoBehaviour

{

// Start is called before the first frame update

void Start()

{


}


// Update is called once per frame

void Update()

{

System.DateTime current = System.DateTime.Now;

System.DateTime lastMidnight = current.AddDays(0).Date;


double secondsSinceMidnight = (current - lastMidnight).TotalSeconds;


double secondsInADay = (current.AddDays(1).Date - lastMidnight).TotalSeconds;



transform.eulerAngles = new Vector3(0, 0, 360 / (360 / ((float)secondsSinceMidnight) * ((float)secondsInADay) / 360));

}



}


using System.Collections;

using System.Collections.Generic;

using UnityEngine;

using UnityEngine.UI;


public class narratorText : MonoBehaviour

{

public publicVariables myVariables;


public Animator myAnimator;


public Text thisNarratorText;


public bool firstTime = true;


// Start is called before the first frame update

void Start()

{


}


// Update is called once per frame

void Update()

{

if(Input.GetMouseButtonDown(0) && firstTime == true)

{

firstTime = false;

myAnimator.SetTrigger("FadeOutTrigger");

StartCoroutine(waitABit());

}


}


IEnumerator waitABit()

{

yield return new WaitForSecondsRealtime(5);


transform.GetComponent<RectTransform>().anchorMin = new Vector2(0.5f, 1);


transform.GetComponent<RectTransform>().anchorMax = new Vector2(0.5f, 1);


thisNarratorText.rectTransform.anchoredPosition = new Vector3(0, -60, 0);


thisNarratorText.text = "Could you, perhaps, help Life find a place to sprout?";

myAnimator.SetTrigger("FadeInTrigger");

yield return new WaitForSecondsRealtime(10);

myAnimator.SetTrigger("FadeOutTrigger");

yield return new WaitForSecondsRealtime(2);

thisNarratorText.text = "Life is delicate.";

myAnimator.SetTrigger("FadeInTrigger");

yield return new WaitForSecondsRealtime(10);

myAnimator.SetTrigger("FadeOutTrigger");

yield return new WaitForSecondsRealtime(2);

thisNarratorText.text = "Life is strong.";

myAnimator.SetTrigger("FadeInTrigger");

yield return new WaitForSecondsRealtime(10);

myAnimator.SetTrigger("FadeOutTrigger");

yield return new WaitForSecondsRealtime(2);

thisNarratorText.text = "Life is slow.";

myAnimator.SetTrigger("FadeInTrigger");

yield return new WaitForSecondsRealtime(10);

myAnimator.SetTrigger("FadeOutTrigger");

yield return new WaitForSecondsRealtime(2);

gameObject.SetActive(false);

}

}



using System.Collections;

using System.Collections.Generic;

using UnityEngine;


public class lifeScript : MonoBehaviour

{

private List<Vector2> points = new List<Vector2>();

private List<Vector2> simplifiedPoints = new List<Vector2>();

public PolygonCollider2D polygonCollider2D;

public Sprite sprite;



// Start is called before the first frame update

void Start()

{

gameObject.AddComponent<PolygonCollider2D>();

polygonCollider2D = gameObject.GetComponent<PolygonCollider2D>();


StartCoroutine(UpdatePolygonCollider2D());


}


// Update is called once per frame

void Update()

{


}



IEnumerator UpdatePolygonCollider2D(float tolerance = 0.05f)

{

yield return new WaitForSeconds(3);


sprite = gameObject.GetComponent<SpriteRenderer>().sprite;


polygonCollider2D.pathCount = sprite.GetPhysicsShapeCount();

for (int i = 0; i < polygonCollider2D.pathCount; i++)

{

sprite.GetPhysicsShape(i, points);

LineUtility.Simplify(points, tolerance, simplifiedPoints);

polygonCollider2D.SetPath(i, simplifiedPoints);

}


StartCoroutine(UpdatePolygonCollider2D());

}



}



using System.Collections;

using System.Collections.Generic;

using UnityEngine;


public class spriteChanger : MonoBehaviour

{

public SpriteRenderer lifeSprite;


public SpriteRenderer mySprite;


public string earlyName;



// Start is called before the first frame update

void Start()

{


}


// Update is called once per frame

void Update()

{

if(lifeSprite.sprite.name != earlyName)

{

mySprite.sprite = lifeSprite.sprite;

earlyName = lifeSprite.sprite.name;

}

}

}


using System.Collections;

using System.Collections.Generic;

using UnityEngine;

using UnityEngine.Rendering.Universal;


public class sunsetScript : MonoBehaviour

{


//public Animator myAnimator;

public Camera mainCamera;

//public float addOn;




public Light2D myIntensity;




float yVelocity = 0.0f;



void Start()

{

myIntensity = gameObject.GetComponent<Light2D>();

}

void Update()

{

if (System.DateTime.Now.Hour == 18 || System.DateTime.Now.Hour == 6)

{



if (myIntensity.intensity < 0.8f)

{

myIntensity.intensity = Mathf.SmoothDamp(myIntensity.intensity, 0.2f + ((float)System.DateTime.Now.Minute) / 120, ref yVelocity, 0.3f);

}



myIntensity.falloffIntensity = Mathf.SmoothDamp(myIntensity.falloffIntensity, 0.3f + ((float)System.DateTime.Now.Minute) / 120,ref yVelocity, 0.3f);





}


if (System.DateTime.Now.Hour == 19 || System.DateTime.Now.Hour == 7)

{



if (myIntensity.intensity < 0.8f)

{

myIntensity.intensity = Mathf.SmoothDamp(myIntensity.intensity, 0.7f + ((float)System.DateTime.Now.Minute) / 120, ref yVelocity, 0.3f);

}




myIntensity.falloffIntensity = Mathf.SmoothDamp(myIntensity.falloffIntensity, 0.3f + (60/120) + ((float)System.DateTime.Now.Minute) / 120, ref yVelocity, 0.3f);





}


if (System.DateTime.Now.Hour != 6 && System.DateTime.Now.Hour != 18 && System.DateTime.Now.Hour != 19 && System.DateTime.Now.Hour != 7)

{


if(System.DateTime.Now.Hour <= 12 && System.DateTime.Now.Hour > 7)

{

myIntensity.intensity = Mathf.SmoothDamp(myIntensity.intensity, (12 - ((float)System.DateTime.Now.Hour)) / 10, ref yVelocity, 0.03f);

}


if (System.DateTime.Now.Hour > 12 && System.DateTime.Now.Hour < 6)

{

myIntensity.intensity = Mathf.SmoothDamp(myIntensity.intensity, (((float)System.DateTime.Now.Hour - 12)) / 10, ref yVelocity, 0.03f);

}


if (System.DateTime.Now.Hour > 19 && System.DateTime.Now.Hour < 6)

{

myIntensity.intensity = Mathf.SmoothDamp(myIntensity.intensity, 0, ref yVelocity, 0.03f);

}




myIntensity.falloffIntensity = Mathf.SmoothDamp(myIntensity.falloffIntensity, 0.3f, ref yVelocity, 0.03f);




}


}

}