예제 #1
0
 public IEnumerator MouseEvent()
 {
     if (player == null)
     {
         yield break;
     }
     Collider2D[] col;
     while (Input.GetMouseButton(0))
     {
         col = Physics2D.OverlapPointAll(Camera.main.ScreenToWorldPoint(Input.mousePosition));
         if (col.Length > 0 && col[0].name == name)
         {
             select();
         }
         else
         {
             deselect();
         }
         yield return(null);
     }
     col = Physics2D.OverlapPointAll(Camera.main.ScreenToWorldPoint(Input.mousePosition));
     if (col.Length > 0 && col[0].name == name)
     {
         if (player.name == "player")
         {
             DaVinciS.info.text = name;
         }
         else
         {
             if (visible)
             {
                 DaVinciS.info.text = name;
             }
             else
             {
                 i += 1;
                 if (i == 14)
                 {
                     i = 0;
                 }
                 DaVinciS.info.text = "目标" + player.name + ",猜测值:" + i;
                 DaVinciS.setKeyCard(this);
             }
         }
     }
 }
예제 #2
0
    public IEnumerator move()
    {
        int cnt = 0;

        while (game.isPlaying())
        {
            if (!game.inGame(i))
            {
                takeTurn();
                if (!game.inGame(i))
                {
                    StartCoroutine(game.gameOver());
                    yield break;
                }
                cnt++;
                if (cnt >= role.Length - 1)
                {
                    break;
                }
            }
            bool isWhite = decideColor(i, o);
            if (pool[isWhite?0:1].Count() == 0)
            {
                isWhite = !isWhite;
            }
            if (pool[isWhite?0:1].Count() != 0)
            {
                role[i].draw(pool[isWhite?0:1].getRandom());
            }
            DaVinciS.info.text = "轮到" + role[i].name + "猜牌";
            yield return(new WaitForSeconds(1f));

            int p      = decidePlayer(i, o, isWhite) ? 0 : o,
                cindex = decideTarget(p, isWhite);
            if (cindex < 0)
            {
                isWhite = !isWhite;
                p       = decidePlayer(i, o, isWhite) ? 0 : o;
                cindex  = decideTarget(p, isWhite);
            }
            CardS c = role[p].getCard(cindex);
            DaVinciS.setKeyCard(c);
            int gs = decideGuess(p, cindex, isWhite);
            c.setI(gs);
            DaVinciS.info.text = role[i].name + "目标" + role[p].name + ",猜测值:" + gs;
            yield return(new WaitForSeconds(2f));

            if (!game.judge(role[i], true))
            {
                takeTurn();
                if (!game.inGame(i))
                {
                    if (game.inGame(0))
                    {
                        game.turn();
                    }
                    else
                    {
                        StartCoroutine(game.gameOver());
                    }
                    yield break;
                }
                cnt++;
                if (cnt >= role.Length - 1)
                {
                    yield return(new WaitForSeconds(1));

                    break;
                }
            }
            else if (!game.isPlaying())
            {
                StartCoroutine(game.gameOver());
                yield break;
            }
            yield return(new WaitForSeconds(1));
        }
        game.turn();
    }