Exemple #1
0
    /// <summary>
    /// Compares completion time, blocked used, and blocks collected for l1 and l2
    /// </summary>
    /// <param name="l1"></param>
    /// <param name="l2"></param>
    /// <param name="compareResult">+1 is returned for each parameter that l2 was better</param>
    /// <returns></returns>
    public static LevelStats GetLowest(LevelStats l1, LevelStats l2, ref LevelStats compareResult)
    {
        LevelStats lsr = l1.Clone() as LevelStats;

        //if l2 was completed faster than l1, make l2 new lowest
        if (l2.Time < lsr.Time)
        {
            lsr.Time           = l2.Time;
            compareResult.Time = 1;
        }
        //if l2 used less blocks than l1, make l2 new lowest
        if (l2.BlocksUsed < lsr.BlocksUsed)
        {
            lsr.BlocksUsed           = l2.BlocksUsed;
            compareResult.BlocksUsed = 1;
        }
        //if l2 collected more blocks than l1, make l2 new highest
        if (l2.BlocksCollected.Collected > lsr.BlocksCollected.Collected)
        {
            lsr.BlocksCollected.Collected           = l2.BlocksCollected.Collected;
            compareResult.BlocksCollected.Collected = 1;
        }

        return(lsr);
    }
Exemple #2
0
    // Use this for initialization
    void Awake()
    {
        LevelStats pb = new LevelStats(12, 100, 30);

        pb.BlocksCollected.Collected = 90;

        LevelStats newpb = pb.Clone() as LevelStats;

        newpb.Time = pb.Time - 1;
        FasterTime(pb, newpb);

        newpb.Time       = pb.Time;
        newpb.BlocksUsed = pb.BlocksUsed - 1;
        LessUsed(pb, newpb);

        newpb.BlocksUsed = pb.BlocksUsed;
        newpb.BlocksCollected.Collected = pb.BlocksCollected.Collected + 1;
        MoreCollected(pb, newpb);

        newpb.Time = pb.Time - 1;
        MoreCollectedLessTime(pb, newpb);

        GlobalManager.Instance.GenerateTestCompletionStats();
        List <Dictionary <string, LevelStats> > ds = Serializer <List <Dictionary <string, LevelStats> > > .Deserialize("LevelStats.bin");

        var statDictionary = GlobalManager.Instance.LevelCompletionStats[0];

        WriteDictionaryRanks(statDictionary);
        GetRankings(newpb, statDictionary);

        newpb.Time = 1;
        newpb.BlocksCollected.Collected = 100;
        newpb.BlocksUsed = 1;

        GetRankings(newpb, statDictionary);

        //LevelRanking pbRanking = pb.GetLevelRanking(GlobalManager.Instance.LevelCompletionStats[LevelNumber]);
    }