Exemple #1
0
        /// <summary>
        /// Mutates its genes once, and applies penalties if overmutated
        /// </summary>
        public void MutateSelf()
        {
            Dictionary <GeneStat, float> mutationAttempt = new Dictionary <GeneStat, float>();

            foreach (GeneStat stat in currentGenes.Keys)
            {
                //Bulwark mutation is 20%-500% - base is 90%-110%
                mutationAttempt.Add(stat, Stage.instance.sceneDef.baseSceneName == "artifactworld" ?
                                    (float)decimal.Round((decimal)Mathf.Clamp(Random.Range(currentGenes[stat] * 0.2f, currentGenes[stat] * 5.0f), 0.01f, 10.00f), 2) :
                                    (float)decimal.Round((decimal)Mathf.Clamp(Random.Range(currentGenes[stat] * 0.9f, currentGenes[stat] * 1.1f), 0.01f, 10.00f), 2));
            }
            mutationAttempt = CorrectOvermutation(mutationAttempt);
            Dictionary <ItemDef, int> itemsToGive = GeneTokenCalc.GetTokensToAdd(currentGenes, mutationAttempt);

            foreach (KeyValuePair <ItemDef, int> pair in itemsToGive)
            {
                characterBody.inventory.GiveItem(pair.Key, pair.Value);
            }
            currentGenes = mutationAttempt;
#if DEBUG
            GeneticsArtifactPlugin.geneticLogSource.LogInfo(Stage.instance.sceneDef.baseSceneName + " " +
                                                            characterBody.name + " " +
                                                            currentGenes[GeneStat.MaxHealth].ToString() + " " +
                                                            currentGenes[GeneStat.MoveSpeed].ToString() + " " +
                                                            currentGenes[GeneStat.AttackSpeed].ToString() + " " +
                                                            currentGenes[GeneStat.AttackDamage].ToString());
#endif
        }
Exemple #2
0
        private void Awake()
        {
            if (Instance == null)
            {
                Instance = this;
            }
            geneticLogSource   = Instance.Logger;
            geneticAssetBundle = AssetBundle.LoadFromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream("GeneticsArtifact.ArtifactResources.genetics"));

            ArtifactOfGenetics.Init();
            GeneTokens.Init();
            GeneTokenCalc.RegisterHooks();
            GeneEngineDriver.RegisterHooks();
        }