Ejemplo n.º 1
0
    public bool add(CardS card)
    {
        //Debug.Log(card.name);
        if (card == null)
        {
            return(false);
        }
        cards.Add(card);
        card.player    = this;
        card.scale     = transform.localScale.x;
        card.default_x = transform.position.x;
        card.y         = transform.position.y;
        card.default_y = transform.position.y;
        card.getCV().flush();
        for (int i = 0; i < cards.Count; i++)
        {
            cards[i].position = i;

            /*cards[i].SetLayer(-i);
             * Vector3 p = cards[i].transform.GetChild(0).transform.position;
             * cards[i].transform.GetChild(0).transform.position =
             *      new Vector3(p.x, p.y, cards[i].transform.position.z-0.5f);/**/
            cards[i].SetPosition();
        }
        return(true);
    }
Ejemplo n.º 2
0
 public void add(CardS card)
 {
     if (card == null)
     {
         return;
     }
     list.Add(card);
     card.player    = null;
     card.position  = 0;
     card.scale     = 0f;
     card.default_x = 0f;
     card.y         = 0f;
     card.default_y = 0f;
     card.SetLayer(0f);
     card.setVisible(false);
     card.x = transform.position.x;
     card.getCV().flush();
 }
Ejemplo n.º 3
0
 public void draw(CardS card)
 {
     if (card == null)
     {
         return;
     }
     temp        = card;
     card.player = this;
     card.getCV().flush();
     card.default_x = transform.position.x;
     card.y         = transform.position.y;
     card.default_y = transform.position.y;
     card.position  = cards.Count + 1;
     card.moveForTemp();
     card.scale = transform.localScale.x;
     for (int i = 0; i < cards.Count; i++)
     {
         cards[i].moveForTemp();
     }
 }
Ejemplo n.º 4
0
    public IEnumerator MouseEvent()
    {
        if (player.hasTemp() || (Count() == 0 && aPool.Count() == 0))
        {
            game.play(true);
            if (isWhite)
            {
                if (DaVinciS.keyCard != null && !DaVinciS.keyCard.getVisible())
                {
                    bool result = game.judge(player, true);
                    yield return(new WaitForSeconds(1));

                    if (!result)
                    {
                        game.turn();
                    }
                    else
                    {
                        DaVinciS.info.text = "轮到玩家猜牌";
                    }
                }
            }
            else
            {
                if (DaVinciS.keyCard != null && !DaVinciS.keyCard.getVisible())
                {
                    game.judge(player, false);
                    yield return(new WaitForSeconds(1));

                    game.turn();
                }
            }
        }
        else
        {
            game.play(false);
            CardS c = getRandom();
            if (c != null)
            {
                c.scale = player.transform.localScale.x;
                c.getCV().flush();
                Camera camera = Camera.main;
                if (camera)
                {
                    //转换对象到当前屏幕位置
                    Vector3 screenPosition = camera.WorldToScreenPoint(c.transform.position);
                    //鼠标屏幕坐标
                    Vector3 mScreenPosition;
                    //若鼠标左键一直按着则循环继续
                    while (Input.GetMouseButton(0))
                    {
                        //鼠标屏幕上新位置
                        mScreenPosition = new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenPosition.z);
                        // 对象新坐标
                        c.Drag(camera.ScreenToWorldPoint(mScreenPosition));
                        //协同,等待下一帧继续
                        yield return(new WaitForFixedUpdate());
                    }
                    c.StopDraging();
                    if (c.transform.position.y >= 0)
                    {
                        add(c);
                        c.Drag(transform.position);
                        c.scale = 0f;
                    }
                    else
                    {
                        player.draw(c);
                    }
                }
            }
        }
    }