Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        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));
            }
        }
Ejemplo n.º 3
0
        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());
        }
Ejemplo n.º 4
0
        public DynamicObject SpawnObject(Objects.ID type, Point position)
        {
            DynamicObject dynamicObject = (DynamicObject)GridObject.Create(type, position);

            AddNewItem(dynamicObject);
            return(dynamicObject);
        }
Ejemplo n.º 5
0
        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());
        }
Ejemplo n.º 6
0
 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.");
         }
     }
 }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
        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));
        }
Ejemplo n.º 9
0
        public static GridObject CreateObject(ReadStream stream)
        {
            Objects.ID id = Objects.ID.Unknown;
            stream.Stream(ref id);
            stream.BackUp(SaveUtils.GetNumBits(id));

            return(CreateObject(id));
        }
Ejemplo n.º 10
0
        public static GridObject Create(Objects.ID typeID, Point startinPosition)
        {
            GridObject dynamicObject = Emoji.CreateObject(typeID);

            dynamicObject.mType     = typeID;
            dynamicObject.mPosition = startinPosition;
            return(dynamicObject);
        }
Ejemplo n.º 11
0
        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]);
        }
Ejemplo n.º 12
0
        public static GridObject CreateObject(Objects.ID id)
        {
            Type objectType = ObjectTraits.GetObjectTraits(id).mDynamicObjectType;

            Debug.Assert(objectType.IsSubclassOf(typeof(GridObject)));

            return((GridObject)Activator.CreateInstance(objectType));
        }
Ejemplo n.º 13
0
        public static string GetRandomEmoji(Objects.ID id)
        {
            string[] displayChars = ObjectTraits.GetObjectTraits(id).mDisplayEmoji;

            int displayEmojiIndex = Game.random.Next() % displayChars.Length;

            return(displayChars[displayEmojiIndex]);
        }
Ejemplo n.º 14
0
 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));
     }
 }
Ejemplo n.º 15
0
        public GridObject FindObjectAdjacentTo(Point position, Objects.ID typeToFind)
        {
            DynamicObject dynamicObject = FindDynamicObjectAdjacentTo(position, typeToFind);

            if (dynamicObject != null)
            {
                return(dynamicObject);
            }

            return(FindStaticObjectAdjacentTo(position, typeToFind));
        }
Ejemplo n.º 16
0
        public DynamicObject FindFirstDynamicObject(Objects.ID id)
        {
            foreach (var dynamicObject in mDynamicObjects)
            {
                if (dynamicObject.GetTypeID() == id)
                {
                    return(dynamicObject);
                }
            }

            return(null);
        }
Ejemplo n.º 17
0
        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);
        }
Ejemplo n.º 18
0
        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);
        }
Ejemplo n.º 19
0
        public InventoryEntry GetEntry(Objects.ID type)
        {
            foreach (InventoryEntry entry in mEntries)
            {
                if (entry.mType == type)
                {
                    return(entry);
                }
            }

            return(null);
        }
Ejemplo n.º 20
0
        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!");
            }
        }
Ejemplo n.º 21
0
        public void RemoveItem(Objects.ID type)
        {
            InventoryEntry entry = GetEntry(type);

            if (entry.IsStackable())
            {
                //entry.mQuantity--;
            }
            else
            {
                mEntries.Remove(entry);
            }
        }
Ejemplo n.º 22
0
 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));
     }
 }
Ejemplo n.º 23
0
        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]);
            }
        }
Ejemplo n.º 24
0
        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);
        }
Ejemplo n.º 25
0
        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);
        }
Ejemplo n.º 26
0
        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);
            }
        }
Ejemplo n.º 27
0
 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.");
     }
 }
Ejemplo n.º 28
0
        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);
        }
Ejemplo n.º 29
0
        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);
        }
Ejemplo n.º 30
0
 public override void Stream(ref Objects.ID type)
 {
     mBitStream.WriteByte((byte)type, SaveUtils.GetNumBits(type));
 }