Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using System.Threading;
- public class SeasonControl: MonoBehaviour {
- public int currentYear;
- public float globalTimer;
- public float seasonTimer;
- public bool realtimeTesting = false;
- private CustomTerrainScriptAtsV3Snow snowScript;
- public enum Season{
- Spring = 0,
- Summer,
- Fall,
- Winter
- }
- public Season currentSeason;
- // Use this for initialization
- void Start () {
- snowScript = GameObject.FindGameObjectWithTag("ActTerrain").GetComponent<CustomTerrainScriptAtsV3Snow>();
- }
- // Update is called once per frame
- void Update () {
- if(!realtimeTesting)
- {
- if(Input.GetKeyDown(KeyCode.U))
- {
- triggerWinter();
- }
- if(Input.GetKeyDown(KeyCode.I))
- {
- triggerSummer();
- }
- return;
- }
- globalTimer += Time.deltaTime;
- if(globalTimer > 0 && globalTimer % seasonTimer == 0)
- {
- triggerSeasonChange();
- globalTimer = 0;
- }
- }
- private void triggerSeasonChange()
- {
- int seasonIndex = (int)currentSeason;
- seasonIndex++;
- if(seasonIndex > 3)
- {
- seasonIndex = 0;
- currentYear++;
- }
- currentSeason = (Season)seasonIndex;
- }
- public void triggerSummer()
- {
- snowScript.triggerng = true;
- snowScript.triggerSnow = false;
- }
- public void triggerWinter()
- {
- snowScript.triggerng = true;
- snowScript.triggerSnow = true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement