• 大小: 12.1MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-07-21
  • 语言: 其他
  • 标签:

资源简介

unity单机斗地主 完整项目 下载用unity打开即可

资源截图

代码片段和文件信息

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class CardUI : ReuseableobjectIPointerClickHandler {
    //显示的图片
    private Image image;
    
    private Card card;
    private bool isSelected;

    //销毁卡牌
    public void Destroy()
    {
        PoolManager.Instance.HideObjet(gameobject);//调用对象池
    }
    //卡牌信息
    public Card Card
    {
        get
        {
            return card;
        }
        set
        {
            card = value;
            SetImage();
        }
    }


    //设置显示图片
    public void SetImage()
    {
        if (card.BelongTo==CharacterType.Player||card.BelongTo==CharacterType.Desk)
        {
            //更换sprite
            image.sprite = Resources.Load(“Pokers/“+card.CardName);
        }
        else
        {
            image.sprite = Resources.Load(“Pokers/CardBack“);
        }
    }

    //显示地主的三张底牌
    public void SetImage(bool isDesk)
    {
        if (isDesk)  
          //更换sprite
          image.sprite = Resources.Load(“Pokers/“ + card.CardName);
        else
        {
            image.sprite = Resources.Load(“Pokers/CardBack“);

        }
    }


    //点击事件
    public void OnPointerClick(PointerEventData eventData)
    {
        if (eventData.button==PointerEventData.InputButton.Left)
        {
            if (card.BelongTo==CharacterType.Player)
           
              Selected = !Selected;
           
        }
    }

    //是否选中
    public bool Selected
    {
        get
        {
            return isSelected;
        }
        set
        {

            if (value == isSelected || card.BelongTo != CharacterType.Player)
                return;
            if (value)
                transform.localPosition += Vector3.up * 10;
            else
                transform.localPosition -= Vector3.up * 10;

            isSelected = value;
        }
    }


    public void SetPosition(Transform parentint index)
    {
        transform.SetParent(parentfalse);
        transform.SetSiblingIndex(index);//设置场景视窗的索引
        if (card.BelongTo == CharacterType.Desk || card.BelongTo == CharacterType.Player)
        {
            transform.localPosition = Vector3.right * 30 * index;
            //底牌也是被选中装态
            if (isSelected)
                transform.localPosition += Vector3.up * 10;

        }
        else if (card.BelongTo==CharacterType.ComputerLeft||card.BelongTo==CharacterType.ComputerRight)
        {
            transform.localPosition = Vector3.down * 10 * index;
        }
    }

    //使用之前
    public override void BeforeGetobject()//赋初值
    {
        image = GetComponent();
    }

    //摧毁之前
    public override void BeforeHideobject()//还原操作 override 重写 overload重载
    {
        isSelected = false;
        image.sprite = null;
        card = null;
    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-06-12 23:54  doudizhu\
     目录           0  2018-06-10 21:28  doudizhu\.vs\
     目录           0  2018-06-10 21:28  doudizhu\.vs\doudizhu\
     目录           0  2018-06-11 09:37  doudizhu\.vs\doudizhu - 副本\
     目录           0  2018-06-11 09:37  doudizhu\.vs\doudizhu - 副本\DesignTimeBuild\
     文件         318  2018-06-12 20:57  doudizhu\.vs\doudizhu - 副本\DesignTimeBuild\.dtbcache
     目录           0  2018-06-10 21:33  doudizhu\.vs\doudizhu - 副本\v15\
     文件      226816  2018-06-12 23:54  doudizhu\.vs\doudizhu - 副本\v15\.suo
     目录           0  2018-06-10 21:29  doudizhu\.vs\doudizhu - 副本\v15\Server\
     目录           0  2018-06-10 21:29  doudizhu\.vs\doudizhu - 副本\v15\Server\sqlite3\
     文件           0  2018-06-10 21:29  doudizhu\.vs\doudizhu - 副本\v15\Server\sqlite3\db.lock
     文件     1093632  2018-06-12 23:35  doudizhu\.vs\doudizhu - 副本\v15\Server\sqlite3\storage.ide
     文件       32768  2018-06-12 22:11  doudizhu\.vs\doudizhu - 副本\v15\Server\sqlite3\storage.ide-shm
     文件     4165352  2018-06-12 23:54  doudizhu\.vs\doudizhu - 副本\v15\Server\sqlite3\storage.ide-wal
     目录           0  2018-06-10 21:28  doudizhu\.vs\doudizhu\DesignTimeBuild\
     文件         278  2018-06-08 23:10  doudizhu\.vs\doudizhu\DesignTimeBuild\.dtbcache
     目录           0  2018-06-10 21:28  doudizhu\.vs\doudizhu\v15\
     文件      208384  2018-06-10 20:47  doudizhu\.vs\doudizhu\v15\.suo
     目录           0  2018-06-10 21:28  doudizhu\.vs\doudizhu\v15\Server\
     目录           0  2018-06-10 21:28  doudizhu\.vs\doudizhu\v15\Server\sqlite3\
     文件           0  2018-06-04 14:34  doudizhu\.vs\doudizhu\v15\Server\sqlite3\db.lock
     文件     1114112  2018-06-10 18:23  doudizhu\.vs\doudizhu\v15\Server\sqlite3\storage.ide
     文件       32768  2018-06-10 14:50  doudizhu\.vs\doudizhu\v15\Server\sqlite3\storage.ide-shm
     文件     4173592  2018-06-10 20:47  doudizhu\.vs\doudizhu\v15\Server\sqlite3\storage.ide-wal
     目录           0  2018-06-10 21:28  doudizhu\Assets\
     目录           0  2018-06-10 21:28  doudizhu\Assets\Fonts\
     文件         191  2018-06-04 14:24  doudizhu\Assets\Fonts.meta
     文件     1848672  2018-06-04 14:12  doudizhu\Assets\Fonts\ygyxsziti2.0.ttf
     文件         490  2018-06-04 14:17  doudizhu\Assets\Fonts\ygyxsziti2.0.ttf.meta
     目录           0  2018-06-12 23:36  doudizhu\Assets\Resources\
     文件         191  2018-06-04 14:23  doudizhu\Assets\Resources.meta
............此处省略2700个文件信息

评论

共有 条评论