Exemple #1
0
        /// <summary>
        /// Used to apply changes from Welcome packet to existing character.
        /// </summary>
        /// <param name="newGuy">Changes to MainPlayer.ActiveCharacter, contained in a CharacterData object</param>
        /// <param name="copyPaperdoll">Set to true if paperdoll data from newGuy should be applied to this character</param>
        public void ApplyData(CharacterData newGuy, bool copyPaperdoll = true)
        {
            ID             = newGuy.ID;
            Name           = newGuy.Name;
            PaddedGuildTag = newGuy.GuildTag;
            if (copyPaperdoll)
            {
                //only set the doll graphic info in render data - don't change the paperdoll info!
                RenderData.SetBoots(newGuy.Boots);
                RenderData.SetArmor(newGuy.Armor);
                RenderData.SetHat(newGuy.Hat);
                RenderData.SetShield(newGuy.Shield);
                RenderData.SetWeapon(newGuy.Weapon);
            }
            Stats.SetHP(newGuy.HP);
            Stats.SetMaxHP(newGuy.MaxHP);
            Stats.SetTP(newGuy.TP);
            Stats.SetMaxTP(newGuy.MaxTP);

            RenderData.SetDirection(newGuy.Direction);
            RenderData.SetHairStyle(newGuy.HairStyle);
            RenderData.SetHairColor(newGuy.HairColor);
            RenderData.SetGender(newGuy.Gender);
            RenderData.SetRace(newGuy.Race);
            RenderData.SetSitting(newGuy.Sitting);
            RenderData.level = newGuy.Level;
            RenderData.SetWalkFrame(0);
            State      = RenderData.sitting == SitState.Standing ? CharacterActionState.Standing : CharacterActionState.Sitting;
            CurrentMap = newGuy.Map;
            X          = newGuy.X;
            Y          = newGuy.Y;
            //GuildRankNum = newGuy.GuildRankNum; //todo: ???
        }
Exemple #2
0
        public bool EquipItem(ItemType type, short id = 0, short graphic = 0, bool rewrite = false, sbyte subloc = -1)
        {
            switch (type)
            {
            case ItemType.Weapon:
                if (PaperDoll[(int)EquipLocation.Weapon] != 0 && !rewrite)
                {
                    return(false);
                }
                PaperDoll[(int)EquipLocation.Weapon] = id;
                RenderData.SetWeapon(graphic);
                break;

            case ItemType.Shield:
                if (PaperDoll[(int)EquipLocation.Shield] != 0 && !rewrite)
                {
                    return(false);
                }
                PaperDoll[(int)EquipLocation.Shield] = id;
                RenderData.SetShield(graphic);
                break;

            case ItemType.Armor:
                if (PaperDoll[(int)EquipLocation.Armor] != 0 && !rewrite)
                {
                    return(false);
                }
                PaperDoll[(int)EquipLocation.Armor] = id;
                RenderData.SetArmor(graphic);
                break;

            case ItemType.Hat:
                if (PaperDoll[(int)EquipLocation.Hat] != 0 && !rewrite)
                {
                    return(false);
                }
                PaperDoll[(int)EquipLocation.Hat] = id;
                RenderData.SetHat(graphic);
                break;

            case ItemType.Boots:
                if (PaperDoll[(int)EquipLocation.Boots] != 0 && !rewrite)
                {
                    return(false);
                }
                PaperDoll[(int)EquipLocation.Boots] = id;
                RenderData.SetBoots(graphic);
                break;

            case ItemType.Gloves:
                if (PaperDoll[(int)EquipLocation.Gloves] != 0 && !rewrite)
                {
                    return(false);
                }
                PaperDoll[(int)EquipLocation.Gloves] = id;
                break;

            case ItemType.Accessory:
                if (PaperDoll[(int)EquipLocation.Accessory] != 0 && !rewrite)
                {
                    return(false);
                }
                PaperDoll[(int)EquipLocation.Accessory] = id;
                break;

            case ItemType.Belt:
                if (PaperDoll[(int)EquipLocation.Belt] != 0 && !rewrite)
                {
                    return(false);
                }
                PaperDoll[(int)EquipLocation.Belt] = id;
                break;

            case ItemType.Necklace:
                if (PaperDoll[(int)EquipLocation.Necklace] != 0 && !rewrite)
                {
                    return(false);
                }
                PaperDoll[(int)EquipLocation.Necklace] = id;
                break;

            case ItemType.Ring:
                if (subloc != -1)
                {
                    //subloc was explicitly specified
                    if (!rewrite && PaperDoll[(int)EquipLocation.Ring1 + subloc] != 0)
                    {
                        return(false);
                    }
                    PaperDoll[(int)EquipLocation.Ring1 + subloc] = id;
                }
                else
                {
                    if (PaperDoll[(int)EquipLocation.Ring1] != 0 && PaperDoll[(int)EquipLocation.Ring2] != 0 && !rewrite)
                    {
                        return(false);
                    }
                    if (PaperDoll[(int)EquipLocation.Ring1] != 0 && PaperDoll[(int)EquipLocation.Ring2] == 0)
                    {
                        PaperDoll[(int)EquipLocation.Ring2] = id;
                    }
                    else
                    {
                        PaperDoll[(int)EquipLocation.Ring1] = id;
                    }
                }
                break;

            case ItemType.Armlet:
                if (subloc != -1)
                {
                    //subloc was explicitly specified
                    if (!rewrite && PaperDoll[(int)EquipLocation.Armlet1 + subloc] != 0)
                    {
                        return(false);
                    }
                    PaperDoll[(int)EquipLocation.Armlet1 + subloc] = id;
                }
                else
                {
                    if (PaperDoll[(int)EquipLocation.Armlet1] != 0 && PaperDoll[(int)EquipLocation.Armlet2] != 0 && !rewrite)
                    {
                        return(false);
                    }
                    if (PaperDoll[(int)EquipLocation.Armlet1] != 0 && PaperDoll[(int)EquipLocation.Armlet2] == 0)
                    {
                        PaperDoll[(int)EquipLocation.Armlet2] = id;
                    }
                    else
                    {
                        PaperDoll[(int)EquipLocation.Armlet1] = id;
                    }
                }
                break;

            case ItemType.Bracer:
                if (subloc != -1)
                {
                    //subloc was explicitly specified
                    if (!rewrite && PaperDoll[(int)EquipLocation.Bracer1 + subloc] != 0)
                    {
                        return(false);
                    }
                    PaperDoll[(int)EquipLocation.Bracer1 + subloc] = id;
                }
                else
                {
                    if (PaperDoll[(int)EquipLocation.Bracer1] != 0 && PaperDoll[(int)EquipLocation.Bracer2] != 0 && !rewrite)
                    {
                        return(false);
                    }
                    if (PaperDoll[(int)EquipLocation.Bracer1] != 0 && PaperDoll[(int)EquipLocation.Bracer2] == 0)
                    {
                        PaperDoll[(int)EquipLocation.Bracer2] = id;
                    }
                    else
                    {
                        PaperDoll[(int)EquipLocation.Bracer1] = id;
                    }
                }
                break;

            default:
                throw new ArgumentOutOfRangeException("type", "Invalid item type for equip!");
            }

            return(true);
        }