Ejemplo n.º 1
0
        void Take(string itemName)
        {
            if (string.IsNullOrEmpty(itemName))
            {
                Messages.Add("Take what?"); return;
            }

            var item = CurrentRoom.TakeItem(itemName);

            if (item != null)
            {
                if (item.Takeable)
                {
                    Messages.Add($"Added {item.Name} to your inventory");
                    Inventory.Add(item);
                    CompletedEvents.Add($"{item.Name.ToUpper()}TAKEN");
                }
                else
                {
                    Messages.Add($"{item.NonTakeableMessage}");
                }
            }
            else
            {
                Messages.Add($"What are you talking about there is no {itemName}");
            }
        }
Ejemplo n.º 2
0
 private void TriggerItemEvent(Item item)
 {
     if (CurrentRoom == _rooms["Locked"])
     {
         CompletedEvents.Add("KEYUSED");
         GameEvents["KEYUSED"].Invoke();
     }
 }
            private void handleSyncCompleteEvent(SyncResult result)
            {
                if (result is Error error)
                {
                    ReportedErrors.Add(error.Exception);
                }

                if (result is Success success)
                {
                    CompletedEvents.Add(success.Operation);
                }
            }
Ejemplo n.º 4
0
        private Game(IGameState gameState)
        {
            PlayerName = gameState.PlayerName;
            Restored   = true;
            foreach (var gameEvent in gameState.EventLog)
            {
                CompletedEvents.Add(gameEvent);
            }

            Setup();
            CurrentRoom = _rooms[gameState.CurrentRoom.Name];
        }