Ejemplo n.º 1
0
    void OnTriggerEnter2D(Collider2D collider)
    {
        PlayerGems gems = collider.GetComponent <PlayerGems>();

        if (gems)
        {
            switch (_color)
            {
            case GemColor.Red:
                gems.CollectRed();
                break;

            case GemColor.Blue:
                gems.CollectBlue();
                break;

            case GemColor.Green:
                gems.CollectGreen();
                break;

            case GemColor.Yellow:
                gems.CollectYellow();
                break;
            }
            Instantiate(_soundPrefab, transform.position, Quaternion.identity);
            Destroy(gameObject);
        }
    }
    public void OnPlayerCreate(GameObject player)
    {
        _playerGems = player.GetComponent <PlayerGems>();

        _lastRed = _playerGems.Red;
        SetGem(_playerGems.Red, _redGemImage, _redGemEmptySprite, _redGemSprite);

        _lastBlue = _playerGems.Blue;
        SetGem(_playerGems.Blue, _blueGemImage, _blueGemEmptySprite, _blueGemSprite);

        _lastGreen = _playerGems.Green;
        SetGem(_playerGems.Green, _greenGemImage, _greenGemEmptySprite, _greenGemSprite);

        _lastYellow = _playerGems.Yellow;
        SetGem(_playerGems.Yellow, _yellowGemImage, _yellowGemEmptySprite, _yellowGemSprite);

        StartCoroutine(CollectCoroutine());
    }