Skip to content
Snippets Groups Projects
Commit 7b22d4a1 authored by Ganderse's avatar Ganderse
Browse files

Question appears

question and answers appears
parent e0324bd3
Branches QuickMathSpawner
No related tags found
1 merge request!1Quick math spawner
......@@ -283,7 +283,7 @@ MonoBehaviour:
m_VertexBufferAutoSizeReduction: 0
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_margin: {x: 6.698781, y: 0, z: 5.8307414, w: 0}
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
_SortingLayer: 0
......
......@@ -357,6 +357,7 @@ RectTransform:
- {fileID: 1991450322}
- {fileID: 1916589645}
- {fileID: 868471780}
- {fileID: 1190772311}
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
......@@ -381,6 +382,7 @@ MonoBehaviour:
time: {fileID: 1920053230}
score: {fileID: 1567280594}
difficulty: {fileID: 1991450319}
question: {fileID: 1190772310}
timeVar: 0
minutes: 0
seconds: 0
......@@ -1079,6 +1081,141 @@ RectTransform:
m_CorrespondingSourceObject: {fileID: 2011250697325498489, guid: b71fe29555c2148a2afa27da435d2a08, type: 3}
m_PrefabInstance: {fileID: 1155846752}
m_PrefabAsset: {fileID: 0}
--- !u!1 &1190772310
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1190772311}
- component: {fileID: 1190772313}
- component: {fileID: 1190772312}
m_Layer: 5
m_Name: Question
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1190772311
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1190772310}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.67969, y: 0.67969, z: 0.67969}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 377141111}
m_RootOrder: 6
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -61.9, y: 125.6}
m_SizeDelta: {x: 200, y: 50}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1190772312
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1190772310}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: Targets
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 4294967295
m_fontColor: {r: 1, g: 1, b: 1, a: 1}
m_enableVertexGradient: 0
m_colorMode: 3
m_fontColorGradient:
topLeft: {r: 1, g: 1, b: 1, a: 1}
topRight: {r: 1, g: 1, b: 1, a: 1}
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
bottomRight: {r: 1, g: 1, b: 1, a: 1}
m_fontColorGradientPreset: {fileID: 0}
m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 36
m_fontSizeBase: 36
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 2
m_VerticalAlignment: 256
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0
m_lineSpacingMax: 0
m_paragraphSpacing: 0
m_charWidthMaxAdj: 0
m_enableWordWrapping: 1
m_wordWrappingRatios: 0.4
m_overflowMode: 0
m_linkedTextComponent: {fileID: 0}
parentLinkedComponent: {fileID: 0}
m_enableKerning: 1
m_enableExtraPadding: 0
checkPaddingRequired: 0
m_isRichText: 1
m_parseCtrlCharacters: 1
m_isOrthographic: 1
m_isCullingEnabled: 0
m_horizontalMapping: 0
m_verticalMapping: 0
m_uvLineOffset: 0
m_geometrySortingOrder: 0
m_IsTextObjectScaleStatic: 0
m_VertexBufferAutoSizeReduction: 0
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: -176.5672, w: 0}
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!222 &1190772313
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1190772310}
m_CullTransparentMesh: 1
--- !u!1001 &1334661669
PrefabInstance:
m_ObjectHideFlags: 0
......@@ -1450,7 +1587,7 @@ MonoBehaviour:
spawner: {fileID: 0}
fpsCam: {fileID: 402788698}
source: {fileID: 0}
clip: {fileID: 0}
clip: {fileID: 8300000, guid: f6ac903baf1ee4c42a89fb7389e6d619, type: 3}
range: 100
damage: 100
firerate: 0.05
......
......@@ -14,6 +14,7 @@ public class GameHud : MonoBehaviour
public GameObject time;
public GameObject score;
public GameObject difficulty;
public GameObject question;
//public UnityEngine.UI.Text targetsHitText;
//Game Variable
......@@ -25,11 +26,13 @@ public class GameHud : MonoBehaviour
public string fTime = "";
public float scoreValue = 0;
public float diffValue = 0.0f;
public string quesiton { get; set; }
//Text Components
TextMeshProUGUI targetsHitText;
TextMeshProUGUI timeText;
TextMeshProUGUI scoreText;
TextMeshProUGUI difficultyText;
TextMeshProUGUI questionText;
// Start is called before the first frame update
......@@ -39,6 +42,7 @@ public class GameHud : MonoBehaviour
timeText = time.GetComponent<TextMeshProUGUI>();
scoreText = score.GetComponent<TextMeshProUGUI>();
difficultyText = difficulty.GetComponent<TextMeshProUGUI>();
questionText = question.GetComponent<TextMeshProUGUI>();
UpdateHUD();
}
......@@ -54,7 +58,7 @@ public class GameHud : MonoBehaviour
private void UpdateHUD()
{
questionText.text = quesiton;
targetsHitText.text = targetsHit.ToString() + "/" + totalHit.ToString();
timeText.text = fTime;// "Time : " + Math.Truncate(timeVar) + "s";
scoreText.text = "Score : " + Math.Truncate(scoreValue).ToString();
......@@ -62,6 +66,7 @@ public class GameHud : MonoBehaviour
//Debug.Log(targetsHit.ToString());
}
public void IncreaseTargetsHit()
{
targetsHit++;
......
......@@ -61,7 +61,7 @@ public class MathTarget : MonoBehaviour
givenAnswer = targetQuestion.AnswerCandidate;
issCorrect = targetQuestion.isCorrect;
Debug.Log("My current answer is:" + givenAnswer);
// Debug.Log("My current answer is:" + givenAnswer);
targetAnswerText.text = givenAnswer.ToString();
......@@ -102,7 +102,7 @@ public class MathTarget : MonoBehaviour
// Access the targetAgesAndStates dictionary from the QuickMathSpawner script
QuickMathSpawner spawner = FindObjectOfType<QuickMathSpawner>();
spawner.RemoveTargetFromDictionary(gameObject);
Debug.Log("Dying, next line destroys all targets");
// Debug.Log("Dying, next line destroys all targets");
Destroy(gameObject);
spawner.DestroyAllTargets();
source.PlayOneShot(clip);
......
......@@ -41,7 +41,7 @@ public class MathWeapon : MonoBehaviour
//Debug.Log(target);
if (target != null && Time.time > firerate + lastShot)
{
Debug.Log("Shot game object " + target);
// Debug.Log("Shot game object " + target);
spawner.AdjustDifficulty(target.issCorrect);
target.TakeDamage(damage);
......
......@@ -67,6 +67,30 @@ public class QuickMathSpawner : MonoBehaviour
}
}
public string toString()
{
char operatorr = '#';
switch (oOperator)
{
case OperationType.PLUS:
operatorr = '+';
break;
case OperationType.MINUS:
operatorr = '-';
break;
case OperationType.TIMES:
operatorr = '*';
break;
case OperationType.DIV:
operatorr = '/';
break;
}
return LeftOperand.ToString() + operatorr + RightOperand.ToString();
}
}
private Animations animate;
......@@ -130,14 +154,12 @@ public class QuickMathSpawner : MonoBehaviour
//int[][] QuestionAndAnswer = new int[] { };
//TODO Adjust the difficulty
if (difficulty <= 7.0f)
{
//ADDITION SUBSTRACTION {+, -}
QuestionOperator = rnd.Next(2);
QuestionOperator = rnd.Next(1);
switch (QuestionOperator)
{
......@@ -172,7 +194,7 @@ public class QuickMathSpawner : MonoBehaviour
break;
}
Debug.Log("Question and Answer" + QuestionsAndAnswers);
//Debug.Log("Question and Answer" + QuestionsAndAnswers);
......@@ -188,7 +210,7 @@ public class QuickMathSpawner : MonoBehaviour
//HARDER
}*/
Debug.Log("Created a question " + QuestionsAndAnswers[0].toString());
}
public void QuestionDelete(int index)
......@@ -280,18 +302,20 @@ public class QuickMathSpawner : MonoBehaviour
{
/*TODO CURRENT TASK: WHEN INITATING, WE NEED TO PASS THE QUESTION AND ANSWER TO THE TARGET. THE TARGET HAS A BOOL CORRECTANSWER. */
QuestionCreator();
hud.quesiton = QuestionsAndAnswers[0].toString();
hud.UpdateTotalHit();
hud.UpdateTotalHit();
//obj.AddComponent<Target>();
//obj.transform.localScale
//Spawning the targets
GameObject firstTarget = Instantiate(target);
firstTarget.transform.position = new Vector3(-2, 2, transform.position[2]);
Debug.Log("Spawning first target");
firstTarget.transform.position = new Vector3(-1.7f, 1.4f, transform.position[2]);
//Debug.Log("Spawning first target");
GameObject secondTarget = Instantiate(target);
secondTarget.transform.position = new Vector3(2, 2, transform.position[2]);
secondTarget.transform.position = new Vector3(1.5f, 1.4f, transform.position[2]);
timeTargetSpawn = Time.time;
......@@ -325,11 +349,12 @@ public class QuickMathSpawner : MonoBehaviour
public void DestroyAllTargets()
{
Debug.Log("Destroying all targets");
// Debug.Log("Destroying all targets");
foreach (GameObject target in new List<GameObject>(targetAgesAndStates.Keys))
{
targetAgesAndStates.Remove(target);
DestroyImmediate(target);
hud.quesiton = "";
}
timeSinceLastQuestion = 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment