Пример #1
0
    public void EmitQuestionsMap(out Dictionary <GameData.PillarType, List <QuestionData.question> > map)
    {
        map = new Dictionary <GameData.PillarType, List <question> >();

        foreach (var q in questions)
        {
            GameData.PillarType qKey = q.GetQuestionType();
            List <question>     questionList;
            if (map.ContainsKey(qKey))
            {
                questionList = map[qKey];
            }
            else
            {
                questionList = new List <question>();
                map.Add(qKey, questionList);
            }
            questionList.Add(q);
        }
    }
Пример #2
0
    public bool AddFreePillar(out GameData.PillarType pillar, System.Action <PlayerController> onPillarLanded)
    {
        var slot = GameData.current.GetCurrentDataSlot();

        pillar = GameData.PillarType.None;

        foreach (var pillarNeeded in slot.pillarsNeeded)
        {
            if (pillarsAcquired.Contains(pillarNeeded) == false)
            {
                pillar = pillarNeeded;
            }
        }

        if (pillar != GameData.PillarType.None)
        {
            return(AddPillar(pillar, onPillarLanded));
        }

        return(false);
    }
Пример #3
0
    public bool GetFreePillar(out GameData.PillarType pillar)
    {
        var slot = GameData.current.GetCurrentDataSlot();

        pillar = GameData.PillarType.None;

        foreach (var pillarNeeded in slot.pillarsNeeded)
        {
            if (pillarsAcquired.Contains(pillarNeeded) == false)
            {
                pillar = pillarNeeded;
            }
        }

        if (pillar != GameData.PillarType.None)
        {
            return(true);
        }

        return(false);
    }
Пример #4
0
    public void PillarWon(GameData.PillarType pillar)
    {
        Debug.Log("Won A Pillar: " + pillar.ToString());

        redPillar.SetActive(false);
        bluePillar.SetActive(false);
        greenPillar.SetActive(false);
        yellowPillar.SetActive(false);
        purplePillar.SetActive(false);
        orangePillar.SetActive(false);

        switch (pillar)
        {
        case GameData.PillarType.Blue:
            bluePillar.SetActive(true);
            break;

        case GameData.PillarType.Red:
            redPillar.SetActive(true);
            break;

        case GameData.PillarType.Green:
            greenPillar.SetActive(true);
            break;

        case GameData.PillarType.Orange:
            orangePillar.SetActive(true);
            break;

        case GameData.PillarType.Purple:
            purplePillar.SetActive(true);
            break;

        case GameData.PillarType.Yellow:
            yellowPillar.SetActive(true);
            Debug.Log("yellow");
            break;
        }
    }
Пример #5
0
    public bool AddPillar(GameData.PillarType pillarType, System.Action <PlayerController> onPillarLanded)
    {
        this.OnPillarLanded = onPillarLanded;
        var renderer = gameObject.GetComponentInChildren <MeshRenderer>();

        Vector3 offset = new Vector3(0f, pillarDropHeight, 0.0f);

        if (pillarsAcquired.Contains(pillarType) == false)
        {
            pillarsAcquired.Add(pillarType);

            GameObject targetObject   = null;
            Vector3    targetPosition = Vector3.zero;

            switch (pillarType)
            {
            case GameData.PillarType.Red:
                redPillar.transform.parent        = redPillarSlot.transform;
                redPillar.transform.localPosition = offset;
                redPillar.SetActive(true);
                targetObject   = redPillar.gameObject;
                targetPosition = redPillarSlot.transform.position;
                break;

            case GameData.PillarType.Green:
                greenPillar.transform.parent        = greenPillarSlot.transform;
                greenPillar.transform.localPosition = offset;                //.position = greenPillarSlot.transform.position + offset;
                greenPillar.SetActive(true);
                targetObject   = greenPillar.gameObject;
                targetPosition = greenPillarSlot.transform.position;
                break;

            case GameData.PillarType.Blue:
                bluePillar.transform.parent        = bluePillarSlot.transform;
                bluePillar.transform.localPosition = offset;                //.position = bluePillarSlot.transform.position + offset;
                bluePillar.SetActive(true);
                targetObject   = bluePillar.gameObject;
                targetPosition = bluePillarSlot.transform.position;
                break;

            case GameData.PillarType.Yellow:
                yellowPillar.transform.parent        = yellowPillarSlot.transform;
                yellowPillar.transform.localPosition = offset;                //.position = yellowPillarSlot.transform.position + offset;
                yellowPillar.SetActive(true);
                targetObject   = yellowPillar.gameObject;
                targetPosition = yellowPillarSlot.transform.position;
                break;

            case GameData.PillarType.Purple:
                purplePillar.transform.parent        = purplePillarSlot.transform;
                purplePillar.transform.localPosition = offset;                //.position = purplePillarSlot.transform.position + offset;
                purplePillar.SetActive(true);
                targetObject   = purplePillar.gameObject;
                targetPosition = purplePillarSlot.transform.position;
                break;

            case GameData.PillarType.Orange:
                orangePillar.transform.parent        = orangePillarSlot.transform;
                orangePillar.transform.localPosition = offset;                //.position = orangePillarSlot.transform.position + offset;
                orangePillar.SetActive(true);
                targetObject   = orangePillar.gameObject;
                targetPosition = orangePillarSlot.transform.position;
                break;
            }

            if (targetObject != null)
            {
                GameCamera.LookCamera(targetObject);                //, 2f);
                iTween.MoveTo(targetObject, iTween.Hash("position", targetPosition, "time", pillarDropTime, "easeType", iTween.EaseType.easeOutBounce, "onComplete", "PillarHasLanded", "oncompletetarget", gameObject));
            }

            return(true);
        }
        return(false);
    }
Пример #6
0
    private QuestionData.question GetNextQuestion(Node node, GameData.PillarType defaultPillar, bool useDefaultPillar)
    {
        QuestionData.question result = null;

        // First get the pillar color code from the node that being selected by the player
        GameData.PillarType qtype;
        if (node != null)
        {
            qtype = GameData.GetColorTypeFromNodeType(node.nodeType);
        }
        else
        {
            qtype = defaultPillar;
        }

        if (useDefaultPillar)
        {
            qtype = defaultPillar;
        }

        // Create temp question list to fetch on
        List <QuestionData.question> questions = new List <QuestionData.question>();

        // Find on which colors are we about to take the question list from
        if (questionsMap.ContainsKey(qtype))
        {
            questions = questionsMap[qtype];
        }
        else // We are having QuestionType == Random here
        {
            // If we don't have the pillar color mapped on the questionsMap, just random the section

            int index = Random.Range(0, questionsMap.Keys.Count - 1);

            // Search our random key to get the list of the questions
            int i = 0;
            foreach (var qsValues in questionsMap.Keys)
            {
                if (index == i)
                {
                    questions = questionsMap[qsValues];
                    break;
                }
                i++;
            }
        }

        bool found = false;

        // We loop until we found the question that not being used yet, it's very dangerous, might end up infinite loop
        // TODO: DON'T USE LOOP
        while (!found)
        {
            int qRandomNo = Random.Range(0, questions.Count - 1);
            var que       = questions[qRandomNo];
            if (usedQuestions.Contains(que) == false)
            {
                result = que;
                usedQuestions.Add(que);

                found = true;
            }
        }

        if (result == null)
        {
            usedQuestions.Clear();
            result = QuestionData.current.questions[0];
        }

        return(result);
    }