Exemple #1
0
        public override void Action(Player player, GameMaster gm, Board board)
        {
            base.Action(player, gm, board);

            if (player.IsInJail)
            {
                View.PrintPlayerIsInJailSince(player);
                if (player.NbTurnInJail < 3 && player.NbTurnInJail != -1)
                {
                    int roll1 = gm.Dice1.Roll();
                    int roll2 = gm.Dice2.Roll();

                    View.PrintRollResults(roll1, roll2);

                    if (roll1 == roll2)
                    {
                        View.PrintPlayerOutJail(roll1 == roll2);
                        player.NbTurnInJail = -1;
                        player.IsInJail     = false;
                        Tile currentTile = board.Move(player, roll1 + roll2);
                        currentTile.Action(player, gm, board);
                    }
                    else
                    {
                        player.NbTurnInJail++;
                    }
                }
                else
                {
                    View.PrintPlayerOutJail(false);
                    int roll1 = gm.Dice1.Roll();
                    int roll2 = gm.Dice2.Roll();
                    View.PrintRollResults(roll1, roll2);

                    player.NbTurnInJail = -1;
                    player.IsInJail     = false;
                    Tile currentTile = board.Move(player, roll1 + roll2);
                    currentTile.Action(player, gm, board);
                }
            }
            else
            {
                View.PrintJailVisitOnly();
            }
        }
    private void ActionCheck(Tile t)
    {
        if (!actionPerformed && holdTimer >= decayTime)
        {
            Vector3 toPillar = pullPoint - transform.position;
            float   angle    = Vector3.Angle(lastDirToPillar, toPillar);
            deltaAngle     += angle;
            lastDirToPillar = toPillar;

            if (deltaAngle > 480)
            {
                rb.AddForce(rb.velocity * -Acceleration / 4, ForceMode.Acceleration);
                if (deltaAngle > 480 * 1.5)//(toPillar.magnitude <= 1)
                {
                    rb.AddForce(toPillar * Acceleration, ForceMode.Acceleration);
                    deltaAngleAction += angle;
                    if (deltaAngleAction > 360)
                    {
                        //print("player performed action");
                        actionPerformed = true;
                        if (!t.Action(this))
                        {
                            if (Inventory.IsEmpty())
                            {
                                GetTile(t);
                            }
                            else
                            {
                                PlaceTileOnTop(t);
                            }
                        }
                    }
                }
                else
                {
                    rb.AddForce(toPillar.normalized * Acceleration / 2, ForceMode.Acceleration);
                }
            }
        }
    }