BulletHell/Assets/BulletHellTemplate/Core/FavouriteCharacter.cs

40 lines
1.1 KiB
C#
Raw Permalink Normal View History

2025-09-19 14:56:58 +05:00
using System;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
namespace BulletHellTemplate
{
public class FavouriteCharacter : MonoBehaviour
{
private int characterId;
/// <summary>
/// Sets the character ID that will be saved as the favorite.
/// </summary>
/// <param name="_characterId">The ID of the character.</param>
public void SetCharacterId(int _characterId)
{
characterId = _characterId;
}
/// <summary>
/// Called when the user clicks to set the favorite character.
/// Saves the favorite character locally and in the database.
/// </summary>
public async void OnClickSetFavourite()
{
2025-09-19 19:43:49 +05:00
RequestResult ok = await BackendManager.Service.UpdatePlayerCharacterFavouriteAsync(characterId);
if(ok.Success)
2025-09-19 14:56:58 +05:00
{
2025-09-19 19:43:49 +05:00
UICharacterMenu.Singleton.UpdateFavouriteSelected(characterId);
return;
2025-09-19 14:56:58 +05:00
}
2025-09-19 19:43:49 +05:00
Debug.LogError($"Failed to update favourite character");
2025-09-19 14:56:58 +05:00
}
}
}