Beispiel #1
0
    public void Spawn(GemTypeSO gemType)
    {
        _particle.textureSheetAnimation.RemoveSprite(0);
        _particle.textureSheetAnimation.AddSprite(gemType.Sprite);

        this.gameObject.SetActive(true);
        _particle.Play();
    }
Beispiel #2
0
    public void ExplodeGems(BackToBackCount gemCount)
    {
        if (gemCount.HasEnoughHorizontalToMatch())
        {
            // TODO - collect type of gems to use as power
            foreach (Gem gem in gemCount.horizontalGems)
            {
                if (gem.gemTypeSO.GemType != GemType.Empty)
                {
                    Instantiate(gemExplosion, gem.transform.position, gem.transform.rotation);
                    count++;
                    if (color != gem.gemTypeSO.GemColor)
                    {
                        color = gem.gemTypeSO.GemColor;
                    }
                }
                GemTypeSO gemTypeSO = new GemTypeSO();
                gemTypeSO.GemType  = GemType.Empty;
                gemTypeSO.GemColor = GemColor.Empty;
                gem.SetType(gemTypeSO);
            }
        }
        if (gemCount.HasEnoughVerticalToMatch())
        {
            // TODO - collect type of gems to use as power
            foreach (Gem gem in gemCount.verticalGems)
            {
                if (gem.gemTypeSO.GemType != GemType.Empty)
                {
                    Instantiate(gemExplosion, gem.transform.position, gem.transform.rotation);
                    count++;
                    if (color != gem.gemTypeSO.GemColor)
                    {
                        color = gem.gemTypeSO.GemColor;
                    }
                }
                GemTypeSO gemTypeSO = new GemTypeSO();
                gemTypeSO.GemType  = GemType.Empty;
                gemTypeSO.GemColor = GemColor.Empty;
                gem.SetType(gemTypeSO);
            }
        }

        if (count > 0)
        {
            PlayerPowerups(count, color);
            count = 0;
        }
    }
Beispiel #3
0
    public void Setup(GridManager grid, Vector3 initialPosition = default, GemTypeSO gemType = null, GridSlot initialSlot = null)
    {
        _gridManager            = grid;
        this.transform.position = initialPosition;
        this.gameObject.SetActive(true);

        if (gemType != null)
        {
            this.SetGemType(gemType);
        }

        if (initialSlot != null)
        {
            this.GoToSlot(initialSlot);
        }
    }
Beispiel #4
0
 public void SetGemType(GemTypeSO newType)
 {
     _spriteRenderer.sprite = newType.Sprite;
     this.Type = newType.Type;
 }
Beispiel #5
0
 public void SetType(GemTypeSO gemScriptableObject)
 {
     gemTypeSO = gemScriptableObject;
     gameObject.GetComponent <SpriteRenderer>().sprite = gemScriptableObject.Sprite;
 }
Beispiel #6
0
 public void SpawnObj(GemTypeSO gemType, Vector3 position)
 {
     this.SpawnObj(position).Spawn(gemType);
 }