Exemplo n.º 1
0
 public void addRow(HarvestResRow para_nwRow)
 {
     if(rows == null) { rows = new List<HarvestResRow>(); }
     rows.Add(para_nwRow);
 }
Exemplo n.º 2
0
    public override void buildPage(int para_pageID, GameObject para_pageParent)
    {
        if(pageInitFlags == null) { pageInitFlags = new bool[]{false,false}; }

        if(para_pageID == 0)
        {
            string reqPageObjName = "ResultScreens_A";
            Transform reqResultScreenPage = transform.FindChild(reqPageObjName);
            Transform subPageTemplate = reqResultScreenPage.FindChild("Pages").FindChild("Ac"+acPKey);
            subPageTemplate.gameObject.SetActive(true);

            if(pageInitFlags[0] == false)
            {
                // Load necessary items.
                string fullPathToTemplate = reqPageObjName + "*" + "Pages" + "*" + ("Ac"+acPKey);

                // Init Items.
                HarvestGameyResultData gameyData = (HarvestGameyResultData) acResultData.getGameyData();

                int numCorrectHarvests = gameyData.getNumCorrectHarvests();
                int numMachinesBroken = gameyData.getNumMachinesBroken();
                string timeStr = gameyData.getTimeString();

                string[] elementNames   = {"FieldTitle-0","FieldTitle-1","FieldTitle-2","FieldContent-0","FieldContent-1","FieldContent-2"};
                string[] elementContent = {LocalisationMang.translate("Correct harvests"),LocalisationMang.translate("Broken machines"),LocalisationMang.translate("Time"),""+numCorrectHarvests,""+numMachinesBroken,timeStr};
                bool[] destroyGuideArr = {false,false,false,false,false,false};
                int[] textElementTypeArr = {0,0,0,0,0,0};
                prepTextElements(elementNames,elementContent,destroyGuideArr,textElementTypeArr,fullPathToTemplate);

                pageInitFlags[0] = true;
            }
        }
        else if(para_pageID == 1)
        {
            string reqPageObjName = "ResultScreens_B";
            Transform reqResultScreenPage = transform.FindChild(reqPageObjName);
            Transform subPageTemplate = reqResultScreenPage.FindChild("Pages").FindChild("Ac"+acPKey);
            subPageTemplate.gameObject.SetActive(true);

            if(pageInitFlags[1] == false)
            {
                // Load necessary items.
                string fullPathToTemplate = reqPageObjName + "*" + "Pages" + "*" + ("Ac"+acPKey);

                // Init Items.
                resTable = new HarvestResTable();

                List<HarvestResColumn> columnData = new List<HarvestResColumn>();

                List<ILevelConfig> presentedContent = acResultData.getPresentedContent();
                List<LevelOutcome> outcomeList = acResultData.getOutcomeList();

                Debug.Log(presentedContent.Count);
                Debug.Log(outcomeList.Count);

                for(int i=0; i<presentedContent.Count; i++)
                {
                    HarvestLevelConfig tmpContent = (HarvestLevelConfig) presentedContent[i];
                    HarvestLevelOutcome tmpOutcome = (HarvestLevelOutcome) outcomeList[i];

                    if(i == 0)
                    {
                        // Add headers.
                        for(int k=0; k<tmpContent.machineDescriptions.Length; k++)
                        {
                            resTable.addHeaderName(tmpContent.machineDescriptions[k]);
                            columnData.Add(new HarvestResColumn());
                        }
                    }

                    // Add column data.
                    int[] levelCorrectMachines = tmpContent.correctMachines;
                    for(int k=0; k<levelCorrectMachines.Length; k++)
                    {

                        bool playerGotThisCorrect = false;

                        int tmpCorrectMachineIndex = levelCorrectMachines[k];

                        if(tmpOutcome.isPositiveOutcome())
                        {
                            playerGotThisCorrect = true;
                        }
                        else
                        {
                            if(tmpOutcome.getMachinesGivenGoodInput().Contains(tmpCorrectMachineIndex))
                            {
                                playerGotThisCorrect = true;
                            }
                        }

                        columnData[tmpCorrectMachineIndex].addCell(new HarvestResCell(i,tmpContent.harvestingWord,playerGotThisCorrect));
                    }

                }

                // Convert columns to rows.
                bool canMakeMoreRows = true;
                int dataRowIndex = 0;
                while(canMakeMoreRows)
                {
                    canMakeMoreRows = false;

                    List<HarvestResCell> nwRowData = new List<HarvestResCell>();
                    for(int i=0; i<columnData.Count; i++)
                    {
                        List<HarvestResCell> columnContent = columnData[i].columnContent;
                        if((columnContent != null)&&(dataRowIndex < (columnContent.Count)))
                        {
                            nwRowData.Add(columnContent[dataRowIndex]);
                            canMakeMoreRows = true;
                        }
                        else
                        {
                            nwRowData.Add(null);
                        }
                    }

                    if(canMakeMoreRows)
                    {
                        HarvestResRow nwRow = new HarvestResRow(nwRowData);
                        resTable.addRow(nwRow);
                    }

                    dataRowIndex++;
                }

                string[] elementNames   = {"TableScrollArea"};
                string[] elementContent = {"Table Scroll Area"};
                bool[] destroyGuideArr = {true};
                int[] textElementTypeArr = {0};
                prepTextElements(elementNames,elementContent,destroyGuideArr,textElementTypeArr,fullPathToTemplate);

                columnEqualGuiWidth = ((uiBounds["TableScrollArea"].width * 0.9f) / (columnData.Count * 1.0f));
                float minimumColumnWidth = (uiBounds["TableScrollArea"].width * 0.25f);
                if(columnEqualGuiWidth <= minimumColumnWidth)
                {
                    columnEqualGuiWidth = minimumColumnWidth;
                }

                pageInitFlags[1] = true;
            }
        }
    }