/// <summary> /// Method to substract 1 life point from the player /// </summary> public void dmgTaken() { textObjLifeDown = textObj.GetComponent <Text>(); textObjLifeDown.text = "<color=red>-1</color>"; textObjLifeDown = Instantiate(textObj, lifeText.transform.position, Quaternion.identity); textObjLifeDown.transform.SetParent(ui); textObjLifeDown = null; life--; OnLifeChange?.Invoke(life); }
public bool this[int x, int y] { get { return(world[x, y]); } set { if (world[x, y] != value) { world[x, y] = value; OnLifeChange?.Invoke(x, y, value); } } }
/// <summary> /// Method to add one life point to the player /// </summary> public void AddLife() { Instantiate(uiParticle, lifeBubble.transform.position, Quaternion.identity); textObjLifeUp = textObj.GetComponent <Text>(); textObjLifeUp.text = "<color=green>+1</color>"; textObjLifeUp = Instantiate(textObj, lifeText.transform.position, Quaternion.identity); textObjLifeUp.transform.SetParent(ui); textObjLifeUp = null; life++; OnLifeChange?.Invoke(life); }
private void OnCollisionEnter2D(Collision2D collision) { life--; OnLifeChange?.Invoke(life); if (collision.gameObject.tag == "Ball") { Ball.isMoving = false; } if (life == 0) { GameObject[] block = GameObject.FindGameObjectsWithTag("Block"); foreach (GameObject obj in block) { GameObject.Destroy(obj); } } }
public void InvokeLife() { OnLifeChange?.Invoke(life); }