33 lines
828 B
C#
33 lines
828 B
C#
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
|
||
|
// ReSharper disable once CheckNamespace
|
||
|
namespace BlueWaterProject
|
||
|
{
|
||
|
[Serializable]
|
||
|
public class PlayerInventory
|
||
|
{
|
||
|
[SerializeField] private List<FishInfo> fishInfoList = new();
|
||
|
|
||
|
public void AddFish(string name, int? count = null)
|
||
|
{
|
||
|
var existingFish = fishInfoList.Find(fish => fish.Name == name);
|
||
|
|
||
|
if (existingFish != null)
|
||
|
{
|
||
|
existingFish.AddCount(count);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
fishInfoList.Add(new FishInfo(name, 1));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public int GetFishCount(string name)
|
||
|
{
|
||
|
var fish = fishInfoList.Find(f => f.Name == name);
|
||
|
return fish?.Count ?? 0;
|
||
|
}
|
||
|
}
|
||
|
}
|