/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> public override void Update(double deltaTime) { if (tutorial != null) { tutorial.Update((float)deltaTime); } hullVolumeFrame.Visible = MapEntity.SelectedList.Any(s => s is Hull); cam.MoveCamera((float)deltaTime, true, GUIComponent.MouseOn == null); if (characterMode || wiringMode) { if (dummyCharacter == null || Entity.FindEntityByID(dummyCharacter.ID) != dummyCharacter) { ToggleCharacterMode(null, null); } else { foreach (MapEntity me in MapEntity.mapEntityList) { me.IsHighlighted = false; } if (wiringMode && dummyCharacter.SelectedConstruction == null) { List <Wire> wires = new List <Wire>(); foreach (Item item in Item.ItemList) { var wire = item.GetComponent <Wire>(); if (wire != null) { wires.Add(wire); } } Wire.UpdateEditing(wires); } if (dummyCharacter.SelectedConstruction == null) { Vector2 mouseSimPos = FarseerPhysics.ConvertUnits.ToSimUnits(dummyCharacter.CursorPosition); foreach (Limb limb in dummyCharacter.AnimController.Limbs) { limb.body.SetTransform(mouseSimPos, 0.0f); } dummyCharacter.AnimController.Collider.SetTransform(mouseSimPos, 0.0f); } dummyCharacter.ControlLocalPlayer((float)deltaTime, cam, false); dummyCharacter.Control((float)deltaTime, cam); dummyCharacter.Submarine = Submarine.MainSub; cam.TargetPos = Vector2.Zero; } } else { MapEntity.UpdateSelecting(cam); } //GUIComponent.ForceMouseOn(null); if (!characterMode && !wiringMode) { if (MapEntityPrefab.Selected != null) { MapEntityPrefab.Selected.UpdatePlacing(cam); } MapEntity.UpdateEditor(cam); } leftPanel.Update((float)deltaTime); topPanel.Update((float)deltaTime); if (wiringMode) { if (!dummyCharacter.SelectedItems.Any(it => it != null && it.HasTag("Wire"))) { wiringToolPanel.GetChild <GUIListBox>().Deselect(); } wiringToolPanel.Update((float)deltaTime); } if (loadFrame != null) { loadFrame.Update((float)deltaTime); if (PlayerInput.RightButtonClicked()) { loadFrame = null; } } else if (saveFrame != null) { saveFrame.Update((float)deltaTime); } else if (selectedTab > -1) { GUItabs[selectedTab].Update((float)deltaTime); if (PlayerInput.RightButtonClicked()) { selectedTab = -1; } } if ((characterMode || wiringMode) && dummyCharacter != null) { dummyCharacter.AnimController.FindHull(dummyCharacter.CursorWorldPosition, false); foreach (Item item in dummyCharacter.SelectedItems) { if (item == null) { continue; } item.SetTransform(dummyCharacter.SimPosition, 0.0f); item.Update((float)deltaTime, cam); item.SetTransform(item.body.SimPosition, 0.0f); } if (dummyCharacter.SelectedConstruction != null) { if (dummyCharacter.SelectedConstruction != null) { dummyCharacter.SelectedConstruction.UpdateHUD(cam, dummyCharacter); } if (PlayerInput.KeyHit(InputType.Select) && dummyCharacter.FocusedItem != dummyCharacter.SelectedConstruction) { dummyCharacter.SelectedConstruction = null; } } CharacterHUD.Update((float)deltaTime, dummyCharacter); } GUI.Update((float)deltaTime); }
public override void Select() { base.Select(); GameMain.DebugDraw = true; cam = new Camera(); GUIpanel = new GUIFrame(new Rectangle(0, 0, 300, GameMain.GraphicsHeight), ""); GUIpanel.Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f); physicsButton = new GUIButton(new Rectangle(0, 50, 200, 25), "Physics", Alignment.Left, "", GUIpanel); physicsButton.OnClicked += TogglePhysics; new GUITextBlock(new Rectangle(0, 80, 0, 25), "Limbs:", "", GUIpanel); limbList = new GUIListBox(new Rectangle(0, 110, 0, 250), Color.White * 0.7f, "", GUIpanel); limbList.OnSelected = SelectLimb; new GUITextBlock(new Rectangle(0, 360, 0, 25), "Joints:", "", GUIpanel); jointList = new GUIListBox(new Rectangle(0, 390, 0, 250), Color.White * 0.7f, "", GUIpanel); while (Character.CharacterList.Count > 1) { Character.CharacterList.First().Remove(); } if (Character.CharacterList.Count == 1) { if (editingCharacter != Character.CharacterList[0]) { UpdateLimbLists(Character.CharacterList[0]); } editingCharacter = Character.CharacterList[0]; Vector2 camPos = editingCharacter.AnimController.Limbs[0].body.SimPosition; camPos = ConvertUnits.ToDisplayUnits(camPos); camPos.Y = -camPos.Y; cam.TargetPos = camPos; if (physicsEnabled) { editingCharacter.Control(1.0f, cam); } else { cam.TargetPos = Vector2.Zero; } } textures = new List <Texture2D>(); texturePaths = new List <string>(); foreach (Limb limb in editingCharacter.AnimController.Limbs) { if (limb.sprite == null || texturePaths.Contains(limb.sprite.FilePath)) { continue; } textures.Add(limb.sprite.Texture); texturePaths.Add(limb.sprite.FilePath); } }