Skip to content

Commit

Permalink
Ya se pueden abrir preguntas y respuestas
Browse files Browse the repository at this point in the history
  • Loading branch information
davidrochin committed Apr 16, 2018
1 parent e85b0a5 commit d162629
Show file tree
Hide file tree
Showing 22 changed files with 3,253 additions and 476 deletions.
23 changes: 20 additions & 3 deletions Jeopardy/Assets/Classes/Question.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,41 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

[System.Serializable]
public class Question {

public string text;
public string answer;

public int points;
public int value;
public Category category;

public Question(string questionText, string answer, int points, Category category) {
this.text = questionText;
this.answer = answer;
this.points = points;
this.value = points;
this.category = category;
}

public override string ToString() {
return "Pregunta: " + text + ", Respuesta: " + answer + ", Valor: " + points + ", Categoría: " + category.ToString();
return "Pregunta: " + text + ", Respuesta: " + answer + ", Valor: " + value + ", Categoría: " + category.ToString();
}

public void Show() {
Canvas canvas = GameObject.FindObjectOfType<Canvas>();
if(canvas == null) { canvas = new GameObject("Canvas").AddComponent<Canvas>(); }

GameObject panel = Resources.Load("question_panel") as GameObject;
panel = GameObject.Instantiate(panel, canvas.transform, false);

panel.transform.Find("question_text").GetComponent<Text>().text = text;

//Agregar el componente que muestra la respuesta
AnswerShower answerShower = panel.AddComponent<AnswerShower>();
answerShower.question = this;

}

public static Question[] FromCSV() {
Expand Down
23 changes: 23 additions & 0 deletions Jeopardy/Assets/Classes/QuestionCollection.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class QuestionCollection {

public List<Question> questions;

public QuestionCollection(Question[] questions) {
this.questions = new List<Question>(questions);
}

public Question RandomWithValue(int value) {
Question[] results = questions.FindAll(x => x.value == value).ToArray();
return results[Random.Range(0, results.Length - 1)];
}

public Question RandomWithValueAndCategory(int value, Question.Category category) {
Question[] results = questions.FindAll(x => x.value == value && x.category == category).ToArray();
return results[Random.Range(0, results.Length - 1)];
}

}
11 changes: 0 additions & 11 deletions Jeopardy/Assets/Classes/QuestionReader.cs

This file was deleted.

171 changes: 171 additions & 0 deletions Jeopardy/Assets/Resources/question_panel.prefab
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1001 &100100000
Prefab:
m_ObjectHideFlags: 1
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications: []
m_RemovedComponents: []
m_ParentPrefab: {fileID: 0}
m_RootGameObject: {fileID: 1218439856269182}
m_IsPrefabParent: 1
--- !u!1 &1218439856269182
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 224427850518321010}
- component: {fileID: 222076114908623550}
- component: {fileID: 114903234933871722}
m_Layer: 5
m_Name: question_panel
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &1603244778178036
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 224942574397031370}
- component: {fileID: 222863958130907512}
- component: {fileID: 114606300582917454}
- component: {fileID: 114579908619626012}
m_Layer: 5
m_Name: question_text
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &114579908619626012
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1603244778178036}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 1573420865, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_EffectColor: {r: 0, g: 0, b: 0, a: 1}
m_EffectDistance: {x: 8.35, y: -6.78}
m_UseGraphicAlpha: 1
--- !u!114 &114606300582917454
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1603244778178036}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 708705254, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_FontData:
m_Font: {fileID: 12800000, guid: a30f933bed2f6504bae572c0ef6aaeb7, type: 3}
m_FontSize: 14
m_FontStyle: 0
m_BestFit: 1
m_MinSize: 10
m_MaxSize: 94
m_Alignment: 4
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: "\xBFEl texto de la pregunta va aqu\xED?"
--- !u!114 &114903234933871722
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1218439856269182}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.10942906, g: 0.15763047, b: 0.64705884, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 21300000, guid: 8e31a0b6b65fafd4d82e63a4d08ef8d1, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
--- !u!222 &222076114908623550
CanvasRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1218439856269182}
--- !u!222 &222863958130907512
CanvasRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1603244778178036}
--- !u!224 &224427850518321010
RectTransform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1218439856269182}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 224942574397031370}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!224 &224942574397031370
RectTransform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1603244778178036}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 224427850518321010}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: -453.2, y: -46}
m_Pivot: {x: 0.5, y: 0.5}
10 changes: 10 additions & 0 deletions Jeopardy/Assets/Resources/question_panel.prefab.meta

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

Loading

0 comments on commit d162629

Please sign in to comment.