mirror of
https://github.com/ConjureETS/PillowFight.git
synced 2026-03-24 09:00:58 +00:00
79 lines
1.6 KiB
C#
79 lines
1.6 KiB
C#
using UnityEngine;
|
|
using System.Collections;
|
|
using InputHandler;
|
|
using MenusHandler;
|
|
|
|
public class GameManager : MonoBehaviour
|
|
{
|
|
public int PlayerCount = 4;
|
|
private static GameManager _instance;
|
|
public MomBehavior mom;
|
|
|
|
public static GameManager Instance
|
|
{
|
|
get { return _instance; }
|
|
}
|
|
|
|
void Awake()
|
|
{
|
|
_instance = this;
|
|
|
|
/*
|
|
if (_instance != null)
|
|
{
|
|
Destroy(gameObject);
|
|
}
|
|
else
|
|
{
|
|
_instance = this;
|
|
DontDestroyOnLoad(gameObject);
|
|
}*/
|
|
}
|
|
|
|
void Start()
|
|
{
|
|
for (int i = 0; i < PlayerCount; i++)
|
|
{
|
|
InputManager.Instance.AddCallback(i, HandleMenuInput);
|
|
}
|
|
}
|
|
|
|
public void PushMenuContext()
|
|
{
|
|
for (int i = 0; i < PlayerCount; i++)
|
|
{
|
|
InputManager.Instance.PushActiveContext("Menu", i);
|
|
}
|
|
}
|
|
|
|
public void PopMenuContext()
|
|
{
|
|
for (int i = 0; i < PlayerCount; i++)
|
|
{
|
|
InputManager.Instance.PopActiveContext(i);
|
|
}
|
|
}
|
|
|
|
private void HandleMenuInput(MappedInput input)
|
|
{
|
|
float yAxis = 0f;
|
|
|
|
if (input.Ranges.ContainsKey("SelectOptionUp"))
|
|
{
|
|
yAxis = input.Ranges["SelectOptionUp"];
|
|
}
|
|
else if (input.Ranges.ContainsKey("SelectOptionDown"))
|
|
{
|
|
yAxis = -input.Ranges["SelectOptionDown"];
|
|
}
|
|
|
|
bool accept = input.Actions.Contains("Accept");
|
|
|
|
MenusManager.Instance.SetInputValues(accept, false, 0f, yAxis);
|
|
}
|
|
|
|
public MomBehavior.State GetMomState() {
|
|
return mom.GetState();
|
|
}
|
|
}
|