コード例 #1
0
ファイル: CharacterSave.cs プロジェクト: Nyarlygames/Plug
 public void GainXPActivity(ActivityStruct activity)
 {
     last       += activity.xpUp;
     xp         += activity.xpUp;
     xpactivity += activity.xpUp;
     if (last >= next)
     {
         last -= next;
         if (age.years < RF.exp_baby_range)
         {
             next *= RF.ratio_growth;
             levelUpXP("growing");
         }
         else if (age.years < RF.exp_teen_range)
         {
             next *= RF.ratio_training;
             levelUpXP("training");
         }
         else if (age.years < RF.exp_adult_range)
         {
             next *= RF.ratio_mastering;
             levelUpXP("mastering");
         }
         else if (age.years >= RF.exp_senior_range)
         {
         }
     }
 }
コード例 #2
0
ファイル: CharacterSave.cs プロジェクト: Nyarlygames/Plug
 public void GainActivityXP(ActivityStruct activity)
 {
     activity.xp += activity.xpUp;
     if (activity.xpCurrent + activity.xpUp >= activity.nextLevel)
     {
         activity.xpCurrent = activity.nextLevel - (activity.xpCurrent + activity.xpUp);
         levelUpActivity(activity);
     }
     else
     {
         activity.xpCurrent += activity.xpUp;
     }
 }
コード例 #3
0
ファイル: CharacterSave.cs プロジェクト: Nyarlygames/Plug
    public void GainActivitySimulated()
    {
        if (available == true)
        {
            // simulate primary
            int pickedAct   = UnityEngine.Random.Range(0, activities.FindAll(act => ((act.status == true) && (act.primaryActivity == true))).Count);
            int successRate = UnityEngine.Random.Range(0, RF.simulate_activity_successmax);

            if (successRate <= RF.simulate_activity_successmin)
            {
                ActivityStruct primaryPick = activities.FindAll(act => ((act.status == true) && (act.primaryActivity == true)))[pickedAct];
                if (activity_history.ContainsKey(primaryPick.name))
                {
                    activity_history[primaryPick.name] += 1;
                }
                else
                {
                    activity_history.Add(primaryPick.name, 1);
                }
                GainActivityXP(primaryPick);
                GainXPActivity(primaryPick);
            }
            SetActivityLocks();
            // simulate secondary
            int pickedActSecondary   = UnityEngine.Random.Range(0, activities.FindAll(act => ((act.status == true) && (act.primaryActivity == false))).Count);
            int successRateSecondary = UnityEngine.Random.Range(0, RF.simulate_activity_secondary_successmax);

            if (successRate <= RF.simulate_activity_secondary_successmin)
            {
                ActivityStruct secondaryPick = activities.FindAll(act => ((act.status == true) && (act.primaryActivity == false)))[pickedAct];
                if (activity_history.ContainsKey(secondaryPick.name))
                {
                    activity_history[secondaryPick.name] += 1;
                }
                else
                {
                    activity_history.Add(secondaryPick.name, 1);
                }
                GainActivityXP(secondaryPick);
                GainXPActivity(secondaryPick);
            }
            SetActivityLocks();
        }
    }
コード例 #4
0
ファイル: CharacterSave.cs プロジェクト: Nyarlygames/Plug
    public void levelUpXP(string rank)
    {
        // IDictionary<string, int> Attributes = abilities.abilities;
        List <string> Attributes = new List <String>();

        Attributes.Add("strength");
        Attributes.Add("endu");
        Attributes.Add("body");
        Attributes.Add("speed");
        Attributes.Add("dexte");
        Attributes.Add("percept");
        Attributes.Add("accu");
        Attributes.Add("autonomy");
        Attributes.Add("spirit");
        Attributes.Add("social");
        Attributes.Add("mental");
        Attributes.Add("lang");
        int addedPoints = 0;
        int addedChars  = 0;

        switch (rank)
        {
        case "growing":
            addedChars = UnityEngine.Random.Range(RF.growing_stats_min, RF.growing_stats_max + 1);
            for (int i = 0; i < addedChars; i++)
            {
                addedPoints = UnityEngine.Random.Range(RF.growing_point_min, RF.growing_point_max + 1);
                int pickStat = UnityEngine.Random.Range(0, Attributes.Count);
                abilities.abilities[Attributes[pickStat]] += addedPoints;
                Attributes.RemoveAt(pickStat);
            }
            break;

        case "training":
            addedChars = UnityEngine.Random.Range(RF.training_stats_min, RF.training_stats_max + 1);
            for (int i = 0; i < addedChars; i++)
            {
                addedPoints = UnityEngine.Random.Range(RF.training_point_min, RF.training_point_max + 1);
                int pickStat = UnityEngine.Random.Range(0, Attributes.Count);
                abilities.abilities[Attributes[pickStat]] += addedPoints;
                Attributes.RemoveAt(pickStat);
            }
            break;

        case "mastering":
            addedChars = UnityEngine.Random.Range(RF.mastering_stats_min, RF.mastering_stats_max + 1);
            int minmainact = -1;
            int minsecact  = -1;
            foreach (KeyValuePair <string, int> act in activity_history)
            {
                if ((activities.Find(actrank => actrank.name == act.Key).primaryActivity == true) && (activity_history[act.Key] >= minmainact))
                {
                    minmainact   = activity_history[act.Key];
                    mainActivity = activities.Find(actrank => actrank.name == act.Key);
                }
                if ((activities.Find(actrank => actrank.name == act.Key).primaryActivity == false) && (activity_history[act.Key] >= minsecact))
                {
                    minsecact    = activity_history[act.Key];
                    mainActivity = activities.Find(actrank => actrank.name == act.Key);
                }
            }
            activity_history = new Dictionary <string, int>();
            if (mainActivity.name != "")
            {
                foreach (KeyValuePair <string, int> entry in mainActivity.affinities)
                {
                    abilities.affinities[mainActivity.name] += 1;
                    abilities.abilities[entry.Key]          += entry.Value;
                    abilities.abilities_history[Attributes.IndexOf(entry.Key)][entry.Key][mainActivity.name] += 1;
                }
            }

            if (secondaryActivity.name != "")
            {
                int increaseSecondary = addedChars - mainActivity.affinities.Count;
                foreach (KeyValuePair <string, int> entry in secondaryActivity.affinities)
                {
                    abilities.affinities[secondaryActivity.name] += 1;
                    abilities.abilities[entry.Key] += entry.Value;
                    abilities.abilities_history[Attributes.IndexOf(entry.Key)][entry.Key][secondaryActivity.name] += 1;
                }
            }

            attributesToSpend += 2;
            skillsToSpend++;
            break;

        default:
            // should not happen
            break;
        }
        level++;
    }
コード例 #5
0
ファイル: CharacterSave.cs プロジェクト: Nyarlygames/Plug
 public void levelUpActivity(ActivityStruct activity)
 {
     activity.level++;
     activity.nextLevel *= activity.ratiolvl;
     activity.xpUp      += activity.ratiogain;
 }
コード例 #6
0
ファイル: CharacterSave.cs プロジェクト: Nyarlygames/Plug
    public void SetActivitiesList()
    {
        ActivityStruct temp = new ActivityStruct();

        temp.name            = "gather";
        temp.status          = true;
        temp.statusPexHigh   = false;
        temp.xpUp            = RF.exp_gatherer_basegain;
        temp.nextLevel       = RF.exp_gatherer_baselvl;
        temp.ratiogain       = RF.exp_gatherer_ratiogain;
        temp.ratiolvl        = RF.exp_gatherer_ratiolvl;
        temp.primaryActivity = true;
        temp.affinities.Add("endu", 2);
        temp.affinities.Add("percept", 1);
        temp.affinities.Add("autonomy", 1);
        activities.Add(temp);
        temp               = new ActivityStruct();
        temp.name          = "fish";
        temp.status        = true;
        temp.statusPexHigh = false;
        temp.xpUp          = RF.exp_fisher_basegain;
        temp.nextLevel     = RF.exp_fisher_baselvl;
        temp.ratiogain     = RF.exp_fisher_ratiogain;
        temp.ratiolvl      = RF.exp_fisher_ratiolvl;
        temp.affinities.Add("dexte", 2);
        temp.affinities.Add("strength", 1);
        temp.affinities.Add("autonomy", 1);
        temp.primaryActivity = true;
        activities.Add(temp);
        temp                 = new ActivityStruct();
        temp.name            = "hunt";
        temp.status          = true;
        temp.statusPexHigh   = false;
        temp.xpUp            = RF.exp_hunter_basegain;
        temp.nextLevel       = RF.exp_hunter_baselvl;
        temp.ratiogain       = RF.exp_hunter_ratiogain;
        temp.ratiolvl        = RF.exp_hunter_ratiolvl;
        temp.primaryActivity = true;
        temp.affinities.Add("endu", 3);
        temp.affinities.Add("percept", 2);
        temp.affinities.Add("accu", 1);
        temp.affinities.Add("strength", 1);
        temp.affinities.Add("autonomy", 1);
        activities.Add(temp);
        temp                 = new ActivityStruct();
        temp.name            = "source";
        temp.status          = false;
        temp.statusPexHigh   = false;
        temp.xpUp            = RF.exp_sourcer_basegain;
        temp.nextLevel       = RF.exp_sourcer_baselvl;
        temp.ratiogain       = RF.exp_sourcer_ratiogain;
        temp.ratiolvl        = RF.exp_sourcer_ratiolvl;
        temp.primaryActivity = true;
        temp.affinities.Add("percept", 3);
        temp.affinities.Add("endu", 1);
        temp.affinities.Add("autonomy", 1);
        activities.Add(temp);
        temp               = new ActivityStruct();
        temp.name          = "cook";
        temp.status        = true;
        temp.statusPexHigh = false;
        temp.xpUp          = RF.exp_cook_basegain;
        temp.nextLevel     = RF.exp_cook_baselvl;
        temp.ratiogain     = RF.exp_cook_ratiogain;
        temp.ratiolvl      = RF.exp_cook_ratiolvl;
        temp.affinities.Add("social", 2);
        temp.affinities.Add("spirit", 1);
        temp.affinities.Add("dexte", 1);
        activities.Add(temp);
        temp               = new ActivityStruct();
        temp.name          = "manage";
        temp.status        = true;
        temp.statusPexHigh = true;
        temp.xpUp          = RF.exp_manager_basegain;
        temp.nextLevel     = RF.exp_manager_baselvl;
        temp.ratiogain     = RF.exp_manager_ratiogain;
        temp.ratiolvl      = RF.exp_manager_ratiolvl;
        temp.affinities.Add("social", 2);
        temp.affinities.Add("lang", 2);
        activities.Add(temp);
        temp               = new ActivityStruct();
        temp.name          = "mentor";
        temp.status        = true;
        temp.statusPexHigh = true; // to remove if pre-requesite, and add elsewhere
        temp.xpUp          = RF.exp_mentor_basegain;
        temp.nextLevel     = RF.exp_mentor_baselvl;
        temp.ratiogain     = RF.exp_mentor_ratiogain;
        temp.ratiolvl      = RF.exp_mentor_ratiolvl;
        temp.affinities.Add("mental", 2);
        temp.affinities.Add("social", 2);
        temp.affinities.Add("endu", 1);
        activities.Add(temp);
        temp               = new ActivityStruct();
        temp.name          = "sage";
        temp.status        = false;
        temp.statusPexHigh = true; // to remove if pre-requesite, and add elsewhere
        temp.xpUp          = RF.exp_sage_basegain;
        temp.nextLevel     = RF.exp_sage_baselvl;
        temp.ratiogain     = RF.exp_sage_ratiogain;
        temp.ratiolvl      = RF.exp_sage_ratiolvl;
        temp.affinities.Add("spirit", 2);
        temp.affinities.Add("social", 2);
        temp.affinities.Add("lang", 1);
        activities.Add(temp);
        temp               = new ActivityStruct();
        temp.name          = "shaman";
        temp.status        = true;
        temp.statusPexHigh = true; // to remove if pre-requesite, and add elsewhere
        temp.xpUp          = RF.exp_shaman_basegain;
        temp.nextLevel     = RF.exp_shaman_baselvl;
        temp.ratiogain     = RF.exp_shaman_ratiogain;
        temp.ratiolvl      = RF.exp_shaman_ratiolvl;
        temp.affinities.Add("spirit", 3);
        temp.affinities.Add("lang", 2);
        temp.affinities.Add("mental", 2);
        temp.affinities.Add("dexte", 1);
        activities.Add(temp);
        temp               = new ActivityStruct();
        temp.name          = "skincraft";
        temp.status        = true;
        temp.statusPexHigh = true; // to remove if pre-requesite, and add elsewhere
        temp.xpUp          = RF.exp_skincraft_basegain;
        temp.nextLevel     = RF.exp_skincraft_baselvl;
        temp.ratiogain     = RF.exp_skincraft_ratiogain;
        temp.ratiolvl      = RF.exp_skincraft_ratiolvl;
        temp.affinities.Add("dexte", 2);
        temp.affinities.Add("accu", 1);
        temp.affinities.Add("spirit", 1);
        activities.Add(temp);
        temp               = new ActivityStruct();
        temp.name          = "woodcraft";
        temp.status        = true;
        temp.statusPexHigh = true; // to remove if pre-requesite, and add elsewhere
        temp.xpUp          = RF.exp_woodcraft_basegain;
        temp.nextLevel     = RF.exp_woodcraft_baselvl;
        temp.ratiogain     = RF.exp_woodcraft_ratiogain;
        temp.ratiolvl      = RF.exp_woodcraft_ratiolvl;
        temp.affinities.Add("dexte", 2);
        temp.affinities.Add("accu", 1);
        temp.affinities.Add("spirit", 1);
        activities.Add(temp);
        temp               = new ActivityStruct();
        temp.name          = "stonecraft";
        temp.status        = true;
        temp.statusPexHigh = true; // to remove if pre-requesite, and add elsewhere
        temp.xpUp          = RF.exp_stonecraft_basegain;
        temp.nextLevel     = RF.exp_stonecraft_baselvl;
        temp.ratiogain     = RF.exp_stonecraft_ratiogain;
        temp.ratiolvl      = RF.exp_stonecraft_ratiolvl;
        temp.affinities.Add("dexte", 2);
        temp.affinities.Add("accu", 1);
        temp.affinities.Add("spirit", 1);
        activities.Add(temp);
        temp               = new ActivityStruct();
        temp.name          = "protect";
        temp.status        = true;
        temp.statusPexHigh = true; // to remove if pre-requesite, and add elsewhere
        temp.xpUp          = RF.exp_protector_basegain;
        temp.nextLevel     = RF.exp_protector_baselvl;
        temp.ratiogain     = RF.exp_protector_ratiogain;
        temp.ratiolvl      = RF.exp_protector_ratiolvl;
        temp.affinities.Add("body", 2);
        temp.affinities.Add("strength", 1);
        temp.affinities.Add("dexte", 1);
        temp.affinities.Add("accu", 1);
        temp.primaryActivity = true;
        activities.Add(temp);
        temp               = new ActivityStruct();
        temp.name          = "lead";
        temp.status        = true;
        temp.statusPexHigh = true; // to remove if pre-requesite, and add elsewhere
        temp.xpUp          = RF.exp_leader_basegain;
        temp.nextLevel     = RF.exp_leader_baselvl;
        temp.ratiogain     = RF.exp_leader_ratiogain;
        temp.ratiolvl      = RF.exp_leader_ratiolvl;
        temp.affinities.Add("social", 2);
        temp.affinities.Add("strength", 2);
        temp.affinities.Add("endu", 2);
        temp.affinities.Add("lang", 2);
        temp.affinities.Add("spirit", 1);
        temp.primaryActivity = true;
        activities.Add(temp);
        temp               = new ActivityStruct();
        temp.name          = "scout";
        temp.status        = true;
        temp.statusPexHigh = true; // to remove if pre-requesite, and add elsewhere
        temp.xpUp          = RF.exp_scout_basegain;
        temp.nextLevel     = RF.exp_scout_baselvl;
        temp.ratiogain     = RF.exp_scout_ratiogain;
        temp.ratiolvl      = RF.exp_scout_ratiolvl;
        temp.affinities.Add("percept", 2);
        temp.affinities.Add("autonomy", 1);
        temp.primaryActivity = true;
        activities.Add(temp);
        temp               = new ActivityStruct();
        temp.name          = "rest";
        temp.status        = false;
        temp.statusPexHigh = false; // to remove if pre-requesite, and add elsewhere
        temp.affinities.Add("body", 1);
        activities.Add(temp);
        temp               = new ActivityStruct();
        temp.name          = "pregnant";
        temp.status        = false;
        temp.statusPexHigh = false; // to remove if pre-requesite, and add elsewhere
        temp.affinities.Add("body", 2);
        temp.affinities.Add("mental", 2);
        temp.xpUp = RF.exp_pregnant_basegain;
        activities.Add(temp);
    }