Exemple #1
0
    public void fetchLevelData()
    {
        if (allLevels == null)
        {
            Debug.Log("Exception: level data not available ... something wrong with plist");
            return;
        }
#if (!MAC_PLATFORM)
        currentLevel = coreManager.getCurrentLevel();
#endif


        //if the game starts from level0 you dont need this check
        if (currentLevel == 0 && currentCategoryID != 178)
        {
            currentLevel = 1;
        }

/*
 #if (MAC_PLATFORM)
 *              currentLevel = 14;
 #endif
 */
        string    currentLevelString = string.Format("level{0}", currentLevel);
        Hashtable currentLevelData   = (Hashtable)allLevels[currentLevelString];

        if (currentLevelData == null)
        {
            Debug.Log("Exception: not data for current level available ... trying level1 ...");
            currentLevelData = (Hashtable)allLevels["level1"];
            if (currentLevelData == null)
            {
                Debug.Log("Exception: not data for any level available ... terminate");
                return;
            }
        }

        easyThreshold = GetAsFloat(currentLevelData["easyThreshold"]);
        hardThreshold = GetAsFloat(currentLevelData["hardThreshold"]);

        failEasyGoto    = GetAsInt(currentLevelData["failEasyGoto"]);
        succeedHardGoto = GetAsInt(currentLevelData["succeedHardGoto"]);
        minQuestions    = GetAsInt(currentLevelData["minQuestions"]);
        maxQuestions    = GetAsInt(currentLevelData["maxQuestions"]);
        numberLineMin   = GetAsInt(currentLevelData["numberLineMin"]);
        numberLineMax   = GetAsInt(currentLevelData["numberLineMax"]);

        showNumbers = (bool)currentLevelData["showNumbers"];

        numberSequence = getNumberSequenceFromString((string)currentLevelData["numberSequence"]);

        ArrayList levelNumbers = (ArrayList)currentLevelData["numbers"];
#if (MAC_PLATFORM)
        numbersForLevel = levelNumbers;
#else
        numbersForLevel = new ArrayList();

        questionsAsked = 0;
        totalQuestions = 0;
        int questionsMastered = 0;

        foreach (string num in levelNumbers)
        {
            Hashtable numDict = (Hashtable)allCategoriesCoreData[num];

            int qPlayed = GetAsInt(numDict["questionsPlayed"]);

            bool hasMastered = (bool)numDict["hasMastered"];
            if (!hasMastered)
            {
                numbersForLevel.Add(num);
                questionsAsked += qPlayed;
                Debug.Log("number for level " + num);
            }
            else
            {
                questionsMastered += qPlayed;
            }
        }
        totalQuestions = questionsMastered + questionsAsked;
#endif
    }
Exemple #2
0
    private int beeStartingPointFromString(string startingPosition, string condition)
    {
        int defaultNumber = numberLineMin;

        if (currentCategoryID.Equals("180"))
        {
            defaultNumber = numberLineMax;
        }

        int number = defaultNumber;

        string [] posArray = startingPosition.Split(new char [] { ',' });
        if (posArray.Length == 0)
        {
            number = initialNumber;
        }
        else if (posArray.Length == 1)
        {
            number = System.Convert.ToInt32(posArray[0]);
        }
        else if (posArray.Length == 2)
        {
            number = (int)Random.Range(System.Convert.ToInt32(posArray[0]), System.Convert.ToInt32(posArray[1]) + 1);
        }
        else
        {
            int index = totalQuestions % posArray.Length;
            number = System.Convert.ToInt32(posArray[index]);
        }

        BWNumberSequence sequence = getNumberSequenceFromString(condition);

        if (sequence == BWNumberSequence.BWNumberSequenceNumberAsked)
        {
            if (number < 0)
            {
                number = -numberToFind;
            }
            else
            {
                number = AGGameState.modInt(numberToFind);
            }
        }

        if (number + numberToFind > numberLineMax)
        {
            number = anySmallerNumberAvailable(number);
            if (number + numberToFind > numberLineMax)
            {
                number = numberLineMax - numberToFind;
            }
            else
            {
                numberToFind = number;
            }
        }
        else if (number + numberToFind < numberLineMin)
        {
            number = anyGreaterNumberAvailable(number);
            if (number + numberToFind < numberLineMin)
            {
                number = numberLineMin - numberToFind;
            }
            else
            {
                numberToFind = number;
            }
        }

        return(number);
    }
Exemple #3
0
    private int initialNumberFromString(string initialNumber)
    {
        int number    = numberLineMin;
        int offNumber = -1000;

        if (initialNumber == null)
        {
            return(number);
        }


        string [] initialArray = initialNumber.Split(new char [] { ':' });

        string numberString = initialArray[0];

        string [] numberArray = numberString.Split(new char [] { ',' });

        if (numberArray == null || numberArray.Length == 0)
        {
            number = numberLineMin;
        }
        else if (numberArray.Length == 1)
        {
            number = System.Convert.ToInt32(numberArray[0]);
        }
        else if (numberArray.Length == 2)
        {
            number = (int)Random.Range(System.Convert.ToInt32(numberArray[0]), System.Convert.ToInt32(numberArray[1]) + 1);
        }
        else
        {
            number = numberLineMin;
        }

        if (initialArray.Length == 2)
        {
            BWNumberSequence condition = getNumberSequenceFromString(initialArray[1]);
            switch (condition)
            {
            case BWNumberSequence.BWNumberSequenceNumberAsked:
                number = numberToFind + number;
                break;

            case BWNumberSequence.BWNumberSequenceStartingPoint:
                offNumber = number;
                number    = beeStartingIndex + number;
                break;

            default:
                number = numberLineMin;
                break;
            }
        }

        if (number < numberLineMin || number > numberLineMax)
        {
            number = numberLineMin;
        }

        //finally
        if (beeStartingIndex == -1000)
        {
            return(number);
        }

        if (currentCategoryID.Equals("180"))
        {
            if (offNumber == -5 && beeStartingIndex == 0)
            {
                number = -3;
            }

            if (currentLevel == 49 || currentLevel == 50)
            {
                if (beeStartingIndex <= 0)
                {
                    number = -3;
                }
                else
                {
                    number = -2;
                }
            }
        }

        if (number + 6 >= numberLineMax)
        {
            number = numberLineMax - 7;
        }

        //Debug.Log("initial number" + number);

        return(number);
    }
	public void fetchLevelData () {
		
		if(allLevels == null) {
			Debug.Log("Exception: level data not available ... something wrong with plist");
			return;
		}
#if (!MAC_PLATFORM)
		currentLevel = coreManager.getCurrentLevel();
#endif
		
		
		//if the game starts from level0 you dont need this check
		if (currentLevel == 0 && currentCategoryID != 178) currentLevel = 1;
/*	
#if (MAC_PLATFORM)
		currentLevel = 14;
#endif
*/
		string currentLevelString = string.Format("level{0}", currentLevel);
	    Hashtable currentLevelData = (Hashtable)allLevels[currentLevelString];
	    
	    if (currentLevelData == null) {
			Debug.Log("Exception: not data for current level available ... trying level1 ...");
	        currentLevelData = (Hashtable)allLevels["level1"];
	        if (currentLevelData == null) {
				Debug.Log("Exception: not data for any level available ... terminate");
	            return;
	        }
	    }
	    
	    easyThreshold = GetAsFloat(currentLevelData["easyThreshold"]);
		hardThreshold = GetAsFloat(currentLevelData["hardThreshold"]);
		
	    failEasyGoto        = GetAsInt(currentLevelData["failEasyGoto"]);
	    succeedHardGoto     = GetAsInt(currentLevelData["succeedHardGoto"]);
	    minQuestions        = GetAsInt(currentLevelData["minQuestions"]);
	    maxQuestions        = GetAsInt(currentLevelData["maxQuestions"]);
	    numberLineMin       = GetAsInt(currentLevelData["numberLineMin"]);
	    numberLineMax       = GetAsInt(currentLevelData["numberLineMax"]);
		
		showNumbers         = (bool)currentLevelData["showNumbers"];
	    
	    numberSequence = getNumberSequenceFromString((string)currentLevelData["numberSequence"]);
		
		ArrayList levelNumbers = (ArrayList)currentLevelData["numbers"];
#if (MAC_PLATFORM)
		numbersForLevel = levelNumbers;
#else
		numbersForLevel = new ArrayList();
		
		questionsAsked = 0;
		totalQuestions = 0;
		int questionsMastered = 0;
		
	    foreach(string num in levelNumbers) {
			
			Hashtable numDict = (Hashtable)allCategoriesCoreData[num];
				
			int qPlayed = GetAsInt(numDict["questionsPlayed"]);
			
			bool hasMastered = (bool)numDict["hasMastered"];
			if(!hasMastered) {
				numbersForLevel.Add(num);
				questionsAsked += qPlayed;
				Debug.Log("number for level " + num);
			} else {
				questionsMastered += qPlayed;
			}	
		}
		totalQuestions = questionsMastered + questionsAsked;
#endif	
	}