Пример #1
0
        private AvatarAsset LoadCarryItemAsset(int carryId)
        {
            var key      = "ri" + (IsSmall ? "_sh" : "_h");
            var document = FigureExtractor.Parts.ContainsKey(key) ? FigureExtractor.Parts[key] : null;

            if (document == null)
            {
                return(null);
            }

            int direction = BodyDirection;

            if (BodyDirection == 4)
            {
                direction = 2;
            }

            if (BodyDirection == 6)
            {
                direction = 0;
            }

            if (BodyDirection == 5)
            {
                direction = 1;
            }

            var part = new FigurePart("0", "ri", false, 0, null);
            var set  = new FigureSet("ri", "", "", false, false, false);

            var asset = LocateAsset((this.IsSmall ? "sh" : "h") + "_" + Action + "_ri_" + carryId + "_" + direction + "_" + Frame, document, null, part, set);

            if (asset == null)
            {
                asset = LocateAsset((this.IsSmall ? "sh" : "h") + "_crr_ri_" + carryId + "_" + direction + "_" + Frame, document, null, part, set);
            }

            if (asset == null)
            {
                LocateAsset((this.IsSmall ? "sh" : "h") + "_std_ri_" + carryId + "_0_" + Frame, document, null, part, set);
            }

            return(asset);
        }
Пример #2
0
        public AvatarAsset(bool isSmall, string action, string name, string fileName, int X, int Y, FigurePart part, FigureSet set, int canvasW, int canvasH, string[] parts)
        {
            this.Name          = name;
            this.X             = X;
            this.Y             = Y;
            this.FileName      = fileName;
            this.Part          = part;
            this.Set           = set;
            this.Parts         = parts;
            this.RenderOrder   = this.Part.OrderId;
            this.IsDrinkCanvas = false;

            if (action == "lay")
            {
                this.ImageY = Y + (canvasW / 2) + (isSmall ? -5 : -20);
                this.ImageX = X + (canvasH / 2) - (isSmall ? -11 : -10);
            }
            else
            {
                this.ImageX = X + (canvasW / 2) + (isSmall ? 5 : 10);
                this.ImageY = Y + (canvasH / 2) - (isSmall ? 11 : 20);
            }
        }
Пример #3
0
        public string ProcessFigure(string figure, string gender, ICollection <ClothingParts> clothingParts, bool hasHabboClub)
        {
            figure = figure.ToLower();
            gender = gender.ToUpper();

            string rebuildFigure = string.Empty;

            #region Check clothing, colors & Habbo Club
            string[] figureParts = figure.Split('.');
            foreach (string part in figureParts.ToList())
            {
                string type = part.Split('-')[0];

                FigureSet figureSet = null;
                if (this._setTypes.TryGetValue(type, out figureSet))
                {
                    int partId        = Convert.ToInt32(part.Split('-')[1]);
                    int colorId       = 0;
                    int secondColorId = 0;

                    Set set = null;
                    if (figureSet.Sets.TryGetValue(partId, out set))
                    {
                        #region Gender Check
                        if (set.Gender != gender && set.Gender != "U")
                        {
                            if (figureSet.Sets.Count(x => x.Value.Gender == gender || x.Value.Gender == "U") > 0)
                            {
                                partId = figureSet.Sets.FirstOrDefault(x => x.Value.Gender == gender || x.Value.Gender == "U").Value.Id;

                                //Fetch the new set.
                                figureSet.Sets.TryGetValue(partId, out set);

                                colorId = GetRandomColor(figureSet.PalletId);
                            }
                            else
                            {
                                //No replacable?
                            }
                        }
                        #endregion

                        #region Colors
                        if (set.Colorable)
                        {
                            //Couldn't think of a better way to split the colors, if I looped the parts I still have to remove Type-PartId, then loop color 1 & color 2. Meh

                            int splitterCounter = part.Count(x => x == '-');
                            if (splitterCounter == 2 || splitterCounter == 3)
                            {
                                #region First Color
                                if (!string.IsNullOrEmpty(part.Split('-')[2]))
                                {
                                    if (int.TryParse(part.Split('-')[2], out colorId))
                                    {
                                        colorId = Convert.ToInt32(part.Split('-')[2]);

                                        Palette palette = GetPalette(colorId);
                                        if (palette != null && colorId != 0)
                                        {
                                            if (figureSet.PalletId != palette.Id)
                                            {
                                                colorId = GetRandomColor(figureSet.PalletId);
                                            }
                                        }
                                        else if (palette == null && colorId != 0)
                                        {
                                            colorId = GetRandomColor(figureSet.PalletId);
                                        }
                                    }
                                    else
                                    {
                                        colorId = 0;
                                    }
                                }
                                else
                                {
                                    colorId = 0;
                                }
                                #endregion
                            }

                            if (splitterCounter == 3)
                            {
                                #region Second Color
                                if (!string.IsNullOrEmpty(part.Split('-')[3]))
                                {
                                    if (int.TryParse(part.Split('-')[3], out secondColorId))
                                    {
                                        secondColorId = Convert.ToInt32(part.Split('-')[3]);

                                        Palette palette = GetPalette(secondColorId);
                                        if (palette != null && secondColorId != 0)
                                        {
                                            if (figureSet.PalletId != palette.Id)
                                            {
                                                secondColorId = GetRandomColor(figureSet.PalletId);
                                            }
                                        }
                                        else if (palette == null && secondColorId != 0)
                                        {
                                            secondColorId = GetRandomColor(figureSet.PalletId);
                                        }
                                    }
                                    else
                                    {
                                        secondColorId = 0;
                                    }
                                }
                                else
                                {
                                    secondColorId = 0;
                                }
                                #endregion
                            }
                        }
                        else
                        {
                            string[] ignore = new string[] { "ca", "wa" };

                            if (ignore.Contains(type))
                            {
                                if (!string.IsNullOrEmpty(part.Split('-')[2]))
                                {
                                    colorId = Convert.ToInt32(part.Split('-')[2]);
                                }
                            }
                        }
                        #endregion

                        if (set.ClubLevel > 0 && !hasHabboClub)
                        {
                            partId = figureSet.Sets.FirstOrDefault(x => x.Value.Gender == gender || x.Value.Gender == "U" && x.Value.ClubLevel == 0).Value.Id;

                            figureSet.Sets.TryGetValue(partId, out set);

                            colorId = GetRandomColor(figureSet.PalletId);
                        }

                        if (secondColorId == 0)
                        {
                            rebuildFigure = rebuildFigure + type + "-" + partId + "-" + colorId + ".";
                        }
                        else
                        {
                            rebuildFigure = rebuildFigure + type + "-" + partId + "-" + colorId + "-" + secondColorId + ".";
                        }
                    }
                }
            }
            #endregion

            #region Check Required Clothing
            foreach (string requirement in this._requirements)
            {
                if (!rebuildFigure.Contains(requirement))
                {
                    if (requirement == "ch" && gender == "M")
                    {
                        continue;
                    }

                    FigureSet figureSet = null;
                    if (this._setTypes.TryGetValue(requirement, out figureSet))
                    {
                        Set set = figureSet.Sets.FirstOrDefault(x => x.Value.Gender == gender || x.Value.Gender == "U").Value;
                        if (set != null)
                        {
                            int partId  = figureSet.Sets.FirstOrDefault(x => x.Value.Gender == gender || x.Value.Gender == "U").Value.Id;
                            int colorId = GetRandomColor(figureSet.PalletId);

                            rebuildFigure = rebuildFigure + requirement + "-" + partId + "-" + colorId + ".";
                        }
                    }
                }
            }
            #endregion

            #region Check Purcashable Clothing
            if (clothingParts != null)
            {
                ICollection <ClothingItem> purchasableParts = PlusEnvironment.GetGame().GetCatalog().GetClothingManager().GetClothingAllParts;

                figureParts = rebuildFigure.TrimEnd('.').Split('.');
                foreach (string part in figureParts.ToList())
                {
                    int partId = Convert.ToInt32(part.Split('-')[1]);
                    if (purchasableParts.Count(x => x.PartIds.Contains(partId)) > 0)
                    {
                        if (clothingParts.Count(x => x.PartId == partId) == 0)
                        {
                            string type = part.Split('-')[0];

                            FigureSet figureSet = null;
                            if (this._setTypes.TryGetValue(type, out figureSet))
                            {
                                Set set = figureSet.Sets.FirstOrDefault(x => x.Value.Gender == gender || x.Value.Gender == "U").Value;
                                if (set != null)
                                {
                                    partId = figureSet.Sets.FirstOrDefault(x => x.Value.Gender == gender || x.Value.Gender == "U").Value.Id;
                                    int colorId = GetRandomColor(figureSet.PalletId);

                                    rebuildFigure = rebuildFigure + type + "-" + partId + "-" + colorId + ".";
                                }
                            }
                        }
                    }
                }
            }
            #endregion

            return(rebuildFigure);
        }
Пример #4
0
        private AvatarAsset LocateAsset(string assetName, FigureDocument document, string[] parts, FigurePart part, FigureSet set)
        {
            var list = document.XmlFile.SelectNodes("//manifest/library/assets/asset");

            for (int i = 0; i < list.Count; i++)
            {
                var asset = list.Item(i);
                var name  = asset.Attributes.GetNamedItem("name").InnerText;

                if (name != assetName)
                {
                    continue;
                }

                var offsetList = asset.ChildNodes;

                for (int j = 0; j < offsetList.Count; j++)
                {
                    var offsetData = offsetList.Item(j);

                    if (offsetData.Attributes.GetNamedItem("key") == null ||
                        offsetData.Attributes.GetNamedItem("value") == null)
                    {
                        continue;
                    }

                    if (offsetData.Attributes.GetNamedItem("key").InnerText != "offset")
                    {
                        continue;
                    }

                    var offsets = offsetData.Attributes.GetNamedItem("value").InnerText.Split(',');

                    return(new AvatarAsset(this.IsSmall, Action, name, FileUtil.SolveFile("figuredata/" + document.FileName + "/", name), int.Parse(offsets[0]), int.Parse(offsets[1]), part, set, CANVAS_HEIGHT, CANVAS_WIDTH, parts));
                }
            }

            return(null);
        }
Пример #5
0
        private AvatarAsset LoadFigureAsset(string[] parts, FigurePart part, FigureSet set)
        {
            var key      = part.Type + (IsSmall ? "_sh" : "_h");
            var document = FigureExtractor.Parts.ContainsKey(key) ? FigureExtractor.Parts[key] : null;

            if (document == null)
            {
                return(null);
            }

            int    direction;
            string gesture;

            if (IsHead(part.Type))
            {
                direction = HeadDirection;
                gesture   = Gesture;

                if (HeadDirection == 4)
                {
                    direction = 2;
                }

                if (HeadDirection == 6)
                {
                    direction = 0;
                }

                if (HeadDirection == 5)
                {
                    direction = 1;
                }
            }
            else
            {
                direction = BodyDirection;
                gesture   = Action;

                if (BodyDirection == 4)
                {
                    direction = 2;
                }

                if (BodyDirection == 6)
                {
                    direction = 0;
                }

                if (BodyDirection == 5)
                {
                    direction = 1;
                }
            }

            // Hide left arm on side view
            if (direction == 1 && part.Type == "ls")
            {
                return(null);
            }

            if (Action == "lay")
            {
                if (BodyDirection >= 4)
                {
                    direction = 2;
                }
            }

            if (CarryDrink > 0 && Action != "lay" && Action != "drk")
            {
                if (new string[] { "ls", "lh" }.Contains(part.Type))
                {
                    gesture = "std";
                }
                if (CarryDrink > 0)
                {
                    if (new string[] { "rs", "rh" }.Contains(part.Type))
                    {
                        gesture = "crr";
                    }
                }
            }



            var asset = LocateAsset((this.IsSmall ? "sh" : "h") + "_" + gesture + "_" + part.Type + "_" + part.Id + "_" + direction + "_" + Frame, document, parts, part, set);

            if (asset == null)
            {
                asset = LocateAsset((this.IsSmall ? "sh" : "h") + "_" + "std" + "_" + part.Type + "_" + part.Id + "_" + direction + "_" + Frame, document, parts, part, set);
            }

            if (asset == null)
            {
                asset = LocateAsset((this.IsSmall ? "sh" : "h") + "_" + "std" + "_" + part.Type + "_" + part.Id + "_" + direction + "_" + 0, document, parts, part, set);
            }

            if (IsSmall)
            {
                if (asset == null)
                {
                    asset = LocateAsset((this.IsSmall ? "sh" : "h") + "_" + "std" + "_" + part.Type + "_" + 1 + "_" + direction + "_" + Frame, document, parts, part, set);
                }
            }

            return(asset);
        }