Beispiel #1
0
 public MySimulation(ConsoleGUI gui, TextInput input)
 {
     actualTime    = DateTime.Now;
     currentDay    = actualTime;
     simulationDay = 1;
     logForBakeryRelatedUpdates.Log("Welcome to this made up bakery!");
     logForBakeryRelatedUpdates.Log("Select which command to run by typing a number from the list of commands");
     commandDisplay.Lines = writer.CommandWriter();
     this.gui             = gui;
     this.input           = input;
 }
Beispiel #2
0
 public override void PassTime(int deltaTime)
 {
     log.Log($"{deltaTime} milliseconds has passed");
     clockDisplay.Value  = DateTime.Now.ToString("HH:mm:ss");
     updateDisplay.Value = "Update: " + gui.LastUpdateTime.Milliseconds;
     renderDisplay.Value = "Render: " + gui.BackBufferRenderTime.Milliseconds;
     printDisplay.Value  = "Print: " + gui.ScreenRenderTime.Milliseconds;
     while (input.HasInput)
     {
         log.Log("Input: " + input.Consume());
     }
 }
Beispiel #3
0
        public MySimulation(ConsoleGUI gui, TextInput input)
        {
            log.Log("Welcome to car repair workshop simulator.");
            log.Log("Press 1 as many times as you want to in oder to simulate a new vehicle being repaired.");
            log.Log("Press 2 to exit simulation.");


            gui.TargetUpdateTime = 700;
            wsg.GenerateEmpoyees(ws);
            wsg.GenerateStock(ws);
            this.gui   = gui;
            this.input = input;
        }
Beispiel #4
0
        public override void Update(int deltaTime)
        {
            clockDisplay.Value  = "Day: " + simulationDay + "  " + actualTime.ToString("HH:mm");
            workingBakers.Lines = writer.WorkingBakers(bakery);
            moneyDisplay.Value  = bakery.currentMoney + " Schmeckles";
            pantryDisplay.Value = ("Sugar: " + bakery.pantry["Sugar"] + "  Egg: " + bakery.pantry["Egg"] + "  Butter: " + bakery.pantry["Butter"]);


            if (generateCustomers)
            {
                actualTime = actualTime.AddMinutes(30);
                string newOrderString          = bakery.GenerateNewOrder(actualTime);
                string orderCompleteString     = bakery.CheckIfOrderIsComplete(actualTime, payments);
                string apprenticeUpgradeString = bakery.UpgradeApprentice(actualTime);
                if (newOrderString != "")
                {
                    newOrdersLog.Log(newOrderString);
                }
                if (orderCompleteString != "")
                {
                    completedOrdersLog.Log(orderCompleteString);
                }
                if (apprenticeUpgradeString != "")
                {
                    logForBakeryRelatedUpdates.Log(apprenticeUpgradeString);
                }
            }


            //making sure that this runs even if month or year changes
            if (actualTime.Day > currentDay.Day || actualTime.Month > currentDay.Month || actualTime.Year > currentDay.Year)
            {
                bakery.currentMoney = (payments.PayRent(bakery.currentMoney));
                bakery.currentMoney = (payments.PayBakers(bakery.currentMoney, bakery.listOfBakers));
                logForBakeryRelatedUpdates.Log("Day " + simulationDay + ": " + "Rent paid!");
                simulationDay++;
                currentDay = actualTime;
            }

            while (input.HasInput)
            {
                string commandInput = input.Consume();
                ExecuteCommand(commandInput, this);
            }
        }
Beispiel #5
0
        public override void Update(int deltaTime)
        {
            if (Action != "")
            {
                log.Log(Action);
                Action = "";
            }

            actionsHeaderDisplay.Value = "Available Commands";
            actionsDisplay.Lines       = _state.Actions;
            clockDisplay.Value         = DateTime.Now.ToString("HH:mm:ss");
            updateDisplay.Value        = "Update: " + gui.LastUpdateTime.Milliseconds;
            renderDisplay.Value        = "Render: " + gui.BackBufferRenderTime.Milliseconds;
            printDisplay.Value         = "Print: " + gui.ScreenRenderTime.Milliseconds;
            while (input.HasInput)
            {
                HandelInput(input.Consume().ToLower());
            }
        }
 public void Log(string message)
 {
     _display.Log(message);
 }
Beispiel #7
0
        //CONSTRUCTOR
        public MySimulation(TextInput input, NutritionClinic theClinic)
        {
            this.input     = input;
            startTime      = DateTime.Now;
            runningTime    = DateTime.Now;
            this.TheClinic = theClinic;
            simState       = new StandardState("MESSAGEBOARD");

            messageBoard.Log($"This is the {theClinic.Name} nutrition clinic!");
            messageBoard.Log($"We help people get back in shape. Lets start by signing in a new client!");
            messageBoard.Log(theClinic.SignInNewClient(ClientGenerator.GenerateRandomClient(theClinic)));
        }
Beispiel #8
0
        public override void PassTime(int deltaTime)
        {
            clockDisplay.Value = time.ToString("mm:ss");
            time = time.AddSeconds(1);
            deathsDisplay.Value        = "Deaths: " + population.Deaths.ToString();
            populationDisplay.Value    = "Population: " + population.Count.ToString();
            birthsDisplay.Value        = "Births: " + population.Births.ToString();
            mostChildrenDisplay1.Value = $"Most Children";
            mostChildrenDisplay2.Value = $"Name: {topHuman?.Name}";
            mostChildrenDisplay3.Value = $"Children: {topHuman?.CountOfChildren()}";


            if (time.Minute == 0 && time.Second == 30)
            {
                population.GetJobs();
                LogAnnouncements(announceJob);
            }

            if (time.Minute == 1 && time.Second == 30)
            {
                population.Payday();
                population.ReducePopulationHunger();
                LogAnnouncements(announcePayday);
            }
            if (time.Minute == 2 && time.Second < 1)
            {
                population.FoodShopping();
                population.EatFood();
            }

            if (time.Minute == 2 && time.Second == 30)
            {
                population.MakeChildrenAdults();
                population.CreateCouples();
                population.MakeChildren();
                LogAnnouncements(announceFamily);
                topHuman = population.MostChildren();
            }

            if (time.Minute == 3)
            {
                population.CheckHunger();
                population.CheckAge();
                LogAnnouncements(announceDeath);

                time = new DateTime();

                population.AgeUpPopulation();
            }

            while (Input.HasInput)
            {
                Input.SetAutoCompleteWordList(Commands);

                switch (Input.Consume())
                {
                case "AddAdult":
                    population.AddHuman(new Adult());
                    log.Log("Added new Adult");
                    break;

                case "AddChild":
                    population.AddHuman(new Child());
                    log.Log("Added new child");
                    break;

                case "KillHuman":
                    population.KillHuman(Globals.random.Next(0, population.Count));
                    LogAnnouncements(true);
                    break;

                case "AnnounceJobs":
                    announceJob = !announceJob;
                    LogCommandAnnouncements(announceJob, "job");
                    break;

                case "AnnouncePayday":
                    announcePayday = !announcePayday;
                    LogCommandAnnouncements(announcePayday, "payday");
                    break;

                case "AnnounceDeath":
                    announceDeath = !announceDeath;
                    LogCommandAnnouncements(announceDeath, "death");
                    break;

                case "AnnounceFamily":
                    announceFamily = !announceFamily;
                    LogCommandAnnouncements(announceFamily, "family");
                    break;

                default:
                    break;
                }
            }
        }