CapersProject/Assets/02.Scripts/Item/Cocktail/CocktailData.cs

80 lines
3.5 KiB
C#
Raw Normal View History

2024-08-22 10:39:15 +00:00
using System;
using System.Collections.Generic;
using BlueWater.Interfaces;
using Sirenix.OdinInspector;
using UnityEngine;
namespace BlueWater.Items
{
[Serializable]
public class CocktailData : IIdx
{
[BoxGroup("Json 데이터 영역")]
[field: SerializeField, Tooltip("고유 식별 ID"), BoxGroup("Json 데이터 영역")]
public string Idx { get; set; }
[field: SerializeField, Tooltip("이름"), BoxGroup("Json 데이터 영역")]
public string Name { get; set; }
[field: SerializeField, Tooltip("오차 범위"), BoxGroup("Json 데이터 영역")]
public int RatioRange { get; set; }
[field: SerializeField, Tooltip("1번 재료 식별 Idx"), BoxGroup("Json 데이터 영역")]
public string IngredientIdx1 { get; set; }
[field: SerializeField, Tooltip("1번 재료 수량 Idx"), BoxGroup("Json 데이터 영역")]
2024-09-10 07:26:29 +00:00
public int IngredientAmount1 { get; set; }
2024-08-22 10:39:15 +00:00
[field: SerializeField, Tooltip("2번 재료 식별 Idx"), BoxGroup("Json 데이터 영역")]
public string IngredientIdx2 { get; set; }
[field: SerializeField, Tooltip("2번 재료 수량 Idx"), BoxGroup("Json 데이터 영역")]
2024-09-10 07:26:29 +00:00
public int IngredientAmount2 { get; set; }
2024-08-22 10:39:15 +00:00
[field: SerializeField, Tooltip("3번 재료 식별 Idx"), BoxGroup("Json 데이터 영역")]
public string IngredientIdx3 { get; set; }
[field: SerializeField, Tooltip("3번 재료 수량 Idx"), BoxGroup("Json 데이터 영역")]
2024-09-10 07:26:29 +00:00
public int IngredientAmount3 { get; set; }
2024-08-22 10:39:15 +00:00
[field: SerializeField, Tooltip("4번 재료 식별 Idx"), BoxGroup("Json 데이터 영역")]
public string IngredientIdx4 { get; set; }
[field: SerializeField, Tooltip("4번 재료 수량 Idx"), BoxGroup("Json 데이터 영역")]
2024-09-10 07:26:29 +00:00
public int IngredientAmount4 { get; set; }
2024-08-22 10:39:15 +00:00
[field: SerializeField, Tooltip("5번 재료 식별 Idx"), BoxGroup("Json 데이터 영역")]
public string IngredientIdx5 { get; set; }
[field: SerializeField, Tooltip("5번 재료 수량 Idx"), BoxGroup("Json 데이터 영역")]
2024-09-10 07:26:29 +00:00
public int IngredientAmount5 { get; set; }
2024-08-22 10:39:15 +00:00
[BoxGroup("직접 추가하는 영역")]
[field: SerializeField, BoxGroup("직접 추가하는 영역")]
public Sprite Sprite { get; set; }
2024-08-22 10:39:15 +00:00
public List<CocktailIngredient> GetValidIngredients()
{
var ingredients = new List<CocktailIngredient>(5);
2024-09-10 07:26:29 +00:00
if (!string.IsNullOrEmpty(IngredientIdx1)) ingredients.Add(new CocktailIngredient(IngredientIdx1, IngredientAmount1));
if (!string.IsNullOrEmpty(IngredientIdx2)) ingredients.Add(new CocktailIngredient(IngredientIdx2, IngredientAmount2));
if (!string.IsNullOrEmpty(IngredientIdx3)) ingredients.Add(new CocktailIngredient(IngredientIdx3, IngredientAmount3));
if (!string.IsNullOrEmpty(IngredientIdx4)) ingredients.Add(new CocktailIngredient(IngredientIdx4, IngredientAmount4));
if (!string.IsNullOrEmpty(IngredientIdx5)) ingredients.Add(new CocktailIngredient(IngredientIdx5, IngredientAmount5));
2024-08-22 10:39:15 +00:00
return ingredients;
}
2024-09-10 07:26:29 +00:00
public int GetCocktailAmount(List<CocktailIngredient> cocktailIngredients)
{
var amount = 0;
foreach (var element in cocktailIngredients)
{
amount += element.Amount;
}
return amount;
}
2024-08-22 10:39:15 +00:00
}
}