コード例 #1
0
    private void ShowResListByType(TemplateResType type)
    {
        SetCurSelectType(type);
        for (int i = 0; i < GameData.instance.resTypeCount; i++)
        {
            if (i == (int)type)
            {
                if (loadResult[(int)type] == false)
                {
                    LoadResListByType((int)type);
                }
                ResContentList[i].parent.parent.gameObject.SetActive(true);
            }
            else
            {
                ResContentList[i].parent.parent.gameObject.SetActive(false);
            }
        }
        if (type == TemplateResType.Body)
        {
            SetPartOccupy(true);
        }
        else
        {
            SetPartOccupy(false);
        }
        Vector2 desPos = typeTransList[(int)type].GetComponent <RectTransform>().anchoredPosition;

        ImgResTypeSelect.DOAnchorPos(desPos, 0.2f);
    }
コード例 #2
0
 /// <summary>
 /// Gets the type of the part type by res.//素材类型 0颜色(身体) 1眼睛 2嘴巴 3头发 4帽子 5饰品 6手 7脚
 /// </summary>
 /// <param name="resType">素材类型</param>
 /// <param name="index">素材下标</param>
 PartType GetPartTypeByResType(TemplateResType resType, int index)
 {
     if (resType == TemplateResType.Body)
     {
         return(PartType.Body);
     }
     if (resType == TemplateResType.Eye)
     {
         if (index % 2 != 0)//右眼
         {
             return(PartType.RightEye);
         }
         return(PartType.LeftEye);
     }
     if (resType == TemplateResType.Mouth)
     {
         return(PartType.Mouth);
     }
     if (resType == TemplateResType.Hair)
     {
         return(PartType.Hair);
     }
     if (resType == TemplateResType.Hat)
     {
         return(PartType.Hat);
     }
     if (resType == TemplateResType.HeadWear)
     {
         return(PartType.HeadWear);
     }
     if (resType == TemplateResType.Hand)
     {
         if (index % 2 != 0)//右手
         {
             return(PartType.RightHand);
         }
         return(PartType.LeftHand);
     }
     if (resType == TemplateResType.Leg)
     {
         if (index % 2 != 0)//右脚
         {
             return(PartType.RightLeg);
         }
         return(PartType.LeftLeg);
     }
     if (resType == TemplateResType.Head)
     {
         return(PartType.Head);
     }
     if (resType == TemplateResType.TrueBody)
     {
         return(PartType.TrueBody);
     }
     return(PartType.Body);
 }
コード例 #3
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="index">siblingIndex</param>
    /// <param name="paramPath">图片路径</param>
    public void InitItem(int index, string paramPath = null)
    {
        Init();
        TemplateResType type = GameManager.instance.curSelectResType;

        partType = GetPartTypeByResType(type, index);
        string path = string.Empty;

        if (paramPath == null)
        {
            path = GameData.instance.resPathList[(int)type][index];
        }
        else
        {
            path = paramPath;
        }
        UIHelper.instance.SetImage(path, image, true);
    }
コード例 #4
0
 //右侧素材类型切换
 public void SetCurSelectType(TemplateResType type)
 {
     if (GameManager.instance.curSelectResType == type)
     {
         return;
     }
     GameManager.instance.SetJoinCurSelectType(type);
     if (type == 0)
     {
         PenScaleSlider.gameObject.SetActive(true);
         ImageScaleSlider.gameObject.SetActive(false);
     }
     else
     {
         PenScaleSlider.gameObject.SetActive(false);
         SetSelectResObj(curSelectResObj);
     }
 }
コード例 #5
0
    //右侧类型图标点击事件
    private void TypeButtonClick(TemplateResType type, bool isClick = false)
    {
        SetSelectResObj(null);

        if (isClick && type == GameManager.instance.curSelectResType)
        {
            return;
        }
        ShowBackBtn(false);
        if (GameManager.instance.curJoinType != JoinType.Animal)
        {
            if (type == TemplateResType.Body)
            {
                //SetPartOccupy(true);
                ImgDrawBg.DOFade(1, 0.5f).OnComplete(() => {
                    ImgDraw.gameObject.SetActive(false);
                    mobilePaint.gameObject.SetActive(true);
                });
            }
            else
            {
                Texture2D t = GetDrawTexture();
                ImgDraw.gameObject.SetActive(true);
                Sprite s = Sprite.Create(t, new Rect(0, 0, t.width, t.height), new Vector2(0.5f, 0.5f));
                ImgDraw.sprite = s;
                ImgDraw.SetNativeSize();
                //ImgDraw.transform.localScale = Vector3.one;
                mobilePaint.gameObject.SetActive(false);
                ImgDrawBg.DOFade(0, 0.5f);
            }
        }

        Sequence seq = DOTween.Sequence();

        seq.Append(ResListTrans.DOLocalMoveX(oriPos_ResContentList, 0.3f));
        seq.InsertCallback(0.2f, () =>
        {
            ShowResListByType(type);
        });
        seq.Append(ResListTrans.DOLocalMoveX(desPos_ResContentList - 50, 0.3f));
        seq.Append(ResListTrans.DOLocalMoveX(desPos_ResContentList, 0.2f));
    }
コード例 #6
0
    public void OnBeginDrag(PointerEventData eventData)
    {
        joinGuide.OperationStart();
        moveSelf = true;
        //if (Mathf.Abs(eventData.delta.x) < Mathf.Abs(eventData.delta.y) )
        Debug.Log(Mathf.Abs(eventData.delta.x) + "   " + Mathf.Abs(eventData.delta.y));
        if (Mathf.Abs(eventData.delta.x) < 0.5f * Mathf.Abs(eventData.delta.y))
        {
            moveSelf = false;
            scrollRect.OnBeginDrag(eventData);
            return;
        }
        AudioManager.instance.PlayOneShotAudio("Audio/option_audio/common_option_audio|dragend");
        TemplateResType type = GameManager.instance.curSelectResType;

        if (type == TemplateResType.Hand || type == TemplateResType.Leg)//手脚
        {
            genParent = GameObject.Find("group_handleg").transform;
        }
        else if (type == TemplateResType.Eye || type == TemplateResType.Mouth || type == TemplateResType.Hair)
        {
            genParent = GameObject.Find("group_eyemouthhair").transform;
        }
        else if (type == TemplateResType.Hat || type == TemplateResType.HeadWear)
        {
            genParent = GameObject.Find("group_hatheadwear").transform;
        }
        else if (type == TemplateResType.Head)
        {
            genParent = GameObject.Find("group_head").transform;
        }
        else if (type == TemplateResType.TrueBody)
        {
            genParent = GameObject.Find("group_truebody").transform;
        }
        GameObject obj = UIHelper.instance.LoadPrefab("Prefabs/join|gen_res", genParent, eventData.position, Vector3.one, false);

        obj.GetComponent <ResDragItem>().InitItem(transform.GetSiblingIndex(), resPath);
        obj.transform.name     = type.ToString();
        eventData.pointerPress = obj;
        eventData.pointerDrag  = obj;
    }
コード例 #7
0
 public void SetJoinCurSelectType(TemplateResType type)
 {
     curSelectResType = type;
 }
コード例 #8
0
    //根据字母或数字,返回包含模板在内的5/6个素材
    public List<string> GetPathList(int index,TemplateResType type)
    {
        List<string> pathList = new List<string>();
        string path = string.Empty;

        //眼睛
        if (type == TemplateResType.Eye)
        {
            int num = 0;
            string mpath = ModulePathList[index][0];
            if (mpath=="")
            {
                num = Math.Min(6, resPathList[1].Count);
            }
            else
            {
                string[] leftst = ModulePathList[index][0].Split('|');
                string[] rightst = ModulePathList[index][1].Split('|');
                for (int i = 0; i < leftst.Length; i++)
                {
                    pathList.Add("sprite/fodder/eye|" + leftst[i]);
                    pathList.Add("sprite/fodder/eye|" + rightst[i]);
                }
                num = Math.Min(6 - leftst.Length, resPathList[1].Count);
            }
          
            int sIndex = 0;
            int eIndex = resPathList[1].Count;
            for (int i = 0; i < num; i++)
            {
                Random rd = new Random();
                int n = rd.Next(sIndex,eIndex);
                while (pathList.Contains(resPathList[1][n]) || n%2!=0)
                {
                    n = rd.Next(sIndex, eIndex);
                }
                pathList.Add(resPathList[1][n]);
                pathList.Add(resPathList[1][n + 1]);
            }
        }
        else if (type == TemplateResType.Mouth)
        {
            string mpath = ModulePathList[index][2];
            int num = 0;
            if (mpath=="")
            {
                num = Math.Min(5, resPathList[2].Count);
            }
            else
            {
                string[] tempPathLst = mpath.Split('|');
                for (int i = 0; i < tempPathLst.Length; i++) {
                    pathList.Add("sprite/fodder/mouth|" + tempPathLst[i]);
                }
                num = Math.Min(5-tempPathLst.Length, resPathList[2].Count);

            }
            int sIndex = 0;
            int eIndex = resPathList[2].Count;
            for (int i = 0; i < num; i++)
            {
                Random rd = new Random();
                int n = rd.Next(sIndex, eIndex);
                while (pathList.Contains(resPathList[2][n]))
                {
                    n = rd.Next(sIndex, eIndex);
                }
                pathList.Add(resPathList[2][n]);
            }
        }
        else if (type == TemplateResType.Hand)
        {
            string mpath = ModulePathList[index][3];
            int num = 0;
            if (mpath == "")
            {
                num = Math.Min(6, resPathList[6].Count);
            }
            else
            {
                string[] leftst = ModulePathList[index][3].Split('|');
                string[] rightst = ModulePathList[index][4].Split('|');
                for (int i = 0; i < leftst.Length; i++)
                {
                    pathList.Add("sprite/fodder/hand|" + leftst[i]);
                    pathList.Add("sprite/fodder/hand|" + rightst[i]);
                }
                num = Math.Min(6- leftst.Length, resPathList[6].Count);
            }
            int sIndex = 0;
            int eIndex = resPathList[6].Count;
            for (int i = 0; i < num; i++)
            {
                Random rd = new Random();
                int n = rd.Next(sIndex, eIndex);
                while (pathList.Contains(resPathList[6][n])||n%2!=0)
                {
                    n = rd.Next(sIndex, eIndex);
                }
                pathList.Add(resPathList[6][n]);
                pathList.Add(resPathList[6][n + 1]);
            }
        }
        else if (type == TemplateResType.Leg)
        {
            string mpath = ModulePathList[index][5];
            int num = 0;
            if (mpath == "")
            {
                num = Math.Min(5, resPathList[7].Count);
            }
            else
            {
                string[] leftst = ModulePathList[index][5].Split('|');
                string[] rightst = ModulePathList[index][6].Split('|');
                for (int i = 0; i < leftst.Length; i++)
                {
                    pathList.Add("sprite/fodder/leg|" + leftst[i]);
                    pathList.Add("sprite/fodder/leg|" + rightst[i]);
                }
                num = Math.Min(5- leftst.Length, resPathList[7].Count);
            }
            int sIndex = 0;
            int eIndex = resPathList[7].Count;
            for (int i = 0; i < num; i++)
            {
                Random rd = new Random();
                int n = rd.Next(sIndex, eIndex);
                while (pathList.Contains(resPathList[7][n]) || n % 2 != 0)
                {
                    n = rd.Next(sIndex, eIndex);
                }
                pathList.Add(resPathList[7][n]);
                pathList.Add(resPathList[7][n + 1]);
            }
        }
        else if (type == TemplateResType.Hat)
        {
            string mpath = ModulePathList[index][7];
            int num = 0;
            if (mpath == "")
            {
                num = Math.Min(5, resPathList[4].Count);
            }
            else
            {
                string[] tempPathLst = mpath.Split('|');
                for (int i = 0; i < tempPathLst.Length; i++)
                {
                    pathList.Add("sprite/fodder/hat|" + tempPathLst[i]);
                }
                num = Math.Min(5- tempPathLst.Length, resPathList[4].Count);
            }
            int sIndex = 0;
            int eIndex = resPathList[4].Count;
            for (int i = 0; i < num; i++)
            {
                Random rd = new Random();
                int n = rd.Next(sIndex, eIndex);
                while (pathList.Contains(resPathList[4][n]))
                {
                    n = rd.Next(sIndex, eIndex);
                }
                pathList.Add(resPathList[4][n]);
            }
        }
        else if (type == TemplateResType.HeadWear)
        {
            string mpath = ModulePathList[index][8];
            int num = 0;
            if (mpath == "")
            {
                num = Math.Min(6, resPathList[5].Count);
            }
            else
            {
                string[] tempPathLst = mpath.Split('|');
                for (int i = 0; i < tempPathLst.Length; i++)
                {
                    pathList.Add("sprite/fodder/headwear|" + tempPathLst[i]);
                }
                num = Math.Min(6-tempPathLst.Length, resPathList[5].Count);
            }
            int sIndex = 0;
            int eIndex = resPathList[5].Count;
            for (int i = 0; i < num; i++)
            {
                Random rd = new Random();
                int n = rd.Next(sIndex, eIndex);
                while (pathList.Contains(resPathList[5][n]))
                {
                    n = rd.Next(sIndex, eIndex);
                }
                pathList.Add(resPathList[5][n]);
            }
        }
        else if (type == TemplateResType.Head)
        {
            string mpath = ModulePathList[index][9];
            int num = 0;
            if (mpath == "")
            {
                num = Math.Min(3, resPathList[8].Count);
            }
            else
            {
                string[] tempPathLst = mpath.Split('|');
                for (int i = 0; i < tempPathLst.Length; i++)
                {
                    pathList.Add("sprite/fodder/head|" + tempPathLst[i]);
                }
                num = Math.Min(3 - tempPathLst.Length, resPathList[8].Count);
            }
            int sIndex = 0;
            int eIndex = resPathList[8].Count;
            for (int i = 0; i < num; i++)
            {
                Random rd = new Random();
                int n = rd.Next(sIndex, eIndex);
                while (pathList.Contains(resPathList[8][n]))
                {
                    n = rd.Next(sIndex, eIndex);
                }
                pathList.Add(resPathList[8][n]);
            }
        }
        else if (type == TemplateResType.TrueBody)
        {
            string mpath = ModulePathList[index][10];
            int num = 0;
            if (mpath == "")
            {
                num = Math.Min(3, resPathList[9].Count);
            }
            else
            {
                string[] tempPathLst = mpath.Split('|');
                for (int i = 0; i < tempPathLst.Length; i++)
                {
                    pathList.Add("sprite/fodder/body|" + tempPathLst[i]);
                }
                num = Math.Min(3 - tempPathLst.Length, resPathList[9].Count);
            }
            int sIndex = 0;
            int eIndex = resPathList[9].Count;
            for (int i = 0; i < num; i++)
            {
                Random rd = new Random();
                int n = rd.Next(sIndex, eIndex);
                while (pathList.Contains(resPathList[9][n]))
                {
                    n = rd.Next(sIndex, eIndex);
                }
                pathList.Add(resPathList[9][n]);
            }
        }

        return pathList;
    }