Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2012
    Posts
    1

    Question Hyperion Engine - How to add a new item in the GameManager?

    edit: How to add a new ITEM in the GameManager. Sorry for failing at making a thread title.

    While I know I can add an item to a room in the Level.cs, I was wondering how I'd go about creating a new item in the GameManager.cs. For instance, I would pick up one item, and it would create a new item in a different room. I tried creating the item in a different room (in the Level.cs) and then moving it with some code, and while that returns no compiler errors, it doesn't work.

    The code I tried was:
    Code:
                if (Player.GetInventoryItem("$5 Bill") != null)
                {
                    Level.Rooms[1, 3].Items.Add(Level.Rooms[0, 0].GetItem("Test"));
                }
    With the "Test" item created like this:

    Code:
     
                room = new Room();
                rooms[0, 0] = room;
                room.Title = "Test Room";
                room.Description = "Room Description";
                room.AddExit(Direction.North);
    
                item = new Item();
                item.Title = "Test";
                item.PickupText = "Text for picking up the item.";
                room.Items.Add(item);
    I assume there's a way to move the item that actually works, or just a way to create a new one. Any help is much appreciated.
    Last edited by TheHorker; 04-24-2012 at 07:02 PM.

  2. #2
    Join Date
    Jan 2007
    Posts
    216
    Why do you create the test room. You can simple pass the item into Items.Add .Also make sure the new item is in the same scope.

    If I put this in the ApplyRules function in GameManager.cs it works just fine:

    Code:
                if (Player.GetInventoryItem("$5 Bill") != null)
                {
                    Item testItem = new Item();
                    testItem.Title = "Test";
                    testItem.PickupText = "Text for picking up the item.";
                    
                    Level.Rooms[1, 3].Items.Add(testItem);
                }

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •