コード例 #1
0
    /// <summary>
    /// 使卡牌精灵化
    /// </summary>
    /// <param name="type"></param>
    /// <param name="card"></param>
    /// <param name="selected"></param>
    void MakeSprite(CharacterType type, Card card, bool selected, int i)
    {
        Debug.Log(string.Format("MakeSprite11==={0}-{1}", card.GetCardSuit, card.GetCardWeight));

        if (!card.isSprite)
        {
            GameObject obj = Resources.Load <GameObject>(string.Format("poke_prefab/Poke_{0}_{1}", (int)card.GetCardSuit, (int)card.GetCardWeight)) as GameObject;
            // GameObject poker = NGUITools.AddChild(GameObject.Find(type.ToString()), obj);

            GameObject player = GameObject.Find(type.ToString());

            GameObject poker = Instantiate(obj);
            poker.transform.position = new Vector3(i * 25 - 200, 0, 0);
            poker.transform.SetParent(player.transform, false);


            CardSprite sprite = poker.AddComponent <CardSprite>();
            sprite.Poker  = card;
            sprite.Select = selected;

            Button pokebtn = poker.transform.Find("Button").gameObject.GetComponent <Button>();
//			pokebtn.name = string.Format("pokebtn_{0}_{1}",card.GetCardSuit, card.GetCardWeight);
//			pokeflag.Add(pokebtn.name, false);
//			pokebtn.onClick.AddListener(delegate() {
//				this.OnPokeClick(pokebtn);
//			});

//            CardSprite sprite = poker.gameObject.GetComponent<CardSprite>();
//            sprite.Poker = card;
//            sprite.Select = selected;
        }
    }
コード例 #2
0
ファイル: CPlayer.cs プロジェクト: aaaa9813/ww_ddz_client
    public void SetTablePai(int[] pai, int num)
    {
        ClearTable();
        //保存当前出的牌,以便清除
        m_nPaiNum = num;
        m_nPai    = pai;

        //m_bflash = true;
        //m_nPai = pai;
        //m_nPaiNum = num;

        //DeskCardsCache.Instance.Clear();
        //for (int i = 0; i < m_nPaiNum; i++)
        //{
        //    DeskCardsCache.Instance.AddCard(m_Cardlist[i]);
        //}


        GameObject deskobj = GameObject.Find("Desk");
        Transform  desktf  = deskobj.transform;


        List <Card>       tmpcard       = new List <Card>();
        List <CardSprite> tmpcardsprite = new List <CardSprite>();

        for (int i = 0; i < num; i++)
        {
            if (!m_Pokerlist.ContainsKey(pai[i]))
            {
                Debug.LogError(string.Format("SetTablePai, pai id:[{0}] is error", pai[i]));
                continue;
            }
            CardSprite cp = m_Pokerlist[pai[i]].GetComponent <CardSprite>();

            tmpcardsprite.Add(cp);
            tmpcard.Add(cp.Poker);

            cp.Poker.Attribution = CharacterType.Desk;
            cp.transform.SetParent(desktf);

            cp.transform.localScale = new Vector3(1, 1, 1);

            m_Pokerlist[pai[i]].SetActive(true);
        }

        //排序所出的牌
        CardRules.SortCards(tmpcard, true);
        for (int i = 0; i < tmpcard.Count; i++)
        {
            for (int j = 0; j < tmpcardsprite.Count; j++)
            {
                if (tmpcardsprite[j].Poker == tmpcard[i])
                {
                    tmpcardsprite[j].GoToPosition(deskobj, i);
                }
            }
        }
    }
コード例 #3
0
    void Start()
    {
        CardLoader.loadCards();

        shuffledCards = new List <Card>(CardLoader.deckBang);
        Shuffle(shuffledCards);

        sprite = gameObject.GetComponent <CardSprite>();
    }
コード例 #4
0
 /// <summary>
 /// 使卡牌精灵化
 /// </summary>
 /// <param name="type"></param>
 /// <param name="card"></param>
 /// <param name="selected"></param>
 void MakeSprite(CharacterType type, Card card, bool selected)
 {
     if (!card.isSprite)
     {
         GameObject obj    = Resources.Load("poker") as GameObject;
         GameObject poker  = NGUITools.AddChild(GameObject.Find(type.ToString()), obj);
         CardSprite sprite = poker.gameObject.GetComponent <CardSprite>();
         sprite.Poker  = card;
         sprite.Select = selected;
     }
 }
コード例 #5
0
 private void RetrieveAssets()
 {
     unlocked = Resources.LoadAll <Sprite>(unlockedPath);
     locked   = Resources.LoadAll <Sprite>(lockedPath);
     for (int i = 0; i < unlocked.Length; i++)
     {
         var sprite = new CardSprite();
         sprite.unlocked = unlocked[i];
         sprite.locked   = locked[i];
         sprites.Add(sprite);
     }
 }
コード例 #6
0
ファイル: CPlayer.cs プロジェクト: aaaa9813/ww_ddz_client
    public void SetDiPai(int[] pai, int num)
    {
        //clear di pai
        m_nPaiNum = 0;

        GameObject deskobj = GameObject.Find("Player");
        Transform  desktf  = deskobj.transform;

        CUser me = m_UserlistById[CPlayer.Instance().m_nUid];

        //  pai.CopyTo(me.m_nPai, 17);



        for (int i = 0; i < 3; i++)
        {
            me.m_nPai.Add(pai[i]);
        }

        List <Card>       tmpcard       = new List <Card>();
        List <CardSprite> tmpcardsprite = new List <CardSprite>();

        for (int i = 0; i < me.m_nPai.Count; i++)
        {
            CardSprite cp = m_Pokerlist[me.m_nPai[i]].GetComponent <CardSprite>();


            tmpcardsprite.Add(cp);
            tmpcard.Add(cp.Poker);


            cp.SetActvie(true);
            cp.Poker.Attribution = CharacterType.Player;
            cp.transform.SetParent(desktf);

            cp.transform.localScale = new Vector3(1, 1, 1);
            m_Pokerlist[me.m_nPai[i]].SetActive(true);
        }

        CardRules.SortCards(tmpcard, true);
        for (int i = 0; i < tmpcard.Count; i++)
        {
            for (int j = 0; j < tmpcardsprite.Count; j++)
            {
                if (tmpcardsprite[j].Poker == tmpcard[i])
                {
                    tmpcardsprite[j].GoToPosition(deskobj, i);
                }
            }
        }
    }
コード例 #7
0
    /// <summary>
    /// 销毁精灵
    /// </summary>
    public void DestroyAllSprites()
    {
        CardSprite[][] cardSprites = new CardSprite[3][];
        cardSprites[0] = GameObject.Find("Player").GetComponentsInChildren <CardSprite>();
        cardSprites[1] = GameObject.Find("ComputerOne").GetComponentsInChildren <CardSprite>();
        cardSprites[2] = GameObject.Find("ComputerTwo").GetComponentsInChildren <CardSprite>();

        for (int i = 0; i < cardSprites.GetLength(0); i++)
        {
            for (int j = 0; j < cardSprites[i].Length; j++)
            {
                cardSprites[i][j].Destroy();
            }
        }
    }
コード例 #8
0
    CardSprite MakeCardPrefab(int vID)
    {
        vID %= Card.Count;                                    //clamp
        GameObject    tGO = new GameObject();                 //Make new game Object
        CardSprite    tCR = tGO.AddComponent <CardSprite> (); //Add Card to it and store in array
        BoxCollider2D tBC = tGO.AddComponent <BoxCollider2D> ();

        tCR.mSR        = tGO.gameObject.AddComponent <SpriteRenderer> ();
        tCR.mSR.sprite = sSpritesBack;          //Initally show back
        tBC.size       = tCR.mSR.sprite.bounds.size;
        tCR.mCard      = new Card(vID);         //Make new card up
        tCR.Show       = false;                 //Show back of card
        tGO.name       = tCR.mCard.ToString();  //Name GameObject
        return(tCR);
    }
コード例 #9
0
 /// <summary>
 /// 使卡牌精灵化
 /// </summary>
 /// <param name="type"></param>
 /// <param name="card"></param>
 /// <param name="selected"></param>
 void MakeSprite(CharacterType type, Card card, bool selected)
 {
     if (!card.isSprite)
     {
         var poker = Resources.Load("Poker") as GameObject;
         var obj   = GameObject.Instantiate(poker);
         obj.transform.localPosition    = Vector3.zero;
         obj.transform.localEulerAngles = Vector3.zero;
         obj.transform.localScale       = Vector3.one;
         obj.transform.SetParent(GameObject.Find(type.ToString()).transform.Find("StartPoint").transform, false);  //需要设置相对坐标系,否则这句放到前面写去
         CardSprite sprite = obj.gameObject.GetComponent <CardSprite>();
         sprite.Poker  = card;
         sprite.Select = selected;
     }
 }
コード例 #10
0
ファイル: BangDeck.cs プロジェクト: salvoilmiosi/bangcardgame
    // Start is called before the first frame update
    void Start()
    {
        CardLoader.loadCards();

        List <Card> shuffledCards = new List <Card>(CardLoader.deckBang);

        DeckShuffler.Shuffle(shuffledCards);

        float z = 0.0f;

        foreach (Card card in shuffledCards)
        {
            GameObject obj = Instantiate(cardPrefab);
            obj.transform.parent   = transform;
            obj.transform.position = new Vector3(0.0f, 0.0f, z);
            CardSprite cardSprite = obj.GetComponent <CardSprite>();
            cardSprite.card = card;
            z += 0.5f;
        }
    }
コード例 #11
0
ファイル: CPlayer.cs プロジェクト: aaaa9813/ww_ddz_client
    public void SetPlayerPai(int[] pai, int num)
    {
        GameObject deskobj = GameObject.Find("Player");
        Transform  desktf  = deskobj.transform;


        List <Card>       tmpcard       = new List <Card>();
        List <CardSprite> tmpcardsprite = new List <CardSprite>();

        for (int i = 0; i < num; i++)
        {
            m_UserlistById[CPlayer.Instance().m_nUid].m_nPai[i] = pai[i];
            if (!m_Pokerlist.ContainsKey(pai[i]))
            {
                Debug.LogError(string.Format("SetTablePai, pai id:[{0}] is error", pai[i]));
                continue;
            }
            CardSprite cp = m_Pokerlist[pai[i]].GetComponent <CardSprite>();


            tmpcardsprite.Add(cp);
            tmpcard.Add(cp.Poker);

            cp.Poker.Attribution = CharacterType.Player;
            cp.transform.SetParent(desktf);
            cp.transform.localScale = new Vector3(1, 1, 1);
            m_Pokerlist[pai[i]].SetActive(true);
        }

        CardRules.SortCards(tmpcard, true);
        for (int i = 0; i < tmpcard.Count; i++)
        {
            for (int j = 0; j < tmpcardsprite.Count; j++)
            {
                if (tmpcardsprite[j].Poker == tmpcard[i])
                {
                    tmpcardsprite[j].GoToPosition(deskobj, i);
                }
            }
        }
    }
コード例 #12
0
ファイル: CDDZTable.cs プロジェクト: gamemans/ddz_client
        public void SetTablePai(int[] pai, int num)
        {
            ClearTable();
            //保存当前出的牌,以便清除
            m_nPaiNum = num;
            m_nPai    = pai;

            //m_bflash = true;
            //m_nPai = pai;
            m_nPaiNum = num;

            //DeskCardsCache.Instance.Clear();
            //for (int i = 0; i < m_nPaiNum; i++)
            //{
            //    DeskCardsCache.Instance.AddCard(m_Cardlist[i]);
            //}

            List <CardSprite> selectedSpriteList = new List <CardSprite>();

            GameObject deskobj = GameObject.Find("Desk");
            Transform  desktf  = deskobj.transform;

            for (int i = 0; i < num; i++)
            {
                if (!m_Pokerlist.ContainsKey(pai[i]))
                {
                    Debug.LogError(string.Format("SetTablePai, pai id:[{0}] is error", pai[i]));
                    continue;
                }
                CardSprite cp = m_Pokerlist[pai[i]].GetComponent <CardSprite>();
                cp.transform.localScale = new Vector3(1, 1, 1);
                cp.transform.SetParent(desktf);
                cp.transform.localScale = new Vector3(1, 1, 1);
                m_Pokerlist[pai[i]].SetActive(true);
                cp.GoToPosition(deskobj, i);
            }
        }
コード例 #13
0
 public void AddSprite(CardSprite sprite)
 {
     sprites.Add(sprite);
 }
コード例 #14
0
ファイル: CPlayer.cs プロジェクト: aaaa9813/ww_ddz_client
    CTable()
    {
        m_nPai = null;

        m_nDipai = new int[3];

        m_nPaiNum = 0;

        m_nChupaiUserId = -1;


        m_UserlistById = new Dictionary <int, CUser>();
        m_Cardlist     = new Dictionary <int, Card>();
        m_Pokerlist    = new Dictionary <int, GameObject>();
        m_bflash       = false;
        m_Sprite       = null;
        int i = 0;

        GameObject pokeobj, poker;

        //创建普通扑克
        for (int color = 0; color < 4; color++)
        {
            for (int value = 0; value < 13; value++)
            {
                i++;
                Weight w    = (Weight)value;
                Suits  s    = (Suits)color;
                string name = string.Format("Poke_{0}_{1}", color, value);
                Card   card = new Card(name, w, s, CharacterType.Desk, (value + 2) % 13 + 1 + color * 13);
                m_Cardlist[card.GetId] = card;

                pokeobj = Resources.Load <GameObject>(string.Format("poke_prefab/Poke_{0}_{1}", (int)card.GetCardSuit, (int)card.GetCardWeight)) as GameObject;
                poker   = Instantiate(pokeobj);

                m_Sprite       = poker.AddComponent <CardSprite>();
                m_Sprite.Poker = card;

                m_Pokerlist[card.GetId] = poker;
            }
        }
        Card smallJoker = new Card("Poke_4_13", Weight.SJoker, Suits.None, CharacterType.Desk, 53);
        Card largeJoker = new Card("Poke_4_14", Weight.LJoker, Suits.None, CharacterType.Desk, 54);

        m_Cardlist[smallJoker.GetId] = smallJoker;
        m_Cardlist[largeJoker.GetId] = largeJoker;

        pokeobj = Resources.Load <GameObject>(string.Format("poke_prefab/Poke_{0}_{1}", (int)smallJoker.GetCardSuit, (int)smallJoker.GetCardWeight)) as GameObject;
        poker   = Instantiate(pokeobj);

        m_Sprite       = poker.AddComponent <CardSprite>();
        m_Sprite.Poker = smallJoker;

        m_Pokerlist[smallJoker.GetId] = poker;



        pokeobj = Resources.Load <GameObject>(string.Format("poke_prefab/Poke_{0}_{1}", (int)largeJoker.GetCardSuit, (int)largeJoker.GetCardWeight)) as GameObject;
        poker   = Instantiate(pokeobj);

        m_Sprite       = poker.AddComponent <CardSprite>();
        m_Sprite.Poker = largeJoker;
        m_Pokerlist[largeJoker.GetId] = poker;
    }
コード例 #15
0
ファイル: SpriteManager.cs プロジェクト: v1996-96/fool
        public void ResetCardsOnWindow(List<Card> cardList)
        {
            _cardUIList = new List<CardUI> { };
            _cardSpriteList = new List<CardSprite> { };

            cardList.ForEach((card) =>
            {
                var c = new CardSprite(
                    _backSprite,
                    Vector2.Zero,
                    new Point(SpriteFrameWidth, SpriteFrameHeight),
                    Point.Zero,
                    0,
                    CardResizeIndex
                );
                c.Card = new CardUI
                {
                    CardPosition = CardPosition.Deck,
                    CardType = card.CardType,
                    CardSuit = card.CardSuit,
                    Index = 0
                };
                _cardSpriteList.Add(c);
            });

            CreateButtons(ButtonType.Pass);

            _buttonSprite.OnHover += () =>
            {
                if (_buttonSprite.ButtonType == ButtonType.Pass)
                    ResetButtons(ButtonType.PassHovered);

                if (_buttonSprite.ButtonType == ButtonType.GetAll)
                    ResetButtons(ButtonType.GetAllHovered);
            };

            _buttonSprite.OnUnHover += () =>
            {
                if (_buttonSprite.ButtonType == ButtonType.PassHovered)
                    ResetButtons(ButtonType.Pass);

                if (_buttonSprite.ButtonType == ButtonType.GetAllHovered)
                    ResetButtons(ButtonType.GetAll);
            };

            _buttonSprite.OnClick += () =>
            {
                if (OnGameButtonClicked != null)
                {
                    OnGameButtonClicked(_buttonSprite.ButtonType);
                }
            };

            ShowCards = false;
        }
コード例 #16
0
ファイル: SpriteManager.cs プロジェクト: v1996-96/fool
        public void ResetCardsOnWindow(List <Card> cardList)
        {
            _cardUIList     = new List <CardUI> {
            };
            _cardSpriteList = new List <CardSprite> {
            };

            cardList.ForEach((card) =>
            {
                var c = new CardSprite(
                    _backSprite,
                    Vector2.Zero,
                    new Point(SpriteFrameWidth, SpriteFrameHeight),
                    Point.Zero,
                    0,
                    CardResizeIndex
                    );
                c.Card = new CardUI
                {
                    CardPosition = CardPosition.Deck,
                    CardType     = card.CardType,
                    CardSuit     = card.CardSuit,
                    Index        = 0
                };
                _cardSpriteList.Add(c);
            });

            CreateButtons(ButtonType.Pass);

            _buttonSprite.OnHover += () =>
            {
                if (_buttonSprite.ButtonType == ButtonType.Pass)
                {
                    ResetButtons(ButtonType.PassHovered);
                }

                if (_buttonSprite.ButtonType == ButtonType.GetAll)
                {
                    ResetButtons(ButtonType.GetAllHovered);
                }
            };

            _buttonSprite.OnUnHover += () =>
            {
                if (_buttonSprite.ButtonType == ButtonType.PassHovered)
                {
                    ResetButtons(ButtonType.Pass);
                }

                if (_buttonSprite.ButtonType == ButtonType.GetAllHovered)
                {
                    ResetButtons(ButtonType.GetAll);
                }
            };

            _buttonSprite.OnClick += () =>
            {
                if (OnGameButtonClicked != null)
                {
                    OnGameButtonClicked(_buttonSprite.ButtonType);
                }
            };

            ShowCards = false;
        }