mirror of
https://github.com/ConjureETS/OuijaMTLGJ2016.git
synced 2026-03-24 10:11:07 +00:00
54 lines
1.2 KiB
C#
54 lines
1.2 KiB
C#
using UnityEngine;
|
|
using System.Collections;
|
|
using InputHandler;
|
|
using System;
|
|
|
|
public class MenuFunctions : MonoBehaviour {
|
|
public GameObject[] players;
|
|
Animator[] anims = {null,null,null };
|
|
public int levelIndex;
|
|
// Use this for initialization
|
|
void Start () {
|
|
for (int i = 0; i < 3; i++)
|
|
{
|
|
InputManager.Instance.PushActiveContext("Menu", i);
|
|
InputManager.Instance.AddCallback(i, HandleButtons);
|
|
}
|
|
|
|
for (int i = 0; i < players.Length; i++)
|
|
{
|
|
anims[i] = players[i].GetComponent<Animator>();
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
private void HandleButtons(MappedInput obj)
|
|
{
|
|
if (obj.Actions.Contains("Dash"))
|
|
{
|
|
anims[obj.PlayerIndex].SetBool("Dashing", !anims[obj.PlayerIndex].GetBool("Dashing"));
|
|
}
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update () {
|
|
int compteur = 0;
|
|
for (int i = 0; i < anims.Length; i++)
|
|
{
|
|
if (anims[i].GetBool("Dashing"))
|
|
{
|
|
++compteur;
|
|
}
|
|
|
|
}
|
|
if (compteur == 3)
|
|
{
|
|
Application.LoadLevel(levelIndex);
|
|
}
|
|
|
|
|
|
}
|
|
}
|