private bool HasAmbientEnergy() { if (base.Cyclops.transform.position.y < -MaxSolarDepth) { energyStatus = 0f; return(false); } depthRatio = Mathf.Clamp01((MaxSolarDepth + Cyclops.transform.position.y) / MaxSolarDepth); DayNightCycle daynightCycle = DayNightCycle.main; if (daynightCycle == null) { energyStatus = 0f; return(false); } lightRatio = daynightCycle.GetLocalLightScalar(); bool hasEnergy = lightRatio > MinRequiredLight; rechargeRatio = depthRatio * lightRatio; if (hasEnergy) { energyStatus = rechargeRatio * PercentageMaker; } return(hasEnergy); }
private void UpdateRecharge() { if (solarCount > 0) { DayNightCycle daynight = DayNightCycle.main; if (daynight == null) { return; } float num = Mathf.Clamp01((Constants.kMaxSolarChargeDepth + parentVehicle.transform.position.y) / Constants.kMaxSolarChargeDepth); float localLightScalar = daynight.GetLocalLightScalar(); float amount = Constants.kSeamothSolarChargePerSecond * localLightScalar * num * (float)solarCount; parentVehicle.relay.ModifyPower(amount, out float modified); } if (thermalCount > 0) { WaterTemperatureSimulation waterSim = WaterTemperatureSimulation.main; if (waterSim != null) { float temperature = waterSim.GetTemperature(parentVehicle.transform.position); float num = thermalReactorCharge.Evaluate(temperature) * thermalCount; parentVehicle.relay.ModifyPower(num * Time.deltaTime, out float modified); } } }
// Use this for initialization private void Start() { //gets a reference to the day and night cycle dayNightCycle = GameObject.Find("DayAndNightSystem").GetComponent <DayNightCycle>(); createStars(); }
void Start() { // copy all actions into array var allActions = new List <ActionBt>(); if (actions == null) { Debug.LogError(gameObject.name + " has no actions assigned in his action set"); return; } actions.ForEach((a) => { if (a == null) { Debug.LogError("No actions assigned to: " + gameObject.name); return; } allActions.AddRange(a.actions); }); // initialise agent agent = new PriorityPlanningAgent(this.gameObject.name, allActions.ToArray(), () => timeControl.SunTime); agent.logger = this.UnityLog; // we need to keep time in order to filter actions by expiration if (timeControl == null) { timeControl = GameObject.FindObjectOfType <DayNightCycle>(); } }
void DayNightCheck() { DayNightCycle dayNightRef = FindObjectOfType <DayNightCycle>(); bool isDayRef = false; if (dayNightRef.isDay) { isDayRef = true; } else { isDayRef = false; } if (isDay != isDayRef) { isDay = isDayRef; if (isDay == false) { SetNight(); } } }
// Start is called before the first frame update void Start() { outliner = GetComponent <Outline>(); player = PlayerMovement.FindObjectOfType <PlayerMovement>(); cycle = DayNightCycle.FindObjectOfType <DayNightCycle>(); }
private void Start() { dayNightCycle = DayNightCycle.instance; dayNightCycle.FullHourEventCallBack.AddListener(StartShadows); LevelManager.instance.EventLevelLoaded.AddListener(ResetShadows); ResetShadows(); }
public override void ChangeCycle(DayNightCycle newCycle) { cycle = newCycle; switch (newCycle) { case DayNightCycle.Day: WalkTo(farm.GetClosestWaypoint(transform.position)); ateToday = false; currentState = iguanaState.gathering; break; case DayNightCycle.Afternoon: break; case DayNightCycle.Night: WalkTo(wpWell); currentState = iguanaState.sleeping; if (!ateToday) { Die(); } break; default: break; } }
private void OnEnable() { triggerCollider = GetComponent <Collider>(); sunScript = GameObject.FindWithTag("Sun").GetComponent <DayNightCycle>(); fadeLineLength = (fadeStart.position - fadeEnd.position).magnitude; }
void Start() { CableTarget = transform; levelStart = FindObjectOfType <LevelStart>(); DayNightCycle = FindObjectOfType <DayNightCycle>(); rb = GetComponent <Rigidbody2D>(); playerSpawnPos = transform.position; deathController = GetComponent <PlayerDeathController>(); spriteRendered = anim.gameObject.GetComponent <SpriteRenderer>(); if (spriteRendered.gameObject.transform.GetChild(0)) { CableTarget = spriteRendered.gameObject.transform.GetChild(0); } CableNextDistance = CableMinDistance; CableLineRendered.SetPosition(0, playerSpawnPos); if (hasCable) { CableLineRendered.SetPosition(1, CableTarget.position); } CanEatLastCablePosition = false; }
protected virtual void OnSceneGUI() { DayNightCycle _target = (DayNightCycle)target; EditorGUI.BeginChangeCheck(); if (_target.light == null || _target.moonLightGo == null || _target.moonLight == null) { return; } if (Event.current.type == EventType.Repaint) { Transform transform = _target.transform; Handles.color = _target.light.color; Handles.ArrowHandleCap( 0, transform.position + transform.forward * 3, transform.rotation, Vector3.Distance(Camera.current.transform.position, _target.transform.position) / 5, EventType.Repaint ); } EditorGUI.EndChangeCheck(); }
public override void OnInspectorGUI() { _target = (SetDayNightCycle)target; DrawDefaultInspector(); // if (Application.isPlaying) { return; } GUILayout.Space(20); GUILayout.BeginVertical(EditorStyles.helpBox); bool HasDayNightCycle = DayNightCycle != null; string messageLog; if (HasDayNightCycle) { GUI.color = Color.green; messageLog = "Has ( " + DayNightCycle.gameObject.name + " ) to preview"; } else { GUI.color = new Color(1f, 0.5f, 0.5f); messageLog = "No ( DayNightCycle ) exist to preview"; if (spawnDayNightCycle != null) { if (GUILayout.Button("Spawn DayNightCycle to Preview")) { DayNightCycle _spawnedDayNight = (DayNightCycle)PrefabUtility.InstantiatePrefab(spawnDayNightCycle); DayNightCycle = _spawnedDayNight; RefreshDayNight(); EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene()); } } } GUILayout.Label(messageLog); GUI.color = Color.white; //======================================================== EditorGUI.BeginChangeCheck(); SerializedProperty overrideTime_p = serializedObject.FindProperty(nameof(_target.overrideTime)); EditorGUILayout.PropertyField(overrideTime_p, new GUIContent("Preview Time")); serializedObject.ApplyModifiedProperties(); if (EditorGUI.EndChangeCheck()) { RefreshDayNight(); } //============================================== GUILayout.EndVertical(); }
private void Update() { if (!bInitialised) { return; } float delta = Time.deltaTime; if (delta <= 0f) { return; } float power = this.powerSource.GetPower(); if (power >= this.regenerationThreshhold) { return; } DayNightCycle main = DayNightCycle.main; if (main == null) { return; } //int count = base.modules.GetCount(TechType.SeamothSolarCharge); float depthScalar = Mathf.Clamp01((Constants.kMaxSolarChargeDepth + gameObject.transform.position.y) / Constants.kMaxSolarChargeDepth); float localLightScalar = main.GetLocalLightScalar(); float rechargeAmount = this.regenerationRate * delta * localLightScalar * depthScalar; //Log.LogDebug($"Adding rechargeAmount {rechargeAmount} to solar cell; delta = {delta}, regenerationRate = {this.regenerationRate}, localLightScalar = {localLightScalar}, depthScalar = {depthScalar}"); this.powerSource.SetPower(Mathf.Min(power + rechargeAmount, this.regenerationThreshhold)); }
// Use this for initialization void Start() { myT = GetComponent <RectTransform>(); slider = GetComponent <Image>(); cycle = FindObjectOfType <DayNightCycle>(); startPos = myT.transform.position; }
internal void Setup(FCSDeepDrillerController mono) { _mono = mono; _isConstructed = () => mono.IsConstructed; if (_containerRoot == null) { QuickLogger.Debug("Initializing Deep Driller StorageRoot"); var storageRoot = new GameObject("DeepDrillerStorageRoot"); storageRoot.transform.SetParent(mono.transform, false); _containerRoot = storageRoot.AddComponent <ChildObjectIdentifier>(); } if (_container == null) { QuickLogger.Debug("Initializing Deep Driller Container"); _container = new ItemsContainer(_containerWidth, _containerHeight, _containerRoot.transform, FCSDeepDrillerBuildable.StorageContainerLabel(), null); _container.Resize(_containerWidth, _containerHeight); _container.isAllowedToAdd += IsAllowedToAdd; _container.onRemoveItem += OnRemoveItemEvent; } DayNightCycle main = DayNightCycle.main; //if (_timeSpawnMedKit < 0.0 && main) //{ // this._timeSpawnMedKit = (float)(main.timePassed + (!this.startWithMedKit ? (double)MedKitSpawnInterval : 0.0)); //} }
private void Awake() { cachedOxygenManager = Player.main.oxygenMgr; cachedDayNight = DayNightCycle.main; cachedTemp = WaterTemperatureSimulation.main; SeraLogger.Message(Main.modName, "SpecialtyTanks is Awake() and running!"); }
// Start is called before the first frame update void Start() { characterStats = GetComponent <CharacterStats>(); time = GameObject.Find("Time").GetComponent <DayNightCycle>(); characterStats.nav.destination = new Vector3(transform.position.x + Random.Range(-3, 4), 0, transform.position.z + Random.Range(-3, 4)); characterSpeed = characterStats.nav.speed; }
public override void ChangeCycle(DayNightCycle newCycle) { if (isNocturnal) { NocturnalCycle(newCycle); } else { switch (newCycle) { case DayNightCycle.Day: shouldSmooth = true; WalkTo(farm.GetClosestWaypoint(transform.position)); fov.ContinueFOV(); break; case DayNightCycle.Afternoon: WalkTo(ocio.GetClosestWaypoint(transform.position)); fov.ContinueFOV(); shouldSmooth = false; shouldPause = true; break; case DayNightCycle.Night: WalkTo(wpHome); fov.StopFOV(); break; } } }
protected override bool HasAmbientEnergy(ref float ambientEnergyStatus) { ambientEnergyStatus = 0f; if (Cyclops.transform.position.y < -MaxSolarDepth) { return(false); } depthRatio = Mathf.Clamp01((MaxSolarDepth + Cyclops.transform.position.y) / MaxSolarDepth); DayNightCycle daynightCycle = DayNightCycle.main; if (daynightCycle == null) { return(false); } lightRatio = daynightCycle.GetLocalLightScalar(); bool hasEnergy = lightRatio > 0.05f; rechargeRatio = depthRatio * lightRatio; if (hasEnergy) { ambientEnergyStatus = rechargeRatio * PercentageMaker; } return(hasEnergy); }
// Update is called once per frame void Update() { sunLightDirection = sunLight.transform.TransformDirection(-Vector3.forward); cameraHeight = skyDomeCamera.position.magnitude; cameraHeight2 = cameraHeight * cameraHeight; DayNightCycle dayNightScript = GetComponent <DayNightCycle>(); float sunPosition = dayNightScript.sunPosition; cloudAlpha = calculateCloudAlpha(sunPosition); material.SetVector("_CameraPosition", new Vector4(skyDomeCamera.position.x, skyDomeCamera.position.y, skyDomeCamera.position.z, 0)); material.SetVector("_LightDirection", new Vector4(sunLightDirection.x, sunLightDirection.y, sunLightDirection.z, 0)); material.SetColor("_InvWaveLength", invWaveLength); material.SetFloat("_CameraHeight", cameraHeight); material.SetFloat("_CameraHeight2", cameraHeight2); material.SetFloat("_OuterRadius", outerRadius); material.SetFloat("_InnerRadius", innerRadius); material.SetFloat("_RayleighConstant", rayleighConstant); material.SetFloat("_MieConstant", mieConstant); material.SetFloat("_SunBrightness", sunBrightness); material.SetFloat("_ScaleDepth", scaleDepth); material.SetFloat("_NSamples", nSamples); material.SetFloat("_SymmetryConstant", symmetryConstant); material.SetTexture("_FewClouds", fewCloudsTexture); material.SetTexture("_ManyClouds", manyCloudsTexture); material.SetFloat("_CloudAlpha", cloudAlpha); material.SetFloat("_GameTime", Time.time * cloudSpeed * 0.005f); material.SetFloat("_LightDim", weather); }
void Start() { Popup.SetActive(false); StartCoroutine("TimeOfDayFiniteStateMachine"); //Start TimeOfDayFiniteStateMachine on Start up _dayPhases = DayPhases.Night; //Set day phase to night on start up _hours = 0; //hours equal five on start up _minutes = 0; //minutes equals fifty nine on start up _counter = 0; //Counter equals fifty nine on start up //date.time.now 현재시간 가져오기 //저장기능 가져오기 _days = 1; //Days equal one on start up if (_instance == null) { _instance = this; } else { Destroy(gameObject); } }
private void updateDayNightCycle() { minuteTimer += Time.deltaTime; if (minuteTimer >= timeForMinute) { minuteTimer = 0.0f; currentMinute += 1; if (currentMinute >= minutesPerHour) { currentMinute = 0; currentHour += 1; if (currentHour >= dayLength) { currentHour = 0; currentDay += 1; ui.updateDay(currentDay); } if (currentHour < dayLength / 2) { currentCycle = DayNightCycle.DAY; } else { currentCycle = DayNightCycle.NIGHT; } ui.updateHour(currentHour); } ui.updateMinute(currentMinute); } }
// Set the day/night cycle of area // type = NWNX_AREA_DAYNIGHTCYCLE_* public static void SetDayNightCycle(uint area, DayNightCycle type) { Internal.NativeFunctions.nwnxSetFunction(PLUGIN_NAME, "SetDayNightCycle"); Internal.NativeFunctions.nwnxPushInt((int)type); Internal.NativeFunctions.nwnxPushObject(area); Internal.NativeFunctions.nwnxCallFunction(); }
private void onInit(NetIncomingMessage msg) { m_myOnlineId = msg.ReadByte(); m_rankProgress = (float)(int)msg.ReadByte() / 255f; m_gold = msg.ReadInt32(); float a_progress = msg.ReadFloat(); float a_speed = msg.ReadFloat(); DayNightCycle dayNightCycle = (DayNightCycle)Object.FindObjectOfType(typeof(DayNightCycle)); if (null != dayNightCycle) { dayNightCycle.Init(a_progress, a_speed); } InitStaticBuildings(); int num = msg.ReadByte(); Debug.Log("Init: other players: " + (num - 1)); int num2 = 0; for (int i = 0; i < num; i++) { num2 = msg.ReadByte(); if (num2 < 0 && num2 > m_playerData.Length - 1) { num2 = m_playerData.Length - 1; } m_playerData[num2].name = msg.ReadString(); m_playerData[num2].aid = msg.ReadUInt64(); m_playerData[num2].handItem = msg.ReadByte(); m_playerData[num2].look = msg.ReadByte(); m_playerData[num2].skin = msg.ReadByte(); m_playerData[num2].body = msg.ReadByte(); m_playerData[num2].rank = msg.ReadByte(); m_playerData[num2].karma = msg.ReadByte(); m_playerData[num2].type = (eCharType)msg.ReadByte(); } int num3 = msg.ReadInt16(); Debug.Log("Init: npcs: " + num3); for (int j = 0; j < num3; j++) { num2 = j; if (num2 < 0 && num2 > m_npcData.Length - 1) { num2 = m_npcData.Length - 1; } m_npcData[num2].handItem = msg.ReadByte(); m_npcData[num2].look = msg.ReadByte(); m_npcData[num2].body = msg.ReadByte(); m_npcData[num2].type = (eCharType)msg.ReadByte(); } int num4 = 0; while (msg.PositionInBytes < msg.LengthBytes && GetAndUpdateBuilding(msg)) { num4++; } Debug.Log("Init: static buildings: " + num4); DebugLogReadWriteMismatch(msg, "onInit"); }
protected virtual void OnSceneGUI() { DayNightCycle _target = (DayNightCycle)target; if (!_target.gameObject.scene.IsValid() || StageUtility.GetMainStage() == null) { return; } if (_target.sunLight == null || Camera.current == null) { return; } if (Event.current.type == EventType.Repaint) { Handles.color = _target.sunLight.color; Handles.ArrowHandleCap( 0, _target.sunLight.transform.position + _target.sunLight.transform.forward, _target.sunLight.transform.rotation, Vector3.Distance(Camera.current.transform.position, _target.transform.position) / 5, EventType.Repaint ); } }
private void Start() { if (this.dayNightCycle == null) { this.dayNightCycle = GameObject.FindObjectOfType <DayNightCycle>(); } }
private void Start() { dayNightCycle = DayNightCycle.instance; dayNightCycle.FullHourEventCallBack.AddListener(StartGlow); material = spriteMaterial.material; initialIntensity = material.GetColor("_EmissionColor"); }
void Start() { currentWave = startingWave; dayNightCycle = GetComponent <DayNightCycle> (); reportManager = GetComponent <ReportManager> (); reportNew = viewReportButton.transform.Find("Image").gameObject; }
void Start() { sun = GameObject.Find("Sun").GetComponent <Light>(); timer = 0f; newTime(); curWeather = "Sunny"; blender = 0f; sun.intensity = 1.6f; dayTracker = sun.gameObject.GetComponent <DayNightCycle>(); //--Set rain state var emission = rain.GetComponent <ParticleSystem>().emission; rainRate = 0f; emission.rateOverTime = rainRate; rain.GetComponent <ParticleSystem>().Play(); //--Set fog RenderSettings.fogColor = clearFog_day; RenderSettings.fogEndDistance = 650f; fader = 1f; //--Clouds currentDensity_low = 1.5f; currentDensity_high = 1.7f; cloudColor_low = day_sunnyCloudColor_low; cloudColor_high = day_sunnyCloudColor_high; }
private void Start() { dayNightCycle = DayNightCycle.instance; playerAttributes.AddAttribute("Energy"); playerAttributes.AddAttribute("Hydration"); playerAttributes.SetAttributeValue("Energy", 10); playerAttributes.SetAttributeValue("Hydration", 100); }
// Use this for initialization void Start() { Cycle = this; dayElapsed = dayStart; updateElapsed = updateThreshold; me = GetComponent<Light>(); }
// Use this for initialization void Awake() { if (Instance != null) { Debug.LogError("More than one DayNightCycle in scene!"); return; } Instance = this; sunIntensity = sun.intensity; NPCs = FindObjectsOfType (typeof(NPC)) as NPC[]; audio = this.GetComponent<AudioSource> (); skyboxColor = new Color (.5f, .5f, .5f);//RenderSettings.skybox.GetColor("_Tint"); }
// Update is called once per frame void Update() { if (Cycle == null) Cycle = this; updateElapsed += Time.deltaTime; dayElapsed += Time.deltaTime; if (updateElapsed >= updateThreshold) { updateElapsed -= updateThreshold; if (dayElapsed >= dayLength) dayElapsed -= dayLength; float percentage = dayElapsed / dayLength; UpdateAngle(percentage); UpdateIntensity(percentage); } }
public Game(IDrawer drawer, uint width, uint height) { curRect.Width = width; curRect.Height = height; Intervals = Observable.Interval(TimeSpan.FromMilliseconds(TimeStep)); _unityContainer = new UnityContainer(); this.RegisterInUnityContainer(); StateQueueManager = _unityContainer.Resolve<StateQueueManager>(); Map = _unityContainer.Resolve<Map>(); loadSaveManager = new LoadSaveManager(); loadSaveManager.LoadSnapshot(Map); _hero = _unityContainer.Resolve<Hero>(); _hero.Map = Map; ActionRepository = _unityContainer.Resolve<IActionRepository>(); _drawer = drawer; Intervals.Subscribe(StateQueueManager); _dayNightCycle = new DayNightCycle(); Intervals.Subscribe(_dayNightCycle); }
// Use this for initialization void Start () { lightInstance = GetComponent<Light>(); lightStr = lightInstance.intensity; DNC = FindObjectOfType<DayNightCycle>(); }
// Use this for initialization void Start() { mScarecrow = FindObjectOfType(typeof(Scarecrow)) as Scarecrow; mCrow = FindObjectOfType(typeof(Crow)) as Crow; mCornStalks = FindObjectsOfType(typeof(CornStalk)) as CornStalk[]; dialogMesh = FindObjectOfType(typeof(TextMesh)) as TextMesh; dialogMesh.renderer.enabled = false; dialogTimeDisplayed = 0f; lastDialogDay = 0; lastDialogLine = 0; batteryIcon = (Texture2D) Resources.Load("PowerIcon", typeof(Texture2D)); batteryMeterColor = Color.green; hungerMeterColor = Color.green; stressMeterColor = Color.green; batteryMeterTexture = GetMeterTexture(batteryMeterColor); hungerMeterTexture = GetMeterTexture(hungerMeterColor); stressMeterTexture = GetMeterTexture(stressMeterColor); dnc = FindObjectOfType(typeof(DayNightCycle)) as DayNightCycle; crowKnownDead = false; robotKnownDead = false; cornKnownDead = false; crowDeadLines = new string[18]; crowDeadLines[0] = "Oh God! What have I done!?"; crowDeadLines[1] = "Filbert. I had named him Filbert."; crowDeadLines[2] = "What do I do now?"; crowDeadLines[3] = "I'm so sorry Filbert. I'm so sorry..."; crowDeadLines[4] = "I... don't know what to do..."; crowDeadLines[5] = "Thought up a song for Filbert today.\nHe would have liked it, I think"; crowDeadLines[6] = "Why did you have to die?"; crowDeadLines[7] = "I miss you..."; crowDeadLines[8] = "Was this all I was created for?"; crowDeadLines[9] = "Where do I go from here?"; crowDeadLines[10] = "Filbert... Filbert... where are you..."; crowDeadLines[11] = "Where are you God?"; crowDeadLines[12] = "Why am I here?"; crowDeadLines[13] = "Life is meaningless..."; crowDeadLines[14] = "The corn does not need me."; crowDeadLines[15] = "The corn does not want me."; crowDeadLines[16] = "I don't want this anymore."; crowDeadLines[17] = "What's the point?"; audio.clip = kNormalMusic; audio.Play(); menuTimer = 0f; }
void Update() { if (dayNight == null) { dayNight = (DayNightCycle)GameObject.FindObjectOfType (typeof(DayNightCycle)); } if (Network.isServer) { if (dayNight) { if (networkViewer) networkViewer.RPC ("dayTimeUpdate", RPCMode.Others, dayNight.Timer); } } }
void Awake() { // Find the DayNightController game object by its name and get the DayNightController script on it. controller = GameObject.Find("GameMaster").GetComponent<DayNightCycle>(); }
void Start() { m_DayNightCycle = FindObjectOfType<DayNightCycle> (); m_CurrentWaveCenter = transform.position.y; }
// Use this for initialization void Start() { if (isServer) { this.dnc = gameObject.GetComponent<DayNightCycle>(); this.nameWorld = GameObject.Find("NetworkManager").GetComponent<NetworkManagerHUD>().World; this.respawn = new List<Vector2>[4] { new List<Vector2>(), new List<Vector2>(), new List<Vector2>(), new List<Vector2>() }; this.chunks = new List<ChunkSave>(); this.players = new List<PlayerSave>(); this.worldPath = Application.dataPath + "/Saves/" + this.nameWorld + "/"; this.chunksPath = worldPath + "/Chunks/"; this.playersPath = worldPath + "/Players/"; // Set world properties string[] world = File.ReadAllLines(this.worldPath + "properties"); string[] properties = world[0].Split('|'); this.seed = int.Parse(properties[0]); this.isCoop = bool.Parse(properties[1]); this.dnc.SetTime(float.Parse(properties[2])); Stats.Load(world[1]); // Find cristals string[] chunksName = Directory.GetFiles(this.chunksPath); foreach (string chunk in chunksName) { if (!chunk.EndsWith(".meta")) { Tuple<Vector2, Team> info = GetCristalInfo(chunk); if (info != null && info.Item2 != Team.Neutre) this.respawn[(int)info.Item2].Add(info.Item1); } } for (int i = 0; i < 4; i++) if (this.respawn[i].Count == 0) this.respawn[i].Add(new Vector2(0, 0)); } }