Exemplo n.º 1
0
        /// <summary>
        /// Constructor of the Character class
        /// </summary>
        /// <param name="gm">The game manager</param>
        /// <param name="pgClass">The class of the pg you want to create</param>
        /// <param name="Name">The name of the pg. Leave to null to enerate it</param>
        public Character(GameManager gm, PGClasses pgClass, string Name = null)
        {
            this.manager = gm;
            CharacterClass classToAssign;

            GeneralData.CharacterClasses.TryGetValue(pgClass, out classToAssign);
            if (classToAssign == null)
            {
                Console.WriteLine("ERROR Creating character " + Name + " with class " + pgClass.ToString() + ": PGClass not found in General Data.");
                return;
            }
            ApplyClass(classToAssign);
            this.Class = pgClass;
            if (Name == null)
            {
                Name = gm.GenerateName();
            }
            this.Name = Name;

            //Set the first level parameters
            LevelImprovement level = LevelImprovements.ElementAt(0);

            this.Energy  += level.EnergyIncrement;
            this.HP      += level.HPIIncrement;
            this.Attack  += level.AttackIncrement;
            this.Defense += level.DefenseIncrement;
            this.Talent  += level.TalentIncrement;
            this.Damage  += level.DamageIncrement;

            Console.WriteLine("Creating new character " + Name + " with class " + pgClass.ToString());
        }
Exemplo n.º 2
0
 /// <summary>
 /// Add experience to the PG. It will level up if enough!
 /// </summary>
 /// <param name="exp">The amount to experience to add.</param>
 public void AddExp(int exp)
 {
     Experience += exp;
     while (Level < LevelImprovements.Count - 1 && Experience >= LevelImprovements.ElementAt(Level + 1).ExperienceNeeded)
     {
         LevelImprovement nextLevel = LevelImprovements.ElementAt(Level + 1);
         ApplyLevelImprovements(nextLevel);
         Level++;
         Console.WriteLine("Character " + Name + " " + Class.ToString() + " has reached level " + (Level + 1) + "!");
     }
 }