Skip to content

Commit

Permalink
Merge pull request #2 from TheWithz/menu-reconfiguration
Browse files Browse the repository at this point in the history
Menu reconfiguration
  • Loading branch information
thewithz authored Feb 6, 2020
2 parents 438a840 + 21ef2ca commit f146d35
Show file tree
Hide file tree
Showing 9 changed files with 9,846 additions and 4,108 deletions.
622 changes: 282 additions & 340 deletions OdysseyNow/Assets/Prefabs/Card.prefab

Large diffs are not rendered by default.

13,105 changes: 9,376 additions & 3,729 deletions OdysseyNow/Assets/Scenes/MainMenu.unity

Large diffs are not rendered by default.

81 changes: 74 additions & 7 deletions OdysseyNow/Assets/Scripts/Graphics/MenuButtonBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@ namespace Graphics
/// </summary>
public class MenuButtonBehavior : MonoBehaviour
{
//if true, will load a scene if clicked
public bool load;
//another UI object that will replace this element on screen, if clicked
// another UI object that will replace this element on screen, if clicked
public GameObject otherMenu;
// another UI object that will replace this element on screen, if clicked
public GameObject gameSelect;
// toggle that determines menu control flow
public Toggle aiToggle;
// toggle that determines menu control flow
public Toggle connectToggle;

/// <summary>
/// On start, set button click listener.
/// On start, set button click lisstener.
/// </summary>
void Start()
{
Expand All @@ -29,15 +33,78 @@ void Start()
/// </summary>
void ButtonClicked()
{
if (load)
{
SceneManager.LoadScene(gameObject.name.Replace(" ", ""));
// if gameSelect is null then this is just a normal button
if(gameSelect != null) {
// if the user wants to play with AI then they must be taken to the game
// select irrespective of connecting an odyssey console.
if(aiToggle.isOn) {
gameSelect.SetActive(true);
// get Game selects child based on card name
gameSelect.transform.Find(transform.name).gameObject.SetActive(true);
transform.parent.gameObject.SetActive(false);
}
// if an odyssey is connected but we don't want to play with AI
else if(connectToggle.isOn)
{
// pulls up the calibrations scene
SceneManager.LoadScene("Calibration");
}
// if an odyssey is not connected and we don't want to play with AI
else
{
// pulls up the card based on the button's name
SceneManager.LoadScene(gameObject.name.Replace(" ", ""));
}
}
else if (otherMenu != null)
{
// if we are the back button in AI select, enable or disable play based on whether or not AI was selected
// this works because AI select back button knows which game selection menu to return to
if (transform.parent.name == "AI Select" && transform.name == "Back Button") {
if(transform.parent.Find("P1 AI Toggle").GetComponent<Toggle>().isOn || transform.parent.Find("P2 AI Toggle").GetComponent<Toggle>().isOn) {
otherMenu.transform.Find("Play Button").gameObject.SetActive(true);
}
else {
otherMenu.transform.Find("Play Button").gameObject.SetActive(false);
}
otherMenu.transform.parent.gameObject.SetActive(true);
}
// if we are the Play button in game select, determine if AI has been selected
if(transform.parent.parent.name == "Game Select" && transform.name == "Play Button") {
Transform aiSelect = transform.root.Find("AI Select");
// if AI has been selected, load the scene cooresponding to the card of the game
// otherwise, show a message to the player that they must select AI
if(aiSelect.Find("P1 AI Toggle").GetComponent<Toggle>().isOn || aiSelect.Find("P2 AI Toggle").GetComponent<Toggle>().isOn) {
Debug.Log(transform.parent.name.Replace(" ", ""));
SceneManager.LoadScene(transform.parent.name.Replace(" ", ""));
}
else {
Debug.Log("Must pick at least 1 AI");
}
return;
}
// if we are the AI select button in game select, move to AI select
if (transform.parent.parent.name == "Game Select" && transform.name == "AI Select Button") {
// Change AI Select's back button to return to the correct card after selection
otherMenu.transform.Find("Back Button").GetComponent<MenuButtonBehavior>().otherMenu = transform.parent.gameObject;
transform.parent.parent.gameObject.SetActive(false);
}
// if we are the Back button in game select, make sure to disable other game selections
if (transform.parent.name == "Game Select" && transform.name == "Back Button") {
foreach(Transform child in transform.parent) {
// don't hide the back button or the odyssey now hal logo
if(child.name != "Back Button" && child.name != "Inverted_OdysseyNowLogo") {
child.gameObject.SetActive(false);
}
}
}
otherMenu.SetActive(true);
transform.parent.gameObject.SetActive(false);
}
else {
// pulls up the card based on the button's parent's name
SceneManager.LoadScene(transform.parent.name.Replace(" ", ""));
}
}
}
}
51 changes: 51 additions & 0 deletions OdysseyNow/Assets/Scripts/Graphics/ToggleButtonBehavior.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

namespace Graphics
{
/// <summary>
/// Behavior of AI toggle buttons and their sliders
/// </summary>
public class ToggleButtonBehavior : MonoBehaviour
{
// slider to choose AI difficulty
public Slider difficultySlider;
public Text sliderText;

/// <summary>
/// On start, set button click listener.
/// </summary>
void Start()
{
gameObject.GetComponent<Toggle>().onValueChanged.AddListener(ToggleClicked);
difficultySlider.onValueChanged.AddListener(value => SliderChanged());
// hide the sliders parent by default
difficultySlider.transform.parent.gameObject.SetActive(false);
}

/// <summary>
/// On toggle, hide or show the slider
/// </summary>
void ToggleClicked(bool on)
{
if(difficultySlider != null && on) {
difficultySlider.transform.parent.gameObject.SetActive(true);
} else if(difficultySlider != null && !on) {
difficultySlider.transform.parent.gameObject.SetActive(false);
}
}

/// <summary>
/// On slider value change, update text to reflect difficulty
/// </summary>
void SliderChanged()
{
if(sliderText != null) {
sliderText.text = "Difficulty: " + difficultySlider.value;
}
}
}
}
11 changes: 11 additions & 0 deletions OdysseyNow/Assets/Scripts/Graphics/ToggleButtonBehavior.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 additions & 2 deletions OdysseyNow/Logs/Packages-Update.log
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,17 @@ The following packages were updated:
com.unity.purchasing from version 2.0.3 to 2.0.6
com.unity.textmeshpro from version 1.3.0 to 2.0.1

=== Thu Jan 16 13:29:27 2020
=== Thu Feb 6 14:34:06 2020

Packages were changed.
Update Mode: updateDependencies

The following packages were updated:
com.unity.ide.vscode from version 1.1.0 to 1.1.3
com.unity.analytics from version 3.3.2 to 3.3.5
com.unity.ide.rider from version 1.1.0 to 1.1.4
com.unity.ide.vscode from version 1.1.0 to 1.1.4
com.unity.multiplayer-hlapi from version 1.0.2 to 1.0.4
com.unity.test-framework from version 1.0.13 to 1.1.9
com.unity.timeline from version 1.1.0 to 1.2.10
The following packages were removed:
[email protected]
13 changes: 6 additions & 7 deletions OdysseyNow/Packages/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
"com.unity.2d.sprite": "1.0.0",
"com.unity.2d.tilemap": "1.0.0",
"com.unity.ads": "2.0.8",
"com.unity.analytics": "3.3.2",
"com.unity.analytics": "3.3.5",
"com.unity.ext.nunit": "1.0.0",
"com.unity.ide.rider": "1.1.0",
"com.unity.ide.vscode": "1.1.3",
"com.unity.multiplayer-hlapi": "1.0.2",
"com.unity.package-manager-ui": "2.2.0",
"com.unity.ide.rider": "1.1.4",
"com.unity.ide.vscode": "1.1.4",
"com.unity.multiplayer-hlapi": "1.0.4",
"com.unity.purchasing": "2.0.6",
"com.unity.test-framework": "1.0.13",
"com.unity.test-framework": "1.1.9",
"com.unity.textmeshpro": "2.0.1",
"com.unity.timeline": "1.1.0",
"com.unity.timeline": "1.2.10",
"com.unity.ugui": "1.0.0",
"com.unity.xr.legacyinputhelpers": "2.0.2",
"com.unity.modules.ai": "1.0.0",
Expand Down
56 changes: 35 additions & 21 deletions OdysseyNow/ProjectSettings/EditorSettings.asset
Original file line number Diff line number Diff line change
@@ -1,21 +1,35 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!159 &1
EditorSettings:
m_ObjectHideFlags: 0
serializedVersion: 7
m_ExternalVersionControlSupport: Visible Meta Files
m_SerializationMode: 2
m_LineEndingsForNewScripts: 2
m_DefaultBehaviorMode: 1
m_SpritePackerMode: 4
m_SpritePackerPaddingPower: 1
m_EtcTextureCompressorBehavior: 1
m_EtcTextureFastCompressor: 1
m_EtcTextureNormalCompressor: 2
m_EtcTextureBestCompressor: 4
m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd
m_ProjectGenerationRootNamespace:
m_UserGeneratedProjectSuffix:
m_CollabEditorSettings:
inProgressEnabled: 1
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!159 &1
EditorSettings:
m_ObjectHideFlags: 0
serializedVersion: 9
m_ExternalVersionControlSupport: Visible Meta Files
m_SerializationMode: 2
m_LineEndingsForNewScripts: 2
m_DefaultBehaviorMode: 1
m_PrefabRegularEnvironment: {fileID: 0}
m_PrefabUIEnvironment: {fileID: 0}
m_SpritePackerMode: 4
m_SpritePackerPaddingPower: 1
m_EtcTextureCompressorBehavior: 1
m_EtcTextureFastCompressor: 1
m_EtcTextureNormalCompressor: 2
m_EtcTextureBestCompressor: 4
m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd;asmref
m_ProjectGenerationRootNamespace:
m_CollabEditorSettings:
inProgressEnabled: 1
m_EnableTextureStreamingInEditMode: 1
m_EnableTextureStreamingInPlayMode: 1
m_AsyncShaderCompilation: 1
m_EnterPlayModeOptionsEnabled: 0
m_EnterPlayModeOptions: 3
m_ShowLightmapResolutionOverlay: 1
m_UseLegacyProbeSampleCount: 1
m_AssetPipelineMode: 1
m_CacheServerMode: 0
m_CacheServerEndpoint:
m_CacheServerNamespacePrefix: default
m_CacheServerEnableDownload: 1
m_CacheServerEnableUpload: 1
4 changes: 2 additions & 2 deletions OdysseyNow/ProjectSettings/ProjectVersion.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
m_EditorVersion: 2019.2.17f1
m_EditorVersionWithRevision: 2019.2.17f1 (8e603399ca02)
m_EditorVersion: 2019.3.0f6
m_EditorVersionWithRevision: 2019.3.0f6 (27ab2135bccf)

0 comments on commit f146d35

Please sign in to comment.