// // Called every frame. 'delta' is the elapsed time since the previous frame. public override void _Process(float delta) { Update(); //AngleLimitRotation += ((Input.IsActionPressed("right") ? 150 : 0) - (Input.IsActionPressed("left") ? 150 : 0)) * delta; //AngleLimitSize += ((Input.IsActionPressed("up") ? 150 : 0) - (Input.IsActionPressed("down") ? 150 : 0)) * delta; //GD.Print(AngleLimitRotation + " - " + (CheckAngleLimit(paddleHolder.RotationDegrees, AngleLimitRotation - AngleLimitSize, AngleLimitRotation + AngleLimitSize) ? "Yep" : "Nope")); AngleLimitRotation += 10 * delta; deltasum += delta * 2; AngleLimitSize = 30 + (10 * Mathf.Sin(deltasum)); if (!CheckAngleLimit(paddleHolder.RotationDegrees, AngleLimitRotation - AngleLimitSize, AngleLimitRotation + AngleLimitSize)) { if (GetNode <Timer>("Timer").IsStopped()) { GetNode <Timer>("Timer").Start(); signalManager.EmitSignal(nameof(SignalManager.TargetAreaLeft)); } } else { if (!GetNode <Timer>("Timer").IsStopped()) { GetNode <Timer>("Timer").Stop(); signalManager.EmitSignal(nameof(SignalManager.TargetAreaEntered)); } } }
void UpdateCurrentSelection() { var sel = Global.inst.selection; if (sel.selected && sel.building != null) { UpdateView(); UpdateInput(); SignalManager.EmitSignal(emitBuildingPanelOn); } else { SignalManager.EmitSignal(emitBuildingPanelOff); ClearView(); } }
protected override void SignalBypass() { base.SignalBypass(); if (recentFilePath == null || recentFilePath != text.text) { if (LoadNewFile(text.text)) { recentFilePath = text.text; SignalManager.EmitSignal(new Signal(emitFileLoad)); } else { Global.inst.textAgent.Update(textRequest, LocalizationSupport.GetLocalizedString(notFound)); } } }
private void OnPaddleAreaEntered(Area2D area) { if (area.IsInGroup("Ball")) { (area.GetParent() as Ball).Redirect(new Vector2(Godot.Mathf.Cos(paddleArea.GlobalRotation), Godot.Mathf.Sin(paddleArea.GlobalRotation))); (area.GetParent() as Ball).Hit(); GetNode <Global>("/root/Global").SpwanHit(area.GlobalPosition); } else if (area.IsInGroup("Enemy")) { if (!GetNode <Global>("/root/Global").defeat&& !GetNode <Global>("/root/Global").victory) { GetNode <Global>("/root/Global").Defeat(); signalManager.EmitSignal(nameof(SignalManager.Defeat)); } } }
void Start() { AddCallback(new Signal(signalSelect), () => { if (Global.inst.edt == null) { return; // Do nothing... } var pos = Global.inst.cursorPointingGrid; var sel = Global.inst.selection; var edt = Global.inst.edt; int su = -1; int sb = -1; if (sel.selected) { if (sel.battleUnit != null) { su = TrySelectUnit(edt, pos, sel.id + 1, edt.units.count - 1); if (su == -1) { su = TrySelectUnit(edt, pos, 0, sel.id - 1); } if (su == -1) { sb = TrySelectBuilding(edt, pos, 0, edt.buildings.count - 1); } if (su == -1 && sb == -1) { su = TrySelectUnit(edt, pos, sel.id, sel.id); } } else { sb = TrySelectBuilding(edt, pos, sel.id + 1, edt.buildings.count - 1); if (sb == -1) { su = TrySelectUnit(edt, pos, 0, edt.units.count - 1); } if (sb == -1 && su == -1) { sb = TrySelectBuilding(edt, pos, 0, sel.id - 1); } if (su == -1 && sb == -1) { sb = TrySelectBuilding(edt, pos, sel.id, sel.id); } } } else { sb = TrySelectBuilding(edt, pos, 0, edt.buildings.count - 1); if (sb == -1) { su = TrySelectUnit(edt, pos, 0, edt.units.count - 1); } } if (sb != -1) { sel.SetBuilding(sb); SignalManager.EmitSignal(emitAfterSelect); } else if (su != -1) { sel.SetUnit(su); SignalManager.EmitSignal(emitAfterSelect); } else { sel.Reset(); } }); }
void Start() { // [Shift + Esc | Ctrl + Esc] quit. RadiacInputController.KeyboardBypass += (Event e) => { if (e.shift || e.control) { if (Input.GetKeyDown(KeyCode.Escape)) { Debug.Log("Quit!"); Application.Quit(); } } }; // [Shift + B] switch the grid pointer. RadiacInputController.KeyboardBypass += (Event e) => { if (e.shift && e.keyCode == KeyCode.B && e.type == EventType.KeyDown) { Global.inst.showGridPointer = !Global.inst.showGridPointer; } }; // [Shift + S | Ctrl + S] save. // Notice this key is not affected by RadiacUI. RadiacInputController.KeyboardBypass += (Event e) => { if (Input.GetKeyDown(KeyCode.S) && (e.shift || e.control)) { bool saved = false; if (Global.inst.edt != null) { Global.inst.edt.Save(Global.inst.edtName); saved = true; } if (Global.inst.map != null) { Global.inst.map.Save(Global.inst.mapName); saved = true; } if (saved) { SignalManager.EmitSignal(new Signal(fileSaveSignal)); } } }; // [Shift + P | Ctrl + P] screenshot. RadiacInputController.KeyboardBypass += (Event e) => { if (Input.GetKeyDown(KeyCode.P) && (e.shift || e.control)) { Directory.CreateDirectory(screenShotPath); ScreenCapture.CaptureScreenshot(screenShotPath + DateTime.Now.ToString("yyyy-mm-dd-hh-mm-ss-ffff") + ".png"); } }; // [Shift + M] switch the map display. // The map displaying will be turned on when enabling map editing without shortkey. RadiacInputController.KeyboardBypass += (Event e) => { if (Input.GetKeyDown(KeyCode.M) && e.shift) { Global.inst.showTiles = !Global.inst.showTiles; } }; // [Shift + ;] switch mous position display. RadiacInputController.KeyboardBypass += (Event e) => { if (Input.GetKeyDown(KeyCode.Semicolon) && e.shift) { Global.inst.showMousePosition = !Global.inst.showMousePosition; } }; // [Shift + D] synchonrize selected object's position with mouse. // RadiacInputController.KeyboardBypass += (Event e) => // { // if(Input.GetKeyDown(KeyCode.D) && e.shift) // { // Global.inst.syncPosition = true; // } // else if(Input.GetKeyUp(KeyCode.D) || !e.shift) // { // Global.inst.syncPosition = false; // } // }; // [Ctrl + C | Shift + C] copy. RadiacInputController.KeyboardBypass += (Event e) => { // This sentence is not necessary since there can't be a selction when edt file is not loaded. // Preserved for bug-preventing... if (Global.inst.edt == null) { return; } if (!Global.inst.selection.selected) { return; } if (Input.GetKeyDown(KeyCode.C) && (e.control || e.shift)) { if (Global.inst.selection.building != null) { Debug.Log("Building to clipboard."); Global.inst.clipBoard = Global.inst.selection.building.Clone(); } else if (Global.inst.selection.battleUnit != null) { Debug.Log("Unit to clipboard."); Global.inst.clipBoard = Global.inst.selection.battleUnit.Clone(); } } }; // [Ctrl + V | Shift + V] paste. RadiacInputController.KeyboardBypass += (Event e) => { if (Global.inst.edt == null) { return; } if (Input.GetKey(KeyCode.V) && (e.control || e.shift)) { if (Global.inst.clipBoard is Building) { // add to the tail; select the tail. Debug.Log("Paste building."); var x = Global.inst.edt.buildings.Add(); x.Assign(Global.inst.clipBoard); Global.inst.selection.SetBuilding(Global.inst.edt.buildings.count - 1); x.x = Global.inst.cursorPointingGrid.x; x.y = Global.inst.cursorPointingGrid.y; } else if (Global.inst.clipBoard is Unit) { // add to the tail; select the tail. Debug.Log("Paste unit."); var x = Global.inst.edt.units.Add(); x.Assign(Global.inst.clipBoard); Global.inst.selection.SetUnit(Global.inst.edt.units.count - 1); x.x = Global.inst.cursorPointingGrid.x; x.y = Global.inst.cursorPointingGrid.y; } } }; // [Ctrl + X | Shift + X] cut. // This equals copy and remove. RadiacInputController.KeyboardBypass += (Event e) => { if (Global.inst.edt == null) { return; } if (!Global.inst.selection.selected) { return; } if (Input.GetKey(KeyCode.X) && (e.control || e.shift)) { if (Global.inst.selection.building != null) { Global.inst.clipBoard = Global.inst.selection.building.Clone(); Global.inst.edt.buildings.Remove(Global.inst.selection.id); } else if (Global.inst.selection.battleUnit != null) { Global.inst.clipBoard = Global.inst.selection.battleUnit.Clone(); Global.inst.edt.units.Remove(Global.inst.selection.id); } Global.inst.selection.Reset(); } }; // [Delete | Shift + Tab] delete current selecetion. RadiacInputController.KeyboardBypass += (Event e) => { if (Global.inst.edt == null) { return; } if (!Global.inst.selection.selected) { return; } if (Input.GetKey(KeyCode.Delete) || (Input.GetKeyDown(KeyCode.Tab) && Input.GetKey(KeyCode.LeftShift))) { if (Global.inst.selection.building != null) { Global.inst.edt.buildings.Remove(Global.inst.selection.id); } else if (Global.inst.selection.battleUnit != null) { Global.inst.edt.units.Remove(Global.inst.selection.id); } Global.inst.selection.Reset(); } }; // [Shift + W] create building. RadiacInputController.KeyboardBypass += (Event e) => { if (Global.inst.edt == null) { return; } if (Input.GetKey(KeyCode.W) && e.shift) { var x = Global.inst.edt.buildings.Add(); x.x = Global.inst.cursorPointingGrid.x; x.y = Global.inst.cursorPointingGrid.y; Global.inst.selection.SetBuilding(Global.inst.edt.buildings.count - 1); } }; // [Shift + E] create unit. RadiacInputController.KeyboardBypass += (Event e) => { if (Global.inst.edt == null) { return; } if (Input.GetKey(KeyCode.E) && e.shift) { var x = Global.inst.edt.units.Add(); var pos = (Global.inst.cursorPointingGrid + new Vector2(0.5f, 0.5f)) * Global.gridSize; x.x = (int)pos.x; x.y = (int)pos.y; Global.inst.selection.SetUnit(Global.inst.edt.units.count - 1); } }; RadiacInputController.KeyboardBypass += (Event e) => { if (Input.GetKeyDown(KeyCode.T) && e.shift) { Global.inst.showDecoration = !Global.inst.showDecoration; } }; // [F1 | H] switch hint panel. RadiacInputController.KeyboardBypass += (Event e) => { if (Input.GetKeyDown(KeyCode.F1) || Input.GetKeyDown(KeyCode.H)) { SignalManager.EmitSignal(new Signal("HintOn")); } else if (Input.GetKeyUp(KeyCode.F1) || Input.GetKeyUp(KeyCode.H)) { SignalManager.EmitSignal(new Signal("HintOff")); } }; }