string HandleTalkCommand(Command talkCommand, Game game) { string personString = talkCommand.GetParameter("person"); string subjectString = talkCommand.GetParameter("subject"); Objects.ID personType = Emoji.GetID(personString); if (personType == Objects.ID.Unknown) { mStatus = Status.Frustrated; return("You can't even figure out who you're trying to talk to."); } Objects.ID subjectType = Objects.ID.Unknown; // Only try to parse if it's not empty if (subjectString != "") { subjectType = Emoji.GetID(subjectString); if (subjectType == Objects.ID.Unknown) { mStatus = Status.Frustrated; return("You can't even figure out what you're trying to talk about."); } } GridObject person = game.mRoom.FindObjectAdjacentTo(mPosition, personType); if (person == null) { mStatus = Status.Frustrated; return("They aren't close enough to talk to."); } return(person.TalkTo(subjectType, game)); }
string LookAtObjectCommand(Command lookAtCommand, Game game) { string objectString = lookAtCommand.GetParameter("object"); Objects.ID objectType = Emoji.GetID(objectString); if (objectType == Objects.ID.Unknown) { mStatus = Status.Frustrated; return("You can't even figure out what that is."); } GridObject targetObject = game.mRoom.GetNearestObject(objectType, mPosition); if (targetObject == null) { if (game.mInventory.Contains(objectType)) { mStatus = Status.Thinking; return(ObjectTraits.GetObjectTraits(objectType).GetDescription(game)); } else { mStatus = Status.Frustrated; return("You don't see that here."); } } else { mStatus = Status.Thinking; return(targetObject.GetDescriptionText(game)); } }
private string HandleTakeCommand(Command takeCommand, Game game) { string objectString = takeCommand.GetParameter("object"); Objects.ID objectTypeToPickUp = Emoji.GetID(objectString); if (objectTypeToPickUp == Objects.ID.Unknown) { return("You couldn't find that nearby"); } StaticObject staticObjectToPickup = game.mRoom.FindStaticObjectAdjacentTo(mPosition, objectTypeToPickUp); if (staticObjectToPickup != null) { return(objectString + " can't be picked up"); } DynamicObject objectToPickUp = game.mRoom.FindDynamicObjectAdjacentTo(mPosition, objectTypeToPickUp); if (objectToPickUp == null) { return("There isn't " + objectString + " nearby"); } if (!objectToPickUp.CanBePickedUp()) { return(objectString + " can't be picked up"); } game.mRoom.MarkObjectForDeletion(objectToPickUp); game.mInventory.AddItem(objectToPickUp); return("You picked up " + objectToPickUp.Render()); }
public DynamicObject SpawnObject(Objects.ID type, Point position) { DynamicObject dynamicObject = (DynamicObject)GridObject.Create(type, position); AddNewItem(dynamicObject); return(dynamicObject); }
public GridObject GetNearestObject(Objects.ID typeID, Point targetPosition) { List <GridObject> matchingObjects = new List <GridObject>(); foreach (DynamicObject dynamicObject in mDynamicObjects) { if (dynamicObject.GetTypeID() == typeID) { matchingObjects.Add(dynamicObject); } } foreach (StaticObject staticObject in mStaticRoomGrid) { if (staticObject.GetTypeID() == typeID) { matchingObjects.Add(staticObject); } } var sortedObjects = from matchingObject in matchingObjects orderby MathUtils.GetDistance(matchingObject.GetPosition(), targetPosition) ascending select matchingObject; if (!sortedObjects.Any()) { return(null); } return(sortedObjects.First()); }
public override string TalkTo(Objects.ID subject, Game game) { if (subject == Objects.ID.Unknown) { if (DoesPlayerLookLikeAScientist(game)) { return("Greetings, scientist. Welcome to the Research Facility."); } else { return("Only scientists allowed in. You don't even look like a scientist."); } } else { if (subject == Objects.ID.LabCoat) { return("Yep that's the uniform of all the scientists here."); } else { return("I don't know anything about that."); } } }
string HandleUseWithoutTargetCommand(Command useCommand, Game game) { string actorString = useCommand.GetParameter("actor"); Objects.ID actorType = Emoji.GetID(actorString); if (actorType == Objects.ID.Unknown) { mStatus = Status.Frustrated; return("You don't have that in your inventory."); } GridObject actorObject = game.mRoom.FindObjectAdjacentTo(mPosition, actorType); if (actorObject == null) { mStatus = Status.Frustrated; return("You couldn't find that nearby."); } ActionResult result = actorObject.UseWithoutTarget(game); if (!result.mSuccess) { mStatus = Status.Frustrated; } return(result.mOutput); }
string HandleGiveCommand(Command giveCommand, Game game) { string objectString = giveCommand.GetParameter("object"); string personString = giveCommand.GetParameter("person"); Objects.ID objectType = Emoji.GetID(objectString); if (objectType == Objects.ID.Unknown) { return("You can't even figure out what you're trying to give."); } if (!game.mInventory.Contains(objectType)) { return("You don't have " + objectString); } Objects.ID personType = Emoji.GetID(personString); if (personType == Objects.ID.Unknown) { mStatus = Status.Frustrated; return("You can't even figure out who you're trying to talk to."); } GridObject person = game.mRoom.FindObjectAdjacentTo(mPosition, personType); if (person == null) { mStatus = Status.Frustrated; return("They aren't close enough to talk to."); } return(person.GiveObject(objectType, game)); }
public static GridObject CreateObject(ReadStream stream) { Objects.ID id = Objects.ID.Unknown; stream.Stream(ref id); stream.BackUp(SaveUtils.GetNumBits(id)); return(CreateObject(id)); }
public static GridObject Create(Objects.ID typeID, Point startinPosition) { GridObject dynamicObject = Emoji.CreateObject(typeID); dynamicObject.mType = typeID; dynamicObject.mPosition = startinPosition; return(dynamicObject); }
public static string GetEmoji(Objects.ID id, int index) { string[] displayChars = ObjectTraits.GetObjectTraits(id).mDisplayEmoji; Debug.Assert(index >= 0 && index < displayChars.Length); return(displayChars[index]); }
public static GridObject CreateObject(Objects.ID id) { Type objectType = ObjectTraits.GetObjectTraits(id).mDynamicObjectType; Debug.Assert(objectType.IsSubclassOf(typeof(GridObject))); return((GridObject)Activator.CreateInstance(objectType)); }
public static string GetRandomEmoji(Objects.ID id) { string[] displayChars = ObjectTraits.GetObjectTraits(id).mDisplayEmoji; int displayEmojiIndex = Game.random.Next() % displayChars.Length; return(displayChars[displayEmojiIndex]); }
public override string TalkTo(Objects.ID subject, Game game) { if (subject == Objects.ID.Blood) { return("The bat's ears perk up when you mention \"blood\""); } else { return(base.TalkTo(subject, game)); } }
public GridObject FindObjectAdjacentTo(Point position, Objects.ID typeToFind) { DynamicObject dynamicObject = FindDynamicObjectAdjacentTo(position, typeToFind); if (dynamicObject != null) { return(dynamicObject); } return(FindStaticObjectAdjacentTo(position, typeToFind)); }
public DynamicObject FindFirstDynamicObject(Objects.ID id) { foreach (var dynamicObject in mDynamicObjects) { if (dynamicObject.GetTypeID() == id) { return(dynamicObject); } } return(null); }
public DynamicObject FindDynamicObjectAdjacentTo(Point position, Objects.ID typeToFind) { foreach (DynamicObject dynamicObject in mDynamicObjects) { if (MathUtils.ArePointsAdjacent(dynamicObject.GetPosition(), position) && dynamicObject.GetTypeID() == typeToFind) { return(dynamicObject); } } return(null); }
string HandleThrowCommand(Command throwCommand, Game game) { string objectString = throwCommand.GetParameter("object"); string directionString = throwCommand.GetParameter("direction"); Objects.ID objectTypeToThrow = Emoji.GetID(objectString); if (objectTypeToThrow == Objects.ID.Unknown) { return("You don't have that"); } if (!game.mInventory.Contains(objectTypeToThrow)) { return("You don't have " + objectString); } Direction direction = Room.GetDirection(directionString); if (direction == Direction.Unknown) { return("Invalid direction"); } Point throwVector = MathUtils.GetVector(direction); Point?furthestLandingPoint = null; for (int distanceThrown = 1; distanceThrown <= 3; distanceThrown++) { Point testPoint = mPosition + throwVector * distanceThrown; if (game.mRoom.CanSpaceBeMovedTo(testPoint)) { furthestLandingPoint = testPoint; } if (!game.mRoom.CanSpaceBeThrownThrough(testPoint)) { break; } } if (furthestLandingPoint == null) { return("No space to throw to the " + direction); } game.mInventory.RemoveItem(objectTypeToThrow); game.mRoom.SpawnObject(objectTypeToThrow, furthestLandingPoint.Value); return("You threw " + objectString); }
public InventoryEntry GetEntry(Objects.ID type) { foreach (InventoryEntry entry in mEntries) { if (entry.mType == type) { return(entry); } } return(null); }
string HandleEatCommand(Command eatCommand, Game game) { string objectString = eatCommand.GetParameter("object"); Objects.ID objectType = Emoji.GetID(objectString); if (objectType == Objects.ID.Unknown) { mStatus = Status.Frustrated; return("You don't have that"); } if (!game.mInventory.Contains(objectType)) { mStatus = Status.Frustrated; return("You don't have " + objectString + " in your inventory."); } game.mInventory.RemoveItem(objectType); if (ObjectTraits.GetObjectTraits(objectType).mIsEdible) { if (ObjectTraits.GetObjectTraits(objectType).mCausesHallucinations) { mStatus = Status.Tripping; game.mRoom.mIsRenderingHallucination = true; return(Emoji.Symbols.Dizzy + " Whoa " + Emoji.Symbols.Dizzy); } else if (ObjectTraits.GetObjectTraits(objectType).mIsHealthyToEat) { mStatus = Status.SavoringFood; return("That was delicious! You feel a renewed sense of determination."); } else { Point?spaceToDropObject = game.mRoom.FindOpenSpaceAdjacentTo(mPosition); if (spaceToDropObject != null) { game.mRoom.SpawnObject(objectType, spaceToDropObject.Value); } mStatus = Status.Vomiting; return("Oh, that was a terrible idea."); } } else { mStatus = Status.Frustrated; return("You can't eat that!"); } }
public void RemoveItem(Objects.ID type) { InventoryEntry entry = GetEntry(type); if (entry.IsStackable()) { //entry.mQuantity--; } else { mEntries.Remove(entry); } }
public override string GiveObject(Objects.ID objectType, Game game) { if (objectType == Objects.ID.Blood) { game.mRoom.MarkObjectForDeletion(this); game.mRoom.SpawnObject(new VampireSetup(mPosition)); return("The bat transforms into a vampire!"); } else { return(base.GiveObject(objectType, game)); } }
public static string GetEmoji(Objects.ID id) { string[] displayChars = ObjectTraits.GetObjectTraits(id).mDisplayEmoji; if (displayChars.Length == 1) { return(displayChars[0]); } else { int index = Game.random.Next() % displayChars.Count(); return(displayChars[index]); } }
public StaticObject FindStaticObjectAdjacentTo(Point position, Objects.ID typeToFind) { var adjacentPoints = MathUtils.GetAdjacentPoints(position); foreach (Point point in adjacentPoints) { StaticObject staticObject = GetStaticObject(point); if (staticObject.GetTypeID() == typeToFind) { return(staticObject); } } return(null); }
public static int GetEmojiIndex(Objects.ID id, string emoji) { string[] displayChars = ObjectTraits.GetObjectTraits(id).mDisplayEmoji; for (int index = 0; index < displayChars.Length; index++) { if (displayChars[index] == emoji) { return(index); } } Debug.Fail("Couldn't find emoji"); return(-1); }
public void AddItem(Objects.ID objectType) { InventoryEntry existingEntry = GetEntry(objectType); if (existingEntry != null && existingEntry.IsStackable()) { //existingEntry.mQuantity++; } else { InventoryEntry entry = new InventoryEntry() { mType = objectType, }; mEntries.Add(entry); } }
public override string TalkTo(Objects.ID subject, Game game) { if (subject == Objects.ID.ThumbsUp) { return("Likes are our bread and butter. They're worth 1 prayer."); } else if (subject == Objects.ID.Retweet) { return("I don't know anything about that."); } else if (subject == Objects.ID.Worshipper) { return("They're our worshippers. They offer up their thoughts and prayers."); } else { return("We offer a mobile phone for 10 prayers. Like = 1 prayer. Retweet = 5 prayers."); } }
public GridObject GetFirstObject(Objects.ID typeID) { foreach (DynamicObject dynamicObject in mDynamicObjects) { if (dynamicObject.GetTypeID() == typeID) { return(dynamicObject); } } foreach (StaticObject staticObject in mStaticRoomGrid) { if (staticObject.GetTypeID() == typeID) { return(staticObject); } } return(null); }
private string HandleDropCommand(Command dropCommand, Game game) { string objectString = dropCommand.GetParameter("object"); string directionString = dropCommand.GetParameter("direction"); Objects.ID objectTypeToDrop = Emoji.GetID(objectString); if (objectTypeToDrop == Objects.ID.Unknown) { return("You don't have that"); } if (!game.mInventory.Contains(objectTypeToDrop)) { return("You don't have " + objectString); } Direction direction = Room.GetDirection(directionString); if (direction == Direction.Unknown) { return("Invalid direction"); } Point prospectiveDropPosition = MathUtils.GetAdjacentPoint(mPosition, direction); if (!game.mRoom.CanSpaceBeMovedTo(prospectiveDropPosition)) { return("Space to the " + direction + " isn't open"); } game.mInventory.RemoveItem(objectTypeToDrop); game.mRoom.SpawnObject(objectTypeToDrop, prospectiveDropPosition); return("You dropped " + objectString); }
public override void Stream(ref Objects.ID type) { mBitStream.WriteByte((byte)type, SaveUtils.GetNumBits(type)); }