private int bowl = 1; // one, becouse it is first ball in this round public static Action NextAction(List <int> pinFalls) { ActionMaster2 am = new ActionMaster2(); Action currentAction = new Action(); foreach (int pinFall in pinFalls) { currentAction = am.Bowl(pinFall); } return(currentAction); }
public void Bowl(int pinFall) { pinFalls.Add(pinFall); ActionMaster2.Action nextAction = ActionMaster2.NextAction(pinFalls); pinSetter.PerformAction(nextAction); try { scoreDisplay.FillRolls(pinFalls); scoreDisplay.FillFrames(ScoreMaster.ScoreCumulative(pinFalls)); } catch { Debug.LogWarning("Something went wrong in Bowl()"); } ball.Reset(); dragLaunch.Reset(); }
///////////////////////////////////////////////////////////////////////////////////////////// void PinsHaveSettled() { int pinsNotStanding = lastSettledCount - PinCounter.amountPinsStanding(); //gets the amount of pins fell (reminder that lastSettledCount equals 10 at this point) lastSettledCount = PinCounter.amountPinsStanding(); //updates last settledcount List <int> pinsNotStandingList = new List <int>(); //Makes a list so it can be processed by the actionmaster, which ONLY takes lists pinsNotStandingList.Add(pinsNotStanding); ActionMaster2.Action action = ActionMaster2.NextAction(pinsNotStandingList); //Makes an action based on pinsNotStandingList. switch (action) //if action... { case ActionMaster2.Action.Tidy: // PinSetter.anim.SetTrigger("tidyTrigger"); break; case ActionMaster2.Action.Reset: PinSetter.anim.SetTrigger("resetTrigger"); break; case ActionMaster2.Action.EndGame: throw new UnityException("Implement the endgame fool"); break; case ActionMaster2.Action.EndTurn: PinSetter.anim.SetTrigger("resetTrigger"); break; } ball.BallReset(); //reset ball to old pos, removes velocity, etc lastUprightCount = -1; //Reintialization lastChangeTime = 0; ///Reintialization PinSetter.ballTouched = false; //Reintialization thaScore.color = Color.green; //make the text green b/c fun //Pin[] oldPins = FindObjectsOfType<Pin>(); //gets all the pins that exist //foreach (Pin pin in oldPins) {Destroy (pin.gameObject);} //Gets every pin in oldPins and destroys them //Instantiate (pins, this.transform.position, Quaternion.identity); //then make new ones!! }