void Update() { if (entity.GetValue("FIRE") == "ON" && particules.isPlaying == false) { particules.Play(); } else if (entity.GetValue("FIRE") == "OFF" && particules.isPlaying) { particules.Stop(); } }
private void Update() { string value = entity.GetValue(key); if (value == currentWeapon.name) { return; } if (value == "FIST") { SetWeapon(0); } else if (value == "SWORD") { SetWeapon(1); } else if (value == "MACE") { SetWeapon(2); } else if (value == "SHOTGUN") { SetWeapon(3); } }
private void Update() { GetComponent <Image>().enabled = parentEntity.gameObject.activeSelf; content.GetComponent <Image>().enabled = parentEntity.gameObject.activeSelf; foreach (Viewer v in allViewer) { v.textContent.gameObject.SetActive(parentEntity.gameObject.activeSelf); } nameEntity.textContent.gameObject.SetActive(parentEntity.gameObject.activeSelf); nameEntity.textContent.text = parentEntity.GetName(); nameEntity.textContent.transform.rotation = Quaternion.identity; //Debug.Log(parentEntity.name + " " + newRect); if (parentEntity.GetName() == "HERO") { trans.SetAsLastSibling(); } Vector3 newPos; if (parentEntity.GetComponent <KingGoblin>()) { newPos = Camera.main.WorldToScreenPoint(parentEntity.transform.position - Vector3.up * 2.0f); } else if (parentEntity.GetName() == "BRIDGE") { newPos = Camera.main.WorldToScreenPoint(parentEntity.transform.position); } else { newPos = Camera.main.WorldToScreenPoint(parentEntity.transform.position - Vector3.up); } transform.position = newPos; transform.rotation = Quaternion.identity; foreach (Viewer v in allViewer) { v.textContent.text = v.key + " : " + parentEntity.GetValue(v.key); v.textContent.transform.rotation = Quaternion.identity; } Vector2 newRect = content.GetComponent <RectTransform>().sizeDelta; newRect.x += space; newRect.y += space; trans.sizeDelta = newRect; content.rotation = Quaternion.identity; }
private void OnTriggerEnter2D(Collider2D other) { if (other.transform.tag != "Attack") { return; } string life = entity.GetValue("LIFE"); int l = 0; if (int.TryParse(life, out l)) { l -= other.transform.parent.GetComponent <PlayerController>().GetComponentInChildren <PlayerWeapon>().GetCurrentWeapon().damage; AudioSource source = GetComponent <AudioSource>(); if (source == null) { source = gameObject.AddComponent <AudioSource>(); } source.clip = other.transform.parent.GetComponent <PlayerController>().GetComponentInChildren <PlayerWeapon>().GetCurrentWeapon().touch; source.loop = false; source.volume = 0.1f; if (source.clip != null) { source.Play(); } int i = 0; foreach (GameObject heart in hearts) { if (i < l) { heart.SetActive(true); } else { heart.SetActive(false); } i++; } entity.SetValue("LIFE", l.ToString()); if (l < 1) { if (enabled) { myAnimator.SetTrigger("Dead"); } enabled = false; myRigidBody.velocity = new Vector2(0, myRigidBody.velocity.y); Instantiate(fx_death, transform.position, Quaternion.identity); Instantiate(deathBossGoblin, transform.position, Quaternion.identity); } else { Instantiate(fx_hurth, transform.position, Quaternion.identity); } } if (l > 0) { JumpTo(column == 0 ? map.GetNbrColumn() - 1 : 0); } }