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

public class seed : MonoBehaviour
{
    //种子样式
    public enum SeedType
    {
        BAI_CAI,
        FAN_QIE,
        NAN_GUA,
        LUO_BO,
        YU_MI,
        QIE_ZI,
        XI_GUA,
        PU_TAO,
        CAO_MEI
    }
    [System.Serializable]
    public struct SeedSprite
    {
        public SeedType seedType;
        public Sprite seedsprite;
    }

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

    public SpriteRenderer spriteCompent;

    private void Awake()
    {
        //spriteCompent = transform.GetComponent<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].seedsprite);
            }
        }
    }

    public void setSeedType(int id)
    {
        SeedType type;
        switch (id)
        {
            case 1:
                type = SeedType.BAI_CAI;
                break;
            case 2:
                type = SeedType.FAN_QIE;
                break;
            case 3:
                type = SeedType.NAN_GUA;
                break;
            case 4:
                type = SeedType.LUO_BO;
                break;
            case 5:
                type = SeedType.YU_MI;
                break;
            case 6:
                type = SeedType.QIE_ZI;
                break;
            case 7:
                type = SeedType.XI_GUA;
                break;
            case 8:
                type = SeedType.PU_TAO;
                break;
            case 9:
                type = SeedType.CAO_MEI;
                break;
            default:
                type = SeedType.BAI_CAI;
                break;
        }
        Spriteflower = type;
        if (ColorDic.ContainsKey(type))
        {
            spriteCompent.sprite = ColorDic[type];
        }
    }

}
