示例#1
0
文件: Text.cs 项目: lavoiee/CIT195
        public static string LookAt(GameObject gameObject)
        {
            string messageBoxText = "";

            messageBoxText =
                $"{gameObject.Name} \n" + "\n" +
                gameObject.Description + "\n" + "\n";

            if (gameObject is CollectibleObject)
            {
                CollectibleObject collectibleObject = gameObject as CollectibleObject;

                messageBoxText += $"The {collectibleObject.Name} has a value of {collectibleObject.Value} and ";

                if (collectibleObject.CanPickup)
                {
                    messageBoxText += "can be picked up";
                }
                else
                {
                    messageBoxText += "can't be picked up";
                }
            }
            else
            {
                messageBoxText += $"The {gameObject.Name} can't not be picked up";
            }
            return(messageBoxText);
        }
示例#2
0
文件: World.cs 项目: lavoiee/CIT195
        public List <GameObject> GetGameObjectsByLocation(int xPos, int yPos)
        {
            List <GameObject> gameObjects = new List <GameObject>();

            // Iterate through the game object list and grab all that are in the current location
            foreach (GameObject gameObject in _gameObjects)
            {
                if (gameObject.yPos == yPos)
                {
                    if (gameObject.xPos == xPos)
                    {
                        if (gameObject is CollectibleObject)
                        {
                            CollectibleObject item = gameObject as CollectibleObject;
                            if (item.Owner == null)
                            {
                                gameObjects.Add(gameObject);
                            }
                        }
                        else
                        {
                            gameObjects.Add(gameObject);
                        }
                    }
                }
            }
            return(gameObjects);
        }