예제 #1
0
파일: GamePlay.cs 프로젝트: Olehadash/Nards
    public void EndStep(int def)
    {
        checkifAllAtHome();

        if (dicecontroller.isItCuch())
        {
            List <Dice> dices = new List <Dice>();
            dices.Add(BoardBuilder.dice_1);
            dices.Add(BoardBuilder.dice_2);
            dices.Add(BoardBuilder.dice_3);
            dices.Add(BoardBuilder.dice_4);
            int i, ii, j = 0, jj = 0;
            for (i = 0; i < dices.Count; i++)
            {
                if (dices[i].Value != 0)
                {
                    j++;
                    if (dices[i].Value * j == def)
                    {
                        for (ii = 0; ii < dices.Count; ii++)
                        {
                            if (dices[ii].Value != 0)
                            {
                                jj++;
                                dices[ii].SetAlpha();
                                dices[ii].Value = 0;
                            }
                            if (jj == j)
                            {
                                break;
                            }
                        }
                        break;
                    }
                }
            }
            if (BoardBuilder.dice_1.Value + BoardBuilder.dice_2.Value + BoardBuilder.dice_3.Value + BoardBuilder.dice_4.Value == 0)
            {
                SwitchTurn();
                return;
            }
        }
        else
        {
            if (BoardBuilder.dice_1.Value == def)
            {
                BoardBuilder.dice_1.SetAlpha();
                BoardBuilder.dice_1.Value = 0;
            }
            else if (BoardBuilder.dice_2.Value == def)
            {
                BoardBuilder.dice_2.SetAlpha();
                BoardBuilder.dice_2.Value = 0;
            }
            else if ((BoardBuilder.dice_1.Value + BoardBuilder.dice_2.Value == def))
            {
                BoardBuilder.dice_1.Value = 0;
                BoardBuilder.dice_2.Value = 0;
            }
            if (BoardBuilder.dice_1.Value + BoardBuilder.dice_2.Value == 0)
            {
                SwitchTurn();
                return;
            }
        }
        //Debug.Log("Step Finished by dice value " + def.ToString());
        if (autoPlayer.ISAnamyStep())
        {
            anamy = true;
        }
        StartCoroutine("WaitAndCheck");
    }