fBaseXtensions.Stats.TrackedProfile.UpdateRangeVariables C# (CSharp) Method

UpdateRangeVariables() public method

Adds to the total values using Starting Values and Right Now Values
public UpdateRangeVariables ( ) : void
return void
        public void UpdateRangeVariables()
        {
            TotalTimeSpan = TotalTimeSpan.Add(DateTime.Now.Subtract(DateStartedProfile));
            //TotalXP += (FunkyGame.Hero.CurrentExp - StartingXP);
            //TotalGold += (FunkyGame.Hero.Coinage - StartingGold);
        }

Usage Example

Exemplo n.º 1
0
        public void ProfileChanged(string sThisProfile)
        {
            //fresh profile?
            if (Profiles.Count == 0)
            {
                //Lets create a new profile
                Profiles.Add(new TrackedProfile(sThisProfile));

                //Reference it to the Collection
                currentprofile = Profiles[Profiles.Count - 1];
            }

            //Did we really change profiles?
            if (Profiles.Count > 0 && currentprofile.ProfileName != sThisProfile)
            {
                //Refresh Profile Target Blacklist
                FunkyGame.Profile.UpdateProfileBlacklist();

                //Set the "end" date for current profile
                currentprofile.UpdateRangeVariables();



                bool foundPreviousEntry = false;
                foreach (TrackedProfile item in Profiles)
                {
                    //Found the profile so lets use that instead!
                    if (item.ProfileName == sThisProfile)
                    {
                        foundPreviousEntry = true;
                        item.RestartRangeVariables();//reset Starting variables

                        //Reference it to the Collection
                        currentprofile = item;
                        break;
                    }
                }


                //Profile was not found.. so lets add it and set it as current.
                if (!foundPreviousEntry)
                {
                    //Lets create a new profile
                    Profiles.Add(new TrackedProfile(sThisProfile));
                    //Reference it to the Collection
                    currentprofile = Profiles[Profiles.Count - 1];
                }
                else
                {//Reorder the profiles!
                    int previousProfileIndex = Profiles.IndexOf(currentprofile);

                    //Copy profiles
                    TrackedProfile[] clone_profiles = new TrackedProfile[Profiles.Count];
                    Profiles.CopyTo(clone_profiles, 0);

                    //Reorder..
                    for (int i = previousProfileIndex; i < Profiles.Count - 1; i++)
                    {
                        Profiles[i] = clone_profiles[i + 1];
                    }

                    //Finally Set the last profile to current!
                    Profiles[Profiles.Count - 1] = currentprofile;
                }

                WriteProfileTrackerOutput(ref FunkyGame.CurrentStats);
            }
        }