Example #1
0
    //------------------------------------------------
    private void loadLevel()
    {
        Debug.Log("Next level loaded...");
        PG_OllyAnimations.changeTexture = true;
        ollyAnimationsSR.isAnimating    = true;
        ollyAnimationsSR.ollyState      = ollyAnimationStates.olly_idle1;

        totalAttempts        = 0;
        totalWrongAttempts   = 0;
        totalCorrects        = 0;
        jumpCount            = 0;
        countModeShapeNumber = 0;
        shapesTappedIndex    = -1;
        pgDataManager.fetchLevelData();
        showReferentBubble();
        pgDataManager.PG_generateQuestion();
        setIckyOllyInitialPosition();


        ickyAnimationsSR.isAnimating = true;
        ickyAnimationsSR.ickyState   = ickyAnimStates.icky_idle1;
        hardModeTime = pgDataManager.getHardModeTime();
        setDataUsingScriptRefrences();
        PG_OllyAnimations.answerShapesCount = pgDataManager.getAnswersListCount();
    }
    void getAllComponentsRef()
    {
        GameObject question = GameObject.Find("Question");

        questionLoader = (NF_QuestionLoader)question.GetComponent <NF_QuestionLoader>();

        GameObject trail = GameObject.Find("Drag_Trail");

        dragTrail       = (NF_DragTrail)trail.GetComponent <NF_DragTrail>();
        ropesGenerator  = (NF_RopesGenerator)this.GetComponent <NF_RopesGenerator>();
        inputController = (NF_InputController)this.GetComponent <NF_InputController>();

        // select skill id On random
        if (AGGameState.currentGameIndex == (int)AGGameIndex.k_NamingFruits)
        {
            currentCategoryID = (int)Random.Range((int)NamingFruits_CategoryID.id_Food, (int)NamingFruits_CategoryID.id_AlplabeticOrder + 1);
            backgroundsCount  = 4;
            backgroundArray   = new string[] { "Green", "Orange", "Blue", "Sunrise" };
            foregroundArray   = new string[] { "Top-Green-Back", "Top-Orange-Back", "Top-Blue-Back", "Top-Sunrise-Back" };
            frontLayerArray   = new string[] { "Top-Green-Front", "Top-Orange-Front", "Top-Blue-Front", "Top-Sunrise-Front" };

            dataManager = new JW_DataManager(AGGameIndex.k_NamingFruits, currentCategoryID, _progressionList.text);
            dataManager.loadCategoryResources(_resourcesData.text);
            dataManager.currentLevel = 1;
            dataManager.fetchLevelData();
        }
        else if (AGGameState.currentGameIndex == (int)AGGameIndex.k_2DShapesColors)
        {
            currentCategoryID = (int)Random.Range((int)SimpleColors_CategoryID.id_Colors, (int)SimpleColors_CategoryID.id_2DShapes + 1);
            backgroundsCount  = 2;
            backgroundArray   = new string[] { "Pink", "Purple" };
            foregroundArray   = new string[] { "Pink-Back-Frill", "Purple-Back-Frill" };
            frontLayerArray   = new string[] { "Pink-Front-Frill", "Purple-Front-Frill" };
            dataManager       = new JW_DataManager(AGGameIndex.k_2DShapesColors, currentCategoryID, _progressionList.text);
            dataManager.loadCategoryResources(_resourcesData.text);
            dataManager.currentLevel = 1;
            dataManager.fetchLevelData();
        }
        Debug.Log("NF_Skill ID:" + currentCategoryID);
    }
    void getAllComponentsRef()
    {
        GameObject question = GameObject.Find("Question");
        questionLoader = (NF_QuestionLoader) question.GetComponent<NF_QuestionLoader>();

        GameObject trail = GameObject.Find("Drag_Trail");
        dragTrail = (NF_DragTrail) trail.GetComponent<NF_DragTrail>();
        ropesGenerator = (NF_RopesGenerator) this.GetComponent<NF_RopesGenerator>();
        inputController = (NF_InputController) this.GetComponent<NF_InputController>();

        // select skill id On random
        if(AGGameState.currentGameIndex == (int) AGGameIndex.k_NamingFruits){
            currentCategoryID=(int)Random.Range((int)NamingFruits_CategoryID.id_Food,(int)NamingFruits_CategoryID.id_AlplabeticOrder+1);
            backgroundsCount=4;
            backgroundArray = new string[] {"Green","Orange","Blue","Sunrise"};
            foregroundArray = new string[] {"Top-Green-Back","Top-Orange-Back","Top-Blue-Back","Top-Sunrise-Back"};
            frontLayerArray = new string[] {"Top-Green-Front","Top-Orange-Front","Top-Blue-Front","Top-Sunrise-Front"};

            dataManager = new JW_DataManager(AGGameIndex.k_NamingFruits,currentCategoryID,_progressionList.text);
            dataManager.loadCategoryResources(_resourcesData.text);
            dataManager.currentLevel=1;
            dataManager.fetchLevelData();

            }
        else if(AGGameState.currentGameIndex == (int) AGGameIndex.k_2DShapesColors){
            currentCategoryID= (int)Random.Range((int)SimpleColors_CategoryID.id_Colors,(int)SimpleColors_CategoryID.id_2DShapes+1);
            backgroundsCount=2;
            backgroundArray = new string[] {"Pink","Purple"};
            foregroundArray = new string[] {"Pink-Back-Frill","Purple-Back-Frill"};
            frontLayerArray = new string[] {"Pink-Front-Frill","Purple-Front-Frill"};
            dataManager = new JW_DataManager(AGGameIndex.k_2DShapesColors,currentCategoryID,_progressionList.text);
            dataManager.loadCategoryResources(_resourcesData.text);
            dataManager.currentLevel=1;
            dataManager.fetchLevelData();
        }
        Debug.Log("NF_Skill ID:" + currentCategoryID);
    }
    public void loadNextQuestion(float timeToLoad)
    {
        float restartLevelTime = 0;

        //restartLevelTime= timeToLoad;
        Debug.Log("Load Next Question");
        int questionAttempts = 0;
        int wrongAttempts    = 0;


        if (isResetInProgress)
        {
            inputController.isTouchEnabled = false;
            return;
        }
        isResetInProgress = true;
        questionAttempts  = inputController.qAttemptsCount();
        wrongAttempts     = inputController.wrongAttempts;
        if (questionAttempts > 0)
        {
#if (MAC_PLATFORM)
            AGGameState.incrementStarCount();
            if (AGGameState.currentGameIndex == (int)AGGameIndex.k_NamingFruits)
            {
                if (dataManager.currentLevel == 17 || dataManager.currentLevel == 8)
                {
                    dataManager.currentLevel = 1;
                }
                else
                {
                    dataManager.currentLevel++;
                }
            }
            else if (AGGameState.currentGameIndex == (int)AGGameIndex.k_2DShapesColors)
            {
                if (dataManager.currentLevel == 17 || dataManager.currentLevel == 20)
                {
                    dataManager.currentLevel = 1;
                }
                else
                {
                    dataManager.currentLevel++;
                }
            }

            if (wrongAttempts >= 5)
            {
                restartLevelTime = 1.5f;
            }
            else if (wrongAttempts < 5)
            {
                inputController.setCelebrationStatus(true);
                restartLevelTime = 3.0f;
            }
            dataManager.fetchLevelData();
            questionAttempts = 0;
            wrongAttempts    = 0;
            CancelInvoke("createOllyModel");
            Invoke("resetAllLevelState", restartLevelTime);
#else
            AGGameState.incrementStarCount();
            bool isLevelDone = dataManager.calculateResult(questionAttempts, answersListCount);
            if (isLevelDone)
            {
                restartLevelTime = 3.0f;
                inputController.setCelebrationStatus(true);
                dataManager.fetchLevelData();
            }
            else if (!isLevelDone)
            {
                if (wrongAttempts == 5)
                {
                    restartLevelTime = 1.25f;
                }
                else
                {
                    restartLevelTime = 2.0f;
                }
            }

            wrongAttempts    = 0;
            questionAttempts = 0;
            CancelInvoke("createOllyModel");
            Invoke("resetAllLevelState", restartLevelTime);
#endif
        }
    }