Skip to content

Commit

Permalink
Preguntas finales
Browse files Browse the repository at this point in the history
  • Loading branch information
davidrochin committed May 18, 2018
1 parent ac7c86f commit 04eb79c
Show file tree
Hide file tree
Showing 7 changed files with 363 additions and 361 deletions.
678 changes: 339 additions & 339 deletions Jeopardy/Assets/Resources/preguntas.csv

Large diffs are not rendered by default.

12 changes: 8 additions & 4 deletions Jeopardy/Assets/Scripts/Board.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ void Awake () {

//Leer preguntas del CSV
questionCollection = new QuestionCollection(Question.FromCSV());
Debug.Log("Se terminaron de parsear las preguntas.");

Build();
}
Expand Down Expand Up @@ -79,11 +80,14 @@ public void PopulateRemaining(int level) {
//Si a la celda le quedan preguntas activas
if(cells[x, y].GetComponent<Cell>().HasActiveQuestions()) {
Cell cell = cells[x, y].GetComponent<Cell>();
//Question[] questions = questionCollection.GetAllWith(y * 200, level, x + 1);
Question[] questions = questionCollection.GetNumberWith(y * 200, level, x + 1, cell.GetActiveQuestions().Length);
cell.SetQuestions(questions);
}
Question[] newQuestions = questionCollection.GetNumberWith(y * 200, level, x + 1, 5);

for (int i = 0; i < cell.questions.Length; i++) {
if (cell.questions[i].active) {
cell.questions[i] = newQuestions[i];
}
}
}
}
}
}
Expand Down
19 changes: 4 additions & 15 deletions Jeopardy/Assets/Scripts/Cell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,26 +53,15 @@ private void OnMouseUpAsButton() {
}
}

private void OnMouseOver() {

if(type == Type.Question && EventSystem.current.IsPointerOverGameObject() == false) {

//Si le hacen clic derecho a la celda
if (Input.GetMouseButtonDown(1)) {
if (cellActive) {
SetActive(false);
} else {
SetActive(true);
}
}
}
}

public void SetQuestions(Question[] questions) {
this.questions = questions;
textMesh.text = "" + this.questions[0].value;
}

public Question[] GetQuestions() {
return questions;
}

public void SetActive(bool active) {
cellActive = active;
if (cellActive) {
Expand Down
3 changes: 3 additions & 0 deletions Jeopardy/Assets/Scripts/ConfigPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ public void Apply() {
//Repopular las celdas que quedan con las preguntas del nuevo nivel
FindObjectOfType<Board>().PopulateRemaining(PlayManager.instance.level);

//Resetear el Score
PlayManager.instance.ResetScore();

Debug.Log("Se aplicó la configuración: " + PlayManager.instance.teamA.name + ", " + PlayManager.instance.teamB.name + ", nivel " + PlayManager.instance.level);
if(OnConfigUpdate != null) OnConfigUpdate();
Close();
Expand Down
5 changes: 5 additions & 0 deletions Jeopardy/Assets/Scripts/PlayManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ public void FinishTurn() {
if(OnFinishTurn != null) OnFinishTurn();
}

public void ResetScore() {
teamA.score = 0;
teamB.score = 0;
}

private void OnGUI() {
/*GUILayout.Label("[Turno] " + teamInTurn.name);
GUILayout.Label(teamA.name + " - " + teamA.score);
Expand Down
2 changes: 1 addition & 1 deletion Jeopardy/Assets/Scripts/QuestionSelector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static QuestionSelector Create(Question[] questions) {

//Agregar la pregunta al selector solo si está activa
if (question.active) {
GameObject item = QuestionSelectorItem.Create(question, selector.transform);
GameObject item = QuestionSelectorItem.Create(question, selector.transform, "Pregunta " + (count + 1));
item.GetComponent<Image>().color = colors[count];
}
count++;
Expand Down
5 changes: 3 additions & 2 deletions Jeopardy/Assets/Scripts/QuestionSelectorItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ void Update () {

}

public static GameObject Create(Question newQuestion, Transform parent) {
public static GameObject Create(Question newQuestion, Transform parent, string itemText) {
GameObject itemPrefab = Resources.Load("selector_item") as GameObject;
GameObject itemObject = Instantiate(itemPrefab, parent, false);
QuestionSelectorItem item = itemObject.GetComponent<QuestionSelectorItem>();

item.question = newQuestion;

item.GetComponentInChildren<Text>().text = item.question.text;
//item.GetComponentInChildren<Text>().text = item.question.text;
item.GetComponentInChildren<Text>().text = itemText;

item.GetComponent<Button>().onClick.AddListener(delegate() {
item.question.Show();
Expand Down

0 comments on commit 04eb79c

Please sign in to comment.