Example #1
0
            public Frame(WzObject src)
            {
                var shift = (((WzVectorProperty)src["face"]["map"]["brow"]).Pos());

                Tex   = new TextureD(src["Face"]).Shift(-shift);
                delay = (short)(((WzIntProperty)src["delay"])?.Value ?? 0);
                if (delay == 0)
                {
                    delay = 2500;
                }
            }
Example #2
0
        public Hair(int hairId, BodyDrawInfo drawInfo)
        {
            _stances = new Dictionary <Stance.Id, Dictionary <Layer, Dictionary <short, TextureD> > >();
            var hairNode = (WzImage)Wz.Character["hair"][$"000{hairId}.img"];

            foreach (var keyValuePair in Stance.Names)
            {
                var stanceName = keyValuePair.Value;
                var stance     = keyValuePair.Key;
                var stanceNode = hairNode[stanceName];
                if (stanceNode == null)
                {
                    continue;
                }
                for (short frame = 0; frame < stanceNode.WzProperties.Count; frame++)
                {
                    var frameNode = stanceNode.WzProperties[frame];
                    foreach (var layerNode0 in frameNode.WzProperties)
                    {
                        var layerNode = layerNode0.GetByUol();
                        var layerName = layerNode.Name;
                        if (!LayersByName.ContainsKey(layerName))
                        {
                            continue;
                        }
                        var layer = (Layer)LayersByName[layerName];
                        if (layerName.Equals("hairShade"))
                        {
                            layerNode = layerNode["0"];
                        }
                        var brow  = ((WzVectorProperty)layerNode["map"]["brow"]).Pos();
                        var shift = drawInfo.GetHairPosition(stance, frame) - brow;
                        if (!_stances.ContainsKey(stance))
                        {
                            _stances[stance] = new Dictionary <Layer, Dictionary <short, TextureD> >();
                        }
                        if (!_stances[stance].ContainsKey(layer))
                        {
                            _stances[stance][layer] = new Dictionary <short, TextureD>();
                        }
                        _stances[stance][layer][frame] = new TextureD(layerNode).Shift(shift);
                    }
                }
            }

            name = (string)Wz.String["Eqp.img"]["Eqp"]["Hair"][$"{hairId}"]["name"].WzValue;
            var args = new[] { "黑色", "红色", "橘黄色", "金色", "绿色", "蓝色", "紫罗兰色", "棕色" };

            color = hairId % 10 < args.Length ? args[hairId % 10] : "";
        }
Example #3
0
        public Clothing(int id, BodyDrawInfo drawInfo)
        {
            _stances = new Dictionary <Stance.Id, Dictionary <Layer, Dictionary <Short, TextureD> > >();
            ItemId   = id;
            var equipData = GameUtil.GetEquipData(ItemId);

            EqSlot    = equipData.EqSlot;
            TwoHanded = EqSlot == EquipSlot.Id.Weapon && new WeaponData(ItemId).TwoHanded;
            const int noneWeaponTypes = 15;
            const int weaponOffset    = noneWeaponTypes + 15;
            const int weaponTypes     = 20;
            var       index           = (ItemId / 10000) - 100;
            Layer     chLayer;

            if (index < noneWeaponTypes)
            {
                chLayer = _layers[index];
            }
            else if (index >= weaponOffset && index < weaponOffset + weaponTypes)
            {
                chLayer = Layer.Weapon;
            }
            else
            {
                chLayer = Layer.Cape;
            }
            var strId    = $"0{ItemId}";
            var category = equipData.ItemData.category;
            var src      = (WzImage)Wz.Character[category][$"{strId}.img"];
            var info     = (WzSubProperty)src["info"];

            VsLot = info.GetString("vslot");
            switch ((int)info["stand"])
            {
            case 1:
                Stand = Stance.Id.Stand1;
                break;

            case 2:
                Stand = Stance.Id.Stand2;
                break;

            default:
                Stand = TwoHanded ? Stance.Id.Stand2 : Stance.Id.Stand1;
                break;
            }

            switch ((int)info["walk"])
            {
            case 1:
                Walk = Stance.Id.Walk1;
                break;

            case 2:
                Walk = Stance.Id.Walk2;
                break;

            default:
                Walk = TwoHanded ? Stance.Id.Walk2 : Stance.Id.Walk1;
                break;
            }

            foreach (var iter in Stance.Names)
            {
                var stanceName = iter.Value;
                var stance     = iter.Key;
                var stanceNode = src[stanceName];
                if (stanceNode == null)
                {
                    continue;
                }
                for (short frame = 0; frame < stanceNode.WzProperties.Count; frame++)
                {
                    var frameNode = (WzSubProperty)stanceNode[$"{frame}"].GetByUol();
                    foreach (var partNode0 in frameNode.WzProperties)
                    {
                        if (partNode0.GetByUol() is WzCanvasProperty)
                        {
                            var partNode = (WzCanvasProperty)partNode0.GetByUol();
                            var part     = partNode.Name;
                            var z        = chLayer;
                            var zs       = partNode.GetString("z");
                            if (part.Equals("mailArm"))
                            {
                                z = Layer.MailArm;
                            }
                            else
                            {
                                if (SubLayerNames.ContainsKey(zs))
                                {
                                    z = SubLayerNames[zs];
                                }
                            }

                            var parent    = "";
                            var parentPos = new Vector2();
                            foreach (var mapNode0 in partNode["map"].WzProperties)
                            {
                                var mapNode = mapNode0.GetByUol();
                                if (mapNode is WzVectorProperty)
                                {
                                    parent    = mapNode.Name;
                                    parentPos = ((WzVectorProperty)mapNode).Pos();
                                }
                            }

                            var shift = new Vector2();
                            switch (EqSlot)
                            {
                            case EquipSlot.Id.Face:
                                shift -= parentPos;
                                break;

                            case EquipSlot.Id.Shoes:
                            case EquipSlot.Id.Gloves:
                            case EquipSlot.Id.Top:
                            case EquipSlot.Id.Bottom:
                            case EquipSlot.Id.Cape:
                                shift = drawInfo.GetBodyPosition(stance, frame) - parentPos;
                                break;

                            case EquipSlot.Id.Hat:
                            case EquipSlot.Id.EarAcc:
                            case EquipSlot.Id.EyeAcc:
                                shift = drawInfo.GetFacePosition(stance, frame) - parentPos;
                                break;

                            case EquipSlot.Id.Shield:
                            case EquipSlot.Id.Weapon:
                                if (parent.Equals("handMove"))
                                {
                                    shift += drawInfo.GetHeadPosition(stance, frame);
                                }
                                else if (parent.Equals("hand"))
                                {
                                    shift += drawInfo.GetArmPosition(stance, frame);
                                }
                                else if (parent.Equals("navel"))
                                {
                                    shift += drawInfo.GetBodyPosition(stance, frame);
                                }
                                shift -= parentPos;
                                break;
                            }

                            if (!_stances.ContainsKey(stance))
                            {
                                _stances[stance] = new Dictionary <Layer, Dictionary <Short, TextureD> >();
                            }
                            if (!_stances[stance].ContainsKey(z))
                            {
                                _stances[stance][z] = new Dictionary <Short, TextureD>();
                            }
                            _stances[stance][z][new Short(frame)] = new TextureD(partNode).Shift(shift);
                        }
                    }
                }
            }

            var transParents = new HashSet <int>()
            {
                1002186
            };

            TransParent = transParents.Contains(ItemId);
        }
Example #4
0
        public ItemData(int id)
        {
            _icons     = new Dictionary <bool, TextureD>();
            itemId     = id;
            unTradAble = false;
            unique     = false;
            unSellAble = false;
            cashItem   = false;
            WzObject src = null, strSrc = null;
            var      strPrefix = $"0{GetItemPrefix(itemId)}";
            var      strId     = $"0{itemId}";
            var      prefix    = GetPrefix(itemId);

            switch (prefix)
            {
            case 1:
                category = GetEqCategory(itemId);
                src      = Wz.Character[category][$"{strId}.img"]["info"];
                strSrc   = Wz.String["Eqp.img"]["Eqp"][category][$"{itemId}"];
                break;

            case 2:
                category = "Consume";
                src      = Wz.Item[category][$"{strPrefix}.img"][strId]["info"];
                strSrc   = Wz.String[$"{category}.img"][$"{itemId}"];
                break;

            case 3:
                category = "Install";
                src      = Wz.Item[category][$"{strPrefix}.img"][strId]["info"];
                strSrc   = Wz.String[$"{category}.img"][$"{itemId}"];
                break;

            case 4:
                category = "Etc";
                src      = Wz.Item[category][$"{strPrefix}.img"][strId]["info"];
                strSrc   = Wz.String[$"{category}.img"][$"{itemId}"];
                break;

            case 5:
                category = "Cash";
                src      = Wz.Item[category][$"{strPrefix}.img"][strId]["info"];
                strSrc   = Wz.String[$"{category}.img"][$"{itemId}"];
                break;
            }

            if (src != null)
            {
                _icons[false] = new TextureD(src["icon"]);
                _icons[true]  = new TextureD(src["iconRaw"]);
                price         = ((WzIntProperty)src["price"])?.Value ?? 0;
                unTradAble    = ((WzIntProperty)src["tradeBlock"])?.Value == 1;
                unique        = ((WzIntProperty)src["only"])?.Value == 1;
                unSellAble    = ((WzIntProperty)src["notSale"])?.Value == 1;
                cashItem      = ((WzIntProperty)src["cash"])?.Value == 1;
                gender        = GetItemGender(itemId);
                name          = ((WzStringProperty)strSrc["name"]).Value;
                desc          = ((WzStringProperty)strSrc["desc"])?.Value;
                valid         = true;
            }
            else
            {
                valid = false;
            }
        }
Example #5
0
        public Body(int skin, BodyDrawInfo drawInfo)
        {
            _stances = new Dictionary <Stance.Id, Dictionary <Layer, Dictionary <short, TextureD> > >();
            var strId    = skin.ToString().PadLeft(2, '0');
            var bodyNode = (WzImage)Wz.Character[$"000020{strId}.img"];
            var headNode = (WzImage)Wz.Character[$"000120{strId}.img"];

            foreach (var keyValuePair in Stance.Names)
            {
                var stanceName = keyValuePair.Value;
                var stance     = keyValuePair.Key;
                var stanceNode = bodyNode[stanceName];
                if (stanceNode == null)
                {
                    continue;
                }
                for (short frame = 0; frame < stanceNode.WzProperties.Count; frame++)
                {
                    var frameNode = stanceNode.WzProperties[frame];

                    foreach (var partNode0 in frameNode.WzProperties)
                    {
                        var partNode = partNode0.GetByUol();
                        if (!(partNode is WzCanvasProperty))
                        {
                            continue;
                        }
                        var z     = ((WzStringProperty)partNode["z"]).Value;
                        var layer = LayerByName(z);
                        if (layer == Layer.None)
                        {
                            continue;
                        }
                        Vector2 shift;
                        var     wzMap = partNode["map"];
                        switch (layer)
                        {
                        case Layer.HandBelowWeapon:
                            shift  = drawInfo.GetHandPosition(stance, frame);
                            shift -= ((WzVectorProperty)wzMap["handMove"])?.Pos() ?? new Vector2();
                            break;

                        default:
                            shift  = drawInfo.GetBodyPosition(stance, frame);
                            shift -= ((WzVectorProperty)wzMap["navel"])?.Pos() ?? new Vector2();
                            break;
                        }

                        if (!_stances.ContainsKey(stance))
                        {
                            _stances[stance] = new Dictionary <Layer, Dictionary <short, TextureD> >();
                        }
                        if (!_stances[stance].ContainsKey(layer))
                        {
                            _stances[stance][layer] = new Dictionary <short, TextureD>();
                        }
                        _stances[stance][layer][frame] = new TextureD(partNode).Shift(shift);
                    }

                    WzObject headSfNode0 = headNode[stanceName]?[frame.ToString()]["head"];
                    if (headSfNode0 == null)
                    {
                        continue;
                    }
                    var headSfNode = headSfNode0.GetByUol();
                    var shift2     = drawInfo.GetHeadPosition(stance, frame);
                    if (!_stances.ContainsKey(stance))
                    {
                        _stances[stance] = new Dictionary <Layer, Dictionary <short, TextureD> >();
                    }
                    if (!_stances[stance].ContainsKey(Layer.Head))
                    {
                        _stances[stance][Layer.Head] = new Dictionary <short, TextureD>();
                    }
                    _stances[stance][Layer.Head][frame] = new TextureD(headSfNode).Shift(shift2);
                }
            }

            var args = new[] { "Light", "Tan", "Dark", "Pale", "Blue", "Green", "", "", "", "Grey", "Pink", "Red" };

            _name = skin < args.Length ? args[skin] : "";
        }