Пример #1
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));
            }
        }
Пример #2
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));
        }
Пример #3
0
        public static string GetRandomEmoji(Objects.ID id)
        {
            string[] displayChars = ObjectTraits.GetObjectTraits(id).mDisplayEmoji;

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

            return(displayChars[displayEmojiIndex]);
        }
Пример #4
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]);
        }
Пример #5
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!");
            }
        }
Пример #6
0
        DynamicObject FindInsectStuckInWeb(Room room)
        {
            foreach (DynamicObject dynamicObject in room.mDynamicObjects)
            {
                if (ObjectTraits.GetObjectTraits(dynamicObject.GetTypeID()).mIsInsect &&
                    room.GetStaticObject(dynamicObject.GetPosition()).GetTypeID() == Objects.ID.SpiderWeb)
                {
                    return(dynamicObject);
                }
            }

            return(null);
        }
Пример #7
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]);
            }
        }
Пример #8
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);
        }
Пример #9
0
        string HandleUseOnTargetCommand(Command useCommand, Game game)
        {
            string actorString  = useCommand.GetParameter("actor");
            string targetString = useCommand.GetParameter("target");

            Objects.ID actorType = Emoji.GetID(actorString);

            if (actorType == Objects.ID.Unknown)
            {
                mStatus = Status.Frustrated;
                return("You don't have that in your inventory.");
            }

            if (!game.mInventory.Contains(actorType))
            {
                mStatus = Status.Frustrated;
                return("You don't have " + actorString);
            }

            Objects.ID targetType = Emoji.GetID(targetString);

            if (targetType == Objects.ID.Unknown)
            {
                mStatus = Status.Frustrated;
                return("You can't find that");
            }

            GridObject targetObject = game.mRoom.FindObjectAdjacentTo(mPosition, targetType);

            if (targetObject == null)
            {
                mStatus = Status.Frustrated;
                return("There isn't " + targetString + " nearby");
            }

            string outText = "";

            if (targetType == Objects.ID.Lock)
            {
                Lock lockObject = targetObject as Lock;
                if (lockObject.CanBeUnlockedBy(actorType))
                {
                    lockObject.Unlock();
                    outText = "You unlocked the door with the " + actorString;
                }
            }
            else if (targetType == Objects.ID.Clamp)
            {
                Objects.ID crushingResult = ObjectTraits.GetObjectTraits(actorType).mCrushingResultType;
                if (crushingResult != Objects.ID.Unknown)
                {
                    game.mInventory.RemoveItem(actorType);
                    game.mInventory.AddItem(crushingResult);
                    outText = "You crushed the " + actorString;
                }
            }

            if (outText == "")
            {
                outText = "You don't think you can do that.";
                mStatus = Status.Frustrated;
            }

            return(outText);
        }