当前位置: 首页>>代码示例>>C#>>正文


C# Key.GetIndex方法代码示例

本文整理汇总了C#中Key.GetIndex方法的典型用法代码示例。如果您正苦于以下问题:C# Key.GetIndex方法的具体用法?C# Key.GetIndex怎么用?C# Key.GetIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Key的用法示例。


在下文中一共展示了Key.GetIndex方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReplaceOutfit

        public static int ReplaceOutfit(SimDescriptionCore sim, Key key, SimOutfit newOutfit, bool alternate)
        {
            bool maternity = ((sim.IsUsingMaternityOutfits) && (!alternate));

            ArrayList outfits = GetOutfits(sim, key.mCategory, alternate);
            if (outfits == null)
            {
                outfits = new ArrayList();
                if (maternity)
                {
                    sim.mMaternityOutfits[key.mCategory] = outfits;
                }
                else
                {
                    sim.Outfits[key.mCategory] = outfits;
                }
            }

            int index = key.GetIndex(sim, alternate);

            if ((index == -1) || (index >= outfits.Count))
            {
                outfits.Add(newOutfit);

                index = outfits.Count - 1;
            }
            else if (index < outfits.Count)
            {
                SimOutfit oldOutfit = outfits[index] as SimOutfit;
                if (oldOutfit != null)
                {
                    bool inUse = false;
                    foreach (OutfitCategories categories in sim.GetCurrentOutfits().Keys)
                    {
                        ArrayList list2 = sim.GetOutfits(categories);
                        if (list2 != null)
                        {
                            foreach (SimOutfit outfit in list2)
                            {
                                if (outfit.Key == oldOutfit.Key)
                                {
                                    inUse = true;
                                    break;
                                }
                            }
                        }

                        if (inUse) break;
                    }

                    if (!inUse)
                    {
                        oldOutfit.Uncache();
                    }
                }

                outfits[index] = newOutfit;
            }
            else
            {
                outfits.Insert(index, newOutfit);
            }

            switch (key.mCategory)
            {
                case OutfitCategories.Special:
                    if (!string.IsNullOrEmpty(key.mSpecialKey))
                    {
                        if (sim.mSpecialOutfitIndices == null)
                        {
                            sim.mSpecialOutfitIndices = new Dictionary<uint, int>();
                        }

                        sim.mSpecialOutfitIndices[ResourceUtils.HashString32(key.mSpecialKey)] = index;
                    }
                    break;
                case OutfitCategories.Everyday:
                    SimDescription simDesc = sim as SimDescription;
                    if (simDesc != null)
                    {
                        simDesc.mDefaultOutfitKey = sim.GetOutfit(OutfitCategories.Everyday, 0).Key;
                    }
                    break;
            }

            return index;
        }
开发者ID:Robobeurre,项目名称:NRaas,代码行数:87,代码来源:CASParts.cs

示例2: RemoveOutfit

        public static void RemoveOutfit(SimDescriptionCore sim, Key key, bool alternate)
        {
            bool maternity = ((sim.IsUsingMaternityOutfits) && (!alternate));

            sim.RemoveOutfit(key.mCategory, key.GetIndex(sim, alternate), true, maternity);

            switch (key.mCategory)
            {
                case OutfitCategories.Special:
                    if (sim.mSpecialOutfitIndices != null)
                    {
                        int index = key.GetIndex(sim, alternate);

                        sim.RemoveSpecialOutfitAtIndex(index);

                        foreach (uint num in new List<uint>(sim.mSpecialOutfitIndices.Keys))
                        {
                            int oldIndex = sim.mSpecialOutfitIndices[num];
                            if (oldIndex > index)
                            {
                                sim.mSpecialOutfitIndices[num] = oldIndex - 1;
                            }
                        }
                    }
                    break;
                case OutfitCategories.Career:
                    CheckIndex(sim, null);
                    break;
                case OutfitCategories.Everyday:
                    SimDescription simDesc = sim as SimDescription;
                    if (simDesc != null)
                    {
                        simDesc.mDefaultOutfitKey = sim.GetOutfit(OutfitCategories.Everyday, 0).Key;
                    }
                    break;
            }            
        }
开发者ID:Robobeurre,项目名称:NRaas,代码行数:37,代码来源:CASParts.cs

示例3: CreateOutfit

        public static SimOutfit CreateOutfit(SimDescriptionCore sim, Key key, SimBuilder builder, ulong components, bool alternate)
        {
            builder.UseCompression = true;

            bool maternity = ((sim.IsUsingMaternityOutfits) && (!alternate));

            string outfitName = null;

            if ((key.mCategory == OutfitCategories.Special) || (key.GetIndex() != -1))
            {
                outfitName = GetOutfitName(sim, key, maternity);
            }
            else
            {
                outfitName = GetOutfitName(sim, key.mCategory, maternity);
            }

            return new SimOutfit(builder.CacheOutfit(outfitName, components, false));
        }
开发者ID:Robobeurre,项目名称:NRaas,代码行数:19,代码来源:CASParts.cs

示例4: GetOutfit

        public static SimOutfit GetOutfit(SimDescriptionCore sim, Key key, bool alternate)
        {
            if (sim == null) return null;

            ArrayList outfits = GetOutfits(sim, key.mCategory, alternate);
            if (outfits == null) return null;

            int index = key.GetIndex(sim, alternate);
            if (index == -1) return null;

            if (index < outfits.Count)
            {
                return outfits[index] as SimOutfit;
            }
            else
            {
                return null;
            }
        }
开发者ID:Robobeurre,项目名称:NRaas,代码行数:19,代码来源:CASParts.cs


注:本文中的Key.GetIndex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。