Checkbox
This commit is contained in:
BIN
Assets/Resources/Art/correct.png
Normal file
BIN
Assets/Resources/Art/correct.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 41 KiB |
68
Assets/Resources/Art/correct.png.meta
Normal file
68
Assets/Resources/Art/correct.png.meta
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f561d069cb851d44b9b0f9f9d5d4bb6d
|
||||||
|
timeCreated: 1495026344
|
||||||
|
licenseType: Free
|
||||||
|
TextureImporter:
|
||||||
|
fileIDToRecycleName: {}
|
||||||
|
serializedVersion: 4
|
||||||
|
mipmaps:
|
||||||
|
mipMapMode: 0
|
||||||
|
enableMipMap: 1
|
||||||
|
sRGBTexture: 1
|
||||||
|
linearTexture: 0
|
||||||
|
fadeOut: 0
|
||||||
|
borderMipMap: 0
|
||||||
|
mipMapFadeDistanceStart: 1
|
||||||
|
mipMapFadeDistanceEnd: 3
|
||||||
|
bumpmap:
|
||||||
|
convertToNormalMap: 0
|
||||||
|
externalNormalMap: 0
|
||||||
|
heightScale: 0.25
|
||||||
|
normalMapFilter: 0
|
||||||
|
isReadable: 0
|
||||||
|
grayScaleToAlpha: 0
|
||||||
|
generateCubemap: 6
|
||||||
|
cubemapConvolution: 0
|
||||||
|
seamlessCubemap: 0
|
||||||
|
textureFormat: 1
|
||||||
|
maxTextureSize: 2048
|
||||||
|
textureSettings:
|
||||||
|
filterMode: -1
|
||||||
|
aniso: -1
|
||||||
|
mipBias: -1
|
||||||
|
wrapMode: -1
|
||||||
|
nPOTScale: 1
|
||||||
|
lightmap: 0
|
||||||
|
compressionQuality: 50
|
||||||
|
spriteMode: 0
|
||||||
|
spriteExtrude: 1
|
||||||
|
spriteMeshType: 1
|
||||||
|
alignment: 0
|
||||||
|
spritePivot: {x: 0.5, y: 0.5}
|
||||||
|
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
spritePixelsToUnits: 100
|
||||||
|
alphaUsage: 1
|
||||||
|
alphaIsTransparency: 0
|
||||||
|
spriteTessellationDetail: -1
|
||||||
|
textureType: 0
|
||||||
|
textureShape: 1
|
||||||
|
maxTextureSizeSet: 0
|
||||||
|
compressionQualitySet: 0
|
||||||
|
textureFormatSet: 0
|
||||||
|
platformSettings:
|
||||||
|
- buildTarget: DefaultTexturePlatform
|
||||||
|
maxTextureSize: 2048
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 1
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
spriteSheet:
|
||||||
|
serializedVersion: 2
|
||||||
|
sprites: []
|
||||||
|
outline: []
|
||||||
|
spritePackingTag:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
BIN
Assets/Resources/Art/incorrect.png
Normal file
BIN
Assets/Resources/Art/incorrect.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 52 KiB |
68
Assets/Resources/Art/incorrect.png.meta
Normal file
68
Assets/Resources/Art/incorrect.png.meta
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5ccb54c1f833b5b45a88348b280c5f12
|
||||||
|
timeCreated: 1495026343
|
||||||
|
licenseType: Free
|
||||||
|
TextureImporter:
|
||||||
|
fileIDToRecycleName: {}
|
||||||
|
serializedVersion: 4
|
||||||
|
mipmaps:
|
||||||
|
mipMapMode: 0
|
||||||
|
enableMipMap: 1
|
||||||
|
sRGBTexture: 1
|
||||||
|
linearTexture: 0
|
||||||
|
fadeOut: 0
|
||||||
|
borderMipMap: 0
|
||||||
|
mipMapFadeDistanceStart: 1
|
||||||
|
mipMapFadeDistanceEnd: 3
|
||||||
|
bumpmap:
|
||||||
|
convertToNormalMap: 0
|
||||||
|
externalNormalMap: 0
|
||||||
|
heightScale: 0.25
|
||||||
|
normalMapFilter: 0
|
||||||
|
isReadable: 0
|
||||||
|
grayScaleToAlpha: 0
|
||||||
|
generateCubemap: 6
|
||||||
|
cubemapConvolution: 0
|
||||||
|
seamlessCubemap: 0
|
||||||
|
textureFormat: 1
|
||||||
|
maxTextureSize: 2048
|
||||||
|
textureSettings:
|
||||||
|
filterMode: -1
|
||||||
|
aniso: -1
|
||||||
|
mipBias: -1
|
||||||
|
wrapMode: -1
|
||||||
|
nPOTScale: 1
|
||||||
|
lightmap: 0
|
||||||
|
compressionQuality: 50
|
||||||
|
spriteMode: 0
|
||||||
|
spriteExtrude: 1
|
||||||
|
spriteMeshType: 1
|
||||||
|
alignment: 0
|
||||||
|
spritePivot: {x: 0.5, y: 0.5}
|
||||||
|
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
spritePixelsToUnits: 100
|
||||||
|
alphaUsage: 1
|
||||||
|
alphaIsTransparency: 0
|
||||||
|
spriteTessellationDetail: -1
|
||||||
|
textureType: 0
|
||||||
|
textureShape: 1
|
||||||
|
maxTextureSizeSet: 0
|
||||||
|
compressionQualitySet: 0
|
||||||
|
textureFormatSet: 0
|
||||||
|
platformSettings:
|
||||||
|
- buildTarget: DefaultTexturePlatform
|
||||||
|
maxTextureSize: 2048
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 1
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
spriteSheet:
|
||||||
|
serializedVersion: 2
|
||||||
|
sprites: []
|
||||||
|
outline: []
|
||||||
|
spritePackingTag:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
26
Assets/Resources/Materials/New Render Texture.renderTexture
Normal file
26
Assets/Resources/Materials/New Render Texture.renderTexture
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!84 &8400000
|
||||||
|
RenderTexture:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_PrefabParentObject: {fileID: 0}
|
||||||
|
m_PrefabInternal: {fileID: 0}
|
||||||
|
m_Name: New Render Texture
|
||||||
|
m_ImageContentsHash:
|
||||||
|
serializedVersion: 2
|
||||||
|
Hash: 00000000000000000000000000000000
|
||||||
|
m_Width: 256
|
||||||
|
m_Height: 256
|
||||||
|
m_AntiAliasing: 1
|
||||||
|
m_DepthFormat: 2
|
||||||
|
m_ColorFormat: 0
|
||||||
|
m_MipMap: 0
|
||||||
|
m_GenerateMips: 1
|
||||||
|
m_SRGB: 0
|
||||||
|
m_TextureSettings:
|
||||||
|
m_FilterMode: 1
|
||||||
|
m_Aniso: 0
|
||||||
|
m_MipBias: 0
|
||||||
|
m_WrapMode: 1
|
||||||
|
m_Dimension: 2
|
||||||
|
m_VolumeDepth: 1
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 024edc9294fa3bf4291f4ac9ab5a96f9
|
||||||
|
timeCreated: 1495026592
|
||||||
|
licenseType: Free
|
||||||
|
NativeFormatImporter:
|
||||||
|
mainObjectFileID: 8400000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
File diff suppressed because it is too large
Load Diff
16
Assets/Scripts/ObjectController.cs
Normal file
16
Assets/Scripts/ObjectController.cs
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class ObjectController : MonoBehaviour {
|
||||||
|
|
||||||
|
// Use this for initialization
|
||||||
|
void Start () {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update is called once per frame
|
||||||
|
void Update () {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
12
Assets/Scripts/ObjectController.cs.meta
Normal file
12
Assets/Scripts/ObjectController.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b6f5890e59f4b7d408b6104abf6da5ae
|
||||||
|
timeCreated: 1495027984
|
||||||
|
licenseType: Free
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -17,11 +17,19 @@ public class QuizController : MonoBehaviour {
|
|||||||
|
|
||||||
public Button btnNextQuestion;
|
public Button btnNextQuestion;
|
||||||
|
|
||||||
private float counterValue = 90;
|
private float counterValue;
|
||||||
|
|
||||||
private const int scoreIncreaseValue = 10;
|
private const int numberOfAnswers = 4;
|
||||||
|
|
||||||
private const int scoreDecreaseValue = 15;
|
private const int scoreCorrectAnswer = 10;
|
||||||
|
|
||||||
|
private const int scoreIncorrectAnswer = -15;
|
||||||
|
|
||||||
|
private const int scoreTimedOut = 0;
|
||||||
|
|
||||||
|
private const int counterInitialValue = 10;
|
||||||
|
|
||||||
|
private const int displayAnswersCounterValue = 3;
|
||||||
|
|
||||||
private int scoreValue = 0;
|
private int scoreValue = 0;
|
||||||
|
|
||||||
@@ -37,6 +45,7 @@ public class QuizController : MonoBehaviour {
|
|||||||
// Use this for initialization
|
// Use this for initialization
|
||||||
void Start () {
|
void Start () {
|
||||||
selectedAnswers = new List<int>();
|
selectedAnswers = new List<int>();
|
||||||
|
counterValue = counterInitialValue;
|
||||||
UpdateScene();
|
UpdateScene();
|
||||||
UpdateCounter();
|
UpdateCounter();
|
||||||
UpdateScore();
|
UpdateScore();
|
||||||
@@ -51,6 +60,11 @@ public class QuizController : MonoBehaviour {
|
|||||||
counterValue -= Time.deltaTime;
|
counterValue -= Time.deltaTime;
|
||||||
UpdateCounter();
|
UpdateCounter();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LoadNextQuestion();
|
||||||
|
counterValue = counterInitialValue;
|
||||||
|
}
|
||||||
|
|
||||||
if (Input.GetMouseButtonDown(0))
|
if (Input.GetMouseButtonDown(0))
|
||||||
{
|
{
|
||||||
@@ -60,37 +74,21 @@ public class QuizController : MonoBehaviour {
|
|||||||
if (Physics.Raycast(ray, out hit, 100))
|
if (Physics.Raycast(ray, out hit, 100))
|
||||||
{
|
{
|
||||||
Debug.Log(hit.transform.gameObject.name);
|
Debug.Log(hit.transform.gameObject.name);
|
||||||
int answerIdx = GetAnswerIdx(hit.transform.gameObject.name) - 4 * questionIdx;
|
int answerIdx = GetAnswerIdx(hit.transform.gameObject.name) - numberOfAnswers * questionIdx;
|
||||||
if (!selectedAnswers.Contains(answerIdx))
|
if (!selectedAnswers.Contains(answerIdx))
|
||||||
selectedAnswers.Add(answerIdx);
|
selectedAnswers.Add(answerIdx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void IncreaseScore()
|
|
||||||
{
|
|
||||||
Debug.Log("Clicked on cube!");
|
|
||||||
scoreValue += scoreIncreaseValue;
|
|
||||||
UpdateScore();
|
|
||||||
}
|
|
||||||
|
|
||||||
void LoadNextQuestion()
|
void LoadNextQuestion()
|
||||||
{
|
{
|
||||||
if (IsAnswerCorrect())
|
scoreValue += GetScore();
|
||||||
IncreaseScore();
|
UpdateScore();
|
||||||
else
|
|
||||||
DecreaseScore();
|
|
||||||
questionIdx = (questionIdx + 1) % 2;
|
questionIdx = (questionIdx + 1) % 2;
|
||||||
selectedAnswers.Clear();
|
selectedAnswers.Clear();
|
||||||
Debug.Log("" + questionIdx);
|
|
||||||
UpdateScene();
|
UpdateScene();
|
||||||
}
|
counterValue = counterInitialValue;
|
||||||
|
|
||||||
public void DecreaseScore()
|
|
||||||
{
|
|
||||||
Debug.Log("Clicked on sphere!");
|
|
||||||
scoreValue -= scoreDecreaseValue;
|
|
||||||
UpdateScore();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateScore()
|
private void UpdateScore()
|
||||||
@@ -110,7 +108,7 @@ public class QuizController : MonoBehaviour {
|
|||||||
// Set right answers
|
// Set right answers
|
||||||
for(int i = 0; i < answers.Length; i++)
|
for(int i = 0; i < answers.Length; i++)
|
||||||
{
|
{
|
||||||
if (i >= 4 * questionIdx && i < 4 * (questionIdx + 1))
|
if (i >= numberOfAnswers * questionIdx && i < numberOfAnswers * (questionIdx + 1))
|
||||||
{
|
{
|
||||||
Debug.Log("Set active: " + i);
|
Debug.Log("Set active: " + i);
|
||||||
answers[i].SetActive(true);
|
answers[i].SetActive(true);
|
||||||
@@ -126,7 +124,15 @@ public class QuizController : MonoBehaviour {
|
|||||||
return System.Int32.Parse(resultString);
|
return System.Int32.Parse(resultString);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsAnswerCorrect() {
|
private int GetScore() {
|
||||||
return selectedAnswers.SequenceEqual(new List<int>(questions[questionIdx].getCorrectAnswers()));
|
// Didn't try
|
||||||
|
if (selectedAnswers.Count == 0)
|
||||||
|
return scoreTimedOut;
|
||||||
|
// Correct answer
|
||||||
|
if (selectedAnswers.SequenceEqual(new List<int>(questions[questionIdx].getCorrectAnswers())))
|
||||||
|
return scoreCorrectAnswer;
|
||||||
|
else
|
||||||
|
return scoreIncorrectAnswer;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user