/// <summary> /// Changes the cycle of the day, from day time to night time, /// or from nigth time to day time every cycle length in seconds. /// </summary> private IEnumerator ChangeCycle() { while (running) { yield return(new WaitForSeconds(CycleLengthInSeconds)); switch (DayCycle) { case DayCycle.Dawn: DayCycle = DayCycle.DayTime; break; case DayCycle.DayTime: DayCycle = DayCycle.Dusk; break; case DayCycle.Dusk: DayCycle = DayCycle.NightTime; break; case DayCycle.NightTime: DayCycle = DayCycle.Dawn; break; } OnCycleChange(); } }
private void Awake() { _instance = this; _spawnPoint = GetComponent <WorldSpawnPoint>(); _dayCycle = GetComponent <DayCycle>(); _worldClock = GetComponent <WorldClock>(); }
public void SaveGame() { GameStateData gsd = new GameStateData(); //put all tree data into an array of FruitTreeData GameObject [] trees = GameObject.FindGameObjectsWithTag("Tree"); FruitTreeData[] treeData = new FruitTreeData[trees.Length]; for (int i = 0; i < treeData.Length; i++) { treeData[i] = trees[i].GetComponent <FruitTree>().Serialize(); } //create a new GameStateData gsd.trees = treeData; ItemSelector item = GameObject.FindGameObjectWithTag("Inventory").GetComponent <ItemSelector>(); //fill in da blanks gsd.seedCount = item.numSeeds; gsd.fruitCount = item.numFruit; gsd.playerEnergy = transform.GetComponent <DirectionalMovement>().energy; gsd.playerPos = transform.parent.position; gsd.playerRot = Camera.main.transform.rotation; DayCycle day = GameObject.FindGameObjectWithTag("Sun").GetComponent <DayCycle>(); gsd.seasonCode = day.seasonCode; gsd.dayCode = day.dayCode; //serialize GameStateData to json string path = Application.persistentDataPath + "/saveData.json"; //write json string to file in persistantDataPath File.WriteAllText(path, JsonUtility.ToJson(gsd)); Debug.Log("Save success"); }
private void Start() { GameManager = GameObject.Find("GameManager"); loop = GameManager.GetComponent <GameLoop>(); player = GameManager.GetComponent <Player>(); day = GameManager.GetComponent <DayCycle>(); }
/// <summary> /// This method loads data from a save into the game (into this instance) /// </summary> public void LoadGame() { if (_DEBUG) { Debug.Log("Loaded saved game"); } SaveGame defaultLoadSlot = new SaveGame(); GameData loaded = defaultLoadSlot.LoadFromFile(SaveType.Json); if (_DEBUG) { Debug.Log("Loaded GameSave from JSON"); Debug.Log("Time created: " + loaded.timeCreated); Debug.Log("Last accessed: " + loaded.timeAccessed); } //Find sceneloader in scene and set required values before loading this._scenePlayerPos[loaded.playerScene] = loaded.GetPlayerPosition(); this._playerHasVisited[loaded.playerScene] = true; // Helper load = new Helper(); DayCycle dayCycle = (DayCycle)Enum.Parse(typeof(DayCycle), loaded.timeOfDay.ToString()); load.GetDayControllerInScene().SetDayCycle(dayCycle); // Assign running data as loaded data this.runningGame = loaded; Debug.Log("Loading from save into scene " + loaded.playerScene); SceneManager.LoadScene(loaded.playerScene); //Load PlayerPos (this is not automatically done if target Scene is current Scene // because the SceneLoader instance already exist and what that is in start() // is not executed. //LoadPlayerData(loaded.playerScene); }
void PopulateLists() { _player = GameObject.FindWithTag("Player"); _endGame = GameObject.Find("HarbourCanvas").GetComponent <EndGame>(); _dayTimer = GameObject.Find("Timer").GetComponent <DayTimer>(); _dayCycle = GameObject.Find("MainLight").GetComponent <DayCycle>(); _rumourScript = GameObject.Find("TownCanvas").GetComponent <RumourGenerator>(); _playerControls = _player.GetComponent <PlayerControls_WM>(); _towns.AddRange(GameObject.FindGameObjectsWithTag("Town")); for (int i = 0; i < _towns.Count; i++) { _buildingScripts.Add(_towns[i].GetComponent <TownManager>()); } _factoryGO.AddRange(GameObject.FindGameObjectsWithTag("Factory")); for (int i = 0; i < _factoryGO.Count; i++) { _factories.Add(_factoryGO[i].GetComponent <Factories>()); } _resourceSpawns.AddRange(GameObject.FindGameObjectsWithTag("ResourceSpawn")); for (int i = 0; i < _resourceSpawns.Count; i++) { _resourceGens.Add(_resourceSpawns[i].GetComponent <ResourceGen>()); } _fowGO.AddRange(GameObject.FindGameObjectsWithTag("FOW")); for (int i = 0; i < _fowGO.Count; i++) { _fow.Add(_fowGO[i].GetComponent <FOW>()); } _spawnGOs.AddRange(GameObject.FindGameObjectsWithTag("Spawn Point")); for (int i = 0; i < _spawnGOs.Count; i++) { _spawns.Add(_spawnGOs[i].GetComponent <SpawnPoint>()); } }
public void ToggleDayAndNightCycle() { dayAndNightCycle = !dayAndNightCycle; transform.rotation = _defaultRotation; _seconds = dayCycleDuration * 0.5f; dayCycle = DayCycle.Day; SwitchLights(); }
// Start is called before the first frame update void Start() { GameManager = GameObject.Find("GameManager"); dialogue = GameManager.GetComponent <DialogueManager>(); day = GameManager.GetComponent <DayCycle>(); player = GameManager.GetComponent <Player>(); canvas = GameManager.GetComponent <CanvasManager>(); }
private void Awake() { dayCycle = GetComponent <DayCycle>(); if (!serialHandler) { enabled = false; } }
void Start() { if (transform.parent.tag == "Player") { Is_Player = true; } Sun = FindObjectOfType <DayCycle>(); Is_DayTime = Sun.IsDay; InDay(); }
public void FromOSD(OSD osd) { OSDArray array = osd as OSDArray; RegionID = (array[0] as OSDMap)["regionID"]; Cycle = new DayCycle(); Cycle.FromOSD(array); Water = new WaterData(); Water.FromOSD(array[3]); }
void Start() { saveManager = new GameObject().AddComponent <SaveManager>(); worldGenerator = new GameObject().AddComponent <WorldGenerator>(); WorldGrid = GameObject.Find("Grid").GetComponent <Grid>(); WorldTilemap = GameObject.Find("Tilemap").GetComponent <Tilemap>(); WorldCamera = GameObject.Find("MainCamera").GetComponent <CameraController>(); DayCycleController = GameObject.Find("SkyLight").GetComponent <DayCycle>(); instance = this; worldGenerator.GenerateWorld(); }
void Awake() { if (instance == null) { instance = this; DontDestroyOnLoad(this); } else { Destroy(this); } }
void Awake() { if (instance == null) { instance = this; } else { Destroy(gameObject); return; } }
private void Start() { DayListeners = new List <IDayListener>(); //Finds the number of states of DayCycles float NumberOfCycles = Convert.ToSingle(Enum.GetValues(typeof(DayCycle)).Length); CycleLengthInSeconds = (DayLengthInMinutes * 60) / NumberOfCycles; DayCycle = DayCycle.Dawn; running = true; StartCoroutine("ChangeCycle"); }
// Start is called before the first frame update // Acts as a initialzing method. void Start() { var temp = GameObject.FindGameObjectWithTag("DayController"); if (temp != null) { dayController = temp.GetComponent <DayController>(); dayController.Subscribe(this); dayCycle = dayController.GetDayCycle(); //Sets initial state SetSpawnState(); } spawnPoints = FindObjectOfType <MoveSpots>(); }
private void Awake() { if (instance == null) { instance = this; } else { Destroy(this); } skybox = RenderSettings.skybox; Hours = StartingTime; deltaTimes = new float[UpdateRate]; }
// Start is called before the first frame update void Start() { day = GameObject.FindGameObjectWithTag("Sun").GetComponent <DayCycle>(); //randomize our colors slightly springColor.r += Random.Range(0, .02f); springColor.g += Random.Range(-.02f, .02f); springColor.b += Random.Range(0, .02f); //fall color fallColor.r += Random.Range(-.02f, .02f); fallColor.g += Random.Range(-.02f, .02f); fallColor.b += Random.Range(0, .02f); //winter color winterColor.b += Random.Range(0, .02f); winterColor.g += Random.Range(0, .02f); mat = transform.GetComponent <MeshRenderer>().sharedMaterial; StartCoroutine(FadeIn()); }
public byte[] GetDefaultAssetData(int type) { OSD osddata; switch (type) { case 0: SkyData sky = new SkyData(); sky.Name = "DefaultSky"; osddata = sky.ToOSD(); break; case 1: WaterData water = new WaterData(); water.Name = "DefaultWater"; osddata = water.ToOSD(); break; case 2: DayCycle day = new DayCycle(); day.Name = "New Daycycle"; DayCycle.TrackEntry te = new DayCycle.TrackEntry(); WaterData dwater = new WaterData(); dwater.Name = "DefaultWater"; day.waterframes["DefaultWater"] = dwater; te.time = 0; te.frameName = "DefaultWater"; day.waterTrack.Add(te); SkyData dsky = new SkyData(); dsky.Name = "DefaultSky"; day.skyframes["DefaultSky"] = dsky; te.time = 0; te.frameName = "DefaultSky"; day.skyTrack0.Add(te); osddata = day.ToOSD(); break; default: return(null); } return(OSDParser.SerializeLLSDNotationToBytes(osddata, true)); }
void Start() { _spawns.AddRange(GameObject.FindGameObjectsWithTag("Spawn Point")); _dayCycle = GameObject.Find("MainLight").GetComponent <DayCycle>(); _clock = GameObject.Find("Clock"); _dayCounter = transform.FindChild("DayCounter").GetComponent <Text>(); StartCoroutine(Timer()); _towns.AddRange(GameObject.FindGameObjectsWithTag("Town")); _rumourScript = GameObject.Find("TownCanvas").GetComponent <RumourGenerator>(); _playerSight = GameObject.Find("SightRadius").GetComponent <PlayerSight>(); UpdateClock(); Time.timeScale = 1.0f; _saveGame = GameObject.Find("Loader").GetComponent <SaveGame>(); GenerateEnemies(); if (_saveGame._skipDay) { Sleep(); } _saveGame._skipDay = false; }
// Start is called before the first frame update void Start() { mMan = GameObject.FindGameObjectWithTag("Player").transform.GetChild(0).GetComponent <MeditationManager>(); dayCycle = GameObject.FindGameObjectWithTag("Sun").GetComponent <DayCycle>(); if (!loaded) { liveBranchPositions = new List <Vector3>(); allBranchPositions = new List <Vector3>(); liveBranchRotations = new List <Quaternion>(); allBranchRotations = new List <Quaternion>(); allBranchScales = new List <Vector3>(); //debugText.text = "Planted"; StartCoroutine(BreakSurface()); } else { //do stuff if (allBranchPositions.Count < 1) { liveBranchPositions.Clear(); liveBranchRotations.Clear(); StartCoroutine(BreakSurface()); } else { for (int i = 0; i < allBranchPositions.Count; i++) { CreateBranchInstantly(allBranchPositions[i], allBranchRotations[i], allBranchScales[i], i != 0); } int branchLevel = allBranchPositions.Count / branchRate + 1; float growTime = branchTime * Mathf.Pow(growthRateDelay, branchLevel); for (int i = 0; i < oldBranchPositions.Count; i++) { StartCoroutine(CreateBranch(growTime, oldBranchPositions[i], oldBranchRotations[i], true)); } } } }
public void LoadGame(GameStateData gsd) { foreach (FruitTreeData tree in gsd.trees) { Transform newTree = Instantiate(treePrefab, tree.myPos, Quaternion.identity); FruitTree ft = newTree.GetComponent <FruitTree>(); ft.Deserialize(tree); } ItemSelector item = GameObject.FindGameObjectWithTag("Inventory").GetComponent <ItemSelector>(); item.numSeeds = gsd.seedCount; item.numFruit = gsd.fruitCount; transform.GetComponent <DirectionalMovement>().energy = gsd.playerEnergy; transform.parent.position = gsd.playerPos; Camera.main.transform.rotation = gsd.playerRot; DayCycle day = GameObject.FindGameObjectWithTag("Sun").GetComponent <DayCycle>(); day.seasonCode = gsd.seasonCode; day.dayCode = gsd.dayCode; }
public void Start() { GameObject temp = GameObject.FindGameObjectWithTag("DayController"); if (temp != null) { dayController = temp.GetComponent <DayController>(); } else { Debug.Log("Can't Find DayController"); } if (dayController != null) { dayController.Subscribe(this); dayCycle = dayController.GetDayCycle(); UpdateIndicator(); } else { Debug.Log("DayController not referenced."); } }
private void Awake() { instance = this; SkyBox = RenderSettings.skybox; StartCoroutine(updateGI()); }
/// <summary> /// Changes the internal day cycle state. /// </summary> /// <param name="dayCycle"></param> public void OnChangeCycle(DayCycle dayCycle) { this.dayCycle = dayCycle; UpdateIndicator(); Debug.Log(this + "-Listener: Cycle changed to " + dayCycle); }
void Start() { statsMaster = GameObject.Find("GameMaster").GetComponent <StatsMaster>(); dayCycle = GameObject.Find("DayCycle").GetComponent <DayCycle>(); context = transform.GetChild(0); }
public override void Run(DataContext context) { var currDate = DateTime.Today; var currYear = currDate.Year; var WeekDay = new DayEffect() { CanDelete = false, Effect = "WEEKDAY", EffectColor = "green darken-1", }; var WeekEnd = new DayEffect() { CanDelete = false, Effect = "WEEKEND", EffectColor = "red darken-2", }; var Holiday = new DayEffect() { CanDelete = false, Effect = "HOLIDAY", EffectColor = "teal darken-4", }; context.DayEffect.Add(WeekDay); context.DayEffect.Add(WeekEnd); context.DayEffect.Add(Holiday); context.SaveChanges(); for (var i = new DateTime(currYear, 1, 1); i < new DateTime(currYear + 1, 1, 1);) { var cycle = new DayCycle() { DateAt = i, IdEffect = (i.DayOfWeek == DayOfWeek.Sunday) ? WeekEnd.Id : WeekDay.Id }; context.DayCycles.Add(cycle); i = i.AddDays(1.0d); } context.SaveChanges(); var categories = (from a in context.RoomCategory select a).ToList(); var effects = (from a in context.DayEffect select a).ToList(); foreach (var effect in effects) { foreach (var category in categories) { var price = new RoomPrice() { IdCategory = category.Id, IdEffect = effect.Id, Price = (new Random().Next(100, 200)) * 1000 }; context.RoomPrice.Add(price); } } context.SaveChanges(); }
private void ChangeDayCycle() { dayCycle = dayCycle == DayCycle.Day ? DayCycle.Night : DayCycle.Day; }
// Use this for initialization void Start() { dayCycleManager = dayCycleManager.GetComponent <DayCycle>(); second = 1f; hour = (float)hourDuration; }
private void OnValidate() { instance = this; SkyBox = RenderSettings.skybox; ApplyTimeOfDay(); }