using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class RipeFruit : MonoBehaviour
{
    //土地农作物样式
    public enum SeedType
    {
        LAND_BAI_CAI,
        LAND_FAN_QIE,
        LAND_NAN_GUA,
        LAND_LUO_BO,
        LAND_YU_MI,
        LAND_QIE_ZI,
        LAND_XI_GUA,
        LAND_PU_TAO,
        LAND_CAO_MEI
    }
    [System.Serializable]
    public struct RipeFruitSprite
    {
        public SeedType seedType;
        public Sprite fruitsprite;
    }

    public RipeFruitSprite[] Sprites;
    public Dictionary<SeedType, Sprite> ColorDic;
    public SeedType Spriteflower;

    public SpriteRenderer spriteCompent;

    private void Awake()
    {
        //spriteCompent = transform.GetComponentInChildren<SpriteRenderer>();
        ColorDic = new Dictionary<SeedType, Sprite>();

        for (int i = 0; i < Sprites.Length; i++)
        {
            if (!ColorDic.ContainsKey(Sprites[i].seedType))
            {
                ColorDic.Add(Sprites[i].seedType, Sprites[i].fruitsprite);
            }
        }
    }

    public void setFruitType(int id)
    {
        SeedType type;
        switch (id)
        {
            case 1:
                type = SeedType.LAND_BAI_CAI;
                break;
            case 2:
                type = SeedType.LAND_FAN_QIE;
                break;
            case 3:
                type = SeedType.LAND_NAN_GUA;
                break;
            case 4:
                type = SeedType.LAND_LUO_BO;
                break;
            case 5:
                type = SeedType.LAND_YU_MI;
                break;
            case 6:
                type = SeedType.LAND_QIE_ZI;
                break;
            case 7:
                type = SeedType.LAND_XI_GUA;
                break;
            case 8:
                type = SeedType.LAND_PU_TAO;
                break;
            case 9:
                type = SeedType.LAND_CAO_MEI;
                break;
            default:
                type = SeedType.LAND_BAI_CAI;
                break;
        }


        Spriteflower = type;
        if (ColorDic.ContainsKey(type))
        {
            spriteCompent.sprite = ColorDic[type];
        }
    }

}
