void DrawLight(CustomLight l, Vector3 pos, Quaternion rot, Vector3 size) { Vector3 relpos = Quaternion.Inverse(rot) * (transform.position - pos); // oriented bounding box cheat // get box closest point to sphere center by clamping float x = Mathf.Clamp(relpos.x, -size.x * .5f, size.x * .5f) - relpos.x; float y = Mathf.Clamp(relpos.y, -size.y * .5f, size.y * .5f) - relpos.y; float z = Mathf.Clamp(relpos.z, -size.z * .5f, size.z * .5f) - relpos.z; if (x * x + y * y + z * z < nearRadiusSqr) { DrawQuad(); // Draw a fullscreen quad if the light's box intersects with the camera near-plane boundingsphere (see SetupQuad()) } else { customLightBuf.DrawMesh(boxMesh, Matrix4x4.TRS(pos, rot, size), deferredMat, 0, 0); } }
public override void OnInspectorGUI() { CustomLight l = target as CustomLight; EditorGUILayout.PropertyField(serializedObject.FindProperty("color")); EditorGUILayout.PropertyField(serializedObject.FindProperty("intensity")); EditorGUILayout.PropertyField(serializedObject.FindProperty("cullingMask")); CustomLight.CustomLightType t = l.type; bool same = true; foreach (Object cl in targets) { if (((CustomLight)cl).type != t) { same = false; break; } } EditorGUILayout.PropertyField(serializedObject.FindProperty("type")); if (same) { switch (l.type) { case CustomLight.CustomLightType.Box: EditorGUILayout.PropertyField(serializedObject.FindProperty("boxRadius"), new GUIContent("Extents")); EditorGUILayout.PropertyField(serializedObject.FindProperty("innerBoxRadius"), new GUIContent("Inner Extents")); EditorGUILayout.PropertyField(serializedObject.FindProperty("boxEdgeRadius"), new GUIContent("Edge Radius")); break; case CustomLight.CustomLightType.Capsule: EditorGUILayout.PropertyField(serializedObject.FindProperty("capsuleRadius"), new GUIContent("Radius")); EditorGUILayout.PropertyField(serializedObject.FindProperty("capsuleLength"), new GUIContent("Length")); break; } } serializedObject.ApplyModifiedProperties(); }
public void Remove(CustomLight o) { m_Lights.Remove(o); }
public void Add(CustomLight o) { Remove(o); m_Lights.Add(o); }
private void AddLightRule() { View view = View.Inflate(this, Resource.Layout.Dialog_Input_lightrule, null); EditText editText = (EditText)view.FindViewById(Resource.Id.dialog_input_value); CheckBox chkEnableCustom = view.FindViewById <CheckBox>(Resource.Id.chkEnableCustom); #region 允许灯光 CheckBox chkAllowLowBeam = view.FindViewById <CheckBox>(Resource.Id.chkAllowLowBeamLight); CheckBox chkAllowHighBeam = view.FindViewById <CheckBox>(Resource.Id.chkAllowHighBeamLight); CheckBox chkAllowOutlineLight = view.FindViewById <CheckBox>(Resource.Id.chkAllowOutlineLight); CheckBox chkAllowFogLight = view.FindViewById <CheckBox>(Resource.Id.chkAllowFogLight); CheckBox chkAllowTurnLeftLight = view.FindViewById <CheckBox>(Resource.Id.chkAllowTurnLeftLight); CheckBox chkAllowTurnRightLight = view.FindViewById <CheckBox>(Resource.Id.chkAllowTurnRightLight); CheckBox chkAllowCautionLight = view.FindViewById <CheckBox>(Resource.Id.chkAllowCautionLight); #endregion #region 禁止灯光 CheckBox chkForbidLowBeam = view.FindViewById <CheckBox>(Resource.Id.chkForbidLowBeamLight); CheckBox chkForbidHighBeam = view.FindViewById <CheckBox>(Resource.Id.chkForbidHighBeamLight); CheckBox chkForbidOutlineLight = view.FindViewById <CheckBox>(Resource.Id.chkForbidOutlineLight); CheckBox chkForbidFogLight = view.FindViewById <CheckBox>(Resource.Id.chkForbidFogLight); CheckBox chkForbidTurnLeftLight = view.FindViewById <CheckBox>(Resource.Id.chkForbidTurnLeftLight); CheckBox chkForbidTurnRightLight = view.FindViewById <CheckBox>(Resource.Id.chkForbidTurnRightLight); CheckBox chkForbidCautionLight = view.FindViewById <CheckBox>(Resource.Id.chkForbidCautionLight); #endregion #region 交替灯光 CheckBox chkAlternateLightOne = view.FindViewById <CheckBox>(Resource.Id.chkAlternateLightOne); CheckBox chkAlternateLightTwo = view.FindViewById <CheckBox>(Resource.Id.chkAlternateLightTwo); CheckBox chkAlternateLightThree = view.FindViewById <CheckBox>(Resource.Id.chkAlternateLightThree); CheckBox chkAlternateLightFour = view.FindViewById <CheckBox>(Resource.Id.chkAlternateLightFour); #endregion //进行一个数据绑定 Spinner lightruleSpinner = (Spinner)view.FindViewById(Resource.Id.LightRulespinner); BindSpinner(lstLightRule.Select(s => s.Key).ToList <string>(), lightruleSpinner); builder = new AlertDialog.Builder(this); alertDialog = builder .SetTitle("新增灯光模拟项目") .SetView(view) .SetNegativeButton("取消", (s, e) => { }) .SetPositiveButton("确定", (s, e) => { //保存地图记录地图 string LightRuleName = editText.Text; if (!string.IsNullOrEmpty(LightRuleName)) { if (!chkEnableCustom.Checked) { int position = lightruleSpinner.SelectedItemPosition; LightRule lightRule = new LightRule(); lightRule.ItemCode = lstItemCode[position]; lightRule.ItemName = LightRuleName; lightRule.LightRuleType = string.Format("TwoPole.Chameleon3.Business.Rules.{0},TwoPole.Chameleon3.Business", lstLightRule[position].Value); lightRule.OperDes = lstLightRule[position].Key; lightRule.VoiceText = LightRuleName; lightRule.VoiceFile = LightRuleName; dataService.SaveLightRule(lightRule); InitLightRule(); } else //表示的是自选组合 { CustomLight customLight = new CustomLight(); if (chkAllowLowBeam.Checked) { customLight.Allowlights += "LowBeam,"; } if (chkAllowHighBeam.Checked) { customLight.Allowlights += "HighBeam,"; } if (chkAllowFogLight.Checked) { customLight.Allowlights += "FogLight,"; } if (chkAllowCautionLight.Checked) { customLight.Allowlights += "CautionLight,"; } if (chkAllowOutlineLight.Checked) { customLight.Allowlights += "OutlineLight,"; } if (chkAllowTurnLeftLight.Checked) { customLight.Allowlights += "LeftIndicatorLight,"; } if (chkAllowTurnRightLight.Checked) { customLight.Allowlights += "RightIndicatorLight,"; } if (string.IsNullOrEmpty(customLight.Allowlights)) { return; } customLight.Allowlights = customLight.Allowlights.Substring(0, customLight.Allowlights.Length - 1); if (chkForbidLowBeam.Checked) { customLight.Fobbidlights += "LowBeam,"; } if (chkForbidHighBeam.Checked) { customLight.Fobbidlights += "HighBeam,"; } if (chkForbidFogLight.Checked) { customLight.Fobbidlights += "FogLight,"; } if (chkForbidCautionLight.Checked) { customLight.Fobbidlights += "CautionLight,"; } if (chkForbidOutlineLight.Checked) { customLight.Fobbidlights += "OutlineLight,"; } if (chkForbidTurnLeftLight.Checked) { customLight.Fobbidlights += "LeftIndicatorLight,"; } if (chkForbidTurnRightLight.Checked) { customLight.Fobbidlights += "RightIndicatorLight,"; } if (string.IsNullOrEmpty(customLight.Fobbidlights)) { return; } customLight.Fobbidlights = customLight.Fobbidlights.Substring(0, customLight.Fobbidlights.Length - 1); if (chkAlternateLightOne.Checked) { customLight.AlternateCount = 1; } if (chkAlternateLightTwo.Checked) { customLight.AlternateCount = 2; } if (chkAlternateLightThree.Checked) { customLight.AlternateCount = 3; } if (chkAlternateLightFour.Checked) { customLight.AlternateCount = 4; } LightRule lightRule = new LightRule(); lightRule.ItemCode = "41601"; lightRule.ItemName = LightRuleName; lightRule.LightRuleType = string.Format("TwoPole.Chameleon3.Business.Rules.CustomLightRule,TwoPole.Chameleon3.Business"); lightRule.OperDes = customLight.ToJson(); lightRule.VoiceText = LightRuleName; lightRule.VoiceFile = LightRuleName; } } else { //开始 } }) .Create(); //创建alertDialog对象 alertDialog.Show(); }
//public float fearLevel = 0; //public float maxFearLevel = 50.0f; //public FrostEffect frost; //public int minGhostCountFearLevel = 5; //public float fearRechargeLevel = 5.0f; void Start() { m_StepCycle = 0f; m_NextStep = m_StepCycle / 2f; m_Animator = GetComponent <Animator>(); m_Rigidbody = GetComponent <Rigidbody>(); m_Capsule = GetComponent <CapsuleCollider>(); uc = GetComponent <NetworkedThirdPersonUserControl>(); m_CapsuleHeight = m_Capsule.height; m_CapsuleCenter = m_Capsule.center; m_Camera = GetComponentInChildren <Camera>(); //navMeshAgent = GetComponent<NavMeshAgent>(); m_Rigidbody.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ; m_OrigGroundCheckDistance = m_GroundCheckDistance; lineRenderer = GetComponentInChildren <LineRenderer>(); m_MouseLook.Init(transform, m_Camera.transform); //GetComponentInChildren<Renderer>().material.color = playerColour; playerScore = 0; gameObject.name = playerName; spawnedParticleSystem = ((GameObject)Instantiate(tempDecalParticleSystem, transform.position, Quaternion.identity)).transform; streamPartcileSystem = ((GameObject)Instantiate(streamPartcileSysemGameObject, transform.position, Quaternion.identity)).GetComponentInChildren <ParticleSystem> (); streamShape = streamPartcileSystem.shape; rootParticleSystem = spawnedParticleSystem.GetComponent <ParticleSystem>(); rootMuzzleParticleSystem = muzzleParticleSystem.GetComponent <ParticleSystem>(); rootMuzzleParticleSystem.Stop(); StopParticleSystem(); weaponRechargeRenderer = weaponRechargeIndicator.GetComponent <Renderer>().material; beamRenderer = lineRenderer.GetComponent <Renderer>().material; beamRenderer.SetColor("_Colour", playerColour * 2); for (i = 0; i < playerColourIndicators.Length; ++i) { playerColourIndicators[i].GetComponent <Renderer>().material.SetColor("_EmissionColor", playerColour * 1.5f); } rootMuzzleParticleSystem.startColor = playerColour; var cbs = rootMuzzleParticleSystem.colorBySpeed; var grad = new ParticleSystem.MinMaxGradient(); grad.colorMin = playerColour; grad.colorMax = Color.white; cbs.color = grad; ParticleSystem sparkspsRootMzzle = rootMuzzleParticleSystem.gameObject.transform.FindChild("Sparks").GetComponent <ParticleSystem>(); sparkspsRootMzzle.startColor = playerColour; var cbssparks = sparkspsRootMzzle.colorBySpeed; cbssparks.color = grad; rootParticleSystem.startColor = playerColour; cbs = rootParticleSystem.colorBySpeed; grad = new ParticleSystem.MinMaxGradient(); grad.colorMin = playerColour; grad.colorMax = Color.white; cbs.color = grad; sparkspsRootMzzle = spawnedParticleSystem.transform.FindChild("Sparks").GetComponent <ParticleSystem>(); sparkspsRootMzzle.startColor = playerColour; cbssparks = sparkspsRootMzzle.colorBySpeed; cbssparks.color = grad; lineRenderer.SetVertexCount(20); spawnedCaptureSphere = Instantiate(captureSpherePrefab); spawnedCaptureSphere.SetActive(false); weaponSteam.Stop(true); positionOnSpawn = transform.position; beamLightCLight = beamLight.GetComponentInChildren <CustomLight> (); beamLightCLight.m_Color = playerColour; for (i = 0; i < 50; ++i) { beamLightSegments.Add(((GameObject)Instantiate(beamLight.gameObject)).transform); } for (i = 0; i < 50; ++i) { beamLightSegments [i].parent = beamLight.transform.parent; beamLightSegments [i].GetComponentInChildren <CustomLight> ().m_TubeLength = 0.45f; beamLightSegments [i].GetComponentInChildren <CustomLight> ().m_Size = 0.005f; beamLightCLightSegments.Add(beamLightSegments [i].GetComponentInChildren <CustomLight> ()); beamLightSegments [i].gameObject.SetActive(false); } beamLight.GetComponentInChildren <CustomLight> ().m_Size = 0.02f; beamLight.gameObject.SetActive(false); beamLightCLight.m_Color = Color.cyan; GameManager.instance.players.Add(this); alexRenderer.material.mainTexture = diffuseTextures[playerID]; maskRenderer.material.mainTexture = maskDiffuseTextures[playerID]; if (!isLocalPlayer) { m_Camera.gameObject.SetActive(false); //if(weaponRechargeIndicator) //weaponRechargeIndicator.gameObject.SetActive(false); } if (isLocalPlayer) { GameManager.instance.RegisterRadarHelper(GetComponent <MakeRadarObject>()); //spawnedParticleSystem.gameObject.SetActive(false); FindObjectOfType <SplitscreenManager>().RegisterCamera(m_Camera); SettingsManager.instance.RegisterPostProfile(m_Camera.GetComponent <PostProcessingBehaviour>().profile); //var pnc = FindObjectsOfType<PlayerNameCanvas>(); //for (var i = 0; i < pnc.Length; i++) //{ // pnc[i].targetCamera = m_Camera; //} GameManager.instance.enemiesRemainigText.Add(enemiesRemainingText); //if (uc.player == null) // uc.Awake(); } //beamMaterial = lineRenderer.material; }
public void Remove(CustomLight light) { lights.Remove(light); }
public void Add(CustomLight light) { Remove(light); lights.Add(light); }
public void Add(CustomLight o) { Remove (o); m_Lights.Add (o); }