void OnCollisionExit2D(Collision2D collision) { if (this.upgrade) { BallDatabase database = GameContext.ballFactory.GetDatabase(); BallType nextType = database.GetNextBallType(this.type); if (nextType != BallType.Null) { ScoreMessage scoreMessage = GameContext.messageDispatcher.AddMessage <ScoreMessage>(); scoreMessage.score = database.GetValue(this.type) * 2; this.type = nextType; this.color = database.GetColor(nextType); this.upgrade = false; } else { this.destroy = true; } } if (this.destroy) { MakeAvailableForReuse(); } }
void Awake() { m_pool = FindObjectOfType <GameObjectPool>(); m_database = FindObjectOfType <BallDatabase>(); }