public void HandlePopoverNeedsInventoryRefresh(WTPopoverDialogue popover) { ImNode node = (ImNode)popover.correspondingEntity; bool hasTitle = false; bool hasDone = false; foreach (ImTableCell cell in popover.tableCells) { if (cell.tableCellType == TableCellType.Done) { hasDone = true; } if (cell.tableCellType == TableCellType.Title) { hasTitle = true; } } if (!hasTitle) { popover.AddTableCell(ImConfig.NameForNodePlacement(node.nodePlacement), TableCellType.Title); } foreach (ImAbstractItem item in inventory) { ImTableCell cellWithItem = null; foreach (ImTableCell itemCell in popover.tableCells) { if (itemCell.item == item) { cellWithItem = itemCell; } } if (cellWithItem == null && item.CanBeUsedOnEntity(popover.correspondingEntity)) { popover.AddTableCell(item.Description(), "Futile_White", item, TableCellType.Item); } if (cellWithItem != null && !item.CanBeUsedOnEntity(popover.correspondingEntity)) { popover.RemoveTableCell(cellWithItem); } } if (!hasDone) { popover.AddTableCell("Done", TableCellType.Done); } }
public WTImmunity() : base("") { instance = this; Futile.AddStage(this); gameLayer = new FContainer(); gameLayer.x = Futile.screen.halfWidth; gameLayer.y = Futile.screen.halfHeight; gameLayer.scale = 0.23f; zoomLevel_ = gameLayer.scale; AddChild(gameLayer); inventory = new List<ImAbstractItem>(); inventory.Add(new ImHealthPill("Health Pill", 15)); inventory.Add(new ImPoisonPill("Poison Pill", 6)); inventory.Add(new ImPoisonPill("Poison Pill", 17)); inventory.Add(new ImHealthPill("Health Pill", 5)); inventory.Add(new ImPoisonPill("Poison Pill", 30)); inventory.Add(new ImHealthPill("Health Pill", 7)); inventory.Add(new ImHealthPill("Health Pill", 42)); float sliceWidth = 460f / 4f; float sliceHeight = 436f / 4f; int sliceHorizontalCount = 6; int sliceVerticalCount = 16; float bodyWidth = sliceWidth * sliceHorizontalCount; float bodyHeight = sliceHeight * sliceVerticalCount; FContainer bodyContainer = new FContainer(); bodyContainer.x -= bodyWidth / 2f; bodyContainer.y -= bodyHeight / 2f; gameLayer.AddChild(bodyContainer); for (int i = 0; i < sliceVerticalCount; i++) { for (int j = 0; j < sliceHorizontalCount; j++) { int imageNum = i * sliceHorizontalCount + j + 1; string imageName = string.Format("bodySlices/body_{0}.png", imageNum.ToString("D2")); FSprite slice = new FSprite(imageName); slice.anchorX = slice.anchorY = 0; slice.x = j * sliceWidth; slice.y = bodyHeight - (i + 1) * sliceHeight; bodyContainer.AddChild(slice); } } organLayer = new ImOrganLayer(); organLayer.owner = this; gameLayer.AddChild(organLayer); veinLayer = new ImVeinLayer(); veinLayer.owner = this; gameLayer.AddChild(veinLayer); nodeLayer = new ImNodeLayer(); nodeLayer.owner = this; gameLayer.AddChild(nodeLayer); /*pop = new ImPopoverDialogue(100f, 100f, 4f, PopoverTriangleDirectionType.PointingRight); AddChild(pop);*/ pop = new WTPopoverDialogue(false, "popover!"); pop.SignalNeedsInventoryRefresh += HandlePopoverNeedsInventoryRefresh; pop.SignalItemUsed += HandleItemUsed; pop.x = Futile.screen.halfWidth; pop.y = Futile.screen.halfHeight; pop.width = 200f; pop.isVisible = false; AddChild(pop); uiLayer = new ImUILayer(); SignalPauseStateChanged += uiLayer.SetTransportBar; AddChild(uiLayer); ImNode node = nodeLayer.NodeForPlacement(NodePlacement.ElbowRight); node.Infect(testVirus); node.InfectionComponent().StartInfecting(); }
public void HandlePopoverNeedsInventoryRefresh(WTPopoverDialogue popover) { ImNode node = (ImNode)popover.correspondingEntity; bool hasTitle = false; bool hasDone = false; foreach (ImTableCell cell in popover.tableCells) { if (cell.tableCellType == TableCellType.Done) hasDone = true; if (cell.tableCellType == TableCellType.Title) hasTitle = true; } if (!hasTitle) popover.AddTableCell(ImConfig.NameForNodePlacement(node.nodePlacement), TableCellType.Title); foreach (ImAbstractItem item in inventory) { ImTableCell cellWithItem = null; foreach (ImTableCell itemCell in popover.tableCells) { if (itemCell.item == item) cellWithItem = itemCell; } if (cellWithItem == null && item.CanBeUsedOnEntity(popover.correspondingEntity)) popover.AddTableCell(item.Description(), "Futile_White", item, TableCellType.Item); if (cellWithItem != null && !item.CanBeUsedOnEntity(popover.correspondingEntity)) popover.RemoveTableCell(cellWithItem); } if (!hasDone) popover.AddTableCell("Done", TableCellType.Done); }
public WTImmunity() : base("") { instance = this; Futile.AddStage(this); gameLayer = new FContainer(); gameLayer.x = Futile.screen.halfWidth; gameLayer.y = Futile.screen.halfHeight; gameLayer.scale = 0.23f; zoomLevel_ = gameLayer.scale; AddChild(gameLayer); inventory = new List <ImAbstractItem>(); inventory.Add(new ImHealthPill("Health Pill", 15)); inventory.Add(new ImPoisonPill("Poison Pill", 6)); inventory.Add(new ImPoisonPill("Poison Pill", 17)); inventory.Add(new ImHealthPill("Health Pill", 5)); inventory.Add(new ImPoisonPill("Poison Pill", 30)); inventory.Add(new ImHealthPill("Health Pill", 7)); inventory.Add(new ImHealthPill("Health Pill", 42)); float sliceWidth = 460f / 4f; float sliceHeight = 436f / 4f; int sliceHorizontalCount = 6; int sliceVerticalCount = 16; float bodyWidth = sliceWidth * sliceHorizontalCount; float bodyHeight = sliceHeight * sliceVerticalCount; FContainer bodyContainer = new FContainer(); bodyContainer.x -= bodyWidth / 2f; bodyContainer.y -= bodyHeight / 2f; gameLayer.AddChild(bodyContainer); for (int i = 0; i < sliceVerticalCount; i++) { for (int j = 0; j < sliceHorizontalCount; j++) { int imageNum = i * sliceHorizontalCount + j + 1; string imageName = string.Format("bodySlices/body_{0}.png", imageNum.ToString("D2")); FSprite slice = new FSprite(imageName); slice.anchorX = slice.anchorY = 0; slice.x = j * sliceWidth; slice.y = bodyHeight - (i + 1) * sliceHeight; bodyContainer.AddChild(slice); } } organLayer = new ImOrganLayer(); organLayer.owner = this; gameLayer.AddChild(organLayer); veinLayer = new ImVeinLayer(); veinLayer.owner = this; gameLayer.AddChild(veinLayer); nodeLayer = new ImNodeLayer(); nodeLayer.owner = this; gameLayer.AddChild(nodeLayer); /*pop = new ImPopoverDialogue(100f, 100f, 4f, PopoverTriangleDirectionType.PointingRight); * AddChild(pop);*/ pop = new WTPopoverDialogue(false, "popover!"); pop.SignalNeedsInventoryRefresh += HandlePopoverNeedsInventoryRefresh; pop.SignalItemUsed += HandleItemUsed; pop.x = Futile.screen.halfWidth; pop.y = Futile.screen.halfHeight; pop.width = 200f; pop.isVisible = false; AddChild(pop); uiLayer = new ImUILayer(); SignalPauseStateChanged += uiLayer.SetTransportBar; AddChild(uiLayer); ImNode node = nodeLayer.NodeForPlacement(NodePlacement.ElbowRight); node.Infect(testVirus); node.InfectionComponent().StartInfecting(); }