private void OnTriggerEnter(Collider other) { if (other.tag == "Boundary") { return; //если соприкосается с Границой - ничего не происхоодит } if (other.tag == "Player") { if (Player.hitPoints > 1) { Destroy(gameObject); Player.hitPoints = Player.hitPoints - 1; GameView.UpdateHitpoints(); return; } else { GameView.GameOver(); } } GameView.AddScore(ScoreValue); Destroy(other.gameObject); // уничтожает объект который прикоснулся Destroy(gameObject); // уничтожает самого себя }
private void SetMatch() { List <PieceDO> bonusPieces = _currentPool.FindAll(p => p.View.HasBonus); foreach (PieceDO pieceDo in bonusPieces) { //TODO set pieces type of animation to destroy which depends on BonusType switch (pieceDo.View.BonusType) { case BonusType.Bomb: ActivateBombBonus(pieceDo); break; case BonusType.Color: ActivateColorBonus(pieceDo); break; case BonusType.Time: ActivateTimeBonus(); break; case BonusType.BlackHole: ActivateBlackHoleBonus(pieceDo.Type); break; case BonusType.SuperCube: _setSuperCubeBonus = true; break; } _bonusController.StartBonus(pieceDo.View.BonusType); } foreach (var pieceDo in _currentPool) { pieceDo.View.ShowRemove(); //pieceDo.View.gameObject.SetActive(false); _grid[pieceDo.Col][pieceDo.Row] = null; AffectAbove(pieceDo); } int score = _currentPool.Count * _config.GetMatchKoeff(_currentPool.Count, _selectedType); _gameView.AddScore(score); if (_selectedType != PieceType.MAGIC_DIAMOND && _selectedType != PieceType.FRIEND_DIAMOND) { _gameView.AddDiamondProgress(_currentPool.Count); } AddNewPieces(); CheckForMatches(); if (_setSuperCubeBonus) { ActivateSuperCubeBonus(); _setSuperCubeBonus = false; } }