public override void Execute(BaseGameEntity pEntity) { Miner pMiner = (Miner)pEntity; //deposit the gold pMiner.AddToWealth(pMiner.GoldCarried); pMiner.GoldCarried = 0; DebugMessages.Instance.WriteLine(String.Format("{0}: Depositing gold. Total savings now: {1}", MainSM.GetEntityName(pEntity.ID()), pMiner.Wealth)); //wealthy enough to have a well earned rest? if (pMiner.Wealth >= Miner.ComfortLevel) { DebugMessages.Instance.WriteLine(String.Format("{0}: WooHoo! Rich enough for now. Back home to mah li'lle lady", MainSM.GetEntityName(pEntity.ID()))); pMiner.GetFSM().ChangeState(new GoHomeAndSleepTilRested()); } //otherwise get more gold else { pMiner.GetFSM().ChangeState(new EnterMineAndDigForNugget()); } }
public override void Execute(BaseGameEntity pEntity) { Miner pMiner = (Miner)pEntity; //Now the miner is at the goldmine he digs for gold until he //is carrying in excess of MaxNuggets. If he gets thirsty during //his digging he packs up work for a while and changes state to //gp to the saloon for a whiskey. pMiner.AddToGoldCarried(1); pMiner.IncreaseFatigue(); DebugMessages.Instance.WriteLine(String.Format("{0}: Pickin' up a nugget", MainSM.GetEntityName(pEntity.ID()))); //if enough gold mined, go and put it in the bank if (pMiner.PocketsFull()) { pMiner.GetFSM().ChangeState(new VisitBankAndDepositGold()); } if (pMiner.Thirsty()) { pMiner.GetFSM().ChangeState(new QuenchThirst()); } }
public override void Execute(BaseGameEntity pEntity) { Miner pMiner = (Miner)pEntity; if (pMiner.HP == 1) { DebugMessages.Instance.WriteLine(String.Format("{0}: Dang it, defeated by a drunkard!", MainSM.GetEntityName(pEntity.ID()))); // Lost fight! Tell Joe we are done. MessageDispatcher.Instance.DispatchMessage((int)MessageDispatcher.SEND_MSG_IMMEDIATELY, pEntity.ID(), (int)EntityName.ent_BarFly, (int)message_type.Msg_DeclineFight, (int)MessageDispatcher.NO_ADDITIONAL_INFO); pMiner.GetFSM().RevertToPreviousState(); } else { // Throw a punch DebugMessages.Instance.WriteLine(String.Format("{0}: Take this, drunken varmint!", MainSM.GetEntityName(pEntity.ID()))); MessageDispatcher.Instance.DispatchMessage((int)MessageDispatcher.SEND_MSG_IMMEDIATELY, pEntity.ID(), (int)EntityName.ent_BarFly, (int)message_type.Msg_IncomingPunch, (int)MessageDispatcher.NO_ADDITIONAL_INFO); } }
public override bool OnMessage(BaseGameEntity pEntity, Telegram pTelegram) { Miner pMiner = (Miner)pEntity; switch (pTelegram.Msg) { case (int)message_type.Msg_IncomingPunch: { if (Utils.RandFloat() <= 0.5) { pMiner.HP = pMiner.HP - 1; DebugMessages.Instance.WriteLine(String.Format("{0}: Ouch, my nose.", MainSM.GetEntityName(pEntity.ID()))); } else { DebugMessages.Instance.WriteLine(String.Format("{0}: Dodged!", MainSM.GetEntityName(pEntity.ID()))); } return(true); } case (int)message_type.Msg_DeclineFight: { DebugMessages.Instance.WriteLine(String.Format("{0}: Yes! Victorious!", MainSM.GetEntityName(pEntity.ID()))); pMiner.GetFSM().RevertToPreviousState(); return(true); } } return(false); }
public override void Execute(BaseGameEntity pEntity) { Miner pMiner = (Miner)pEntity; DebugMessages.Instance.WriteLine(String.Format("{0}: Tastes real good too!", MainSM.GetEntityName(pEntity.ID()))); pMiner.GetFSM().RevertToPreviousState(); }
public override void Execute(BaseGameEntity pEntity) { Miner pMiner = (Miner)pEntity; pMiner.BuyAndDrinkAWhiskey(); DebugMessages.Instance.WriteLine(String.Format("{0}: That's mighty fine sippin' liquer", MainSM.GetEntityName(pEntity.ID()))); pMiner.GetFSM().ChangeState(new EnterMineAndDigForNugget()); }
private void Thread_ProgressChanged(object sender, ProgressChangedEventArgs e) { ArrayList arrReturnValue = DebugMessages.Instance.FlushMessages(); foreach (string strLine in arrReturnValue) { if (strLine.StartsWith(MainSM.GetEntityName((int)EntityName.ent_Miner_Bob))) { txtUpdates.SelectionColor = mColourBob; } else if (strLine.StartsWith(MainSM.GetEntityName((int)EntityName.ent_Elsa))) { txtUpdates.SelectionColor = mColourElsa; } else if (strLine.StartsWith(MainSM.GetEntityName((int)EntityName.ent_BarFly))) { txtUpdates.SelectionColor = mColourBarFly; } else { txtUpdates.SelectionColor = Color.Black; } txtUpdates.AppendText(strLine + Environment.NewLine); } if (e.ProgressPercentage == 100) { txtUpdates.SelectionColor = Color.Black; txtUpdates.AppendText(Environment.NewLine + "Demo Complete!" + Environment.NewLine); } else { lblLocationBob.Text = MainSM.GetLocation((int)Bob.Location); lblStatusBob.Text = Bob.GetFSM().CurrentState.GetType().Name.ToString(); lblLocationWife.Text = MainSM.GetLocation((int)Elsa.Location); lblStatusWife.Text = Elsa.GetFSM().CurrentState.GetType().Name.ToString(); lblLocationBarFly.Text = MainSM.GetLocation((int)Joe.Location); lblStatusBarFly.Text = Joe.GetFSM().CurrentState.GetType().Name.ToString(); } }
public override bool OnMessage(BaseGameEntity pEntity, Telegram pTelegram) { Miner pMiner = (Miner)pEntity; switch (pTelegram.Msg) { case (int)message_type.Msg_Antagonize: { double CurrentTime = MessageDispatcher.Instance.GetRunningTime(); DebugMessages.Instance.WriteLine(String.Format("Message handled by {0} at time: {1}", MainSM.GetEntityName(pEntity.ID()), CurrentTime)); if (pMiner.Location == location_type.saloon) { if (Utils.RandFloat() <= 0.5) { MessageDispatcher.Instance.DispatchMessage((int)MessageDispatcher.SEND_MSG_IMMEDIATELY, pEntity.ID(), (int)EntityName.ent_BarFly, (int)message_type.Msg_AcceptFight, (int)MessageDispatcher.NO_ADDITIONAL_INFO); pMiner.GetFSM().ChangeState(new BobFight()); } else { DebugMessages.Instance.WriteLine(String.Format("{0}: No, I can't be bothered to fight you drunken fool!", MainSM.GetEntityName(pEntity.ID()))); MessageDispatcher.Instance.DispatchMessage((int)MessageDispatcher.SEND_MSG_IMMEDIATELY, pEntity.ID(), (int)EntityName.ent_BarFly, (int)message_type.Msg_DeclineFight, (int)MessageDispatcher.NO_ADDITIONAL_INFO); } } return(true); } } return(false); }
public override bool OnMessage(BaseGameEntity pEntity, Telegram pTelegram) { Miner pMiner = (Miner)pEntity; switch (pTelegram.Msg) { case (int)message_type.Msg_StewReady: { DebugMessages.Instance.WriteLine(String.Format("Message handled by {0} at time {1}", MainSM.GetEntityName(pEntity.ID()), MessageDispatcher.Instance.GetRunningTime())); DebugMessages.Instance.WriteLine(String.Format("{0}: Okay Hun, ahm a comin'", MainSM.GetEntityName(pEntity.ID()))); pMiner.GetFSM().ChangeState(new EatStew()); return(true); } }//end switch return(false); //send message to global message handler }
public override void Execute(BaseGameEntity pEntity) { Miner pMiner = (Miner)pEntity; //if miner is not fatigued start to dig for nuggets again. if (!pMiner.Fatigued()) { DebugMessages.Instance.WriteLine(String.Format("{0}: All mah fatigue has drained away. Time to find more gold!", MainSM.GetEntityName(pEntity.ID()))); pMiner.GetFSM().ChangeState(new EnterMineAndDigForNugget()); } else { //sleep pMiner.DecreaseFatigue(); DebugMessages.Instance.WriteLine(String.Format("{0}: ZZZZ... ", MainSM.GetEntityName(pEntity.ID()))); } }