304 lines
9.8 KiB
C#
304 lines
9.8 KiB
C#
|
|
using System.Collections;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using UnityEngine;
|
||
|
|
using Com.LuisPedroFonseca.ProCamera2D;
|
||
|
|
using UnityEngine.SceneManagement;
|
||
|
|
using UnityEngine.UI;
|
||
|
|
|
||
|
|
public class ManagerController : MonoBehaviour {
|
||
|
|
[SerializeField] ProCamera2DTransitionsFX transition;
|
||
|
|
|
||
|
|
[SerializeField] GameObject shopBackButton;
|
||
|
|
[SerializeField] GameObject mainMenuButton;
|
||
|
|
[SerializeField] ShopController outfitShopScrollView;
|
||
|
|
[SerializeField] ShopController hairShopScrollView;
|
||
|
|
[SerializeField] ShopController foodShopScrollView;
|
||
|
|
[SerializeField] ScenePickerController taskPickerScrollView;
|
||
|
|
[SerializeField] ScenePickerController scenePickerScrollView;
|
||
|
|
[SerializeField] GameObject selectorPanel;
|
||
|
|
[SerializeField] VNController vn;
|
||
|
|
[SerializeField] AudioClip managerTheme;
|
||
|
|
|
||
|
|
[SerializeField] DialogueController dialogue;
|
||
|
|
|
||
|
|
[SerializeField] Transform cityPanel;
|
||
|
|
[SerializeField] Transform homePanel;
|
||
|
|
[SerializeField] Transform boutiquePanel;
|
||
|
|
[SerializeField] Transform salonPanel;
|
||
|
|
[SerializeField] Transform dinerPanel;
|
||
|
|
[SerializeField] Transform statsPanel;
|
||
|
|
|
||
|
|
[SerializeField] Transform studioButton;
|
||
|
|
[SerializeField] Transform boutiqueButton;
|
||
|
|
[SerializeField] Transform salonButton;
|
||
|
|
[SerializeField] Transform dinerButton;
|
||
|
|
|
||
|
|
[SerializeField] Transform dinerPanelBackButton;
|
||
|
|
|
||
|
|
[SerializeField] Image bg;
|
||
|
|
|
||
|
|
[HideInInspector] MusicFadeController music;
|
||
|
|
|
||
|
|
private void Start() {
|
||
|
|
if (GameData.GLOBAL.money < 0) {
|
||
|
|
// Losing via runaway should show the runaway VN scene first.
|
||
|
|
if (GameData.GLOBAL.ranAway) {
|
||
|
|
vn.runawayGameOverAfterDone = true;
|
||
|
|
} else {
|
||
|
|
VNData.NextScene = Dialogue.GameOver;
|
||
|
|
ShowVNScene();
|
||
|
|
}
|
||
|
|
} else if (GameData.GLOBAL.CheckWin() && !GameData.GLOBAL.hasShownWinScene) {
|
||
|
|
GameData.GLOBAL.hasShownWinScene = true;
|
||
|
|
VNData.NextScene = Dialogue.YouWin;
|
||
|
|
ShowVNScene();
|
||
|
|
}
|
||
|
|
transition.TransitionEnter();
|
||
|
|
music = GameObject.FindWithTag("Music").GetComponent<MusicFadeController>();
|
||
|
|
if (music.audioSource.clip != managerTheme) {
|
||
|
|
music.FadeOutThenIn(2.0f, 4.0f, managerTheme);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
private void Awake() {
|
||
|
|
// TODO: Set this in main menu as well
|
||
|
|
// TODO: Maybe 60?
|
||
|
|
#if UNITY_EDITOR
|
||
|
|
QualitySettings.vSyncCount = 0; // VSync must be disabled
|
||
|
|
Application.targetFrameRate = 120;
|
||
|
|
#endif
|
||
|
|
NotifyTaskUnlocks();
|
||
|
|
}
|
||
|
|
|
||
|
|
private void NotifyTaskUnlocks() {
|
||
|
|
foreach (AssignedTask task in System.Enum.GetValues(typeof(AssignedTask))) {
|
||
|
|
if (task == AssignedTask.None) {
|
||
|
|
continue;
|
||
|
|
}
|
||
|
|
AssignedTaskInfo info = VNData.GetCurrentUnlockedVersionOf(task);
|
||
|
|
if (info != null &&
|
||
|
|
info.dialogue != Dialogue.None &&
|
||
|
|
!GameData.GLOBAL.notifiedTaskUnlocks.Contains(info.dialogue)) {
|
||
|
|
GameData.GLOBAL.notifiedTaskUnlocks.Add(info.dialogue);
|
||
|
|
GameObject.FindWithTag("Notifier").GetComponent<NotifierController>().Notify(
|
||
|
|
"New Task",
|
||
|
|
"Unlocked or progressed a task! Task: " + info.name);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public void CloseViews(bool showBackButton = false) {
|
||
|
|
outfitShopScrollView.gameObject.SetActive(false);
|
||
|
|
foodShopScrollView.gameObject.SetActive(false);
|
||
|
|
hairShopScrollView.gameObject.SetActive(false);
|
||
|
|
taskPickerScrollView.gameObject.SetActive(false);
|
||
|
|
scenePickerScrollView.gameObject.SetActive(false);
|
||
|
|
shopBackButton.SetActive(showBackButton);
|
||
|
|
mainMenuButton.SetActive(!showBackButton);
|
||
|
|
selectorPanel.SetActive(false);
|
||
|
|
}
|
||
|
|
|
||
|
|
public void TransitionToVNScene() {
|
||
|
|
vn.CloseManager();
|
||
|
|
transition.OnTransitionExitEnded = ShowVNScene;
|
||
|
|
StartTransition();
|
||
|
|
}
|
||
|
|
|
||
|
|
public void ShopBackButtonPressed() {
|
||
|
|
CloseViews();
|
||
|
|
selectorPanel.SetActive(true);
|
||
|
|
}
|
||
|
|
|
||
|
|
public void OutfitShopButtonPressed() {
|
||
|
|
CloseViews(true);
|
||
|
|
outfitShopScrollView.gameObject.SetActive(true);
|
||
|
|
outfitShopScrollView.SetUp();
|
||
|
|
}
|
||
|
|
|
||
|
|
public void HairShopButtonPressed() {
|
||
|
|
CloseViews(true);
|
||
|
|
hairShopScrollView.gameObject.SetActive(true);
|
||
|
|
hairShopScrollView.SetUp();
|
||
|
|
}
|
||
|
|
|
||
|
|
public void FoodShopButtonPressed() {
|
||
|
|
if (GameData.GLOBAL.hunger == 0) {
|
||
|
|
GameObject.FindWithTag("Notifier").GetComponent<NotifierController>().Notify(
|
||
|
|
"Purchase Failed",
|
||
|
|
"She's not hungry.");
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
CloseViews(true);
|
||
|
|
foodShopScrollView.gameObject.SetActive(true);
|
||
|
|
foodShopScrollView.SetUp();
|
||
|
|
}
|
||
|
|
|
||
|
|
public void TaskPressed() {
|
||
|
|
CloseViews(true);
|
||
|
|
taskPickerScrollView.gameObject.SetActive(true);
|
||
|
|
taskPickerScrollView.SetUp();
|
||
|
|
}
|
||
|
|
|
||
|
|
public void ScenePickerPressed() {
|
||
|
|
CloseViews(true);
|
||
|
|
scenePickerScrollView.gameObject.SetActive(true);
|
||
|
|
scenePickerScrollView.SetUp();
|
||
|
|
}
|
||
|
|
|
||
|
|
public void HomeClicked() {
|
||
|
|
homePanel.gameObject.SetActive(true);
|
||
|
|
cityPanel.gameObject.SetActive(false);
|
||
|
|
}
|
||
|
|
|
||
|
|
public void CityClicked() {
|
||
|
|
cityPanel.gameObject.SetActive(true);
|
||
|
|
homePanel.gameObject.SetActive(false);
|
||
|
|
|
||
|
|
// You can only use the studio in the morning or early afternoon.
|
||
|
|
studioButton.gameObject.SetActive(
|
||
|
|
GameData.GLOBAL.time == 0 ||
|
||
|
|
GameData.GLOBAL.time == 1
|
||
|
|
);
|
||
|
|
|
||
|
|
// You can only shop during mall hours (noon to evening).
|
||
|
|
boutiqueButton.gameObject.SetActive(
|
||
|
|
GameData.GLOBAL.time == 1 ||
|
||
|
|
GameData.GLOBAL.time == 2
|
||
|
|
);
|
||
|
|
salonButton.gameObject.SetActive(
|
||
|
|
GameData.GLOBAL.time == 1 ||
|
||
|
|
GameData.GLOBAL.time == 2
|
||
|
|
);
|
||
|
|
|
||
|
|
// You can always go to the diner... assuming you can afford it.
|
||
|
|
dinerButton.gameObject.SetActive(
|
||
|
|
true
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
public void FoodPurchased() {
|
||
|
|
// TODO: More dynamic VN scene based on food, mood, etc
|
||
|
|
CloseViews(true);
|
||
|
|
vn.awakenOnFinish = new List<Transform>() { foodShopScrollView.transform };
|
||
|
|
VNData.NextScene = Dialogue.Manager_BoughtFood1; // TODO: Bought food thing
|
||
|
|
dialogue.SetUp(false);
|
||
|
|
}
|
||
|
|
|
||
|
|
public void SalonClicked() {
|
||
|
|
// TODO: Check Vero's status (moody or low mood = can't shop)
|
||
|
|
// TODO: Check money and locked hairs (if can't afford anything, can't shop)
|
||
|
|
CloseViews(true);
|
||
|
|
vn.awakenOnFinish = new List<Transform>() { salonPanel, statsPanel };
|
||
|
|
VNData.NextScene = Dialogue.Manager_Salon;
|
||
|
|
dialogue.SetUp(false);
|
||
|
|
hairShopScrollView.gameObject.SetActive(true);
|
||
|
|
hairShopScrollView.SetUp();
|
||
|
|
cityPanel.gameObject.SetActive(false);
|
||
|
|
}
|
||
|
|
|
||
|
|
public void BoutiqueClicked() {
|
||
|
|
// TODO: Check Vero's status (moody or low mood = can't shop)
|
||
|
|
// TODO: Check money and locked hairs (if can't afford anything, can't shop)
|
||
|
|
CloseViews(true);
|
||
|
|
vn.awakenOnFinish = new List<Transform>() { boutiquePanel, statsPanel };
|
||
|
|
VNData.NextScene = Dialogue.Manager_Boutique;
|
||
|
|
dialogue.SetUp(false);
|
||
|
|
outfitShopScrollView.gameObject.SetActive(true);
|
||
|
|
outfitShopScrollView.SetUp();
|
||
|
|
cityPanel.gameObject.SetActive(false);
|
||
|
|
}
|
||
|
|
|
||
|
|
public void DinerClicked() {
|
||
|
|
// TODO: Check money (if can't afford food, can't dine)
|
||
|
|
if (GameData.GLOBAL.hunger == 0) {
|
||
|
|
GameObject.FindWithTag("Notifier").GetComponent<NotifierController>().Notify(
|
||
|
|
"Nope.",
|
||
|
|
"She's not hungry.");
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
dinerPanel.gameObject.SetActive(true);
|
||
|
|
vn.awakenOnFinish = new List<Transform>() { foodShopScrollView.transform, dinerPanelBackButton };
|
||
|
|
VNData.NextScene = Dialogue.Manager_Diner;
|
||
|
|
dialogue.SetUp(false);
|
||
|
|
foodShopScrollView.SetUp();
|
||
|
|
foodShopScrollView.gameObject.SetActive(false); // Will reactivate after the dialogue sequence
|
||
|
|
cityPanel.gameObject.SetActive(false);
|
||
|
|
}
|
||
|
|
|
||
|
|
public void StudioClicked() {
|
||
|
|
WorkPressed();
|
||
|
|
}
|
||
|
|
|
||
|
|
public void DoneShoppingButtonPressed() {
|
||
|
|
SkipPressed();
|
||
|
|
}
|
||
|
|
|
||
|
|
public void SaveButtonPressed() {
|
||
|
|
Debug.Log("TODO: Autosave toggle as option");
|
||
|
|
GameData.Save();
|
||
|
|
Debug.Log("TODO: Play a save noise");
|
||
|
|
}
|
||
|
|
|
||
|
|
void MainMenu() {
|
||
|
|
SceneManager.LoadScene("MainMenu");
|
||
|
|
}
|
||
|
|
|
||
|
|
// Used as a generic Action, which cannot have parameters.
|
||
|
|
void IncrementOnce() {
|
||
|
|
Increment();
|
||
|
|
}
|
||
|
|
|
||
|
|
void Increment(int times = 1) {
|
||
|
|
for (int i = 0; i < times; i++) {
|
||
|
|
GameData.GLOBAL.IncrementTime();
|
||
|
|
}
|
||
|
|
SceneManager.LoadScene("Manager");
|
||
|
|
}
|
||
|
|
|
||
|
|
void ShowVNScene() {
|
||
|
|
SceneManager.LoadScene("SceneViewer");
|
||
|
|
}
|
||
|
|
|
||
|
|
void StartWork() {
|
||
|
|
SceneManager.LoadScene("Work");
|
||
|
|
}
|
||
|
|
|
||
|
|
void ResetManager() {
|
||
|
|
SceneManager.LoadScene("Manager");
|
||
|
|
}
|
||
|
|
|
||
|
|
void StartTransition() {
|
||
|
|
// Disable all interactions somehow
|
||
|
|
GameData.Save();
|
||
|
|
transition.TransitionExit();
|
||
|
|
}
|
||
|
|
|
||
|
|
public void SceneViewButtonPressed(Dialogue scene) {
|
||
|
|
VNData.NextScene = scene;
|
||
|
|
transition.OnTransitionExitEnded = ShowVNScene;
|
||
|
|
StartTransition();
|
||
|
|
Debug.Log("TODO: Make a sound");
|
||
|
|
}
|
||
|
|
|
||
|
|
public void MainMenuPressed() {
|
||
|
|
vn.CloseManager();
|
||
|
|
transition.OnTransitionExitEnded = MainMenu;
|
||
|
|
StartTransition();
|
||
|
|
Debug.Log("TODO: Make a sound");
|
||
|
|
}
|
||
|
|
|
||
|
|
public void SkipPressed() {
|
||
|
|
vn.CloseManager();
|
||
|
|
transition.OnTransitionExitEnded = IncrementOnce;
|
||
|
|
StartTransition();
|
||
|
|
Debug.Log("TODO: Make a sound");
|
||
|
|
}
|
||
|
|
|
||
|
|
public void WorkPressed() {
|
||
|
|
vn.CloseManager();
|
||
|
|
transition.OnTransitionExitEnded = StartWork;
|
||
|
|
StartTransition();
|
||
|
|
Debug.Log("TODO: Make a sound");
|
||
|
|
}
|
||
|
|
}
|