Beispiel #1
0
    private void ShowNewAward(int origRowVal, int origColumnVal, RectTransform orignalRectTransform, jackpotState newState)
    {
        GameObject    newAward         = gameObject;
        RectTransform newRectTransform = GetComponent <RectTransform>();

        switch (newState)
        {
        case jackpotState.Mini:
            closedCount--;
            miniCount++;
            newAward = Instantiate(
                GameConstants.gameConstants.awardMiniPrefab.gameObject,
                GridLayoutManager.gridLayoutManager.transform);
            newRectTransform = newAward.GetComponent <RectTransform>();
            break;

        case jackpotState.Minor:
            closedCount--;
            minorCount++;
            newAward = Instantiate(
                GameConstants.gameConstants.awardMinorPrefab.gameObject,
                GridLayoutManager.gridLayoutManager.transform);
            newRectTransform = newAward.GetComponent <RectTransform>();
            break;

        case jackpotState.Major:
            closedCount--;
            majorCount++;
            newAward = Instantiate(
                GameConstants.gameConstants.awardMajorPrefab.gameObject,
                GridLayoutManager.gridLayoutManager.transform);
            newRectTransform = newAward.GetComponent <RectTransform>();
            break;

        case jackpotState.Grand:
            closedCount--;
            grandCount++;
            newAward = Instantiate(
                GameConstants.gameConstants.awardGrandPrefab.gameObject,
                GridLayoutManager.gridLayoutManager.transform);
            newRectTransform = newAward.GetComponent <RectTransform>();
            break;
        }
        createdObjects.Add(newAward);
        newRectTransform.anchorMin        = orignalRectTransform.anchorMin;
        newRectTransform.anchorMax        = orignalRectTransform.anchorMax;
        newRectTransform.anchoredPosition = orignalRectTransform.anchoredPosition;
        newRectTransform.sizeDelta        = orignalRectTransform.sizeDelta;

        gridState[origRowVal + "" + origColumnVal] = newState;

        if (!newAward.activeSelf)
        {
            newAward.SetActive(true);
        }

        //newRectTransform.GetComponent<AwardHandler>().rowVal = origRowVal;
        //newRectTransform.GetComponent<AwardHandler>().columnVal = origColumnVal;
        Destroy(orignalRectTransform.gameObject);
    }
Beispiel #2
0
    public void ChangeParameterFor(int rowVal, int columnVal, RectTransform orignalRectTransform)
    {
        jackpotState newState = DecideNewParameter();

        ShowNewAward(rowVal, columnVal, orignalRectTransform, newState);

        CheckGridForRewards();
    }
Beispiel #3
0
    public void SaveJsonData(bool rewardsAssigned, jackpotState newState)
    {
        DataStructure newJsonData = new DataStructure();

        //Set Json Data in new variable
        if (rewardsAssigned)
        {
            switch (newState)
            {
            case jackpotState.Mini:
                currMiniTotal += 100000;
                currTotal     += 100000;
                break;

            case jackpotState.Minor:
                currMinorTotal += 200000;
                currTotal      += 200000;
                break;

            case jackpotState.Major:
                currMajorTotal += 500000;
                currTotal      += 500000;
                break;

            case jackpotState.Grand:
                currGrandTotal += 1000000;
                currTotal      += 1000000;
                break;
            }
        }

        newJsonData.totalEarned = currTotal;
        newJsonData.miniTotal   = currMiniTotal;
        newJsonData.minorTotal  = currMinorTotal;
        newJsonData.majorTotal  = currMajorTotal;
        newJsonData.grandTotal  = currGrandTotal;
        SetUiTotal();

        newJsonData.dictionarykeys = new string[
            GridLayoutManager.gridLayoutManager.rowCount * GridLayoutManager.gridLayoutManager.columnCount
                                     ];
        newJsonData.dictionaryValues = new jackpotState[
            GridLayoutManager.gridLayoutManager.rowCount * GridLayoutManager.gridLayoutManager.columnCount
                                       ];

        //      for (int i=0; i< GridLayoutManager.gridLayoutManager.rowCount; i++)
        //{
        //          for(int j=0; j<GridLayoutManager.gridLayoutManager.columnCount; j++)
        //	{
        //              newJsonData.dictionarykeys[(GridLayoutManager.gridLayoutManager.rowCount * i) + j] = (string)(i+""+j) ;
        //              newJsonData.dictionaryValues[(GridLayoutManager.gridLayoutManager.rowCount * i) + j] = GameHandler.gameHandler.gridState[i + "" + j];
        //              Debug.Log("saving ("+i+", "+j+"), kay as : " +
        //                  newJsonData.dictionarykeys[(GridLayoutManager.gridLayoutManager.rowCount * i) + j]+
        //                  " : and value as : " +
        //                  newJsonData.dictionaryValues[(GridLayoutManager.gridLayoutManager.rowCount * i) + j]);
        //          }
        //}

        for (int i = 0; i < GridLayoutManager.gridLayoutManager.rowCount; i++)
        {
            for (int j = 0; j < GridLayoutManager.gridLayoutManager.columnCount; j++)
            {
                newJsonData.dictionarykeys[(GridLayoutManager.gridLayoutManager.rowCount * i) + j]   = (string)(i + "" + j);
                newJsonData.dictionaryValues[(GridLayoutManager.gridLayoutManager.rowCount * i) + j] = GameHandler.gameHandler.gridState[i + "" + j];
                Debug.Log("saving (" + i + ", " + j + "), kay as : " +
                          newJsonData.dictionarykeys[(GridLayoutManager.gridLayoutManager.rowCount * i) + j] +
                          " : and value as : " +
                          newJsonData.dictionaryValues[(GridLayoutManager.gridLayoutManager.rowCount * i) + j]);
            }
        }

        //Debug.Log("saving keys, value as : " + newJsonData.dictionarykeys);
        //Debug.Log("saving values as : " + newJsonData.dictionaryValues);
        newJsonData.scoreComplete = rewardsAssigned;


        //save new data in file
        string jsonDataString = JsonUtility.ToJson(newJsonData, true);

        File.WriteAllText(jsonPath, jsonDataString);
    }
Beispiel #4
0
 public void setAwardState(jackpotState val)
 {
     //changing award state
     myState = val;
 }