void Awake() { this._rigidbody = GetComponent <Rigidbody2D>(); sp = GetComponent <LebensPunkte>(); sp.init(lebensPunkte, damage); this._camera = Camera.main; sc = GetComponent <SceneController>(); }
//Awake is called much earlier that start. Alternatively you could set these values in Init void Awake() { this._rigidbody = GetComponent <Rigidbody2D>(); this._camera = Camera.main; audios = GetComponent <AudioSource>(); sp = GetComponent <LebensPunkte>(); score = GetComponent <Score>(); }
void Awake() { this._rigidbody = GetComponent <Rigidbody2D>(); this._player = FindObjectOfType <PlayerController>().GetComponent <Rigidbody2D>(); this._renderer = GetComponent <SpriteRenderer>(); audios = GetComponent <AudioSource>(); sp = GetComponent <LebensPunkte>(); score = GetComponent <Score>(); }
private void OnCollisionEnter2D(Collision2D other) { PlayerController pc = other.gameObject.GetComponent <PlayerController>(); if (!pc) { return; } LebensPunkte lp = other.gameObject.GetComponent <LebensPunkte>(); lp.minusLebnspunkte(sp.getDamage()); sp.minusLebnspunkte(lp.getDamage()); this._particles.Play(); audios.Play(); if (sp.ifDamage()) { score.addScore(bonus); Debug.Log(Score.score); this.Hit(); } }
private void OnTriggerEnter2D(Collider2D other) { Enemy enemy = other.gameObject.GetComponent <Enemy>(); if (!enemy) { return; } audios.Play(); LebensPunkte lp = other.gameObject.GetComponent <LebensPunkte>(); sp.minusLebnspunkte(lp.getDamage()); lp.minusLebnspunkte(sp.getDamage()); if (lp.ifDamage()) { enemy.Hit(); score.addScore(bonus); Debug.Log(Score.score); } if (sp.ifDamage()) { this.BackToPool(); } }