public BS_DiningTable() { //Dining Table SwinGame.LoadBitmapNamed("diningTable.png", "diningTable.png"); _diningTable = SwinGame.CreateSprite(SwinGame.BitmapNamed("diningTable.png")); // //initialize a food sprite without image _food = SwinGame.CreateSprite(SwinGame.BitmapNamed("")); //get a new customer _customer = BS_PokemonCustomerGenerator.NewCustomer(); //initialize Timer and start it for the first customer, set ticks to 0 and set the state of customer as waiting _gameTime = SwinGame.CreateTimer(); SwinGame.StartTimer(_gameTime); _ticks = 0; _waiting = true; // //initiate a new red status bar _statusBar = new BS_StatusBar("emptyThick.png"); _statusBar.SetFillingImage("redThick.png"); // }
public void ProcessEvent() { if (_waiting) { //keep add time and increase the bar if the customer is waiting if (SwinGame.TimerTicks(_gameTime) > 300) { _ticks = _ticks + 1; SwinGame.ResetTimer(_gameTime); } //old customer rage and leave if the bar reach full. Decrease 0.5 heart life and get a new customer. if (_ticks >= 42) { _customer = BS_PokemonCustomerGenerator.NewCustomer(); _customer.SetX(_diningTable.X + 20); _customer.SetY(_diningTable.Y - 40); _ticks = 0; _sideBar.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(_gameTime) > 150) { _ticks = _ticks - 1; SwinGame.ResetTimer(_gameTime); } if (_ticks < 0) { SetFood(""); _customer = BS_PokemonCustomerGenerator.NewCustomer(); _customer.SetX(_diningTable.X + 20); _customer.SetY(_diningTable.Y - 40); _waiting = true; } } }