public void StartDay() { Time.timeScale = 1.0f; CollectBunny(0); timeLeftInDay = amountOfTimePerDay; powerDispPanel.SetActive(true); shopPanel.SetActive(false); if (we != null) { WirePort pswp = PowerSupply.Instance.gameObject.GetComponent <WirePort>(); we.PlugInWire(pswp); we = null; } foreach (GameObject go in activatedComponents) { go.GetComponent <ComputerComponent>().ResetObj(); } foreach (GameObject component in mainComponents) { MainComponents compMA = component.GetComponent <MainComponents>(); compMA.currentTemp = MainComponents.minTemp; switch (compMA.mca) { case MainCompAttach.CPU: compMA.speed = cpuSpeed; break; case MainCompAttach.GPU: compMA.speed = gpuSpeed; break; case MainCompAttach.RAM: compMA.speed = ramSpeed; break; case MainCompAttach.HDD: compMA.speed = hddSpeed; break; case MainCompAttach.PSU: PowerSupply.Instance.maxPowerDraw = maxPowerDraw = psuWatts; break; default: break; } } dayOver = false; }
private void Start() { wire = GetComponentInChildren <WireEnd>(); }
// Update is called once per frame void Update() { if (numBunnies < 0) { Explode(); return; } if (isTutorial) { Time.timeScale = tutTimeScale; } //Check if there is still time left in the day if (!dayOver || (isTutorial && readyToPlay)) { if (isTutorial) { if (readyToPlay) { if (timeLeftInDay > 0) { timeLeftInDay -= Time.deltaTime; timeDisp.text = "Time Left: " + Mathf.Floor(timeLeftInDay) + "s"; } else { EndDay(); } } } else { if (timeLeftInDay > 0) { timeLeftInDay -= Time.deltaTime; timeDisp.text = "Time Left: " + Mathf.Floor(timeLeftInDay) + "s"; } else { EndDay(); } } } if (!dayOver) { if (timeSinceLastComp < (timeTillNextCompStart * timeChangeMult)) { timeSinceLastComp += Time.deltaTime * speedMult; } else { timeSinceLastComp = 0; if (activatedComponents.Count > 0) { SelectRandomComponent(); } timeTillNextCompStart = Random.Range(minTime, maxTime); } if (currentPowerDraw > maxPowerDraw) { timeChangeMult = .5f; } else { timeChangeMult = 1.0f; } #region Moving Wires RaycastHit hit; Ray ray = cam.ScreenPointToRay(Input.mousePosition); if (Input.GetMouseButtonUp(0) && Physics.Raycast(ray, out hit)) { if (Vector3.Distance(player.transform.position, hit.transform.position) <= maxDist) { if (hit.transform.CompareTag("Wire End")) { if (we == null) { we = hit.transform.GetComponent <WireEnd>(); } we.isSelected = !we.isSelected; wireEndIsSelected = !wireEndIsSelected; if (we.wp != null) { we.wp.isOpen = !we.wp.isOpen; } if (!we.cc.isTurnedOn) { FindObjectOfType <AudioManager>().Play("PlugIn"); } if (!we.isSelected) { we = null; } } } } #endregion } }