public void Update() { if (Input.GetKeyDown(KeyCode.F1)) { Anim anim = GetComponentInChildren <Anim>(); anim.Pause(); } if (Input.GetKeyDown(KeyCode.F2)) { Anim anim = GetComponentInChildren <Anim>(); anim.Resume(); } if (Input.GetKeyDown(KeyCode.F3)) { Anim anim = GetComponentInChildren <Anim>(); anim.Clear(); } if (Input.GetKeyDown(KeyCode.F4)) { Anim anim = GetComponentInChildren <Anim>(); anim.Play(item.portalType.ToString().ToLower()); } if (!hover) { return; } if (Input.GetKeyDown(KeyCode.Space)) { if (item.portalType == PortalType.Closed) { game.SetMessage("You walk into the portal and hurt yourself."); return; } game.TeleportTo(GetDestination(), item.portalType); } if (Input.GetKeyDown(KeyCode.R)) { // If you are over a portal with an installed tool, pick it up if (item.portalType == PortalType.Open && item.installedTool != ToolType.None) { // Reclaim tool to inventory game.inventory.TakeActive(ItemType.Tool, item.installedTool, item.installedNumber); game.SetMessage("You reclaim the " + item.installedTool + item.installedNumber + " tool."); // Remove tool from portal item.installedTool = ToolType.None; item.installedNumber = Level.NO_LEVEL; game.levelManager.ChangeItem(game.level.room, item); UpdateView(); return; } // All remaining usage of R key requires a selected tool in inventory InventorySlot slot = game.inventory.GetActiveSlot(); if (slot == null) { return; } // Cannot use tool on return portal if (item.portalType == PortalType.Return) { game.SetMessage("Portal tools don't work on return portals."); return; } if (item.portalType == PortalType.Closed) { // EMPTY tool cannot be used on closed portal if (slot.number == Level.NO_LEVEL) { game.SetMessage("This portal is disabled and cannot be collected."); } // Tool is loaded; used on closed portal will open it else { item.portalType = PortalType.Open; // change to open portal item.number = slot.number; // using number from portal tool in inventory slot game.levelManager.ChangeItem(game.level.room, item); // Remember changes UpdateView(); // Change portal on display slot.number = Level.NO_LEVEL; // Remove portal number from tool in inventory slot.UpdateView(); // Update inventory display game.SetMessage("You transfer the portal back to the arch."); } return; } // Portal is open and unaugmented Debug.Assert(item.portalType == PortalType.Open); Debug.Assert(item.installedTool == ToolType.None); // Is tool empty? If so, collect portal into tool and close portal if (slot.number == Level.NO_LEVEL) { slot.number = item.number; // Copy portal number into tool slot.UpdateView(); // Update the inventory display item.portalType = PortalType.Closed; // Close portal game.levelManager.ChangeItem(game.level.room, item); // Remember change UpdateView(); // Update display of portal game.SetMessage("You collect portal " + item.number + " into the " + slot.toolType + " tool"); return; } // Tool is full: install tool into the portal, if portal is empty if (slot.number != Level.NO_LEVEL) { // TODO Put "final" number in slot.number item.installedNumber = slot.number; // Copy tool number into portal item.installedTool = slot.toolType; // Copy tool type (add, subtract, etc) into portal game.levelManager.ChangeItem(game.level.room, item); // Remember changes UpdateView(); // Update display of portal to show augmentation slot.Remove(); // Remove inventory slot game.SetMessage("You augment the portal with the " + item.installedTool + " tool"); return; } Debug.Log("You've discovered a bug. Er, I mean, easter egg."); } }