Files
aibis-dream/Assets/Scripts/FixSystem/Book/BookManager.cs
T

47 lines
1.1 KiB
C#

using UnityEngine;
using Yarn.Unity;
using System;
using System.Collections.Generic;
using System.Collections;
public class BookManager : MonoBehaviour
{
public Book book; // Reference to the book script
private AutoFlip flipmanager;
void Start()
{
flipmanager=book.gameObject.GetComponent<AutoFlip>();
// Initially, the book is closed
CloseBook();
}
// Open the book and flip to a specific page
[YarnCommand("OpenBook")]
public void OpenBook()
{
if (!book.gameObject.activeInHierarchy)
{
book.gameObject.SetActive(true);
}
}
[YarnCommand("Flip")]
public IEnumerator FlipToPageYarnCommand(int parameters)
{
// Parse the target page from the parameters
int targetPage =parameters;
// Start the FlipToPageCoroutine and wait for it to finish
yield return StartCoroutine(flipmanager.FlipToPageCoroutine(targetPage));
}
// Close the book
public void CloseBook()
{
if (book.gameObject.activeInHierarchy)
{
book.gameObject.SetActive(false);
}
}
}