mirror of
https://github.com/imperialsushi/gutterball-3.git
synced 2025-06-15 05:07:42 +00:00

Strike it big with amazing bowling action! Everything that made Gutterball 3D a hit is here - incredible 3D graphics, cool ball-rolling controls, hilarious characters - and more! Eight all-new alleys are waxed and ready for you to toss your choice of 85 unique bowling balls. As you play, earn points and cash and unlock alleys and balls. Even customize a ball with your own settings and images! Addictive bowling fun that will bowl you over!
90 lines
No EOL
2.1 KiB
C#
90 lines
No EOL
2.1 KiB
C#
using UnityEngine;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
|
|
public class ActionMasterOld
|
|
{
|
|
public enum Action { Tidy, Reset, EndTurn, EndGame };
|
|
|
|
private int[] bowls = new int[21];
|
|
private int bowl = 1;
|
|
|
|
public static Action NextAction(List<int> pinfFalls)
|
|
{
|
|
ActionMasterOld am = new ActionMasterOld();
|
|
Action currentAction = new Action();
|
|
|
|
foreach (int pinFall in pinfFalls)
|
|
{
|
|
currentAction = am.Bowl(pinFall);
|
|
}
|
|
|
|
return currentAction;
|
|
}
|
|
|
|
private Action Bowl(int pins)
|
|
{ // TODO make private
|
|
if (pins < 0 || pins > 10) { throw new UnityException("Invalid pins"); }
|
|
|
|
bowls[bowl - 1] = pins;
|
|
|
|
if (bowl == 21)
|
|
{
|
|
return Action.EndGame;
|
|
}
|
|
|
|
// Handle last-frame special cases
|
|
if (bowl >= 19 && pins == 10)
|
|
{
|
|
bowl++;
|
|
return Action.Reset;
|
|
}
|
|
else if (bowl == 20)
|
|
{
|
|
bowl++;
|
|
if (bowls[19 - 1] == 10 && bowls[20 - 1] == 0)
|
|
{
|
|
return Action.Tidy;
|
|
}
|
|
else if (bowls[19 - 1] + bowls[20 - 1] == 10)
|
|
{
|
|
return Action.Reset;
|
|
}
|
|
else if (Bowl21Awarded())
|
|
{
|
|
return Action.Tidy;
|
|
}
|
|
else
|
|
{
|
|
return Action.EndGame;
|
|
}
|
|
}
|
|
|
|
if (bowl % 2 != 0)
|
|
{ // First bowl of frame
|
|
if (pins == 10)
|
|
{
|
|
bowl += 2;
|
|
return Action.EndTurn;
|
|
}
|
|
else
|
|
{
|
|
bowl += 1;
|
|
return Action.Tidy;
|
|
}
|
|
}
|
|
else if (bowl % 2 == 0)
|
|
{ // Second bowl of frame
|
|
bowl += 1;
|
|
return Action.EndTurn;
|
|
}
|
|
|
|
throw new UnityException("Not sure what action to return!");
|
|
}
|
|
|
|
private bool Bowl21Awarded()
|
|
{
|
|
// Remember that arrays start counting at 0
|
|
return (bowls[19 - 1] + bowls[20 - 1] >= 10);
|
|
}
|
|
} |