Esempio n. 1
0
    private void GotoMachine()
    {
        if (targetMachine != null)
        {
            //arcade.SetArcadeMachineAvailable(targetMachine);
            targetMachine = null;
        }

        targetMachine = arcade.GetRandomAvailableMachine();
        if (targetMachine != null)
        {
            if (money >= arcade.entryFee)
            {
                money -= arcade.entryFee;
                player.AddMoney(arcade.entryFee);
                agent.isStopped = false;
                if (!targetMachine.SetUser(this))
                {
                    GoToExit();
                }
                customerState     = CustomerState.MovingToMachine;
                agentTarget       = targetMachine.playingArea;
                agent.destination = agentTarget.position;
            }
            else
            {
                GoToExit();
            }
        }
        else
        {
            targetMachine = arcade.GetRandomOccupiedMachine();
            if (targetMachine != null)
            {
                if (!targetMachine.IsQueueFull())
                {
                    if (money >= arcade.entryFee)
                    {
                        money -= arcade.entryFee;
                        player.AddMoney(arcade.entryFee);
                        agent.isStopped = false;
                        if (!targetMachine.SetUser(this))
                        {
                            GoToExit();
                        }
                        customerState     = CustomerState.Idle;
                        agentTarget       = targetMachine.playingArea;
                        agent.destination = targetMachine.GetEndOfQueuePoint();
                    }
                    else
                    {
                        GoToExit();
                    }
                }
                else
                {
                    GoToExit();
                }
            }
            else
            {
                GoToExit();
            }
        }
    }