97 lines
4.9 KiB
C#
97 lines
4.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using BlueWater.Interfaces;
|
|
using Sirenix.OdinInspector;
|
|
using Sirenix.Utilities;
|
|
using UnityEngine;
|
|
|
|
namespace BlueWater.Items
|
|
{
|
|
[Serializable]
|
|
public class CocktailData : IPickup
|
|
{
|
|
[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 데이터 영역")]
|
|
public int IngredientRatio1 { get; set; }
|
|
|
|
[field: SerializeField, Tooltip("2번 재료 식별 Idx"), BoxGroup("Json 데이터 영역")]
|
|
public string IngredientIdx2 { get; set; }
|
|
|
|
[field: SerializeField, Tooltip("2번 재료 수량 Idx"), BoxGroup("Json 데이터 영역")]
|
|
public int IngredientRatio2 { get; set; }
|
|
|
|
[field: SerializeField, Tooltip("3번 재료 식별 Idx"), BoxGroup("Json 데이터 영역")]
|
|
public string IngredientIdx3 { get; set; }
|
|
|
|
[field: SerializeField, Tooltip("3번 재료 수량 Idx"), BoxGroup("Json 데이터 영역")]
|
|
public int IngredientRatio3 { get; set; }
|
|
|
|
[field: SerializeField, Tooltip("4번 재료 식별 Idx"), BoxGroup("Json 데이터 영역")]
|
|
public string IngredientIdx4 { get; set; }
|
|
|
|
[field: SerializeField, Tooltip("4번 재료 수량 Idx"), BoxGroup("Json 데이터 영역")]
|
|
public int IngredientRatio4 { get; set; }
|
|
|
|
[field: SerializeField, Tooltip("5번 재료 식별 Idx"), BoxGroup("Json 데이터 영역")]
|
|
public string IngredientIdx5 { get; set; }
|
|
|
|
[field: SerializeField, Tooltip("5번 재료 수량 Idx"), BoxGroup("Json 데이터 영역")]
|
|
public int IngredientRatio5 { get; set; }
|
|
|
|
[BoxGroup("직접 추가하는 영역")]
|
|
[field: SerializeField, BoxGroup("직접 추가하는 영역")]
|
|
public Sprite Sprite { get; set; }
|
|
|
|
[field: SerializeField]
|
|
public List<CocktailIngredient> ValidIngredients { get; set; } = new(5);
|
|
|
|
//해당 칵테일에 포함된 Ratio를 리턴
|
|
public List<CocktailIngredient> GetValidIngredients(int liquidMaxAmount)
|
|
{
|
|
var ingredients = new List<CocktailIngredient>(5);
|
|
|
|
if (!string.IsNullOrEmpty(IngredientIdx1)) ingredients.Add(new CocktailIngredient(IngredientIdx1, IngredientRatio1, (int)(liquidMaxAmount * (IngredientRatio1 / 100f))));
|
|
if (!string.IsNullOrEmpty(IngredientIdx2)) ingredients.Add(new CocktailIngredient(IngredientIdx2, IngredientRatio2, (int)(liquidMaxAmount * (IngredientRatio2 / 100f))));
|
|
if (!string.IsNullOrEmpty(IngredientIdx3)) ingredients.Add(new CocktailIngredient(IngredientIdx3, IngredientRatio3, (int)(liquidMaxAmount * (IngredientRatio3 / 100f))));
|
|
if (!string.IsNullOrEmpty(IngredientIdx4)) ingredients.Add(new CocktailIngredient(IngredientIdx4, IngredientRatio4, (int)(liquidMaxAmount * (IngredientRatio4 / 100f))));
|
|
if (!string.IsNullOrEmpty(IngredientIdx5)) ingredients.Add(new CocktailIngredient(IngredientIdx5, IngredientRatio5, (int)(liquidMaxAmount * (IngredientRatio5 / 100f))));
|
|
|
|
return ingredients;
|
|
}
|
|
|
|
//해당 칵테일에 포함하는 Ingredient를 찾음 없는 값이면 0을 리턴함
|
|
public int SearchIngredient(string serchIngredientIdx)
|
|
{
|
|
if (!IngredientIdx1.IsNullOrWhitespace() && IngredientIdx1.Equals(serchIngredientIdx)) { return 1; }
|
|
if (!IngredientIdx2.IsNullOrWhitespace() && IngredientIdx2.Equals(serchIngredientIdx)) { return 2; }
|
|
if (!IngredientIdx3.IsNullOrWhitespace() && IngredientIdx3.Equals(serchIngredientIdx)) { return 3; }
|
|
if (!IngredientIdx4.IsNullOrWhitespace() && IngredientIdx4.Equals(serchIngredientIdx)) { return 4; }
|
|
if (!IngredientIdx5.IsNullOrWhitespace() && IngredientIdx5.Equals(serchIngredientIdx)) { return 5; }
|
|
return 0;//
|
|
}
|
|
|
|
public int GetIngredientRatio(string serchIngredientIdx)
|
|
{
|
|
int serchNum = SearchIngredient(serchIngredientIdx);
|
|
|
|
if (serchNum == 1) { return IngredientRatio1;}
|
|
if (serchNum == 2) { return IngredientRatio2;}
|
|
if (serchNum == 3) { return IngredientRatio3;}
|
|
if (serchNum == 4) { return IngredientRatio4;}
|
|
if (serchNum == 5) { return IngredientRatio5;}
|
|
return 0;// 없거나 0으로 표기됨
|
|
}
|
|
}
|
|
} |