Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SkillsForm"/> class.
        /// </summary>
        /// <param name="cooldownManager">The skill cooldown manager.</param>
        /// <param name="position">The position.</param>
        /// <param name="parent">The parent.</param>
        /// <param name="knownSkills">The known skills.</param>
        /// <exception cref="ArgumentNullException"><paramref name="knownSkills" /> is <c>null</c>.</exception>
        public SkillsForm(ISkillCooldownManager cooldownManager, Vector2 position, Control parent,
                          KnownSkillsCollection knownSkills) : base(parent, position, new Vector2(32, 32))
        {
            if (knownSkills == null)
                throw new ArgumentNullException("knownSkills");

            _knownSkills = knownSkills;

            IsVisible = false;

            _cooldownManager = cooldownManager;

            var fontLineSpacing = Font.GetLineSpacing();

            // Find the spacing to use between lines
            _lineSpacing = (int)Math.Max(fontLineSpacing, _iconSize.Y);

            // Create all the skills
            var offset = Vector2.Zero;
            foreach (var skillType in EnumHelper<SkillType>.Values)
            {
                CreateSkillEntry(offset, skillType);
                offset += new Vector2(0, _lineSpacing);
            }
        }
Beispiel #2
0
        void LoadFromQueryValues(ICharacterTable v)
        {
            Name = v.Name;
            _id = v.ID;
            _templateID = v.CharacterTemplateID;
            MoveSpeed = v.MoveSpeed;

            BodyInfo = BodyInfoManager.Instance.GetBody(v.BodyID);

            Teleport(new Vector2(v.LoadX, v.LoadY));
            Resize(BodyInfo.Size);

            ((PersistentCharacterStatusEffects)StatusEffects).Load();

            // Set the character information
            _level = v.Level;
            _exp = v.Exp;
            _cash = v.Cash;
            _hp = v.HP;
            _mp = v.MP;
            RespawnMapID = v.RespawnMapID;
            RespawnPosition = new Vector2(v.RespawnX, v.RespawnY);
            StatPoints = v.StatPoints;

            _knownSkills = new KnownSkillsCollection(this);

            // Create the AI
            if (v.AIID.HasValue)
            {
                if (!SetAI(v.AIID.Value))
                {
                    const string errmsg = "Failed to set Character `{0}`'s AI to ID `{1}`.";
                    if (log.IsErrorEnabled)
                        log.ErrorFormat(errmsg, this, v.AIID.Value);
                    Debug.Fail(string.Format(errmsg, this, v.AIID.Value));
                    RemoveAI();
                }
            }

            // Load the stats
            BaseStats.CopyValuesFrom(v.Stats);

            // Load the Character's items
            Inventory.Load();
            Equipped.Load();

            // Update the mod stats
            UpdateModStats();

            // Additional loading
            HandleAdditionalLoading(v);

            // Set the map
            var m = World.GetMap(v.LoadMapID);
            if (m != null)
                Teleport(m, Position);
            else
                ((IRespawnable)this).Respawn();

            // Mark the Character as loaded
            SetAsLoaded();

            if (log.IsInfoEnabled)
                log.InfoFormat("Loaded Character `{0}`.", Name);
        }
Beispiel #3
0
            public SkillPictureBox(SkillsForm parent, SkillInfo<SkillType> skillInfo, Vector2 position)
                : base(parent, position, _iconSize)
            {
                _knownSkills = parent.KnownSkills;

                SkillInfo = skillInfo;
                Sprite = new Grh(GrhInfo.GetData(SkillInfo.Icon));
                _cooldownManager = parent.CooldownManager;
            }
Beispiel #4
0
        protected void Load(CharacterTemplate template)
        {
            var v = template.TemplateTable;

            Name = v.Name;
            Alliance = _allianceManager[v.AllianceID];
            BodyInfo = BodyInfoManager.Instance.GetBody(v.BodyID);
            CharacterTemplateID = v.ID;
            Resize(BodyInfo.Size);

            _level = v.Level;
            MoveSpeed = v.MoveSpeed;
            _exp = v.Exp;
            _statPoints = v.StatPoints;

            // Create the AI
            if (v.AIID.HasValue)
            {
                if (!SetAI(v.AIID.Value))
                {
                    const string errmsg = "Failed to set Character `{0}`'s AI to ID `{1}`.";
                    if (log.IsErrorEnabled)
                        log.ErrorFormat(errmsg, this, v.AIID.Value);
                    Debug.Fail(string.Format(errmsg, this, v.AIID.Value));
                    RemoveAI();
                }
            }

            // Set the base stats
            BaseStats.CopyValuesFrom(v.Stats);

            // Set known skills
            if (_knownSkills == null)
                _knownSkills = new KnownSkillsCollection(this);

            KnownSkills.SetValues(template.KnownSkills);
        }