//reduces time by 1 turn each time it's called virtual public void UpdateEffect(Character chara) { timer--; if (particles != null && (timer < particles.main.startLifetime.constant || chara.Hp <= 0) && partInst != null) { partInst.GetComponent <ParticleSystem>().Stop(); } if (material != null && (timer < 1 || chara.Hp <= 0)) { chara.gameObject.GetComponentInChildren <Renderer>().material = originalMaterial; } if (shader != null && (timer < 1 || chara.Hp <= 0)) { foreach (Renderer shad in chara.GetComponentsInChildren <Renderer>()) { if (shad.GetComponent <ParticleSystem>() == null) { //edit here if models don't use the standard shader (eg are legacy ones) shad.material.shader = Shader.Find("Standard"); } } } if (gObject != null && (timer < 1 || chara.Hp <= 0)) { Destroy(gObjectInst); } }
public void Clone(Character target) { // make as copy of the particles if (particles != null) { //if given a position, will move particle to there, if not dumps at feet partInst = Instantiate(particles.gameObject); if (target.CharaBodyparts[StatusEffectPosition] != null) { partInst.transform.parent = target.transform; partInst.transform.position = target.CharaBodyparts[StatusEffectPosition].transform.position; } else { partInst.transform.parent = target.transform; partInst.transform.localPosition = Vector3.zero; } } //makes a copy of the materialFIX THIS OR REMOVE AND REPLACE WITH SHADERS if (material != null) { matInst = Instantiate(material); target.GetComponentInChildren <Renderer>().material.EnableKeyword("_METALLICGLOSSMAP"); originalMaterial = target.GetComponentInChildren <Renderer>().material; matInst.SetTexture("_MetallicGlossMap", target.GetComponentInChildren <Renderer>().material.mainTexture); target.gameObject.GetComponentInChildren <Renderer>().material = matInst; } if (shader != null) { //shaderInst = Instantiate(shader); //CAN'T INSTANTIATE SHADERS OR ELSE IT CRASHES THE BUILD shaderInst = shader; foreach (Renderer shad in target.GetComponentsInChildren <Renderer>()) { if (shad.GetComponent <ParticleSystem>() == null) { shad.material.shader = shaderInst; } } } //spawns the gameobject instance at targets feet(meybe make localTransform param?) if (gObject != null) { gObjectInst = Instantiate(gObject); if (target.CharaBodyparts[StatusEffectPosition] != null) { gObjectInst.transform.parent = target.transform; gObjectInst.transform.position = target.CharaBodyparts[StatusEffectPosition].transform.position; } else { gObjectInst.transform.parent = target.transform; gObjectInst.transform.localPosition = Vector3.zero; } } }