private void Right_Button() { GameObject Light = gameObject.transform.FindChild("Rantan").gameObject; LightSystem hoge = Light.GetComponent <LightSystem>(); hoge.Lighting(); }
//RenderTexture iterativeRT1; //RenderTexture iterativeRT2; // Use this for initialization void Awake() { lightSystem = FindObjectOfType <LightSystem> (); if (lightSystem == null) { throw new UnityException("Scene missing LightSystem"); } if (!GetComponent <Camera> ()) { throw new UnityException("Ambient Light Script should be attached to ambient obstacle camera"); } lightAmbientRT = lightSystem.GetAmbientRT(); lightAmbientObstacleRT = lightSystem.GetLightAmbientObstacleRT(); /*iterativeRT1 = new RenderTexture (lightAmbientRT.width, lightAmbientRT.height, lightAmbientRT.depth); * iterativeRT1.Create (); * iterativeRT2 = new RenderTexture (lightAmbientRT.width, lightAmbientRT.height, lightAmbientRT.depth); * iterativeRT2.Create ();*/ ambientLightMaterial = new Material(Shader.Find("Lighting/AmbientLight")); ambientLightMaterial.SetTexture("_ObstacleTex", lightAmbientObstacleRT); //ambientLightMaterial.SetColor ("_AmbientColor", ambientColor); ambientLightMaterial.SetFloat("_ObstacleMul", obstacleMul); ambientLightMaterial.SetFloat("_SamplingDist", samplingDist); }
// Use this for initialization void Start() { lightSystem = FindObjectOfType <LightSystem> (); if (lightSystem == null) { throw new UnityException("Scene missing light system gameobject"); } renderer = GetComponent <Renderer> (); if (renderer == null) { throw new UnityException("Missing Renderer component in light source"); } if (centerGizmo) { centerPos = centerGizmo.position; } else { centerPos = transform.position; } Material material = new Material(Shader.Find("Lighting/LightSource")); material.mainTexture = renderer.material.mainTexture; material.SetTexture("_ObstacleTex", lightSystem.GetLightObstacleRT()); material.SetFloat("_ObstacleMul", obstacleMul); material.SetVector("_centerPos", new Vector4(centerPos.x, centerPos.y, 1, 1)); material.SetColor("_ColorTint", colorTint); renderer.material = material; }
public static void PropInstancePopulateGroupData(PropInfo info, int layer, InstanceID id, Vector3 position, Vector3 scale, Vector3 angle, ref int vertexIndex, ref int triangleIndex, Vector3 groupPosition, RenderGroup.MeshData data, ref Vector3 min, ref Vector3 max, ref float maxRenderDistance, ref float maxInstanceDistance) { LightSystem lightSystem = RenderManager.instance.lightSystem; if (info.m_prefabDataLayer == layer) { float y = info.m_generatedInfo.m_size.y * scale.y; float num = Mathf.Max(info.m_generatedInfo.m_size.x, info.m_generatedInfo.m_size.z) * scale.y * 0.5f; min = Vector3.Min(min, position - new Vector3(num, 0f, num)); max = Vector3.Max(max, position + new Vector3(num, y, num)); maxRenderDistance = Mathf.Max(maxRenderDistance, info.m_maxRenderDistance); maxInstanceDistance = Mathf.Max(maxInstanceDistance, info.m_maxRenderDistance); } else if (info.m_effectLayer == layer || (info.m_effectLayer == lightSystem.m_lightLayer && layer == lightSystem.m_lightLayerFloating)) { Matrix4x4 matrix4x = default; matrix4x.SetTRS(position, Quaternion.AngleAxis(angle.x, Vector3.left) * Quaternion.AngleAxis(angle.y, Vector3.down) * Quaternion.AngleAxis(angle.z, Vector3.back), scale); for (int i = 0; i < info.m_effects.Length; i++) { Vector3 pos = matrix4x.MultiplyPoint(info.m_effects[i].m_position); Vector3 dir = matrix4x.MultiplyVector(info.m_effects[i].m_direction); info.m_effects[i].m_effect.PopulateGroupData(layer, id, pos, dir, ref vertexIndex, ref triangleIndex, groupPosition, data, ref min, ref max, ref maxRenderDistance, ref maxInstanceDistance); } } }
// Use this for initialization void Start() { // initialize all MazeTools MazeTool[] tools = { top, bottom, left, right, back, front }; for (int i = 0; i < tools.Length; i++) { tools[i].Start(); tools[i].gameObject.SetActive(false); } // initialize the MazeStructure mazeStruct = new MazeStructure(top, bottom, left, right, front, back, radius); cells = mazeStruct.MakeCells(cellFloor, cellWalls, cellWallTops, cellFloorMat, cellWallMat, cellWallTopMat, lightFlicker, radius); // initialize this transform.position = mazeStruct.GetStartSphere(); skyboxMaterial = Resources.Load <Material>("Overcast2 Skybox"); skyboxMaterial.SetColor("_Tint", new Color32((byte)128, (byte)128, (byte)128, (byte)128)); GetComponent <OVRCameraRig>().Init(); this.playerRigid = gameObject.AddComponent <Rigidbody> (); this.playerRigid.freezeRotation = true; Physics.gravity = Vector3.zero; SphereCollider collider = gameObject.AddComponent <SphereCollider>(); collider.material = (PhysicMaterial)Resources.Load("WallPhysics", typeof(PhysicMaterial)); collider.radius = 1.5f; collider.center = new Vector3(0, .4f, 0); // initialize other objects Vector3 keyPos = mazeStruct.FindKeySphere().normalized *(radius - 2.5f); Quaternion keyRot = Quaternion.LookRotation(Vector3.Cross(-keyPos, Vector3.one), -keyPos); key = (Key)Instantiate(key, keyPos, keyRot); cLight = ((GameObject)Instantiate(cLight.gameObject, cLight.gameObject.transform.localPosition, Quaternion.identity)).GetComponent <Light>(); lights = ((GameObject)Instantiate(lights.gameObject, new Vector3(85.4f, 100f, 100f), Quaternion.identity)).GetComponent <LightSystem>(); lamp = ((GameObject)Instantiate(lamp.gameObject, lamp.gameObject.transform.localPosition, Quaternion.identity)).GetComponent <Lamp>(); lamp.transform.rotation = Quaternion.Euler(70.7834f, 342.207f, 321.425f); lamp.gameObject.SetActive(false); lantern = GameObject.Find("Lantern"); lantern.SetActive(false); // create and initialize player and monster //print("Monster: "+monster); monster = (Monster)Instantiate(monster, new Vector3(4.79f, 47.36f, -.038f), Quaternion.identity); AudioSource src = gameObject.AddComponent <AudioSource>(); src.clip = lightsOutInit; monster.gameObject.SetActive(false); angle = Mathf.PI / 2; AudioSource src1 = gameObject.AddComponent <AudioSource>(); src1.clip = lightOff; lights.Init(mazeStruct, cells, src1); }
private void InitMainSystems() { transformsSystem = ECSWorld.AddSystem <TransformsSystem>(); camerasSystem = ECSWorld.AddSystem <CamerasSystem>(); lightSystem = ECSWorld.AddSystem <LightSystem>(); renderSystem = ECSWorld.AddSystem <RenderSystem>(); ECSWorld.Refresh(); }
private void Awake() { system = SmartHomeController.GetSystem <LightSystem>(); lightNames = system.GetDeviceNames(); groupNameList = system.GetGroupNames(); UIHelper.PopulateList(lightList, lightNames); UIHelper.PopulateList(groupList, groupNameList); Console.WriteLine("Populate the Group and Light Lists"); }
public void ExplorerDiff() { LightSystem lightsys = new LightSystem(); lightsys.drainrate = 0; string convertedData = JsonUtility.ToJson(lightsys); System.IO.File.WriteAllText(Application.persistentDataPath + "/" + "lightsys", convertedData); SceneManager.LoadScene(1); }
private void OnTriggerEnter2D(Collider2D collision) { if(collision.GetComponent<CharacterMovement>()) { pcInside = true; } if(collision.GetComponent<LightSystem>()) { ls = collision.GetComponent<LightSystem>(); } }
// Start is called before the first frame update void Start() { Instructions.enabled = false; musicManager = FindObjectOfType <MusicManager>(); GameState = GameState.Introduction; player = FindObjectOfType <PlayerController>(); lightSystem = FindObjectOfType <LightSystem>(); batteryBank = FindObjectOfType <BatteryBank>(); blackImage.enabled = false; winText.enabled = false; gameOverText.enabled = false; playAgain.enabled = false; }
// Start is called before the first frame update void Start() { rb2d = GetComponent <Rigidbody2D>(); spriteRenderers = GetComponentsInChildren <SpriteRenderer>(); animators = GetComponentsInChildren <Animator>(); playerCollider = GetComponent <Collider2D>(); gameManager = FindObjectOfType <GameManager>(); musicManager = FindObjectOfType <MusicManager>(); narrationManager = FindObjectOfType <NarrationManager>(); batteryBank = FindObjectOfType <BatteryBank>(); lightSystem = FindObjectOfType <LightSystem>(); }
// Use this for initialization void Start() { lightSystem = FindObjectOfType <LightSystem> (); if (lightSystem == null) { throw new UnityException("Scene missing light system gameobject"); } blitMaterial = new Material(Shader.Find("Lighting/Mixer")); blitMaterial.SetTexture("_LightTex", lightSystem.GetLightSourceRT()); blitMaterial.SetTexture("_AmbientLightTex", lightSystem.GetAmbientRT()); blitMaterial.SetFloat("_Scale", lightSystem.lightCameraOverlap); }
// Start is called before the first frame update void Start() { gameManager = FindObjectOfType <GameManager>(); spriteRenderer = GetComponent <SpriteRenderer>(); Collider = GetComponent <Collider2D>(); batteryBank = FindObjectOfType <BatteryBank>(); narrationManager = FindObjectOfType <NarrationManager>(); state = startState; //InDarkZone = CheckInDarkZone(); lightSystem = GetComponentInParent <LightSystem>(); }
// Start is called before the first frame update void Start() { currentLight = baseLight; lightBar.value = currentLight; LightSystem loadedLightSys = new LightSystem(); JsonUtility.FromJsonOverwrite(File.ReadAllText(Application.persistentDataPath + "/lightsys"), loadedLightSys); drainrate = loadedLightSys.drainrate; if (drainrate == 0) { infImg.SetActive(true); } }
public bool Init() { string sceneConfigPath = Application.dataPath + "/" + LightingData.constConfigPath; string scenePath = Application.dataPath + "/Res/Scene/"; Scene curScene = SceneManager.GetActiveScene(); if (curScene == null) { window.Close(); window = null; UnityEditor.EditorUtility.DisplayDialog("Title", "请先打开场景", "是"); return(false); } m_sceneName = curScene.name; lightSystem = new LightSystem(new LightingData(curScene.name, sceneConfigPath, SceneTools.getConfigPath(), scenePath)); recoverSystem = new LightRecoverSystem(new LightingData(curScene.name, sceneConfigPath, SceneTools.getConfigPath(), scenePath)); lightSystem.OnInit(); Lightmapping.completed = lightSystem.BakeOver; return(true); }
void Start() { _lightS = new LightSystem(transform.localScale); _minLightScale = _lightS.getMinLightScale(); }
// Update is called once per frame void Update() { //Update score scoreTxt.text = score.ToString(); //if we are not in the middle of a movement if (!anim.GetCurrentAnimatorStateInfo(0).IsTag("moving")) { if (ObjVelocity.y > 0.05) { anim.SetTrigger("Right"); sfx.clip = clips[Random.Range(0, clips.Length)]; sfx.Play(); } else if (ObjVelocity.y < -0.05) { sfx.clip = clips[Random.Range(0, clips.Length)]; sfx.Play(); anim.SetTrigger("Left"); } } if (dead) { Die(); } if (Input.GetKey(KeyCode.Escape)) { //Show pause menu and unlock cursor pauseMenu.SetActive(true); //Re enable fps controller (Player.GetComponent("FirstPersonController") as MonoBehaviour).enabled = false; Cursor.lockState = CursorLockMode.None; Cursor.visible = true; } if (Input.GetMouseButtonDown(0) && !dead && !pauseMenu.activeInHierarchy) { if (tutorial.activeInHierarchy) { tutorial.SetActive(false); } LightSystem.lanternUp = true; lightobj.gameObject.SetActive(true); fireImg.SetActive(true); sfx.clip = clips[Random.Range(0, clips.Length)]; sfx.Play(); anim.SetTrigger("Up"); } if (Input.GetMouseButtonUp(0) && LightSystem.lanternUp && !dead && !pauseMenu.activeInHierarchy) { LightSystem.lanternUp = false; sfx.clip = clips[Random.Range(0, clips.Length)]; sfx.Play(); lightobj.gameObject.SetActive(false); fireImg.SetActive(false); anim.SetTrigger("Down"); } Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; float dist = 15f; if (Physics.Raycast(ray, out hit, dist) && hit.transform.tag == "Oil") { //Show UI hit.transform.GetComponentInChildren <Canvas>().GetComponentInChildren <Text>().text = "e"; lastobj = hit.transform.gameObject; //Pick up if player presses e if (Input.GetKey("e") && !dead) { //Add random amount of light LightSystem.AddLight(Random.Range(55, 125)); //Update bar LightSystem.updateVal = true; //Delete model Destroy(hit.transform.gameObject); //Cap at max value if (LightSystem.currentLight > LightSystem.baseLight) { LightSystem.currentLight = LightSystem.baseLight; } } } else { try { //Hide UI lastobj.GetComponentInChildren <Canvas>().GetComponentInChildren <Text>().text = ""; } catch { } } }
public static bool LateUpdate(RenderManager __instance, CameraInfo ___m_cameraInfo, uint ___m_currentFrame, LightSystem ___m_lightSystem, FastList <IRenderableManager> ___m_renderables) { ___m_currentFrame++; __instance.m_outOfInstances = false; PrefabPool.m_canCreateInstances = 1; ___m_lightSystem.m_lightBuffer.Clear(); __instance.m_overlayBuffer.Clear(); Singleton <InfoManager> .instance.UpdateInfoMode(); if (Singleton <LoadingManager> .instance.m_loadingComplete) { __instance.UpdateCameraInfo(); //__instance.UpdateColorMap(); UpdateColorMapMethod.Invoke(__instance, new object[0]); try { for (int i = 0; i < ___m_renderables.m_size; i++) { ___m_renderables.m_buffer[i].BeginRendering(___m_cameraInfo); } } finally { } try { Vector3 min = ___m_cameraInfo.m_bounds.min; Vector3 max = ___m_cameraInfo.m_bounds.max; if (___m_cameraInfo.m_shadowOffset.x < 0f) { max.x -= ___m_cameraInfo.m_shadowOffset.x; } else { min.x -= ___m_cameraInfo.m_shadowOffset.x; } if (___m_cameraInfo.m_shadowOffset.z < 0f) { max.z -= ___m_cameraInfo.m_shadowOffset.z; } else { min.z -= ___m_cameraInfo.m_shadowOffset.z; } int num = Mathf.Max((int)((min.x - 128f) / 384f + 22.5f), 0); int num2 = Mathf.Max((int)((min.z - 128f) / 384f + 22.5f), 0); int num3 = Mathf.Min((int)((max.x + 128f) / 384f + 22.5f), 44); int num4 = Mathf.Min((int)((max.z + 128f) / 384f + 22.5f), 44); int num5 = 5; int num6 = 10000; int num7 = 10000; int num8 = -10000; int num9 = -10000; __instance.m_renderedGroups.Clear(); for (int j = num2; j <= num4; j++) { for (int k = num; k <= num3; k++) { int num10 = j * 45 + k; RenderGroup renderGroup = __instance.m_groups[num10]; if (renderGroup != null && renderGroup.Render(___m_cameraInfo)) { __instance.m_renderedGroups.Add(renderGroup); int num11 = k / num5; int num12 = j / num5; int num13 = num12 * 9 + num11; MegaRenderGroup megaRenderGroup = __instance.m_megaGroups[num13]; if (megaRenderGroup != null) { megaRenderGroup.m_layersRendered2 |= (megaRenderGroup.m_layersRendered1 & renderGroup.m_layersRendered); megaRenderGroup.m_layersRendered1 |= renderGroup.m_layersRendered; megaRenderGroup.m_instanceMask |= renderGroup.m_instanceMask; num6 = Mathf.Min(num6, num11); num7 = Mathf.Min(num7, num12); num8 = Mathf.Max(num8, num11); num9 = Mathf.Max(num9, num12); } } } } for (int l = num7; l <= num9; l++) { for (int m = num6; m <= num8; m++) { int num14 = l * 9 + m; __instance.m_megaGroups[num14]?.Render(); } } for (int n = 0; n < __instance.m_renderedGroups.m_size; n++) { RenderGroup renderGroup2 = __instance.m_renderedGroups.m_buffer[n]; int num15 = renderGroup2.m_x / num5; int num16 = renderGroup2.m_z / num5; int num17 = num16 * 9 + num15; MegaRenderGroup megaRenderGroup2 = __instance.m_megaGroups[num17]; if (megaRenderGroup2 != null && megaRenderGroup2.m_groupMask != 0) { renderGroup2.Render(megaRenderGroup2.m_groupMask); } } } finally { } try { #if Debug var allSw = Stopwatch.StartNew(); var dipsSw = new Stopwatch(); var times = new Dictionary <string, long>(); #endif var action = new Action <IRenderableManager>((manager) => { #if Debug var actionSw = Stopwatch.StartNew(); #endif manager.EndRendering(___m_cameraInfo); #if Debug actionSw.Stop(); times[manager.GetType().Name] = actionSw.ElapsedTicks; #endif }); #if UseTask var parallized = new List <IRenderableManager>(); var notParallized = new List <IRenderableManager>(); foreach (var manager in ___m_renderables) { if (Parallized.Contains(manager.GetType().Name)) { parallized.Add(manager); } else { notParallized.Add(manager); } } Patcher.Dispatcher.Clear(); var task = Task.Create(() => { #if Debug Logger.Debug($"Start task (thread={Thread.CurrentThread.ManagedThreadId})"); var tasksw = Stopwatch.StartNew(); #endif foreach (var manager in parallized) { #if Debug var actionDispSw = new Stopwatch(); Patcher.Dispatcher.Add(() => actionDispSw.Start()); #endif action(manager); #if Debug Patcher.Dispatcher.Add(() => times[$"Dispatcher {manager.GetType().Name}"] = actionDispSw.ElapsedTicks); #endif } #if Debug tasksw.Stop(); Logger.Debug($"End task {tasksw.ElapsedTicks}"); #endif }); task.Run(); #if Debug var npSw = Stopwatch.StartNew(); #endif foreach (var manager in notParallized) { action(manager); } #if Debug npSw.Stop(); Logger.Debug($"Not parallized duration {npSw.ElapsedTicks}"); #endif while (!task.hasEnded || !Patcher.Dispatcher.NothingExecute) { #if Debug dipsSw.Start(); #endif Patcher.Dispatcher.Execute(); #if Debug dipsSw.Stop(); #endif } #else for (int num18 = 0; num18 < ___m_renderables.m_size; num18++) { action(___m_renderables.m_buffer[num18]); } #endif #if Debug allSw.Stop(); Logger.Debug($"Dispatcher: Duration={dipsSw.ElapsedTicks}; {nameof(Patcher.Dispatcher.Executed)}={Patcher.Dispatcher.Executed}; {nameof(Patcher.Dispatcher.Count)}={Patcher.Dispatcher.Count}"); Logger.Debug(SWResult("RenderManager.LateUpdate", allSw.ElapsedTicks, allSw.ElapsedTicks)); Logger.Debug(string.Join("", times.Select(t => SWResult(t.Key, t.Value, allSw.ElapsedTicks)).ToArray())); #endif string SWResult(string name, long current, long all) => $"\n{name}={current}({(int)((double)current * 100 / (double)all)}%)"; } finally { } ___m_lightSystem.EndRendering(___m_cameraInfo); } return(false); }
// Start is called before the first frame update void Start() { narrationManager = FindObjectOfType <NarrationManager>(); lightSystem = FindObjectOfType <LightSystem>(); audioSource = GetComponent <AudioSource>(); }