Exemple #1
0
    public PuzzleQuestion GetQuestion(PuzzleQuestion dup, PuzzleQuestion dup2)
    {
        ResetQuestionsIfAllHaveBeenAsked();
        PuzzleQuestion unAsked;

        unAsked = myPuzzle.Where(t => t.img != dup.img).Where(t => t.img != dup2.img).OrderBy(t => Random.Range(0, 100)).FirstOrDefault();
        return(unAsked);
    }
Exemple #2
0
 private void rollPuzzle()
 {
     testPuzzle = allPuzzle.GetQuestion();
     preparePuzzle();
     prepareAnswer();
     number++;
     numberText.text = "" + (number);
 }
Exemple #3
0
 public PuzzleQuestion[] GetRandom3()
 {
     PuzzleQuestion[] random = new PuzzleQuestion[3];
     random[0]       = GetQuestion();
     random[0].asked = true;
     random[1]       = GetQuestion(random[0]);
     random[2]       = GetQuestion(random[0], random[1]);
     return(random);
 }
Exemple #4
0
    private void OnGUI()
    {
        EditorGUILayout.BeginHorizontal();
        {
            EditorGUILayout.LabelField(_currentFileTitle, EditorStyles.boldLabel);

            if (GUILayout.Button("Reload"))
            {
                SetFile(_file);
            }

            if (GUILayout.Button("Save"))
            {
                if (_dirty)
                {
                    string assetPath = AssetDatabase.GetAssetPath(_file);
                    File.WriteAllText(assetPath, _game.Save());
                    AssetDatabase.Refresh();

                    SetFile(_file);
                }
            }
        }
        EditorGUILayout.EndHorizontal();

        TextAsset newFile = EditorGUILayout.ObjectField("File", _file, typeof(TextAsset), false) as TextAsset;

        if (newFile != _file)
        {
            SetFile(newFile);
        }

        if (string.IsNullOrEmpty(_error) == false)
        {
            EditorGUILayout.HelpBox(_error, MessageType.Error);
        }

        if (_game == null)
        {
            return;
        }

        EditorGUILayout.Space();

        EditorGUILayout.BeginHorizontal();
        {
            if (GUILayout.Button("Delete All"))
            {
                if (EditorUtility.DisplayDialog("Delete all round", "Are you sure you want to delete all rounds?", "Delete", "Cancel"))
                {
                    _game.GameRounds = new List <Round>();
                    _game.SerializedRoundQuestions = new List <string>();

                    SetGameDirty();
                }
            }

            if (GUILayout.Button("Collapse All"))
            {
                for (int i = 0; i < _game.GameRounds.Count; i++)
                {
                    _roundCollapsed[i] = true;

                    Question[] questions = _game.GetQuestionsForRound <Question>(i);

                    _questionCollapsed[i] = new Dictionary <int, bool>();

                    if (questions == null)
                    {
                        continue;
                    }

                    for (int j = 0; j < questions.Length; j++)
                    {
                        _questionCollapsed[i][j] = true;
                    }
                }
            }

            if (GUILayout.Button("Open All"))
            {
                for (int i = 0; i < _game.GameRounds.Count; i++)
                {
                    _roundCollapsed[i] = false;

                    Question[] questions = _game.GetQuestionsForRound <Question>(i);

                    _questionCollapsed[i] = new Dictionary <int, bool>();

                    if (questions == null)
                    {
                        continue;
                    }

                    for (int j = 0; j < questions.Length; j++)
                    {
                        _questionCollapsed[i][j] = false;
                    }
                }
            }
        }
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.Space();

        EditorGUILayout.BeginHorizontal(GUI.skin.box);
        {
            _scrollPosition = EditorGUILayout.BeginScrollView(_scrollPosition, false, true);

            for (int i = 0; i < _game.GameRounds.Count; i++)
            {
                switch (_game.GetRound(i))
                {
                case Round.ThreeSixNine:
                    DrawThreeSixNine(i);
                    break;

                case Round.Puzzle:
                    DrawPuzzle(i);
                    break;

                case Round.OpenDoor:
                    DrawOpenDoor(i);
                    break;

                case Round.Gallery:
                    DrawGallery(i);
                    break;

                case Round.CollectiveMemory:
                    DrawCollectiveMemory(i);
                    break;

                case Round.Finale:
                    DrawFinale(i);
                    break;

                case Round.Bonus:
                    DrawBonus(i);
                    break;

                case Round.Done:
                    DrawDone(i);
                    break;
                }
            }

            EditorGUILayout.EndScrollView();
        }
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.Space();

        EditorGUILayout.BeginHorizontal();
        {
            _roundToAdd = (Round)EditorGUILayout.EnumPopup(_roundToAdd);

            if (GUILayout.Button("Add Round"))
            {
                SetGameDirty();

                switch (_roundToAdd)
                {
                case Round.ThreeSixNine:
                    ThreeSixNineQuestion[] threeSixNineQuestions = new ThreeSixNineQuestion[15];
                    for (int i = 0; i < threeSixNineQuestions.Length; i++)
                    {
                        threeSixNineQuestions[i] = new ThreeSixNineQuestion();
                    }

                    QuestionContainer <ThreeSixNineQuestion> threeSixNineContainer = new QuestionContainer <ThreeSixNineQuestion>();
                    threeSixNineContainer.Questions = threeSixNineQuestions;

                    _game.AddRound(_roundToAdd, threeSixNineContainer);
                    break;

                case Round.Puzzle:
                    PuzzleQuestion[] puzzleQuestions = new PuzzleQuestion[3];
                    for (int i = 0; i < puzzleQuestions.Length; i++)
                    {
                        puzzleQuestions[i]         = new PuzzleQuestion();
                        puzzleQuestions[i].Answers = new PuzzleAnswer[3];

                        for (int j = 0; j < puzzleQuestions[i].Answers.Length; j++)
                        {
                            puzzleQuestions[i].Answers[j]       = new PuzzleAnswer();
                            puzzleQuestions[i].Answers[j].Words = new[] { "", "", "", "" };
                        }
                    }

                    QuestionContainer <PuzzleQuestion> puzzleContainer = new QuestionContainer <PuzzleQuestion>();
                    puzzleContainer.Questions = puzzleQuestions;

                    _game.AddRound(_roundToAdd, puzzleContainer);
                    break;

                case Round.OpenDoor:
                    OpenDoorQuestion[] openDoorQuestions = new OpenDoorQuestion[3];
                    for (int i = 0; i < openDoorQuestions.Length; i++)
                    {
                        openDoorQuestions[i]         = new OpenDoorQuestion();
                        openDoorQuestions[i].Answers = new OpenDoorAnswer[4];

                        for (int j = 0; j < openDoorQuestions[i].Answers.Length; j++)
                        {
                            openDoorQuestions[i].Answers[j] = new OpenDoorAnswer();
                        }
                    }

                    QuestionContainer <OpenDoorQuestion> openDoorContainer = new QuestionContainer <OpenDoorQuestion>();
                    openDoorContainer.Questions = openDoorQuestions;

                    _game.AddRound(_roundToAdd, openDoorContainer);
                    break;

                case Round.Gallery:
                    GalleryQuestion[] galleryQuestions = new GalleryQuestion[3];
                    for (int i = 0; i < galleryQuestions.Length; i++)
                    {
                        galleryQuestions[i]         = new GalleryQuestion();
                        galleryQuestions[i].Answers = new GalleryAnswer[10];

                        for (int j = 0; j < galleryQuestions[i].Answers.Length; j++)
                        {
                            galleryQuestions[i].Answers[j] = new GalleryAnswer();
                        }
                    }

                    QuestionContainer <GalleryQuestion> galleryContainer = new QuestionContainer <GalleryQuestion>();
                    galleryContainer.Questions = galleryQuestions;

                    _game.AddRound(_roundToAdd, galleryContainer);
                    break;

                case Round.Bonus:
                    _game.AddRound <Question>(_roundToAdd, null);
                    break;

                case Round.Done:
                    _game.AddRound <Question>(_roundToAdd, null);
                    break;

                case Round.CollectiveMemory:
                    CollectiveMemoryQuestion[] collectiveMemoryQuestions = new CollectiveMemoryQuestion[3];
                    for (int i = 0; i < collectiveMemoryQuestions.Length; i++)
                    {
                        collectiveMemoryQuestions[i]             = new CollectiveMemoryQuestion();
                        collectiveMemoryQuestions[i].Answers     = new string[5];
                        collectiveMemoryQuestions[i].TimeRewards = new int[5];

                        for (int j = 0; j < collectiveMemoryQuestions[i].Answers.Length; j++)
                        {
                            collectiveMemoryQuestions[i].Answers[j]     = "Antwoord " + (i + 1);
                            collectiveMemoryQuestions[i].TimeRewards[j] = 0;
                        }
                    }

                    QuestionContainer <CollectiveMemoryQuestion> collectiveMemoryContainer = new QuestionContainer <CollectiveMemoryQuestion>();
                    collectiveMemoryContainer.Questions = collectiveMemoryQuestions;

                    _game.AddRound(_roundToAdd, collectiveMemoryContainer);
                    break;

                case Round.Finale:
                    FinaleQuestion[] finaleQuestions = new FinaleQuestion[12];
                    for (int i = 0; i < finaleQuestions.Length; i++)
                    {
                        finaleQuestions[i]         = new FinaleQuestion();
                        finaleQuestions[i].Answers = new FinaleAnswer[5];

                        for (int j = 0; j < finaleQuestions[i].Answers.Length; j++)
                        {
                            finaleQuestions[i].Answers[j] = new FinaleAnswer();
                        }
                    }

                    QuestionContainer <FinaleQuestion> finaleContainer = new QuestionContainer <FinaleQuestion>();
                    finaleContainer.Questions = finaleQuestions;

                    _game.AddRound(_roundToAdd, finaleContainer);
                    break;
                }
            }
        }
        EditorGUILayout.EndHorizontal();

        if (_roundIndexToRemove != -1)
        {
            _game.RemoveRound(_roundIndexToRemove);
            SetGameDirty();
            _roundIndexToRemove = -1;
        }
    }