コード例 #1
0
    public float CalculateSideDropPercent()
    {
        float result = 0, total = 0;

        foreach (GameObject testingUnit in finishedUnits)
        {
            SideDetectionController detector = testingUnit.GetComponentInChildren <SideDetectionController>();
            result += detector.getSideCount();
            total  += detector.getTopCount() + detector.getSideCount() + detector.getBottomCount();
        }
        //print("checking result and total: " + result.ToString() + "   " + total.ToString());
        //print("checking result/total: " + (result / total).ToString());
        return(result / total);
    }
コード例 #2
0
    void SumAndPrint()
    {
        int topSum = 0, bottomSum = 0, sideSum = 0;

        foreach (GameObject testingUnit in finishedUnits)
        {
            //print(string.Format("Summing for unit {0}", testingUnit.name));
            SideDetectionController detector = testingUnit.GetComponentInChildren <SideDetectionController>();
            topSum    += detector.getTopCount();
            bottomSum += detector.getBottomCount();
            sideSum   += detector.getSideCount();
        }
        print(string.Format("Top: {0},   Bottom: {1},   Side: {2}", topSum, bottomSum, sideSum));
    }