/// <summary> /// 增加一条数据 /// </summary> public void Add(Light.Model.newsinfo model) { StringBuilder strSql=new StringBuilder(); strSql.Append("insert into newsinfo("); strSql.Append("id,title,content,subtitle,isread,ishot,createman,createtime"); strSql.Append(") values ("); strSql.Append("@id,@title,@content,@subtitle,@isread,@ishot,@createman,@createtime"); strSql.Append(") "); MySqlParameter[] parameters = { new MySqlParameter("@id", MySqlDbType.Int32,10) , new MySqlParameter("@title", MySqlDbType.VarChar,500) , new MySqlParameter("@content", MySqlDbType.VarChar,500) , new MySqlParameter("@subtitle", MySqlDbType.VarChar,500) , new MySqlParameter("@isread", MySqlDbType.Bit) , new MySqlParameter("@ishot", MySqlDbType.Bit) , new MySqlParameter("@createman", MySqlDbType.Int32,10) , new MySqlParameter("@createtime", MySqlDbType.DateTime) }; parameters[0].Value = model.id; parameters[1].Value = model.title; parameters[2].Value = model.content; parameters[3].Value = model.subtitle; parameters[4].Value = model.isread; parameters[5].Value = model.ishot; parameters[6].Value = model.createman; parameters[7].Value = model.createtime; DbHelperMySQL.ExecuteSql(strSql.ToString(),parameters); }
public override void CreateCustom() { Light l = new Light(); l.directional = true; l.Position = Vector3Extensions.GetUnit(new Vector3(-1, 1, 4)); Spawn(l, true); }
//Called when a level is loaded void OnLevelWasLoaded() { restartTimer = 0; totalMinutes = 0; playTimer = 0; GameOver = false; if (Application.loadedLevel == 1) { theSun = GameObject.Find("spotlight").GetComponent<Light>(); mHero = GameObject.Find("Hero").GetComponent<Hero>(); mTimer = GameObject.Find("Timer").GetComponent<Slider>(); mHBar = GameObject.Find("hpBar").GetComponent<Slider>(); mMin = GameObject.Find("minCounter").GetComponent<Text>(); mSec = GameObject.Find("secCounter").GetComponent<Text>(); Info = GameObject.Find("Info").GetComponent<Text>(); mPanel = GameObject.Find("Panel").GetComponent<Image>(); mPanel.gameObject.SetActive(false); Info.gameObject.SetActive(false); if(gameType == ENDLESS || gameType == DEBUG) { mTimer.gameObject.SetActive(false); } SpawnVariableControl(); StartCoroutine(MasterSpawner(Troll)); } else { SetButtons(); } }
public Chronic(string name, Water water, Light light, Food food) : this(name) { Water = water; Light = light; Food = food; }
void Start () { mainLight = GetComponent<Light>(); skyMat = RenderSettings.skybox; }
public override void Create() { { Node t = new Node(); t.Draw = new ArrayList(new IDrawable[] { Root.Instance.ResourceManager.Load<SupComMap>("terrain/SCMP_015.scmap") }); t.Position = new Vector3(0, -900, 0); Spawn(t, true); } { PlayerStart n = new PlayerStart(); n.rotationspeed = new Vector3(0, 1, 0); n.Position = new Vector3(0, 0, 500); Spawn(n, true); } { Light l = new Light(); l.directional = true; l.Position = Vector3Extensions.GetUnit(new Vector3(1, 3, 4)); Spawn(l,true); } { EclipticNode n = new EclipticNode(); //n.Draw.Add(new Ecliptic(new Color3f(0, 0, 0.5f), 10000, 100)); Spawn(n, true); } }
void Start() { pointLight = GetComponent<Light>(); startColor = pointLight.color; anchorManager = ImportExportAnchorManager.Instance; }
void DrawLights(Light[] lights, ref int i) { GUIContent tooltip = new GUIContent("", "Is the game object active in hierarchy and the light component enabled."); foreach (Light light in lights) { if (light == null) continue; EditorGUI.BeginDisabledGroup(light.shadows == LightShadows.None); EditorGUILayout.BeginHorizontal(); string controlName = "ObjectField-" + i; GUI.SetNextControlName(controlName); EditorGUILayout.ObjectField(light, typeof(Light), true); if (GUILayout.Button("Select")) { Selection.activeGameObject = light.gameObject; SceneView.lastActiveSceneView.FrameSelected(); GUI.FocusControl(controlName); } if (GUILayout.Button("Disable shadows")) { light.shadows = LightShadows.None; } GUILayout.Toggle(light.gameObject.activeInHierarchy && light.enabled, tooltip, GUILayout.ExpandWidth (false)); EditorGUILayout.EndHorizontal(); EditorGUI.EndDisabledGroup(); } }
// Update is called once per frame void Update() { if(myLight == null){ myLight = GetComponentInChildren<Light>(); }else{ if(myLight.intensity>0){//light is on if(goingToGoal){ if(Vector3.Distance(goal,transform.position)>0.5f){ transform.parent.position = (goal-transform.parent.position)*speed + transform.parent.position; //transform.position = (goal-transform.position)*speed + transform.position; }else{ goingToGoal = false; } }else{ if(Vector3.Distance(original,transform.position)>0.5f){ transform.parent.position = (original-transform.parent.position)*speed + transform.parent.position; //transform.position = (original-transform.position)*speed + transform.position; }else{ goingToGoal = true; } } }else{//light is off } } }
/* METHODES */ //Constructor void Awake() { //Lien avec les composants des particules GemPartEmitter = GetComponent<ParticleEmitter>(); //Lien avec l'Emitter des particules GemPartAnimation = GetComponent<ParticleAnimator>(); //Lien avec l'Animator des particules InitialColor = Color.magenta; //Définition de la couleur initiale de la Gemme OppositeColor = new Color32(255,132,0,255); //Définition de la couleur opposé de la Gemme //Initialisation du tableau dynamiquement GemPartStarkle = new Color[5]; //Initialisation des 5 couleurs comosant le Renderer //Lien avec la Lumière GemLight = GetComponent<Light>(); GemTitle = GameObject.Find("Title").GetComponent<TextMesh>(); //Lien avec le GUIText de la scène //Initialisation des statuts GemPartEmitter.emit = false; //Dissimulation des particules GemTitle.renderer.enabled = false; //Dissimulation du texte ChangeMode = false; //Récuparation des scripts Blue = GameObject.FindGameObjectWithTag("Blue").GetComponent<BlueGem>(); Yellow = GameObject.FindGameObjectWithTag("Yellow").GetComponent<YellowGem>(); White = GameObject.FindGameObjectWithTag("White").GetComponent<WhiteGem>(); Black = GameObject.FindGameObjectWithTag("Black").GetComponent<BlackGem>(); Red = GameObject.FindGameObjectWithTag("Red").GetComponent<RedGem>(); }
void Start() { ThisBody = GetComponent<Rigidbody2D>(); Anim = GetComponent<Animator>(); TailLight = Light.GetComponent<Light>(); // SpriteRen = GetComponent<SpriteRenderer>(); }
private void CreateFlare() { Light[] lights = gameObject.GetComponentsInChildren<Light>(); Arguments.ValidateNotNullOrEmpty<Light>(lights); int lightCount = lights.Length; if (lightCount == 1) { // there is only the primary light attached, so I need to create another for the flare // avoid getting the flareLight prefab with Resources.Load("Lights/FlareLight") _flareLight = Instantiate<Light>(UsefulPrefabs.Instance.flareLight); //_flareLight.transform.parent = _transform; UnityUtility.AttachChildToParent(_flareLight.gameObject, _transform.gameObject); //float radiusOfStar = (gameObject.GetSafeMonoBehaviourComponentInParents<Star>().collider as SphereCollider).radius; float radiusOfStar = (gameObject.GetSafeMonoBehaviourComponentInParents<StarView>().collider as SphereCollider).radius; Vector3 flareLightLocationBehindStar = Vector3.forward * (radiusOfStar + 2F); _flareLight.transform.localPosition = flareLightLocationBehindStar; } else if (lightCount == 2) { _flareLight = lights[1]; } else { D.Warn("There are more lights attached than needed: {0}".Inject(lightCount)); _flareLight = lights[1]; } _flareLight.range = Constants.ZeroF; _flareLight.flare = flares[rng.Next(flares.Length)]; _originalIntensity = _flareLight.intensity; }
/// <summary> /// Find all needed components. /// </summary> void Awake () { mWidget = GetComponentInChildren<UIWidget>(); Renderer ren = renderer; if (ren != null) mMat = ren.material; mLight = light; }
/// <summary> /// 增加一条数据 /// </summary> public void Add(Light.Model.marriageimageinfo model) { StringBuilder strSql=new StringBuilder(); strSql.Append("insert into marriageimageinfo("); strSql.Append("id,url,marriageid,createman,createtime"); strSql.Append(") values ("); strSql.Append("@id,@url,@marriageid,@createman,@createtime"); strSql.Append(") "); MySqlParameter[] parameters = { new MySqlParameter("@id", MySqlDbType.Int32,10) , new MySqlParameter("@url", MySqlDbType.VarChar,500) , new MySqlParameter("@marriageid", MySqlDbType.Int32,10) , new MySqlParameter("@createman", MySqlDbType.Int32,10) , new MySqlParameter("@createtime", MySqlDbType.DateTime) }; parameters[0].Value = model.id; parameters[1].Value = model.url; parameters[2].Value = model.marriageid; parameters[3].Value = model.createman; parameters[4].Value = model.createtime; DbHelperMySQL.ExecuteSql(strSql.ToString(),parameters); }
//AudioSource gunShot; void Start() { shootableMask = LayerMask.GetMask ("Shootable"); gunLight = GetComponent <Light> (); anim = GetComponent<Animator>(); }
// Use this for initialization void Start () { offSwitch = GameObject.Find ("Lswitch2"); onSwitch = GameObject.Find ("Lswitch1"); MC = GameObject.Find ("Main Camera").GetComponent<Light>(); }
/// <summary> /// /// </summary> void Awake() { m_Transform = transform; // the muzzleflash is meant to use the 'Particles/Additive' // (unity default) shader which has the 'TintColor' property m_Color = renderer.material.GetColor("_TintColor"); m_Color.a = 0.0f; m_ForceShow = false; // if a light is present in the prefab we will cache and use it m_Light = light; if (m_Light != null) { m_LightIntensity = m_Light.intensity; m_Light.intensity = 0.0f; } m_Renderer = renderer; if (m_Renderer != null) m_Material = renderer.material; }
/// <summary> /// 增加一条数据 /// </summary> public void Add(Light.Model.regioninfo model) { StringBuilder strSql=new StringBuilder(); strSql.Append("insert into regioninfo("); strSql.Append("id,countryid,regionname,creatman,creattime,remark"); strSql.Append(") values ("); strSql.Append("@id,@countryid,@regionname,@creatman,@creattime,@remark"); strSql.Append(") "); MySqlParameter[] parameters = { new MySqlParameter("@id", MySqlDbType.Int32,10) , new MySqlParameter("@countryid", MySqlDbType.Int32,10) , new MySqlParameter("@regionname", MySqlDbType.VarChar,10) , new MySqlParameter("@creatman", MySqlDbType.Int32,10) , new MySqlParameter("@creattime", MySqlDbType.DateTime) , new MySqlParameter("@remark", MySqlDbType.VarChar,200) }; parameters[0].Value = model.id; parameters[1].Value = model.countryid; parameters[2].Value = model.regionname; parameters[3].Value = model.creatman; parameters[4].Value = model.creattime; parameters[5].Value = model.remark; DbHelperMySQL.ExecuteSql(strSql.ToString(),parameters); }
void Awake() { laserRender = GetComponent<Renderer> (); laserLight = GetComponent<Light> (); laserCollider = GetComponent<BoxCollider> (); time = 0f; }
protected void Start() { lightComponent = GetComponent<Light>(); lightIntensity = lightComponent.intensity; lightComponent.enabled = (TOD_Sky.Instance.Components.Weather.Weather == type); }
void Cache () { mCached = true; mWidget = GetComponent<UIWidget>(); if (mWidget != null) return; mSr = GetComponent<SpriteRenderer>(); if (mSr != null) return; #if UNITY_4_3 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 Renderer ren = renderer; #else Renderer ren = GetComponent<Renderer>(); #endif if (ren != null) { mMat = ren.material; return; } #if UNITY_4_3 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 mLight = light; #else mLight = GetComponent<Light>(); #endif if (mLight == null) mWidget = GetComponentInChildren<UIWidget>(); }
private static void _UpdateColor(Light obj, LightPropertyType pType, float val) { Color c = obj.color; switch(pType) { case LightPropertyType.Color_R: c.r = val; break; case LightPropertyType.Color_G: c.g = val; break; case LightPropertyType.Color_B: c.b = val; break; case LightPropertyType.Color_RGB: c.r = val; c.g = val; c.b = val; break; case LightPropertyType.Color_A: c.a = val; break; } obj.color = c; }
private IEnumerator PulseLightSize(Light light, float minSize, float maxSize, float time, bool repeating = false) { light.range = minSize; float timer = 0; float frameRate = Time.frameCount/Time.time; float step = (maxSize - minSize)/frameRate; while (timer < time/2.0f) { light.range += step; timer += Time.deltaTime; yield return new WaitForEndOfFrame(); } light.range = maxSize; while (timer < time) { light.range -= step; timer += Time.deltaTime; yield return new WaitForEndOfFrame(); } light.range = minSize; if (repeating) { beginBlinkingCoroutine(); } }
void Start() { myLight = GetComponentInChildren<Light>(); particles = GetComponentInChildren<ParticleSystem>(); particles.enableEmission = true; myLight.intensity = 2; }
// Use this for initialization void Start() { // set animation this.animation = GetComponent<Animation> (); // set fire ligth this.fireLigth = this.effects.GetComponent<Light> (); }
public void SetPlayerIndex(int networkId) { /* switch(networkId){ case 1: playerIndex = 3;break; case 2: playerIndex = 1;break; case 3: playerIndex = 2;break; } */ playerIndex = networkId; helmetLight = GetComponent<Light>(); //Calls the light component on the spotlight //Set the color of the interactable button both background light and particles to the correct user. switch (playerIndex){ case 1: helmetLight.color = new Color(0.2F, 0.2F, 1, 1F); //blue nonFocusedHelmetLight.color = new Color(0.2F, 0.2F, 1, 1F); //blue break; case 2: helmetLight.color = new Color(1, 0.2F, 0.2F, 1F); //red nonFocusedHelmetLight.color = new Color(1, 0.2F, 0.2F, 1F); //red break; case 3: helmetLight.color = new Color(0.2F, 1, 0.2F, 1F); //green nonFocusedHelmetLight.color = new Color(0.2F, 1, 0.2F, 1F); //green break; default: Debug.Log("Invalid playerIndex"); break; } }
// Use this for initialization void Start() { contadorNiveles = contadorNiveles - 1; l = GetComponentInChildren<Light>(); Nivel = this.gameObject; nivel -= 1; l.enabled = false; levelPanel = Instantiate(levelInfoPrefab); levelPanel.transform.SetParent(canvas.transform, false); levelPanel.transform.position = new Vector3(transform.position.x, transform.position.x, transform.position.z); //levelPanel.GetComponentInChildren<Text>().text = Nivel.name; levelPanel.GetComponentInChildren<Text>().text = levelName; if(ruta){ ruta.GetComponentsInChildren<LightSwitch>(); } if(OneReset){ for(i=0;i<cantidadNiveles;i++){ completado[i] = false; } OneReset = false; } }
/* METHODES */ //Constructor void Awake() { // A retenir : GemLight = gameObject.AddComponent("Light") as Light; //Lien avec les composants des particules GemPartEmitter = GetComponent<ParticleEmitter>(); //Lien avec l'Emitter des particules GemPartAnimation = GetComponent<ParticleAnimator>(); //Lien avec l'Animator des particules //GemPartRenderer = GetComponent<ParticleRenderer>(); //Lien avec le Renderer des particules InitialColor = Color.yellow; //Définition de la couleur initiale de la Gemme OppositeColor = Color.magenta; //Définition de la couleur opposé de la Gemme //Initialisation du tableau dynamiquement GemPartStarkle = new Color[5]; //Initialisation des 5 couleurs comosant le Renderer //Lien avec la Lumière GemLight = GetComponent<Light>(); GemTitle = GameObject.Find("GUI Text"); //Lien avec le GUIText de la scène //Initialisation des statuts GemPartEmitter.emit = false; //Dissimulation des particules GemTitle.guiText.enabled = false; //Dissimulation du texte MyPart = (ParticleSystem) Instantiate(test); ChangeMode = false; }
protected override void onFlightStart() { ping = gameObject.AddComponent<AudioSource>(); WWW www = new WWW("file://" + KSPUtil.ApplicationRootPath.Replace("\\", "/") + "Parts/mumech_MuonDetector/ping.wav"); if ((ping != null) && (www != null)) { ping.clip = www.GetAudioClip(false); ping.volume = 0; ping.Stop(); } disk = transform.Find("model/disk"); if (disk != null) { MIN_PING_DIST = 150000; MIN_PING_TIME = 0.2; MAX_PING_TIME = 15; led = transform.Find("model/led"); originalLensShader = led.renderer.material.shader; pingLight = led.gameObject.AddComponent<Light>(); pingLight.type = LightType.Point; pingLight.renderMode = LightRenderMode.ForcePixel; pingLight.shadows = LightShadows.None; pingLight.range = 1; pingLight.enabled = false; } RenderingManager.AddToPostDrawQueue(3, new Callback(drawGUI)); }
private static void _UpdateColorRelative(Light obj, LightPropertyType pType, float val) { Color c = obj.color; switch(pType) { case LightPropertyType.Color_R_Relative: c.r = Mathf.Clamp01(c.r + val); break; case LightPropertyType.Color_G_Relative: c.g = Mathf.Clamp01(c.g + val); break; case LightPropertyType.Color_B_Relative: c.b = Mathf.Clamp01(c.b + val); break; case LightPropertyType.Color_RGB_Relative: c.r = Mathf.Clamp01(c.r + val); c.g = Mathf.Clamp01(c.g + val); c.b = Mathf.Clamp01(c.b + val); break; case LightPropertyType.Color_A_Relative: c.a = Mathf.Clamp01(c.a + val); break; } obj.color = c; }
/// <summary> /// Exports the light. /// </summary> /// <param name="writer">The writer.</param> /// <param name="light">The light.</param> /// <param name="inheritedTransform">The inherited transform.</param> protected virtual void ExportLight(T writer, Light light, Transform3D inheritedTransform) { }
public void Start() { _lightComponent = GetComponent <Light>(); }
private void Start() { torchLight = GetComponentInChildren <Light>(); }
void DrawWidgets(Light l, GPUShadowType shadowType, ShadowAlgorithm shadowAlgorithm, ShadowVariant shadowVariant, ShadowPrecision shadowPrecision, bool globalOverride) { #if UNITY_EDITOR var dict = m_Entries[(int)shadowType]; int[] algoOptions = new int[dict.Count]; GUIContent[] algoDescs = new GUIContent[dict.Count]; int idx = 0; foreach (var entry in dict) { algoOptions[idx] = (int)entry.Key; algoDescs[idx] = new GUIContent(entry.Value.algorithmDesc); idx++; } using (new UnityEditor.EditorGUI.DisabledGroupScope(globalOverride)) { UnityEditor.EditorGUI.BeginChangeCheck(); shadowAlgorithm = (ShadowAlgorithm)UnityEditor.EditorGUILayout.IntPopup(new GUIContent("Shadow Algorithm"), (int)shadowAlgorithm, algoDescs, algoOptions); if (UnityEditor.EditorGUI.EndChangeCheck()) { shadowVariant = 0; } } UnityEditor.EditorGUI.indentLevel++; Entry e = dict[shadowAlgorithm]; int varsAvailable = e.variantsAvailable; int[] varOptions = new int[varsAvailable]; GUIContent[] varDescs = new GUIContent[varsAvailable]; idx = 0; for (int writeIdx = 0; writeIdx < varsAvailable; idx++) { if (e.variantDels[idx].low != null || e.variantDels[idx].high != null) { varOptions[writeIdx] = idx; varDescs[writeIdx] = new GUIContent(e.variantDescs[idx]); writeIdx++; } } UnityEditor.EditorGUILayout.BeginHorizontal(); using (new UnityEditor.EditorGUI.DisabledGroupScope(globalOverride)) { shadowVariant = (ShadowVariant)UnityEditor.EditorGUILayout.IntPopup(new GUIContent("Variant + Precision"), (int)shadowVariant, varDescs, varOptions); if (e.variantDels[(int)shadowVariant].low != null && e.variantDels[(int)shadowVariant].high != null) { GUIContent[] precDescs = new GUIContent[] { new GUIContent("High"), new GUIContent("Low") }; int[] precOptions = new int[] { 0, 1 }; shadowPrecision = (ShadowPrecision)UnityEditor.EditorGUILayout.IntPopup((int)shadowPrecision, precDescs, precOptions, GUILayout.MaxWidth(65)); } else { using (new UnityEditor.EditorGUI.DisabledScope()) { GUIContent[] precDescs = new GUIContent[] { new GUIContent(e.variantDels[(int)shadowVariant].low == null ? "High" : "Low") }; int[] precOptions = new int[] { e.variantDels[(int)shadowVariant].low == null ? 0 : 1 }; UnityEditor.EditorGUILayout.IntPopup(precOptions[0], precDescs, precOptions, GUILayout.MaxWidth(65)); shadowPrecision = (ShadowPrecision)precOptions[0]; } } } AdditionalLightData ald = l.GetComponent <AdditionalLightData>(); GPUShadowAlgorithm packedAlgo = ShadowUtils.Pack(shadowAlgorithm, shadowVariant, shadowPrecision); int[] shadowData = null; if (!GUILayout.Button("Reset", GUILayout.MaxWidth(80.0f))) { shadowData = ald.GetShadowData((int)packedAlgo); } UnityEditor.EditorGUILayout.EndHorizontal(); if (shadowPrecision == ShadowPrecision.Low) { e.variantDels[(int)shadowVariant].low(l, shadowAlgorithm, shadowVariant, shadowPrecision, ref shadowData); } else { e.variantDels[(int)shadowVariant].high(l, shadowAlgorithm, shadowVariant, shadowPrecision, ref shadowData); } ald.SetShadowAlgorithm((int)shadowAlgorithm, (int)shadowVariant, (int)shadowPrecision, (int)packedAlgo, shadowData); UnityEditor.EditorGUI.indentLevel--; #endif }
public Result SetLight(int index, ref Light arg1) { return(_device.SetLight(index, ref arg1)); }
private void Awake() { // Init attached components. audioSource = GetComponent <AudioSource>(); lightSource = GetComponent <Light>(); }
/// <summary> /// Hack /// </summary> /// <param name="light"></param> /// <param name="world"></param> /// <param name="recalcNormals"></param> public void UpdateShadow(Light light, Matrix4 world, bool recalcNormals) { this.shadowImplementation.UpdateShadow(light, world, recalcNormals); }
// Start is called before the first frame update void Start() { lt = GetComponent <Light>(); }
// Use this for initialization void Start() { doorLight = GameObject.FindWithTag("doorLight").GetComponent <Light>(); doorLight.color = Color.red; }
void Start() { rb = GetComponent <Light>(); rb.enabled = false; }
static void Main(string[] args) { ManualResetEvent pause = new ManualResetEvent(false); var btnStartCancel = new Button(); var btnPower = new Button(); var btnTimer = new Button(); var door = new Door(); var output = new Output(); var timer = new Timer(); var display = new Display(output); var light = new Light(output); var powerTube = new PowerTube(output); var cookController = new CookController(timer, display, powerTube); var userInterface = new UserInterface(btnPower, btnTimer, btnStartCancel, door, display, light, cookController); cookController.UI = userInterface; Print("--- Main Scenario ---"); Print("--- User Opens the door ---"); door.Open(); Print(""); Print("--- User Closes the door ---"); door.Close(); Print(""); Print("--- User presses the power button 3 times ---"); for (int i = 0; i < 3; i++) { btnPower.Press(); } Print(""); Print("--- User presses the time button ---"); btnTimer.Press(); Print(""); Print("--- User presses the start/cancel button ---"); btnStartCancel.Press(); Print(""); pause.WaitOne(60100); Print(""); Print("--- User Opens the door after the dish is done ---"); door.Open(); Print(""); Print("--- User Closes the door ---"); door.Close(); Print(""); Print("--- Extension 3: The user presses the Start-Cancel button during cooking --- "); Print("--- User Opens the door ---"); door.Open(); Print(""); Print("--- User Closes the door ---"); door.Close(); Print(""); Print("--- User presses the power button 3 times ---"); for (int i = 0; i < 3; i++) { btnPower.Press(); } Print(""); Print("--- User presses the time button ---"); btnTimer.Press(); Print(""); Print("--- User presses the start/cancel button ---"); btnStartCancel.Press(); Print(""); pause.WaitOne(7100); Print(""); Print("--- User presses the start/cancel button after 7s ---"); btnStartCancel.Press(); Print(""); // Wait while the classes, including the timer, do their job System.Console.WriteLine("Tast enter når applikationen skal afsluttes"); System.Console.ReadLine(); }
private void Awake() { _light = GetComponent <Light>(); chargeAmount = 1f; }
private void Awake() { _light = GetComponent <Light>(); StartCoroutine(IntensityChanger()); }
void Start() { _config = Config.getInstance(); this.light = GetComponent <Light>(); }
private void Start() { _light = GetComponent <Light>(); StartCoroutine(OnGradient()); }
public LightOffCommand(Light light) { _light = light; }
// Use this for initialization void Start() { objectLight = GetComponent <Light>(); }
// Drive state from OnEnable and OnDisable? OnEnable on RegisterLodDataInput seems to get called on script reload void OnEnable() { // We don't run in "prefab scenes", i.e. when editing a prefab. Bail out if prefab scene is detected. #if UNITY_EDITOR if (PrefabStageUtility.GetCurrentPrefabStage() != null) { return; } #endif if (!_primaryLight && _searchForPrimaryLightOnStartup) { _primaryLight = RenderSettings.sun; } if (!VerifyRequirements()) { enabled = false; return; } #if UNITY_EDITOR if (!Validate(this, ValidatedHelper.DebugLog)) { enabled = false; return; } #endif Instance = this; Scale = Mathf.Clamp(Scale, _minScale, _maxScale); _lodTransform = new LodTransform(); _lodTransform.InitLODData(_lodCount); // Resolution is 4 tiles across. var baseMeshDensity = _lodDataResolution * 0.25f / _geometryDownSampleFactor; // 0.4f is the "best" value when base mesh density is 8. Scaling down from there produces results similar to // hand crafted values which looked good when the ocean is flat. _lodAlphaBlackPointFade = 0.4f / (baseMeshDensity / 8f); // We could calculate this in the shader, but we can save two subtractions this way. _lodAlphaBlackPointWhitePointFade = 1f - _lodAlphaBlackPointFade - _lodAlphaBlackPointFade; Root = OceanBuilder.GenerateMesh(this, _oceanChunkRenderers, _lodDataResolution, _geometryDownSampleFactor, _lodCount); CreateDestroySubSystems(); _commandbufferBuilder = new BuildCommandBuffer(); InitViewpoint(); if (_attachDebugGUI && GetComponent <OceanDebugGUI>() == null) { gameObject.AddComponent <OceanDebugGUI>().hideFlags = HideFlags.DontSave; } #if UNITY_EDITOR EditorApplication.update -= EditorUpdate; EditorApplication.update += EditorUpdate; #endif foreach (var lodData in _lodDatas) { lodData.OnEnable(); } _canSkipCulling = false; }
void Awake() { Red = Reddl.GetComponentInChildren <Light> (); Yellow = Yellowdl.GetComponentInChildren <Light>(); Green = Greendl.GetComponentInChildren <Light> (); }
public void filterSkyParams(DayNightEventsController.lightParameters sky, Light celestialLight) { RenderSettings.fogColor = Color.Lerp(sky.skyColor, sky.sunColor, 0.5f); // celestialLight.intensity *= (1.0f - rainIntensity); }
public override string ToString() => Light.ToString();
// Update is called once per frame void LateUpdate() { childDirLight = transform.GetChild(0).GetComponent <Light>(); childDirLight.intensity = 1.0f - GetComponent <Light>().intensity; }
public static int GetComponent1_wrap(long L) { try { long nThisPtr = FCLibHelper.fc_get_inport_obj_ptr(L); UnityEngine.GameObject obj = get_obj(nThisPtr); string arg0 = FCLibHelper.fc_get_string_a(L, 0); long nRetPtr = 0; switch (arg0) { case "SkinnedMeshRenderer": { SkinnedMeshRenderer ret_obj = obj.GetComponent <SkinnedMeshRenderer>(); nRetPtr = FCGetObj.PushObj <SkinnedMeshRenderer>(ret_obj); } break; case "Renderer": { Renderer ret_obj = obj.GetComponent <Renderer>(); nRetPtr = FCGetObj.PushObj <Renderer>(ret_obj); } break; case "MeshRenderer": { MeshRenderer ret_obj = obj.GetComponent <MeshRenderer>(); nRetPtr = FCGetObj.PushObj <MeshRenderer>(ret_obj); } break; case "Animation": { Animation ret_obj = obj.GetComponent <Animation>(); nRetPtr = FCGetObj.PushObj <Animation>(ret_obj); } break; case "Collider": { Collider ret_obj = obj.GetComponent <Collider>(); nRetPtr = FCGetObj.PushObj <Collider>(ret_obj); } break; case "BoxCollider": { BoxCollider ret_obj = obj.GetComponent <BoxCollider>(); nRetPtr = FCGetObj.PushObj <BoxCollider>(ret_obj); } break; case "BoxCollider2D": { BoxCollider2D ret_obj = obj.GetComponent <BoxCollider2D>(); nRetPtr = FCGetObj.PushObj <BoxCollider2D>(ret_obj); } break; case "MeshCollider": { MeshCollider ret_obj = obj.GetComponent <MeshCollider>(); nRetPtr = FCGetObj.PushObj <MeshCollider>(ret_obj); } break; case "SphereCollider": { SphereCollider ret_obj = obj.GetComponent <SphereCollider>(); nRetPtr = FCGetObj.PushObj <SphereCollider>(ret_obj); } break; case "Rigidbody": { Rigidbody ret_obj = obj.GetComponent <Rigidbody>(); nRetPtr = FCGetObj.PushObj <Rigidbody>(ret_obj); } break; case "Camera": { Camera ret_obj = obj.GetComponent <Camera>(); nRetPtr = FCGetObj.PushObj <Camera>(ret_obj); } break; case "AudioSource": { AudioSource ret_obj = obj.GetComponent <AudioSource>(); nRetPtr = FCGetObj.PushObj <AudioSource>(ret_obj); } break; case "Transform": { Transform ret_obj = obj.GetComponent <Transform>(); nRetPtr = FCGetObj.PushObj <Transform>(ret_obj); } break; case "Component": { Component ret_obj = obj.GetComponent <Component>(); nRetPtr = FCGetObj.PushObj <Component>(ret_obj); } break; case "ParticleSystem": { ParticleSystem ret_obj = obj.GetComponent <ParticleSystem>(); nRetPtr = FCGetObj.PushObj <ParticleSystem>(ret_obj); } break; case "Light": { Light ret_obj = obj.GetComponent <Light>(); nRetPtr = FCGetObj.PushObj <Light>(ret_obj); } break; case "Button": { Button ret_obj = obj.GetComponent <Button>(); nRetPtr = FCGetObj.PushObj <Button>(ret_obj); } break; case "Text": { Text ret_obj = obj.GetComponent <Text>(); nRetPtr = FCGetObj.PushObj <Text>(ret_obj); } break; default: break; } long ret_ptr = FCLibHelper.fc_get_return_ptr(L); FCLibHelper.fc_set_value_wrap_objptr(ret_ptr, nRetPtr); } catch (Exception e) { Debug.LogException(e); } return(0); }
void InitializeLightConstants(List <VisibleLight> lights, int lightIndex, out Vector4 lightPos, out Vector4 lightColor, out Vector4 lightDistanceAttenuation, out Vector4 lightSpotDir, out Vector4 lightSpotAttenuation) { lightPos = k_DefaultLightPosition; lightColor = k_DefaultLightColor; lightDistanceAttenuation = k_DefaultLightSpotAttenuation; lightSpotDir = k_DefaultLightSpotDirection; lightSpotAttenuation = k_DefaultLightAttenuation; // When no lights are visible, main light will be set to -1. // In this case we initialize it to default values and return if (lightIndex < 0) { return; } VisibleLight lightData = lights[lightIndex]; if (lightData.lightType == LightType.Directional) { Vector4 dir = -lightData.localToWorld.GetColumn(2); lightPos = new Vector4(dir.x, dir.y, dir.z, 0.0f); } else { Vector4 pos = lightData.localToWorld.GetColumn(3); lightPos = new Vector4(pos.x, pos.y, pos.z, 1.0f); } // VisibleLight.finalColor already returns color in active color space lightColor = lightData.finalColor; // Directional Light attenuation is initialize so distance attenuation always be 1.0 if (lightData.lightType != LightType.Directional) { // Light attenuation in lightweight matches the unity vanilla one. // attenuation = 1.0 / 1.0 + distanceToLightSqr * quadraticAttenuation // then a smooth factor is applied to linearly fade attenuation to light range // the attenuation smooth factor starts having effect at 80% of light range // smoothFactor = (lightRangeSqr - distanceToLightSqr) / (lightRangeSqr - fadeStartDistanceSqr) // We rewrite smoothFactor to be able to pre compute the constant terms below and apply the smooth factor // with one MAD instruction // smoothFactor = distanceSqr * (1.0 / (fadeDistanceSqr - lightRangeSqr)) + (-lightRangeSqr / (fadeDistanceSqr - lightRangeSqr) // distanceSqr * oneOverFadeRangeSqr + lightRangeSqrOverFadeRangeSqr float lightRangeSqr = lightData.range * lightData.range; float fadeStartDistanceSqr = 0.8f * 0.8f * lightRangeSqr; float fadeRangeSqr = (fadeStartDistanceSqr - lightRangeSqr); float oneOverFadeRangeSqr = 1.0f / fadeRangeSqr; float lightRangeSqrOverFadeRangeSqr = -lightRangeSqr / fadeRangeSqr; float quadAtten = 25.0f / lightRangeSqr; lightDistanceAttenuation = new Vector4(quadAtten, oneOverFadeRangeSqr, lightRangeSqrOverFadeRangeSqr, 1.0f); } if (lightData.lightType == LightType.Spot) { Vector4 dir = lightData.localToWorld.GetColumn(2); lightSpotDir = new Vector4(-dir.x, -dir.y, -dir.z, 0.0f); // Spot Attenuation with a linear falloff can be defined as // (SdotL - cosOuterAngle) / (cosInnerAngle - cosOuterAngle) // This can be rewritten as // invAngleRange = 1.0 / (cosInnerAngle - cosOuterAngle) // SdotL * invAngleRange + (-cosOuterAngle * invAngleRange) // If we precompute the terms in a MAD instruction float cosOuterAngle = Mathf.Cos(Mathf.Deg2Rad * lightData.spotAngle * 0.5f); // We neeed to do a null check for particle lights // This should be changed in the future // Particle lights will use an inline function float cosInnerAngle; if (lightData.light != null) { cosInnerAngle = Mathf.Cos(LightmapperUtils.ExtractInnerCone(lightData.light) * 0.5f); } else { cosInnerAngle = Mathf.Cos((2.0f * Mathf.Atan(Mathf.Tan(lightData.spotAngle * 0.5f * Mathf.Deg2Rad) * (64.0f - 18.0f) / 64.0f)) * 0.5f); } float smoothAngleRange = Mathf.Max(0.001f, cosInnerAngle - cosOuterAngle); float invAngleRange = 1.0f / smoothAngleRange; float add = -cosOuterAngle * invAngleRange; lightSpotAttenuation = new Vector4(invAngleRange, add, 0.0f); } Light light = lightData.light; // TODO: Add support to shadow mask if (light != null && light.bakingOutput.mixedLightingMode == MixedLightingMode.Subtractive && light.bakingOutput.lightmapBakeType == LightmapBakeType.Mixed) { if (m_MixedLightingSetup == MixedLightingSetup.None && lightData.light.shadows != LightShadows.None) { m_MixedLightingSetup = MixedLightingSetup.Subtractive; lightDistanceAttenuation.w = 0.0f; } } }
void RenderCascadedShadows(ScriptableRenderContext context) { float tileSize = shadowMapSize / 2; cascadedShadowMap = SetShadowRenderTarget(); shadowBuffer.BeginSample("Render Shadows"); //shadowBuffer.SetGlobalVector(globalShadowDataId, new Vector4(0f, shadowDistance * shadowDistance)); context.ExecuteCommandBuffer(shadowBuffer); shadowBuffer.Clear(); Light shadowLight = cull.visibleLights[0].light; shadowBuffer.SetGlobalFloat(shadowBiasId, shadowLight.shadowBias); var shadowSettings = new DrawShadowsSettings(cull, 0); var tileMatrix = Matrix4x4.identity; tileMatrix.m00 = tileMatrix.m11 = 0.5f; for (int i = 0; i < shadowCascades; i++) { Matrix4x4 viewMatrix, projectionMatrix; ShadowSplitData splitData; cull.ComputeDirectionalShadowMatricesAndCullingPrimitives(0, i, shadowCascades, shadowCascadeSplit, (int)tileSize, shadowLight.shadowNearPlane, out viewMatrix, out projectionMatrix, out splitData); Vector2 tileOffset = ConfigureShadowTile(i, 2, tileSize); shadowBuffer.SetViewProjectionMatrices(viewMatrix, projectionMatrix); context.ExecuteCommandBuffer(shadowBuffer); shadowBuffer.Clear(); cascadeCullingSpheres[i] = shadowSettings.splitData.cullingSphere = splitData.cullingSphere; cascadeCullingSpheres[i].w *= splitData.cullingSphere.w; context.DrawShadows(ref shadowSettings); //计算世界到阴影图矩阵 CalculateWorldToShadowMatrix(ref viewMatrix, ref projectionMatrix, out worldToShadowCascadeMatrices[i]); tileMatrix.m03 = tileOffset.x * 0.5f; tileMatrix.m13 = tileOffset.y * 0.5f; worldToShadowCascadeMatrices[i] = tileMatrix * worldToShadowCascadeMatrices[i]; } shadowBuffer.DisableScissorRect(); shadowBuffer.SetGlobalTexture(cascadeShadowMapId, cascadedShadowMap); shadowBuffer.SetGlobalVectorArray(cascadeCullingSpheresId, cascadeCullingSpheres); //设置全局矩阵 shadowBuffer.SetGlobalMatrixArray(worldToShadowCascadeMatricesId, worldToShadowCascadeMatrices); float invShadowMapSize = 1 / shadowMapSize; //Shadow Map Size shadowBuffer.SetGlobalVector(cascadeShadowMapSizeId, new Vector4(invShadowMapSize, invShadowMapSize, shadowMapSize, shadowMapSize)); shadowBuffer.SetGlobalFloat(cascadeShadowStrengthId, shadowLight.shadowStrength); //是否是硬阴影 bool hard = shadowLight.shadows == LightShadows.Hard; CoreUtils.SetKeyword(shadowBuffer, cascadedShadowsHardKeyword, hard); CoreUtils.SetKeyword(shadowBuffer, cascadedShadowsSoftKeyword, !hard); shadowBuffer.EndSample("Render Shadows"); context.ExecuteCommandBuffer(shadowBuffer); shadowBuffer.Clear(); }
public SwitchedOnState(LightSwitchStates lightSwitchStates, Light light) { _lightSwitchStates = lightSwitchStates; _light = light; }
public override void OnMissileCollisionReaction(Mission.MissileCollisionReaction collisionReaction, Agent attacker, Agent victim, sbyte attachedBoneIndex) { if (!_fireArrowEnabled) { return; } Dictionary <Mission.Missile, ParticleSystem> existMissiles = new Dictionary <Mission.Missile, ParticleSystem>(); foreach (Mission.Missile missile in Mission.Current.Missiles) { if (_missileParticles.ContainsKey(missile)) { existMissiles.Add(missile, _missileParticles[missile]); _missileParticles.Remove(missile); } } foreach (KeyValuePair <Mission.Missile, ParticleSystem> item in _missileParticles) { Mission.Missile missile = item.Key; Light light = missile.Entity.GetLight(); //击中敌人箭矢必须熄灭,因为插在Agent身上的箭的粒子效果是无法显示的 if (victim != null) { missile.Entity.RemoveAllParticleSystems(); if (light != null) { missile.Entity.RemoveComponent(light); } } else { ParticleSystem particle = item.Value; MatrixFrame localFrame = particle.GetLocalFrame().Elevate(0.6f); particle.SetLocalFrame(ref localFrame); if (light != null) { light.Frame = light.Frame.Elevate(0.15f); light.Intensity = FireLordConfig.FireArrowLightIntensity; } ArrowFireData fireData = new ArrowFireData(); localFrame = new MatrixFrame(Mat3.Identity, new Vec3(0, 0, 0)).Elevate(0.6f); fireData.bigFireParticle = ParticleSystem.CreateParticleSystemAttachedToEntity("psys_campfire", missile.Entity, ref localFrame); fireData.timer = new MissionTimer(FireLordConfig.StickedArrowsBurningTime / 2); fireData.missile = missile; _hitArrowFires.Add(fireData); } if (FireLordConfig.IgniteTargetWithFireArrow && victim != null && victim.IsHuman) { if (AgentFireDatas.ContainsKey(victim)) { AgentFireData fireData = AgentFireDatas[victim]; if (!fireData.isBurning) { fireData.firebar += FireLordConfig.IgnitionPerFireArrow; fireData.attacker = attacker; } } else { AgentFireData fireData = new AgentFireData(); fireData.firebar += FireLordConfig.IgnitionPerFireArrow; fireData.attacker = attacker; AgentFireDatas.Add(victim, fireData); } } } _missileParticles = existMissiles; }
public void createScene() { // set background and some fog AdvancedMogreFramework.Singleton.m_pViewport.BackgroundColour = new ColourValue(1.0f, 1.0f, 0.8f); m_pSceneMgr.SetFog(FogMode.FOG_LINEAR, new ColourValue(1.0f, 1.0f, 0.8f), 0, 15, 100); // set shadow properties m_pSceneMgr.ShadowTechnique = ShadowTechnique.SHADOWTYPE_TEXTURE_MODULATIVE; m_pSceneMgr.ShadowColour = new ColourValue(0.5f, 0.5f, 0.5f); m_pSceneMgr.SetShadowTextureSize(1024); m_pSceneMgr.ShadowTextureCount = 1; // disable default camera control so the character can do its own m_pCameraMan.setStyle(CameraStyle.CS_MANUAL); // use a small amount of ambient lighting m_pSceneMgr.AmbientLight = new ColourValue(0.3f, 0.3f, 0.3f); // add a bright light above the scene Light light = m_pSceneMgr.CreateLight(); light.Type = (Light.LightTypes.LT_POINT); light.Position = new Mogre.Vector3(-10, 40, 20); light.SpecularColour = ColourValue.White; // create a floor mesh resource MeshManager.Singleton.CreatePlane("floor", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, new Plane(Mogre.Vector3.UNIT_Y, 0), 100, 100, 10, 10, true, 1, 10, 10, Mogre.Vector3.UNIT_Z); // create a floor entity, give it a material, and place it at the origin Entity floor = m_pSceneMgr.CreateEntity("Floor", "floor"); floor.SetMaterialName("Examples/Rockwall"); floor.CastShadows = (false); m_pSceneMgr.RootSceneNode.AttachObject(floor); //Navmesh Navmesh floorNavMesh = MeshToNavmesh.LoadNavmesh(floor); NavmeshQuery query; NavmeshPoint retStartPoint; NavmeshPoint retEndPoint; org.critterai.Vector3 pointStart = new org.critterai.Vector3(0, 0, 0); org.critterai.Vector3 pointEnd = new org.critterai.Vector3(0, 0, 0); org.critterai.Vector3 extents = new org.critterai.Vector3(2, 2, 2); NavStatus status = NavmeshQuery.Create(floorNavMesh, 100, out query); Console.WriteLine("Status returned when NavmeshQuery was built: " + status); NavmeshQueryFilter filter = new NavmeshQueryFilter(); filter.IncludeFlags = 1; status = query.GetNearestPoint(pointStart, extents, filter, out retStartPoint); Console.WriteLine("\nStatus of startPoint GetNearestPoint: " + status); status = query.GetNearestPoint(pointEnd, extents, filter, out retEndPoint); Console.WriteLine("\nStatus of endPoint GetNearestPoint: " + status); uint[] path = new uint[100]; int pathCount; status = query.FindPath(retStartPoint, retEndPoint, filter, path, out pathCount); Console.WriteLine("\nStatus of Find path: " + status); // create our character controller m_pChara = new SinbadCharacterController(this, m_pCamera, new Mogre.Vector3(0, 5, 0), 0); SinbadCharacterController bot1 = new SinbadCharacterController(this, m_pCamera, new Mogre.Vector3(-10, 5, 0), 1, false); SinbadCharacterController bot2 = new SinbadCharacterController(this, m_pCamera, new Mogre.Vector3(0, 5, -10), 2, false); SinbadCharacterController bot3 = new SinbadCharacterController(this, m_pCamera, new Mogre.Vector3(10, 5, 0), 3, false); agents.Add(m_pChara); agents.Add(bot1); agents.Add(bot2); agents.Add(bot3); AdvancedMogreFramework.Singleton.m_pTrayMgr.toggleAdvancedFrameStats(); StringVector items = new StringVector(); items.Insert(items.Count, "Help"); ParamsPanel help = AdvancedMogreFramework.Singleton.m_pTrayMgr.createParamsPanel(TrayLocation.TL_TOPLEFT, "HelpMessage", 100, items); help.setParamValue("Help", "H / F1"); }
// Update is called once per frame void Update() { Light light = GetComponent <Light>(); light.enabled = _enabled; }
public override void OnMissionTick(float dt) { if (!_initialized && Mission.Current != null && Agent.Main != null) { _initialized = true; Initialize(); } //每支箭落地燃烧,4秒火势变弱,8秒熄灭(默认) if (_hitArrowFires.Count > 0) { List <ArrowFireData> _deleteitems = new List <ArrowFireData>(); foreach (ArrowFireData item in _hitArrowFires) { if (item.timer.Check(true)) { if (!item.delete) { item.delete = true; GameEntity entity = item.bigFireParticle.GetEntity(); if (entity != null) { entity.GetLight().Intensity = FireLordConfig.FireArrowLightIntensity - 35; entity.RemoveComponent(item.bigFireParticle); } } else { GameEntity entity = item.missile.Entity; if (entity != null) { entity.RemoveAllParticleSystems(); Light light = entity.GetLight(); if (light != null) { entity.RemoveComponent(light); } } _deleteitems.Add(item); } } } foreach (ArrowFireData item in _deleteitems) { _hitArrowFires.Remove(item); } } //计算每个agent的着火条,满了就点燃 if (AgentFireDatas.Count > 0) { List <Agent> _deleteAgent = new List <Agent>(); foreach (KeyValuePair <Agent, AgentFireData> item in AgentFireDatas) { Agent agent = item.Key; AgentFireData fireData = item.Value; if (fireData.isBurning) { if (FireLordConfig.IgnitionDealDamage && fireData.damageTimer.Check(true) && agent.IsActive()) { Blow blow = CreateBlow(fireData.attacker, agent); agent.RegisterBlow(blow); if (fireData.attacker == Agent.Main) { TextObject text = GameTexts.FindText("ui_delivered_burning_damage", null); text.SetTextVariable("DAMAGE", blow.InflictedDamage); InformationManager.DisplayMessage(new InformationMessage(text.ToString())); } else if (agent == Agent.Main) { TextObject text = GameTexts.FindText("ui_received_burning_damage", null); text.SetTextVariable("DAMAGE", blow.InflictedDamage); InformationManager.DisplayMessage(new InformationMessage(text.ToString(), Color.ConvertStringToColor("#D65252FF"))); } } if (fireData.burningTimer.Check()) { if (fireData.fireEntity != null) { foreach (ParticleSystem particle in fireData.particles) { fireData.fireEntity.RemoveComponent(particle); } if (fireData.fireLight != null) { fireData.fireLight.Intensity = 0; Skeleton skeleton = agent.AgentVisuals.GetSkeleton(); if (skeleton != null) { skeleton.RemoveComponent(fireData.fireLight); } } fireData.fireEntity = null; fireData.fireLight = null; } fireData.firebar = 0; fireData.isBurning = false; } } else { if (fireData.firebar >= FireLordConfig.IgnitionBarMax) { fireData.isBurning = true; fireData.burningTimer = new MissionTimer(FireLordConfig.IgnitionDurationInSecond); fireData.damageTimer = new MissionTimer(1f); EquipmentIndex index = agent.GetWieldedItemIndex(Agent.HandIndex.MainHand); if (index == EquipmentIndex.None) { return; } GameEntity wieldedWeaponEntity = agent.GetWeaponEntityFromEquipmentSlot(index); Skeleton skeleton = agent.AgentVisuals.GetSkeleton(); if (skeleton == null) { return; } fireData.particles = new ParticleSystem[_ignitionBoneIndexes.Length]; for (byte i = 0; i < _ignitionBoneIndexes.Length; i++) { MatrixFrame localFrame = new MatrixFrame(Mat3.Identity, new Vec3(0, 0, 0)); ParticleSystem particle = ParticleSystem.CreateParticleSystemAttachedToEntity("psys_campfire", wieldedWeaponEntity, ref localFrame); skeleton.AddComponentToBone(_ignitionBoneIndexes[i], particle); fireData.particles[i] = particle; } //只有通过扔掉再重新捡起这把武器,才能让粒子效果出现 FireSwordLogic.DropLock = true; agent.DropItem(index); SpawnedItemEntity spawnedItemEntity = wieldedWeaponEntity.GetFirstScriptOfType <SpawnedItemEntity>(); agent.OnItemPickup(spawnedItemEntity, EquipmentIndex.None, out bool removeItem); fireData.fireEntity = wieldedWeaponEntity; FireSwordLogic.DropLock = false; Light light = Light.CreatePointLight(FireLordConfig.IgnitionLightRadius); light.Intensity = FireLordConfig.IgnitionLightIntensity; light.LightColor = FireLordConfig.IgnitionLightColor; skeleton.AddComponentToBone(0, light); fireData.fireLight = light; } else { fireData.firebar -= dt * FireLordConfig.IgnitionDropPerSecond; fireData.firebar = Math.Max(fireData.firebar, 0); if (!agent.IsActive()) { _deleteAgent.Add(agent); } } } } foreach (Agent agent in _deleteAgent) { AgentFireData fireData = AgentFireDatas[agent]; GameEntity entity = fireData.fireEntity; if (entity != null) { entity.RemoveAllParticleSystems(); } Skeleton skeleton = agent.AgentVisuals.GetSkeleton(); if (skeleton != null && fireData.fireLight != null) { skeleton.RemoveComponent(fireData.fireLight); } AgentFireDatas.Remove(agent); } } }