From 2044f401eae9b34c5dbd4fba96b09812cbdb3575 Mon Sep 17 00:00:00 2001 From: poemdexter Date: Wed, 9 Jul 2014 12:01:09 -0500 Subject: [PATCH] uses joystick inputs now (button 1 to launch). --- Assets/Scenes/launcher.unity | Bin 61452 -> 61452 bytes Assets/Scripts/CaroselWheel.cs | 44 ++++++++++++++++++++++++++++----- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/Assets/Scenes/launcher.unity b/Assets/Scenes/launcher.unity index c41a0f3830076b7ff91b7050e854308d99f4f898..130accd9efac5e62170bf0cab1aa73a6f76ffe8b 100644 GIT binary patch delta 251 zcmeBqz})kIc|*vJdLIS`hBPR?TF$ArK!|}M0mv7J;%h)L24Mz<5Fnogio5;4xkdoR zGJ$+XDDDA@odAjy$9o7W2z(-1*5uMa5J0ThFprvx_iVGdu&1E3(XfscS<0ir+yH-EjM zF3isjw8tYgCnsMaJijO>WwQJm*UcGkbQm!troVOF{NSw)qXe1`pne7huIr0!CNFqv JGr8dX8~}S4Jn;Yk diff --git a/Assets/Scripts/CaroselWheel.cs b/Assets/Scripts/CaroselWheel.cs index 2e26b96..0a2304a 100644 --- a/Assets/Scripts/CaroselWheel.cs +++ b/Assets/Scripts/CaroselWheel.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Linq; using Prime31.GoKitLite; using UnityEngine; using System.Collections; @@ -25,9 +26,16 @@ private void Start() { DataLoader dl = new DataLoader(); List assets = dl.GetGameAssetsList(); - InstantiateGames(assets); - SetUpGamesAtStart(); - UpdateData(); + if (!assets.Any()) + { + title.text = "No Games Found"; + } + else + { + InstantiateGames(assets); + SetUpGamesAtStart(); + UpdateData(); + } } private void InstantiateGames(List a) @@ -67,22 +75,46 @@ private void SetUpGamesAtStart() private void Update() { - if (currentPosition > 0 && Input.GetKeyDown(KeyCode.LeftArrow)) // move to left game + if (currentPosition > 0 && GetKeyInputLeft()) // move to left game { ShiftTilesRight(currentPosition); UpdateData(); } - else if (currentPosition < games.Length - 1 && Input.GetKeyDown(KeyCode.RightArrow)) // move to right game + else if (currentPosition < games.Length - 1 && GetKeyInputRight()) // move to right game { ShiftTilesLeft(currentPosition); UpdateData(); } - else if (Input.GetKeyDown(KeyCode.Return)) + else if (GetKeyInputButton1()) { LaunchGame(); } } + private bool GetKeyInputLeft() + { + return Input.GetButtonDown("P1_Left") + || Input.GetButtonDown("P2_Left") + || Input.GetButtonDown("P3_Left") + || Input.GetButtonDown("P4_Left"); + } + + private bool GetKeyInputRight() + { + return Input.GetButtonDown("P1_Right") + || Input.GetButtonDown("P2_Right") + || Input.GetButtonDown("P3_Right") + || Input.GetButtonDown("P4_Right"); + } + + private bool GetKeyInputButton1() + { + return Input.GetButtonDown("P1_Button1") + || Input.GetButtonDown("P2_Button1") + || Input.GetButtonDown("P3_Button1") + || Input.GetButtonDown("P4_Button1"); + } + private void ShiftTilesRight(int current) { if (currentPosition - 1 >= 0)