public void InitParticules() { GameObject g = GameObject.FindGameObjectWithTag("ParticuleManager"); if (g != null) { pm = g.GetComponent <ParticuleManager>(); GameObject g1 = pm.GetParticuleAttack(fighter); if (g1 != null) { attackParticules = g1.GetComponent <ParticleSystem>(); } GameObject g2 = pm.GetParticuleImpact(fighter); if (g2 != null) { impParticules = g2.GetComponent <ParticleSystem>(); } } }
void Update() { if (fighter.nID != 0) { if (!initPar) { initPar = true; InitParticules(); } } if (fighter.nCurrentHealth == 0 && fighterRenderer != null) { fighterRenderer.enabled = false; gameObject.transform.GetChild(0).gameObject.SetActive(false); ui.SetActive(false); canvas.SetActive(false); Renderer[] rs = GetComponentsInChildren <Renderer>(); foreach (Renderer r in rs) { r.enabled = false; } // mutation } if (fighter.justTookDamage) { fighter.justTookDamage = false; slash.Play(); if (!isTrigger) { isTrigger = true; GameObject g = GameObject.FindGameObjectWithTag("ParticuleManager"); if (g != null && fighter.eCreatureType == CreatureType.Monster) { ParticuleManager pm = g.GetComponent <ParticuleManager>(); GameObject go = Instantiate(pm.defaultParticules.trigger) as GameObject; // go.transform.position = ui.transform.position; go.transform.parent = ui.transform; go.transform.localPosition = Vector3.zero; go.transform.localPosition = new Vector3(go.transform.localPosition.x, go.transform.localPosition.y + 0.5f, go.transform.localPosition.z - 2f); ParticleSystem par = go.GetComponent <ParticleSystem>(); par.Play(); Destroy(go, 2f); } } } if (fighter.bTryToescape && !bHasBeenTurned) { bHasBeenTurned = true; fighterRenderer.gameObject.transform.Rotate(new Vector3(0, 180, 0)); // renderer.gameObject.transform.Rotate(new Vector3(0, 180, 0)); } if (fighter.justdidAction) { fighter.justdidAction = false; if (fighter.lastAction == ActionType.ATTACK) { if (fighter.lastActionResult == RollResultEnum.Fail) { GameObject go = Instantiate(pm.GetParticuleOfAction(fighter.lastAction, fighter.lastActionResult)) as GameObject; go.transform.position = ui.transform.position; go.transform.localPosition = new Vector3(go.transform.localPosition.x - 0.5f, go.transform.localPosition.y, go.transform.localPosition.z); particulPlaying = go.GetComponent <ParticleSystem>(); particulPlaying.Play(); Destroy(go, 5f); } else { GameObject partic = pm.GetParticuleAttack(fighter); if (partic != null) { GameObject go = Instantiate(partic) as GameObject; go.transform.position = ui.transform.position; go.transform.localPosition = new Vector3(go.transform.localPosition.x, go.transform.localPosition.y, go.transform.localPosition.z); particulPlaying = go.GetComponent <ParticleSystem>(); particulPlaying.Play(); Destroy(go, 5f); } partic = pm.GetParticuleImpact(fighter); if (partic != null) { GameObject go2 = Instantiate(partic) as GameObject; go2.transform.position = fighter.lastAttackedUI.ui.transform.position; go2.transform.localPosition = new Vector3(go2.transform.localPosition.x, go2.transform.localPosition.y, go2.transform.localPosition.z); go2.GetComponent <ParticleSystem>().Play(); Destroy(go2, 5f); } if (fighter.lastActionResult == RollResultEnum.Crit) { GameObject g = GameObject.FindGameObjectWithTag("ParticuleManager"); ParticuleManager pm = g.GetComponent <ParticuleManager>(); GameObject go2 = Instantiate(pm.defaultParticules.attackCriti) as GameObject; go2.transform.parent = fighter.lastAttackedUI.ui.transform; go2.transform.localPosition = Vector3.zero; go2.transform.localPosition = new Vector3(go2.transform.localPosition.x - 0.5f, go2.transform.localPosition.y + 1, go2.transform.localPosition.z); go2.GetComponent <ParticleSystem>().Play(); Destroy(go2, 5f); } // attackParticules.Play(); // particulPlaying = attackParticules; } } else if (fighter.lastAction == ActionType.TALK) { RollResultEnum result = RollResultEnum.Normal; if (fighter.eCreatureType == CreatureType.Monster) { result = fighter.lastActionResult; } GameObject go = Instantiate(pm.GetParticuleOfAction(fighter.lastAction, result)) as GameObject; GameObject meshHolder = GameObject.FindGameObjectWithTag("DialogueMesh"); if (meshHolder == null) { go.transform.position = ui.transform.position; } else { // meshHolder.GetComponent<MeshMonsterBuble>().UpdateMeshHoldePosition(); go.transform.position = meshHolder.transform.position; } go.transform.localPosition = new Vector3(go.transform.localPosition.x - 1f, go.transform.localPosition.y, go.transform.localPosition.z); talkParticules = go.GetComponent <ParticleSystem>(); talkParticules.Play(); particulPlaying = talkParticules; Destroy(go, 5f); } else if (fighter.lastAction == ActionType.FEAR) { GameObject go = Instantiate(pm.GetParticuleOfAction(fighter.lastAction, fighter.lastActionResult)) as GameObject; GameObject meshHolder = GameObject.FindGameObjectWithTag("DialogueMesh"); if (meshHolder == null) { go.transform.position = ui.transform.position; } else { // meshHolder.GetComponent<MeshMonsterBuble>().UpdateMeshHoldePosition(); go.transform.position = meshHolder.transform.position; } go.transform.localPosition = new Vector3(go.transform.localPosition.x - 1f, go.transform.localPosition.y, go.transform.localPosition.z); fearParticules = go.GetComponent <ParticleSystem>(); fearParticules.Play(); particulPlaying = fearParticules; Destroy(go, 5f); } else { particulPlaying = null; } } if (particulPlaying == null || particulPlaying.isStopped) { fighter.performingAction = false; } }