using UnityEngine;
using UnityEngine.UI;
using TMPro;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using UnityEngine.Audio;
using com.ootii.Actors;
using com.ootii.Actors.AnimationControllers;
using com.ootii.Cameras;
using com.ootii.Input;
[System.Serializable]
public class Page
{
public string title;
public string leftPageText;
// You can add more properties if needed, such as rightPageText, images, etc.
}
[System.Serializable]
public class Book
{
public string bookTitle;
public Sprite bookIcon;
public Sprite bookBackground;
public string puzzleHint; // Puzzle hint specific to the book
public Sprite puzzleHintBackground; // Background sprite for the puzzle hint
public AudioClip ambientSound; // Ambient sound specific to the book
public List pages;
public bool requiresKnowledge = true; // New property to determine if the book requires knowledge to read
public Book(string title)
{
bookTitle = title;
pages = new List<Page>();
}
// You can add more properties and methods specific to a book here
}
public class BookController : MonoBehaviour
{
public List books = new List(); // List of all books
private Book currentBook; // The currently selected book
private int currentBookIndex = 0; // Index of the current book
private int currentPageIndex = 0; // Index of the current page within the current book
public TextMeshProUGUI titleTextUI; // TextMeshProGUI for the title
public TextMeshProUGUI pageTextUI; // TextMeshProUGUI for the page
public Image bookIconUI; // UI element for the book icon
public Image bookBackgroundUI; // UI element for the book background
public TextMeshProUGUI puzzleHintTextUI; // Reference to the puzzle hint TextMeshPro element
public Image puzzleHintBackgroundUI; // Reference to the puzzle hint background Image element
public Button nextButton; // Button to flip forward
public Button prevButton; // Button to flip backward
public Button closeButton;
public GameObject puzzleHintUI;
public AudioMixer audioMixer;
public AudioSource pageAudioSource;
public AudioSource ambientAudioSource;
public AudioClip closeSound;
public AudioClip pageTurnClip; // Assign this in the inspector
public Animator animator; // Animator for page flip animations
public bool playerHasKnowledge = false; // Player's ability to read the real text
//private int currentPageIndex = 0; // Index of the current page
private InsaneMode insaneModeScript;
public UnityInputSource InputSource;
public CameraController camRig;
public ActorController actorController;
public MotionController motionController;
private Dictionary<string, string> lovecraftianDictionary = new Dictionary<string, string>
{
// Common words
{"the", "yog"}, {"and", "soth"}, {"to", "leng"}, {"of", "oveh"}, {"a", "cthun"},
{"in", "fhtagn"}, {"is", "gnaiih"}, {"you", "yhah"}, {"that", "n'gha"}, {"it", "zhro"},
{"he", "tharanak"}, {"with", "ephai"}, {"as", "s'uhn"}, {"for", "y'hah"}, {"his", "gotha"},
{"on", "n'ghft"}, {"are", "or'azh"}, {"by", "zhro"}, {"be", "throd"}, {"was", "nafl"},
{"this", "ilyaa"}, {"not", "nah"}, {"but", "bug"}, {"from", "fhalma"}, {"they", "tharan"},
{"her", "hrii"}, {"we", "wgah'n"}, {"have", "agl"}, {"which", "kadishtu"}, {"an", "uln"},
{"at", "kn'a"}, {"can", "k'yarnak"}, {"my", "nog"}, {"all", "fhalma"}, {"your", "li'hee"},
{"their", "ron"}, {"has", "gnaiih"}, {"do", "nafl"}, {"our", "or'azh"}, {"more", "nafll"},
{"one", "uaaah"}, {"who", "uh'e"}, {"I", "ai"}, {"them", "throd"},
{"what", "tharanak"}, {"when", "zhro"}, {"would", "y'hah"}, {"there", "y'hah'nn"},
{"like", "lyeh'n"}, {"if", "ph'nglui"}, {"time", "eeeh"}, {"no", "nog"}, {"out", "yugg"},