public override void _Process(float delta) { if (!Input.IsActionJustPressed("ui_cancel") || Popup != null) { return; } Popup = PopupScene.Instance <WindowDialog>(); Popup.GetNode("Button_quit").Connect("pressed", this, nameof(PopupQuit)); Popup.Connect("popup_hide", this, nameof(PopupClosed)); Popup.GetNode("Button_resume").Connect("pressed", this, nameof(PopupClosed)); CanvasLayer.AddChild(Popup); Popup.PopupCentered(); Input.SetMouseMode(Input.MouseMode.Visible); GetTree().Paused = true; }
/// <summary> Push a new scene onto the stack. </summary> public static void Push(PrimeScene scene, bool hideSceneBelow = true) { if (scene == null) { return; } scene.IsHidingSceneBelow = hideSceneBelow; SuspendTopScene(hideSceneBelow); Stack.Add(scene); if (scene.AttachToViewport) { CanvasLayer canvasLayer = new CanvasLayer(); canvasLayer.Name = $"{scene.Name}"; canvasLayer.AddChild(scene); StackRoot.AddChild(canvasLayer); } else { StackRoot.AddChild(scene); } Tree.SetInputAsHandled(); scene.OnPushed(); scene.OnCurrent(); }
public void AddNickLabel(int Id, string Nick) { Label Instance = NickLabelScene.Instance() as Label; Instance.Text = Nick; NickLabelLayer.AddChild(Instance); NickLabels[Id] = Instance; }
public void AddNickLabel(int Id, string Nick) { var Instance = (Label)NickLabelScene.Instance(); Instance.Text = Nick; NickLabelLayer.AddChild(Instance); NickLabels[Id] = Instance; }
public static void UpdateLabel() { if (Labels.Count > 0) { if (!Node.IsInstanceValid(instance)) { var layer = new CanvasLayer(); layer.AddChild(instance = new DrawDebugLabels()); layer.AddChild(vScroll = new VScrollBar()); Scene.Current.AddChild(layer); layer.Owner = Scene.Current; instance.Owner = layer; vScroll.Owner = layer; } if (Labels.Count < lastcount) // fixes text bug when less text is printed than last frame { var layer = instance.GetParent(); layer.RemoveChild(instance); layer.AddChild(instance); } builder.Clear(); vScroll.MaxValue = (Labels.Count - 1).min(1); int scroll = (int)vScroll.Value; int count = 0; while (count < 50) { var current = scroll + count; if (current >= Labels.Count) { break; } builder.Append(Labels[current]); count++; } instance.Text = builder.ToString(); lastcount = Labels.Count; Labels.Clear(); } else if (Node.IsInstanceValid(instance)) { instance.GetParent().QueueFree(); } }
public void initChalkIcons() { var startPosition = new Vector2(0, 175); var vSpace = 30.0f; PackedScene chalkIconScn = (PackedScene)ResourceLoader.Load("res://Nodes/chalkIcon.tscn"); for (int i = 0; i < colorOptions.Count; i++) { var color = colorOptions[i]; var chalkIcon = (chalkButton)chalkIconScn.Instance(); var cSprite = (Sprite)chalkIcon.GetNode("chalk_icon"); cSprite.SelfModulate = colorOptions[i]; var posX = currentColorIndex == i ? 20.0f:0.0f; chalkIcon.Position = startPosition + new Vector2(posX, vSpace * i); chalkIcon.colorIndex = i; // Owner.AddChild(chalkIcon); CanvasLayer c = GetTree().GetNodesInGroup("CANVAS")[0] as CanvasLayer; c.AddChild(chalkIcon); } }
void LoadGalaxy(PackedScene galaxyScene) { GalaxyMap = galaxyScene.Instance() as GalaxyMap; hudRoot.AddChild(GalaxyMap); GalaxyMap.Visible = false; //Randomize galaxy map edge weights? if (simulationMode == SimulationMode.Gamma && galaxySeed != 0) { GalaxyMap.RandomizeEdgeWeights(galaxySeed); } foreach (GalaxyMapNode mapNode in GalaxyMap.Nodes) { var newSolarSystem = LoadSolarSystemIntoViewportContainer(mapNode.Name); } var startingViewportContainer = SolarSystemViewportContainersByName[GalaxyMap.StartingNode.Name]; MoveChild(startingViewportContainer, GetChildCount() - 1); //Spawn colony ships ColonyShip firstColonyShip = null; for (int i = 0; i < colonyShipScenes.Count; i++) { var newColonyShip = colonyShipScenes[i].Instance() as ColonyShip; //newColonyShip.LandingSequenceTriggered += HandleColonyShipLandingSequenceTriggered; ColonyShips.Add(newColonyShip.ShipName, newColonyShip); //Move colony ship back to origin if (newColonyShip != null) { if (newColonyShip.GetParent() != null) { newColonyShip.GetParent().RemoveChild(newColonyShip); } SolarSystemViewportContainersByName[GalaxyMap.StartingNode.Name].GetChild(0).AddChild(newColonyShip); //gameObjectsRoot.AddChild(newColonyShip); newColonyShip.CurrentSolarSystemName = GalaxyMap.StartingNode.Name; newColonyShip.GlobalPosition = Vector2.Left * 100f + Vector2.Up * 100f * i; } OnColonyShipSpawned?.Invoke(newColonyShip); if (firstColonyShip == null) { firstColonyShip = newColonyShip; } } //Set camera/info panel focus ColonyShip focusShip = null; foreach (var pair in ColonyShips) { if (pair.Key == startFocusedOnShip) { focusShip = pair.Value; } } if (focusShip == null) { GD.PrintErr("No focus ship designed in GameCore inspector panel. Choosing Nostromo by default."); focusShip = ColonyShips[ShipNames.Nostromo]; } else { shipInfoPanels.FocusShip = focusShip; } }
public CharacterPlayer(int x, int y, Level level) : base(x, y, level) { if (level != null) { _camera = new Camera(); _camera.Current = true; switch (Type) { case CharacterType.Player_East: _camera.Transform = Transform.Identity.Rotated(Vector3.Up, Mathf.Pi * -0.5f); break; case CharacterType.Player_West: _camera.Transform = Transform.Identity.Rotated(Vector3.Up, Mathf.Pi * 0.5f); break; case CharacterType.Player_South: _camera.Transform = Transform.Identity.Rotated(Vector3.Up, Mathf.Pi * -1.0f); break; } _moveSpeed = Level.CellSize * 200.0f; _turnSpeed = 3f; _useRay = new RayCast(); _useRay.Enabled = true; _useRay.ExcludeParent = true; _useRay.CastTo = Vector3.Forward * (Level.CellSize * 0.5f); _useRay.CollisionMask = (uint)( Level.CollisionLayers.Characters | Level.CollisionLayers.Static | Level.CollisionLayers.Walls); _useRay.AddException(this); _camera.AddChild(_useRay); _flashDuration = 0.5f; _flashRect = new ColorRect(); _flashRect.MouseFilter = Control.MouseFilterEnum.Ignore; _flashRect.Color = new Color(0.75f, 0.75f, 0f, 1f); _flashRect.AnchorTop = _flashRect.AnchorLeft = 0f; _flashRect.AnchorRight = _flashRect.AnchorBottom = 1f; _flashRect.SetAsToplevel(true); _flashRect.ShowOnTop = true; _flashRect.Visible = false; _flashTween = new Tween(); _flashTween.Connect("tween_all_completed", this, "OnFlashTweenCompleted"); _flashRect.AddChild(_flashTween); _flashCanvas = new CanvasLayer(); _flashCanvas.AddChild(_flashRect); _camera.AddChild(_flashCanvas); AddChild(_camera); SetProcess(true); SetPhysicsProcess(true); } }