コード例 #1
0
ファイル: PinSetter.cs プロジェクト: ChloeLiang/bowlmaster
    void PinsHaveSettled()
    {
        int standing = CountStanding();
        int pinFall  = lastSettledCount - standing;

        lastSettledCount = standing;

        ActionMaster.Action action = actionMaster.Bowl(pinFall);
        if (action == ActionMaster.Action.Tidy)
        {
            animator.SetTrigger("tidyTrigger");
        }
        else if (action == ActionMaster.Action.EndTurn)
        {
            animator.SetTrigger("resetTrigger");
            lastSettledCount = 10;
        }
        else if (action == ActionMaster.Action.Reset)
        {
            animator.SetTrigger("resetTrigger");
            lastSettledCount = 10;
        }
        else if (action == ActionMaster.Action.EndGame)
        {
            throw new UnityException("Don't know how to handle end game yet");
        }

        ball.Reset();
        lastStandingCount     = -1;     // Indicates pins have settled, and ball not back in box
        ballOutOfPlay         = false;
        standingDisplay.color = Color.green;
    }
コード例 #2
0
ファイル: PinSetter.cs プロジェクト: jordondueck/space-bowls
    public void ActionMasterHandler()
    {
        int pinsFallen = lastSettledCount - CountStanding();

        lastSettledCount = CountStanding();

        Debug.Log("Pins knocked down: " + pinsFallen);

        ActionMaster.Action action = actionMaster.Bowl(pinsFallen);
        Debug.Log(action);

        if (action == ActionMaster.Action.Tidy)
        {
            animator.SetTrigger("tidyTrigger");
        }
        else if (action == ActionMaster.Action.Reset)
        {
            animator.SetTrigger("resetTrigger");
            lastSettledCount = 10;
        }
        else if (action == ActionMaster.Action.EndTurn)
        {
            animator.SetTrigger("resetTrigger");
            lastSettledCount = 10;
        }
        else if (action == ActionMaster.Action.EndGame)
        {
            throw new UnityException("End game action not set.");
        }
    }
コード例 #3
0
ファイル: PinSetter.cs プロジェクト: Preshecan/Bowling-Game
    public void StateActions()
    {
        ActionMaster.Action action = actionMaster.Bowl(CountFallenPins());
        Debug.Log(action);


        if (action == ActionMaster.Action.Tidy)
        {
            animator.SetTrigger("tidyTrigger");
        }
        else if (action == ActionMaster.Action.EndTurn)
        {
            animator.SetTrigger("resetTrigger");
            lastSettledCount = 10;
        }
        else if (action == ActionMaster.Action.Reset)
        {
            animator.SetTrigger("resetTrigger");
            lastSettledCount = 10;
        }
        else if (action == ActionMaster.Action.EndGame)
        {
            throw new UnityException("Don't know how to handle end-game yet");
        }
    }
コード例 #4
0
    void PinsHaveSettled()
    {
        int pinsFallen = lastSettledCount - CountStanding();

        lastSettledCount = CountStanding();

        lastStandingCount = -1; // indicate pins have settled
        ballExitedLane    = false;
        text.color        = Color.cyan;
        ball.Reset();

        ActionMaster.BowlAction whatToDo = actionMaster.Bowl(pinsFallen);

        switch (whatToDo)
        {
        case (ActionMaster.BowlAction.Tidy):
            TidyPins();
            break;

        case (ActionMaster.BowlAction.EndTurn):
        case (ActionMaster.BowlAction.Reset):
            RenewPins();
            break;

        case (ActionMaster.BowlAction.EndGame):
            throw new UnityException("dont know how to end game yet");
        }
    }
コード例 #5
0
    void PinsHaveSettled()
    {
        int pinFall = lastSettledCount - CountStanding();

        lastSettledCount = CountStanding();

        ActionMaster.Action action = actionMaster.Bowl(pinFall);
        Debug.Log("You just hit: " + pinFall + " pins." + "    Current action: " + action);

        if (action == ActionMaster.Action.Tidy)
        {
            animator.SetTrigger("tidyTrigger");
        }
        else if (action == ActionMaster.Action.EndTurn)
        {
            animator.SetTrigger("resetTrigger");
            lastSettledCount = 10;
        }
        else if (action == ActionMaster.Action.Reset)
        {
            animator.SetTrigger("resetTrigger");
            lastSettledCount = 10;
        }
        else if (action == ActionMaster.Action.EndGame)
        {
            throw new UnityException("Still thinking how to handle End Game.");
        }

        ball.Reset();
        lastStandingCount     = -1;
        ballOutOfPlay         = false;
        standingDisplay.color = Color.green;
    }
コード例 #6
0
ファイル: PinSetter.cs プロジェクト: pingevt/bowlmaster
    void PinsHaveSettled()
    {
        int pinFall = lastSettledCount - CountStanding();

        lastSettledCount = CountStanding();

        ActionMaster.Action action = actionMaster.Bowl(pinFall);
        Debug.Log("pinFall: " + pinFall + " Action: " + action);

        if (action == ActionMaster.Action.Tidy)
        {
            animator.SetTrigger("tidyTrigger");
        }
        else if (action == ActionMaster.Action.EndTurn || action == ActionMaster.Action.Reset)
        {
            lastSettledCount = 10;
            animator.SetTrigger("resetTrigger");
        }
        else if (action == ActionMaster.Action.EndGame)
        {
            throw new UnityException("Don't know how to handle end game yet");
        }

        ball.Reset();
        lastStandingCount     = -1;     // Indicates opins have settled
        ballOutOfPlay         = false;
        standingDisplay.color = Color.green;
    }
コード例 #7
0
ファイル: ActionMaster.cs プロジェクト: rehan303/Bowlmaster
    public static Action NextAction(List<int> pinFalls)
    {
        ActionMaster am = new ActionMaster();
        Action currentAction = new Action();

        foreach (int pinFall in pinFalls) {
            currentAction =  am.Bowl(pinFall);
        }

        return currentAction;
    }
コード例 #8
0
    //takes list of previous pinfalls and returns next action
    //static so can be called directly from the class
    public static Action NextAction(List <int> pinFalls)
    {
        ActionMaster am            = new ActionMaster();
        Action       currentAction = new Action();

        foreach (int pinFall in pinFalls)
        {
            currentAction = am.Bowl(pinFall);
        }
        return(currentAction);
    }
コード例 #9
0
    private int bowl    = 1; //丟出保齡球的次數

    public static Action NextAction(List <int> pinFalls)
    {
        ActionMaster actionMaster = new ActionMaster();
        Action       nextAction   = new Action();

        foreach (int pinFall in pinFalls)
        {
            nextAction = actionMaster.Bowl(pinFall);
        }
        return(nextAction);
    }
コード例 #10
0
ファイル: ActionMaster.cs プロジェクト: a-suniala/BowlMaster
    public static ActionState NextAction(List<int> pinFalls)
    {
        ActionMaster actionMaster = new ActionMaster();
        ActionState currentAction = new ActionState();

        foreach (int pinFall in pinFalls) {
            currentAction = actionMaster.Bowl (pinFall);
        }

        return currentAction;
    }
コード例 #11
0
 public void T04FinalFrameStrikeGrantsTwoExtraTurns(){
     foreach (int i in Enumerable.Range(0, 20)) {
         if (i == 19){
             Assert.AreEqual(reset, actionMaster.Bowl(10));
             Assert.AreEqual(tidy, actionMaster.Bowl(3));
             Assert.AreEqual(endGame, actionMaster.Bowl(3));
         }else {
             actionMaster.Bowl(3);
         }
     } // foreach (int i in Enumerable.Range(0, 20)) {
     actionMaster = new ActionMaster();
     foreach (int i in Enumerable.Range(0, 20)) {
         if (i == 19){
             Assert.AreEqual(reset, actionMaster.Bowl(10));
             Assert.AreEqual(reset, actionMaster.Bowl(10));
             Assert.AreEqual(endGame, actionMaster.Bowl(10));
         }else {
             actionMaster.Bowl(3);
         }
     } // foreach (int i in Enumerable.Range(0, 20)) {
 } // public void T04FinalFrameStrikeGrantsTwoExtraTurns(){
コード例 #12
0
    public static Action NextAction(List <int> pinsFall)
    {
        ActionMaster actionMaster = new ActionMaster();
        Action       result       = new Action();

        foreach (int pins in pinsFall)
        {
            result = actionMaster.Bowl(pins);
        }

        return(result);
    }
コード例 #13
0
    // and now you're thinking with portals
    // so this is how you recycle code instead of redoing everything from scratch
    public static Action NextAction(List <int> pinFalls)
    {
        ActionMaster am            = new ActionMaster(); // instantiate new ActionMaster and currentAction, so don't f**k with numbers
        Action       currentAction = new Action();

        foreach (int pin in pinFalls)
        {
            currentAction = am.Bowl(pin); // cycle and loop Bowl(), until the last action is received
        }

        return(currentAction);
    }
コード例 #14
0
ファイル: PinSetter.cs プロジェクト: aRvBfan/Bowlmaster
    private void PinsHaveSettled()
    {
        int standing = CountStanding();
        int pinFall  = lastSettleCount - standing;

        lastSettleCount = standing;

        ActionMaster.Action action = actionMaster.Bowl(pinFall);

        HandleAction(action);
        Debug.Log("Pinfall: " + pinFall + " " + action);

        ball.Reset();
        lastStandingCount     = -1; //indicates pins have settled, and ball not back in box
        ballLeftBox           = false;
        standingDisplay.color = Color.green;
    }
コード例 #15
0
    public static Action NextAction(List <int> pinFalls)
    {
        //takes a list of pinFalls from GameManager and returns the next action
        //I guess then we need to get the latest pinFall from the list

        Action       lastActionReturned = new Action();
        ActionMaster staticActionMaster = new ActionMaster();

        int county = 0;

        foreach (int pinFall in pinFalls)
        {
            lastActionReturned = staticActionMaster.Bowl(pinFall, pinFalls);
            Debug.Log("Pinfall index of " + county + " with pinfall " + pinFall + " gave action of " + lastActionReturned);
            county++;
        }

        return(lastActionReturned);
    }
コード例 #16
0
    void PinsHaveSettled()
    {
        ball.Reset();
        standingPinsText.color = Color.green;
        lastSettledCount      -= CountStanding();
        ActionMaster.Action action = actionMaster.Bowl(lastSettledCount);
        Debug.Log(action + " " + lastSettledCount);
        if (action.Equals(ActionMaster.Action.TIDY))
        {
            animator.SetTrigger("tidyTrigger");
        }
        else
        {
            lastSettledCount = 10;
            animator.SetTrigger("resetTrigger");
        }

        lastStandingCount = -1;
        ballLeftBox       = false;
    }
コード例 #17
0
ファイル: PinSetter.cs プロジェクト: fargum/test
    void PinsHaveSettled()
    {
        int countStanding = CountStanding();
        int pinFall       = lastSettledCount - countStanding;

        lastSettledCount = countStanding;
        var action = actionMaster.Bowl(pinFall);

        if (action == ActionMaster.BowlResult.Tidy)
        {
            animator.SetTrigger("TidyTrigger");
        }
        else if (action == ActionMaster.BowlResult.EndTurn)
        {
            animator.SetTrigger("resetTrigger");
            lastSettledCount = 10;
        }

        ball.Reset();
        LastStandingCount = -1;
        BallLeftBox       = false;
        TextCount.color   = Color.green;
    }
コード例 #18
0
 public void T01OneStrikeReturnsEndTurn()
 {
     Assert.AreEqual(endTurn, actionMaster.Bowl(10));
 }
コード例 #19
0
 public void T01BowlNotTenReturnsTidy(){
     foreach (int i in Enumerable.Range(0, 9)){
         actionMaster = new ActionMaster();
         Assert.AreEqual(tidy, actionMaster.Bowl(i));
     }
 }
コード例 #20
0
 public void T00InvalidPinCount()
 {
     Assert.Throws <UnityException>(() => actionMaster.Bowl(-1));
 }
コード例 #21
0
 public void T01SingleStrikeEndsTurn()
 {
     Assert.AreEqual(endTurn, actionMaster.Bowl(10));
 }
コード例 #22
0
 public void T01OneStrikereturnsEndTurn()
 {
     Assert.AreEqual(endturn, a.Bowl(10));
 }
コード例 #23
0
 public void TestBowlStrikeEndsTurn()
 {
     ActionMaster.BowlResult result = actionMaster.Bowl(10);
     Assert.AreEqual(ActionMaster.BowlResult.EndTurn, result);
 }