Ejemplo n.º 1
0
        /// <summary>
        /// Checks whether a matching entry exists between before the provided <c>insertionIndex</c>.
        /// If the entry exist later, it is moved to this <c>insertionIndex</c>.
        /// If the entry does not exit, it is inserted at <c>insertionIndex</c>.
        /// </summary>
        /// <param name="skill"></param>
        /// <param name="level"></param>
        /// <param name="insertionIndex"></param>
        /// <param name="newEntriesPriority"></param>
        /// <returns>True if the searched entry existed or is already trained; false if an insertion or a move was required.</returns>
        private bool EnsurePrerequisiteExistBefore(StaticSkill skill, int level, int insertionIndex, int newEntriesPriority)
        {
            // Is the wanted level already known by the character ?
            if (m_character.GetSkillLevel(skill) >= level)
            {
                return(true);
            }

            // Is the prerequisite already planned before this very entry ?
            // Then we continue the foreach loop to the next prereq
            int skillIndex = IndexOf(skill, level);

            if (skillIndex != -1 && skillIndex < insertionIndex)
            {
                return(true);
            }


            // The prerequisite is not planned yet, we insert it just before this very entry
            if (skillIndex == -1)
            {
                PlanEntry newEntry = new PlanEntry(this, skill, level);
                newEntry.Type     = PlanEntryType.Prerequisite;
                newEntry.Priority = newEntriesPriority;

                InsertCore(insertionIndex, newEntry);
                return(false);
            }

            // The prerequisite exists but it's located later in the plan
            // So we move it at the insertion index
            MoveCore(skillIndex, insertionIndex);
            return(false);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Resets the scratchpad from the <see cref="ICharacter"/> it was built upon.
        /// </summary>
        private void ResetFromCharacter()
        {
            m_learningFactor = 1.0f;
            m_trainingTime   = TimeSpan.Zero;
            m_trainedSkills.Clear();

            // Initialize attributes-related stuff
            for (int i = 0; i < m_attributes.Length; i++)
            {
                var attrib = m_character[(EveAttribute)i];
                m_attributes[i].Reset(attrib.Base, attrib.ImplantBonus);
            }

            // Initialize skills
            m_totalSP = 0;
            foreach (var skill in StaticSkills.AllSkills)
            {
                int sp    = m_character.GetSkillPoints(skill);
                int level = m_character.GetSkillLevel(skill);

                m_totalSP += sp;
                m_skillSP[skill.ArrayIndex]     = sp;
                m_skillLevels[skill.ArrayIndex] = level;

                // For learning classes, we update attributes.
                switch (skill.LearningClass)
                {
                case LearningClass.Learning:
                    m_learningFactor = 1.0f + 0.02f * level;
                    for (int i = 0; i < m_attributes.Length; i++)
                    {
                        m_attributes[i].Update(m_learningFactor);
                    }
                    break;

                case LearningClass.LowerTierAttribute:
                    m_attributes[(int)skill.AttributeModified].LowerSkillBonus = level;
                    break;

                case LearningClass.UpperTierAttribute:
                    m_attributes[(int)skill.AttributeModified].UpperSkillBonus = level;
                    break;

                default:
                    break;
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Resets the scratchpad from the <see cref="ICharacter"/> it was built upon.
        /// </summary>
        private void ResetFromCharacter()
        {
            m_trainingTime = TimeSpan.Zero;
            m_trainedSkills.Clear();

            // Initialize attributes-related stuff
            for (int i = 0; i < m_attributes.Length; i++)
            {
                var attrib = m_character[(EveAttribute)i];
                m_attributes[i].Reset(attrib.Base, attrib.ImplantBonus);
            }

            // Initialize skills
            m_totalSP = 0;
            foreach (var skill in StaticSkills.AllSkills)
            {
                int sp    = m_character.GetSkillPoints(skill);
                int level = m_character.GetSkillLevel(skill);

                m_totalSP += sp;
                m_skillSP[skill.ArrayIndex]     = sp;
                m_skillLevels[skill.ArrayIndex] = level;
            }
        }