public MWMarioDiningTable() { //Dining Table SwinGame.LoadBitmapNamed("diningTable.png", "diningTable.png"); _mariodiningTable = SwinGame.CreateSprite(SwinGame.BitmapNamed("diningTable.png")); // //initialize a food sprite without image _mariofood = SwinGame.CreateSprite(SwinGame.BitmapNamed("")); //get a new customer _mariocustomer = MWMarioCustomerGenerator.NewMarioCustomer(); //initialize Timer and start it for the first customer, set ticks to 0 and set the state of customer as waiting _mariogameTime = SwinGame.CreateTimer(); SwinGame.StartTimer(_mariogameTime); _marioticks = 0; _mariowaiting = true; // //initiate a new red status bar _mariostatusBar = new MWStatusBar("emptyThick.png"); _mariostatusBar.SetFillingImage("redThick.png"); // }
public void ProcessEvent() { if (_mariowaiting) { //keep add time and increase the bar if the customer is waiting if (SwinGame.TimerTicks(_mariogameTime) > 700) { _marioticks = _marioticks + 1; SwinGame.ResetTimer(_mariogameTime); } //old customer rage and leave if the bar reach full. Decrease 0.5 heart life and get a new customer. if (_marioticks >= 42) { _mariocustomer = MWMarioCustomerGenerator.NewMarioCustomer(); _mariocustomer.SetX(_mariodiningTable.X + 20); _mariocustomer.SetY(_mariodiningTable.Y - 40); _marioticks = 0; _mariosideBar.DecreaseGameLife(); } } else { //reduce the bar when the customer is eating. Clear the table and get a new customer when the bar reach empty. Then set the waiting to be true. if (SwinGame.TimerTicks(_mariogameTime) > 150) { _marioticks = _marioticks - 1; SwinGame.ResetTimer(_mariogameTime); } if (_marioticks < 0) { MarioSetFood(""); _mariocustomer = MWMarioCustomerGenerator.NewMarioCustomer(); _mariocustomer.SetX(_mariodiningTable.X + 20); _mariocustomer.SetY(_mariodiningTable.Y - 40); _mariowaiting = true; } } }