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

public class FruitCodeType : MonoBehaviour
{
    //样式
    public enum SeedType
    {
        //种子
        BAI_CAI,
        FAN_QIE,
        NAN_GUA,
        LUO_BO,
        YU_MI,
        QIE_ZI,
        XI_GUA,
        PU_TAO,
        CAO_MEI,
        //果实
        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,
        //土地
        LAND_GREEN,
        LAND_YELLOW,
        LAND_GOLD,
        //金币，加速剂
        JIA_SU_JI,
        JINBI
    }
    [System.Serializable]
    public struct SeedSprite
    {
        public SeedType seedType;
        public Sprite seedsprite;
    }

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

    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 SpriteRenderer fruitTypeObj;
    public void setFruitShow(bool isShow)
    {
        if (isShow)
        {
            fruitTypeObj.color = new Color(1, 1, 1, 255);
        }
        else
        {
            fruitTypeObj.color = new Color(1, 1, 1, 0);
        }
    }
    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;
        }

        if (ColorDic.ContainsKey(type))
        {
            fruitTypeObj.sprite = ColorDic[type];
        }
    }
    //土地
    public SpriteRenderer landTypeObj;
    public void setLandType(int id)
    {
        SeedType type;
        switch (id)
        {
            case 0:
                type = SeedType.LAND_GREEN;
                break;
            case 1:
                type = SeedType.LAND_GOLD;
                break;
            case 2:
                type = SeedType.LAND_YELLOW;
                break;
            default:
                type = SeedType.LAND_GREEN;
                break;
        }
        if (ColorDic.ContainsKey(type))
        {
            landTypeObj.sprite = ColorDic[type];
        }
    }
    //浮动框
    //设置浮动的显示隐藏
    public SpriteRenderer floatBgSpriteCompent;//浮动的背景
    public SpriteRenderer floatCodeSpriteCompent;//浮动内的物体
    public void setFloatCodeType(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;
            case 10:
                //设置浮动加速剂
                type = SeedType.JIA_SU_JI;
                break;
            case 11:
                //设置浮动金币
                type = SeedType.JINBI;
                break;
            default:
                type = SeedType.BAI_CAI;
                break;
        }
        if (ColorDic.ContainsKey(type))
        {
            floatCodeSpriteCompent.sprite = ColorDic[type];
        }
    }

    public void setFloatShow(bool isShow)
    {
        isShowType = isShow;
        if (isShow)
        {
            floatBgSpriteCompent.color = new Color(1, 1, 1, 255);
            floatCodeSpriteCompent.color = new Color(1, 1, 1, 255);
        }
        else
        {
            floatBgSpriteCompent.color = new Color(1, 1, 1, 0);
            floatCodeSpriteCompent.color = new Color(1, 1, 1, 0);
        }
    }


    private bool isShowType;

    //是否显示
    public bool getIsShow
    {
        get { return isShowType; }
        set { isShowType = value; }
    }

}
