|
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using UltraCombos;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
using UnityEngine.EventSystems;
|
|
|
|
|
|
|
|
|
|
|
|
namespace uc
|
|
|
|
|
|
{
|
|
|
|
|
|
public class ActivityQueueManager : ActivityManager
|
|
|
|
|
|
{
|
|
|
|
|
|
[Header("Queue Manager")]
|
|
|
|
|
|
public bool initializeOnStart = false;
|
|
|
|
|
|
public bool isPresentMode;
|
|
|
|
|
|
public bool circularMode = false;
|
|
|
|
|
|
public Transform activityQueue;
|
|
|
|
|
|
List<Activity> activity_list = null;
|
|
|
|
|
|
int current_index = -1;
|
|
|
|
|
|
public int CurrentIndex { get { return current_index; } }
|
|
|
|
|
|
public override Activity current_activity
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
if (activity_list != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (activity_list.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (current_index >= 0 && current_index < activity_list.Count)
|
|
|
|
|
|
return activity_list[current_index];
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Initialize()
|
|
|
|
|
|
{
|
|
|
|
|
|
activity_list = new List<Activity>();
|
|
|
|
|
|
if (activityQueue != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
var acts = activityQueue.GetComponentsInChildren<Activity>();
|
|
|
|
|
|
activity_list.AddRange(acts);
|
|
|
|
|
|
initialActivity = activity_list[0];
|
|
|
|
|
|
GenerateActivityQueueFile();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var canvases = Resources.FindObjectsOfTypeAll(typeof(CanvasActivity)) as CanvasActivity[];
|
|
|
|
|
|
var canvas_activities = new List<CanvasActivity>();
|
|
|
|
|
|
canvas_activities.AddRange(canvases);
|
|
|
|
|
|
foreach (var act in activity_list)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (act.canvases.Count > 0)
|
|
|
|
|
|
continue;
|
|
|
|
|
|
act.canvases = canvas_activities.FindAll(
|
|
|
|
|
|
delegate (CanvasActivity ca) {
|
|
|
|
|
|
return (ca.gameObject.name == act.gameObject.name);
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Misc.Verbose(module, string.Format("has {0} activities", activity_list.Count));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void Start()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (initializeOnStart)
|
|
|
|
|
|
Initialize();
|
|
|
|
|
|
|
|
|
|
|
|
SetActivityByIndex(0);
|
|
|
|
|
|
Misc.Verbose(module, string.Format("init with activity: {0}", current_activity.name));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void Update()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
CheckIdle();
|
|
|
|
|
|
|
|
|
|
|
|
if (isPresentMode)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (Input.GetKeyDown(KeyCode.PageDown))
|
|
|
|
|
|
{
|
|
|
|
|
|
NextActivity();
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (Input.GetKeyDown(KeyCode.PageUp))
|
|
|
|
|
|
{
|
|
|
|
|
|
PreviousActivity();
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (Input.GetKeyDown(KeyCode.O))
|
|
|
|
|
|
{
|
|
|
|
|
|
PopToInitial();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
gameObject.name = "Activity Manager: " + current_activity.name;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void NextActivity()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (current_index + 1 >= activity_list.Count && circularMode)
|
|
|
|
|
|
{
|
|
|
|
|
|
SetActivityByIndex(0);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
SetActivityByIndex(current_index + 1);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void PreviousActivity()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (current_index - 1 <0 && circularMode)
|
|
|
|
|
|
{
|
|
|
|
|
|
SetActivityByIndex(activity_list.Count -1);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
SetActivityByIndex(current_index - 1);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void SetActivityByIndex(int index)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (activity_list == null || index < 0 || index >= activity_list.Count)
|
|
|
|
|
|
{
|
|
|
|
|
|
//Debug.LogWarningFormat("Cannot set page {0} in ActivityManager", index);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (current_index == index)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (current_activity != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
current_activity.Leave();
|
|
|
|
|
|
}
|
|
|
|
|
|
current_index = index;
|
|
|
|
|
|
current_activity.Enter();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void PopToInitial()
|
|
|
|
|
|
{
|
|
|
|
|
|
SetActivityByIndex(0);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void PushActivity(Activity newActivity) { }
|
|
|
|
|
|
public override void PopToActivity(Activity targetActivity) { }
|
|
|
|
|
|
public override void PopActivity() { }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ActivityListObject { public List<string> list = new List<string>(); }
|
|
|
|
|
|
|
|
|
|
|
|
void GenerateActivityQueueFile()
|
|
|
|
|
|
{
|
|
|
|
|
|
var obj = new ActivityListObject();
|
|
|
|
|
|
for (int i = 0; i < activity_list.Count; i++)
|
|
|
|
|
|
obj.list.Add(string.Format("{0:D2} - {1}", i, activity_list[i].name));
|
|
|
|
|
|
string json = JsonUtility.ToJson(obj, true);
|
|
|
|
|
|
var root = System.IO.Directory.GetParent(Application.dataPath);
|
|
|
|
|
|
string path = System.IO.Path.Combine(root.FullName, gameObject.name + " Queue.json");
|
|
|
|
|
|
System.IO.File.WriteAllText(path, json);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|