public static RenderPipeline RenderDebugLines(this RenderPipeline pipeline, LineSystem lineSystem) { var stage = new RenderDebugLinesStage(lineSystem, pipeline.Device); pipeline.Add(stage); return(pipeline); }
private void QuickBuy(string[] inputArray, int inputCount, User user) { Product product; BuyTransaction transaction; int id; if (int.TryParse(inputArray[1], out id)) { product = LineSystem.GetProduct(id); if (product != null && product.Active) { transaction = LineSystem.BuyProduct(user, product); if (LineSystem.ExecuteTransaction(transaction)) { UI.DisplayUserBuysProduct(transaction); } else { UI.DisplayInsufficientCash(user, product); } } else { UI.DisplayProductNotFound(inputArray[1]); } } else { UI.DisplayGeneralError(inputArray[1] + " is not a invalid productID"); } }
static void Main(string[] args) { ILineSystem lineSystem = new LineSystem(); ILineSystemUI ui = new LineSystemCLI("Console UI", lineSystem); SystemController sc = new SystemController(ui, lineSystem); ui.Start(); }
static void Main(string[] args) { var lineSystem = new LineSystem(); var UI = new LineSystemCLI(lineSystem); lineSystem.Users.Add(new User("Test", "Test", "Test", "*****@*****.**")); UI.Start(); }
/*======================= * Start spawning customer 1 at a time * =========================*/ // Start is called before the first frame update void Start() { if (instance) { Destroy(this); } instance = this; startDay(); endDayBool = false; }
public CommandParser(LineSystem lineSystem, ILineSystemUI ui) { LineSystem = lineSystem; UI = ui; adminCommands.Add(":close", args => UI.Close()); adminCommands.Add(":activate", args => { ChangeProductBoolField(":activate", args, ProductBoolField.Active, true); }); adminCommands.Add(":deactivate", args => { ChangeProductBoolField(":deactivate", args, ProductBoolField.Active, false); }); adminCommands.Add(":crediton", args => { ChangeProductBoolField(":crediton", args, ProductBoolField.CanBeBoughtOnCredit, true); }); adminCommands.Add(":creditoff", args => { ChangeProductBoolField(":creditoff", args, ProductBoolField.CanBeBoughtOnCredit, false); }); adminCommands.Add(":addcredits", args => { InsertCashTransaction transaction; User user; int amount; if (IsValidArgs(":addcredits", args, 2)) { user = LineSystem.GetUser(args[0]); if (user != null) { if (args[1].TryToCredit(out amount)) { transaction = LineSystem.AddCreditsToAccount(user, amount); UI.DisplayAdminAddedCredits(transaction); LineSystem.ExecuteTransaction(transaction); } else { UI.DisplayGeneralError(args[1] + " is not a invalid cash amount"); } } else { UI.DisplayUserNotFound(args[0]); } } }); }
private void MultiBuy(string[] inputArray, int inputCount, User user) { List <BuyTransaction> transactions = new List <BuyTransaction>(); Product product; int amount, id, price; if (int.TryParse(inputArray[1], out amount) && amount > 0) { if (int.TryParse(inputArray[2], out id)) { product = LineSystem.GetProduct(id); if (product != null && product.Active) { for (int i = 0; i < amount; i++) { transactions.Add(LineSystem.BuyProduct(user, product)); } price = transactions[0].Amount * amount; if (price <= user.Balance) { foreach (var transaction in transactions) { LineSystem.ExecuteTransaction(transaction); } UI.DisplayUserBuysProduct(transactions[0], amount); } else { UI.DisplayInsufficientCash(user, product, amount); } } else { UI.DisplayProductNotFound(inputArray[2]); } } else { UI.DisplayGeneralError(inputArray[2] + " is not a valid productID"); } } else { UI.DisplayGeneralError(inputArray[1] + " is not a valid amount"); } }
// Start is called before the first frame update void Start() { stageSystem = GameObject.Find("System").transform.Find("StageSystem").GetComponent <StageSystem>(); lineSystem = GameObject.Find("System").transform.Find("LineSystem").GetComponent <LineSystem>(); WaitForReset = new WaitForSeconds(ResettingTime); WaitForReplay = new WaitForSeconds(ReplayingTime); wolfText = GameObject.Find("Canvas").transform.Find("Got Wolf").GetComponent <TMPro.TextMeshProUGUI>(); timeText = GameObject.Find("Canvas").transform.Find("Time Text").GetComponent <TMPro.TextMeshProUGUI>(); Set(); NeedReset = true; }
public override void Use() { lineSystem = GameObject.FindObjectOfType <LineSystem>(); if (lineSystem != null) { lineSystem.ActivateCutting(powerUpActiveTime); } StartCoroutine("WaitUntilReset"); go = new GameObject(); AudioSource source = go.AddComponent <AudioSource>(); source.clip = laserSound; source.loop = true; source.volume = volume; go = Instantiate(go); }
public LineSystemTest() { lineSystem = new LineSystem(null); testUser = new User("test", "test", "test", "*****@*****.**", 100000); lineSystem.Products.Add(new Product("test1", 101, true, 24)); lineSystem.Products.Add(new Product("test2", 101, true)); lineSystem.Products.Add(new Product("test3", 101, true)); lineSystem.Users.Add(testUser); lineSystem.Users.Add(new User("test2", "test2", "test2", "[email protected]")); lineSystem.Users.Add(new User("test3", "test3", "test3", "[email protected]")); lineSystem.Transactions.Add(new BuyTransaction(DateTime.Now, testUser, new Product("test", 99, true))); lineSystem.Transactions.Add(new BuyTransaction(DateTime.Now, lineSystem.Users[1], new Product("test", 99, true))); lineSystem.Transactions.Add(new InsertCashTransaction(DateTime.Now, testUser, 100)); lineSystem.Transactions.Add(new InsertCashTransaction(DateTime.Now, lineSystem.Users[2], 100)); }
public void DisplayUserInfo(User user) { var transactions = LineSystem.GetTransactionList(user); transactions.Sort(); Console.WriteLine(user.ToString()); Console.WriteLine("Balance: {0}\n", user.Balance.ToKr()); if (user.Balance < 5000) { Console.WriteLine("Warning. Your balance is less than 50,00 kr. We recommend you refill before next purcash.\n"); } Console.WriteLine("Latest transactions:"); for (int i = 0; i < 10 && i < transactions.Count; i++) { Console.WriteLine(transactions[i].ToString()); } }
//Changes a field of a product depending on the parameters of the method private void ChangeProductBoolField(string commandName, string[] args, ProductBoolField field, bool newValue) { Product product; int id; if (IsValidArgs(commandName, args, 1)) { if (int.TryParse(args[0], out id)) { product = LineSystem.GetProduct(id); if (product != null) { switch (field) { case ProductBoolField.Active: product.Active = newValue; break; case ProductBoolField.CanBeBoughtOnCredit: product.CanBeBoughtOnCredit = newValue; break; default: break; } UI.DisplayGeneralMessage(product.Name + "'s " + field.ToString() + " field was set to " + newValue.ToString()); } else { UI.DisplayProductNotFound(args[0]); } } else { UI.DisplayGeneralError(args[0] + " is not a invalid productID"); } } }
private void GetUser(string[] inputArray, int inputCount) { User user = LineSystem.GetUser(inputArray[0]); if (user != null) { if (inputCount == 1) { UI.DisplayUserInfo(user); } else if (inputCount == 2) { QuickBuy(inputArray, inputCount, user); } else { MultiBuy(inputArray, inputCount, user); } } else { UI.DisplayUserNotFound(inputArray[0]); } }
public LineSystemCLI(LineSystem lineSystem) { LineSystem = lineSystem; Parser = new CommandParser(lineSystem, this); }
public RenderDebugLinesStage(LineSystem lineSystem, GraphicsDevice device) { this.LineSystem = lineSystem; this.Device = device; }