Exemple #1
0
    /// ***********************************************************************
    /// author   : lta
    /// Created  : 03-16-2017
    /// purpose  : 基于动态套装,改变局部并重新组合动态套装
    /// <param name="eTargetSkin">取值套装</param>
    /// <param name="eSlot">目标插槽</param>
    /// ***********************************************************************
    public bool LChangeSkinBaseOnDynamicSkin(ESkin eTargetSkin, ESlot eSlot)
    {
        Skin dynamicSkin = _skeleton.data.FindSkin(_dynamicSkinName);
        var  success     = LSetSkin(dynamicSkin, eTargetSkin, eSlot);

        return(success);
    }
Exemple #2
0
    /// ***********************************************************************
    /// author   : lta
    /// Created  : 03-16-2017
    /// purpose  : 根据套装贴图枚举映射贴图名称
    /// ***********************************************************************
    private string MappingEskin2Name(ESkin eSkin)
    {
        switch (eSkin)
        {
        case ESkin.gun001:
            return("gun001");

        case ESkin.gun002:
            return("gun002");

        default:
            throw new ArgumentOutOfRangeException("eSkin", eSkin, "The Skin Cannot Found in Character's Spine");
        }
    }
Exemple #3
0
 public void ApplySkin(ESkin newSkin)
 {
     foreach (ResourceDictionary dict in Resources.MergedDictionaries)
     {
         if (dict is SkinResourceDictionary skinDict)
         {
             skinDict.UpdateSource();
         }
         else
         {
             dict.Source = dict.Source;
         }
     }
 }
Exemple #4
0
    /// ***********************************************************************
    /// author   : lta
    /// Created  : 03-16-2017
    /// purpose  :
    /// 内部处理:针对传入的需要更改的套装(实时套装),从目标皮肤中根据目标卡槽取出皮肤数据进行替换赋值操作,数据层和表现层同时处理变化
    /// <param name="dynamicSkin">赋值套装</param>
    /// <param name="eSkin">取值套装枚举</param>
    /// <param name="eSlot">目标插槽枚举</param>
    /// ***********************************************************************
    private bool LSetSkin(Skin dynamicSkin, ESkin eSkin, ESlot eSlot)
    {
        if (dynamicSkin != null)
        {
            ExposedList <Slot> slots = _skeleton.slots;
            for (int i = 0, n = slots.Count; i < n; i++)
            {
                Slot slot           = slots.Items[i];
                var  targetSlotName = MappingESlot2Name(eSlot);
                if (slot.data.name != targetSlotName)
                {
                    continue;
                }
                string attachName = slot.data.attachmentName;
                if (attachName != null)
                {
                    string     targetSkinName = MappingEskin2Name(eSkin);
                    Attachment attachment;
                    if (attachName == targetSlotName)
                    {
                        attachment = LGetAttachment(i, targetSlotName, targetSkinName);  // 重写L Get
                        dynamicSkin.Attachments.Remove(new Skin.AttachmentKeyTuple(i, targetSlotName));
                        dynamicSkin.Attachments.Add(new Skin.AttachmentKeyTuple(i, targetSlotName), attachment);
                    }
                    else
                    {
                        attachment = dynamicSkin.GetAttachment(i, attachName);   // 默认Skeleton Get
                    }

                    if (attachment != null)
                    {
                        slot.Attachment = attachment;
                        var attahName = attachment.Name;
                        SetSlotToAttachment(eSlot, attahName, true);
                        break;
                    }
                }
            }
            _skeleton.slots = slots;
        }
        _skeleton.skin = dynamicSkin;
        return(true);
    }
Exemple #5
0
    /// ***********************************************************************
    /// author   : lta
    /// Created  : 03-16-2017
    /// purpose  : 对比数据表跟目前数据表(游戏初始加载后的Spine内置套装数据)差异,并更新数据和表现
    /// ***********************************************************************
    private void CompareAndSetAttachments(Dictionary <ESlot, string> targetAttchments)
    {
        var curAttachments = _dynamicSlotToAttachments;
        var fristSlot      = (ESlot)Enum.Parse(typeof(ESlot), "Null", true);
        int start          = (int)fristSlot;

        foreach (var eSlotKey in targetAttchments)
        {
            ESlot slotKey          = eSlotKey.Key;
            var   curAttachment    = curAttachments[slotKey];
            var   targetAttachment = targetAttchments[slotKey];

            if (curAttachment == null || curAttachment != targetAttachment)
            {
                ESkin eSkins = GetSkinByAttachment(targetAttachment);
                if (eSkins == ESkin.Null)
                {
                    throw new Exception("Eskin 不存在与=数据表_skinContainAttachments中");
                }
                LChangeSkinBaseOnDynamicSkin(eSkins, slotKey);
            }
        }
    }
Exemple #6
0
    /// ***********************************************************************
    /// author   : lta
    /// Created  : 03-16-2017
    /// purpose  : 可交互对象内部绑定了对应的SkinInfo,根据SkinInfo赋值字段进行查找
    /// <param name="skinButton">换装按键</param>
    /// <param name="eSkin">对应皮肤</param>
    /// <param name="slot">对应插槽</param>
    /// ***********************************************************************
    public bool ReceiveClick(Button skinButton, ESkin eSkin, ESlot slot)
    {
        //return ResetActulSlotToAttachment(skinButton, eSkin, slot);

        return(true);
    }