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

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

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

    public SpriteRenderer spriteCompent;

    private void Awake()
    {
        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;
        }
        if (ColorDic.ContainsKey(type))
        {
            spriteCompent.sprite = ColorDic[type];
        }
    }
    //加速剂
    public void setJiasujiType()
    {
        SeedType type = SeedType.JIASUJI;
        if (ColorDic.ContainsKey(type))
        {
            spriteCompent.sprite = ColorDic[type];
        }
    }
    //金币
    public void setCoinType()
    {
        SeedType type= SeedType.JINBI;
        if (ColorDic.ContainsKey(type))
        {
            spriteCompent.sprite = ColorDic[type];
        }
    }

    private int ids = 0;
    private int types = 0;
    public void setFruitIdAndType(int id,int type)
    {
        ids = id;
        types = type;
    }

    public int  getFritId()
    {
        return ids;
    }
    public int getFritType()
    {
        return types;
    }


}
