diff --git a/scenes/game.tscn b/scenes/game.tscn index 164bdf7..e57240f 100644 --- a/scenes/game.tscn +++ b/scenes/game.tscn @@ -59,12 +59,6 @@ layout_mode = 2 mouse_filter = 2 texture = ExtResource("2_n1yht") -[node name="OperationTip" type="RichTextLabel" parent="CanvasLayer/Control/VBoxContainer"] -layout_mode = 2 -mouse_filter = 2 -bbcode_enabled = true -fit_content = true - [node name="FPSLabel" type="Label" parent="CanvasLayer/Control"] layout_mode = 1 anchors_preset = 1 diff --git a/scripts/Config.cs b/scripts/Config.cs index 8236050..c31b801 100644 --- a/scripts/Config.cs +++ b/scripts/Config.cs @@ -108,13 +108,6 @@ public static class Config /// public const long TextChangesBuffetingDuration = 300; - /// - /// Operation prompts, function key text color - /// 操作提示内,功能键文本颜色 - /// - public const string OperationTipActionColor = "#2b8a3e"; - - /// /// Company/Creator name /// 公司/创作者名字 diff --git a/scripts/GameSceneDepend.cs b/scripts/GameSceneDepend.cs index 17f4c30..7d43824 100644 --- a/scripts/GameSceneDepend.cs +++ b/scripts/GameSceneDepend.cs @@ -97,12 +97,6 @@ public static class GameSceneDepend /// 健康条UI /// public static HealthBarUi? HealthBarUi { get; set; } - - /// - /// operation tip - /// 操作提示 - /// - public static RichTextLabel? OperationTipLabel { get; set; } /// /// DynamicUiGroup diff --git a/scripts/character/Player.cs b/scripts/character/Player.cs index cd68e22..a1e1260 100644 --- a/scripts/character/Player.cs +++ b/scripts/character/Player.cs @@ -1,4 +1,3 @@ -using System.Text; using System.Threading.Tasks; using ColdMint.scripts.damage; using ColdMint.scripts.deathInfo; @@ -45,7 +44,6 @@ public partial class Player : CharacterTemplate GlobalPosition); _parabola = GetNode("Parabola"); _platformDetectionRayCast2D = GetNode("PlatformDetectionRayCast"); - UpdateOperationTip(); var healthBarUi = GameSceneDepend.HealthBarUi; if (healthBarUi != null) { @@ -107,109 +105,13 @@ public partial class Player : CharacterTemplate { } - /// - /// Update operation prompt - /// 更新操作提示 - /// - private void UpdateOperationTip() - { - var operationTipLabel = GameSceneDepend.OperationTipLabel; - if (operationTipLabel == null) - { - return; - } - - var operationTipBuilder = new StringBuilder(); - - operationTipBuilder.Append("[color="); - operationTipBuilder.Append(Config.OperationTipActionColor); - operationTipBuilder.Append(']'); - operationTipBuilder.Append(TranslationServerUtils.Translate(InputMap.ActionGetEvents("ui_left")[0].AsText())); - operationTipBuilder.Append("[/color]"); - operationTipBuilder.Append(TranslationServerUtils.Translate("action_move_left")); - operationTipBuilder.Append(' '); - operationTipBuilder.Append("[color="); - operationTipBuilder.Append(Config.OperationTipActionColor); - operationTipBuilder.Append(']'); - operationTipBuilder.Append(TranslationServerUtils.Translate(InputMap.ActionGetEvents("ui_right")[0].AsText())); - operationTipBuilder.Append("[/color]"); - operationTipBuilder.Append(TranslationServerUtils.Translate("action_move_right")); - operationTipBuilder.Append(' '); - operationTipBuilder.Append("[color="); - operationTipBuilder.Append(Config.OperationTipActionColor); - operationTipBuilder.Append(']'); - operationTipBuilder.Append(TranslationServerUtils.Translate(InputMap.ActionGetEvents("ui_up")[0].AsText())); - operationTipBuilder.Append("[/color]"); - operationTipBuilder.Append(TranslationServerUtils.Translate("action_jump")); - if (_collidingWithPlatform) - { - operationTipBuilder.Append(' '); - operationTipBuilder.Append("[color="); - operationTipBuilder.Append(Config.OperationTipActionColor); - operationTipBuilder.Append(']'); - operationTipBuilder.Append( - TranslationServerUtils.Translate(InputMap.ActionGetEvents("ui_down")[0].AsText())); - operationTipBuilder.Append("[/color]"); - operationTipBuilder.Append(TranslationServerUtils.Translate("action_jump_down")); - } - - var nearestItem = FindTheNearestItem(); - if (nearestItem != null) - { - operationTipBuilder.Append(' '); - operationTipBuilder.Append("[color="); - operationTipBuilder.Append(Config.OperationTipActionColor); - operationTipBuilder.Append(']'); - operationTipBuilder.Append( - TranslationServerUtils.Translate(InputMap.ActionGetEvents("pick_up")[0].AsText())); - operationTipBuilder.Append("[/color]"); - operationTipBuilder.Append(TranslationServerUtils.Translate("action_pick_up")); - if (nearestItem is IItem item) - { - operationTipBuilder.Append(item.Name); - } - - operationTipLabel.Text = operationTipBuilder.ToString(); - } - - if (CurrentItem != null) - { - operationTipBuilder.Append(' '); - operationTipBuilder.Append("[color="); - operationTipBuilder.Append(Config.OperationTipActionColor); - operationTipBuilder.Append(']'); - operationTipBuilder.Append(TranslationServerUtils.Translate(InputMap.ActionGetEvents("throw")[0].AsText())); - operationTipBuilder.Append("[/color]"); - operationTipBuilder.Append(TranslationServerUtils.Translate("action_throw")); - if (CurrentItem is IItem item) - { - operationTipBuilder.Append(TranslationServerUtils.Translate(item.Name)); - operationTipBuilder.Append(' '); - operationTipBuilder.Append("[color="); - operationTipBuilder.Append(Config.OperationTipActionColor); - operationTipBuilder.Append(']'); - operationTipBuilder.Append( - TranslationServerUtils.Translate(InputMap.ActionGetEvents("use_item")[0].AsText())); - operationTipBuilder.Append("[/color]"); - operationTipBuilder.Append(TranslationServerUtils.Translate("action_use_item")); - operationTipBuilder.Append(TranslationServerUtils.Translate(item.Name)); - } - } - - operationTipLabel.Text = operationTipBuilder.ToString(); - } - - protected override void HookPhysicsProcess(ref Vector2 velocity, double delta) { //When the collision state between the platform detection ray and the platform changes //在平台检测射线与平台碰撞状态改变时 if (_platformDetectionRayCast2D != null && _platformDetectionRayCast2D.IsColliding() != _collidingWithPlatform) { - //When the state changes, update the action hint - //当状态改变时,更新操作提示 _collidingWithPlatform = _platformDetectionRayCast2D.IsColliding(); - UpdateOperationTip(); } //If the character is on the ground, give an upward velocity when the jump button is pressed @@ -304,12 +206,7 @@ public partial class Player : CharacterTemplate CurrentItem = null; } } - - protected override void WhenUpdateCurrentItem(Node2D? currentItem) - { - UpdateOperationTip(); - } - + /// /// 当玩家手动抛出物品时,施加到物品上的速度值 /// @@ -415,35 +312,7 @@ public partial class Player : CharacterTemplate EventBus.GameOverEvent.Invoke(gameOverEvent); } - - protected override void EnterThePickingRangeBody(Node node) - { - base.EnterThePickingRangeBody(node); - if (CurrentItem == node) - { - //If the node entering the pick range is the node held by the player, then return. - //如果说进入拾捡范围的节点是玩家所持有的节点,那么返回。 - return; - } - - if (node is not Node2D) - { - return; - } - - UpdateOperationTip(); - } - - protected override void ExitThePickingRangeBody(Node node) - { - base.ExitThePickingRangeBody(node); - if (node is not Node2D) - { - return; - } - - UpdateOperationTip(); - } + protected override void OnHit(DamageTemplate damageTemplate) { diff --git a/scripts/loader/sceneLoader/GameSceneLoader.cs b/scripts/loader/sceneLoader/GameSceneLoader.cs index eeede9b..d15d807 100644 --- a/scripts/loader/sceneLoader/GameSceneLoader.cs +++ b/scripts/loader/sceneLoader/GameSceneLoader.cs @@ -33,10 +33,6 @@ public partial class GameSceneLoader : SceneLoaderTemplate //背包Ui容器 var backpackUiContainer = GetNode("CanvasLayer/DynamicUiGroup"); GameSceneDepend.DynamicUiGroup = backpackUiContainer; - //Load operation prompt - //加载操作提示 - var operationTip = GetNode("CanvasLayer/Control/VBoxContainer/OperationTip"); - GameSceneDepend.OperationTipLabel = operationTip; //Loaded weapon container //加载武器容器 var weaponContainer = GetNode("WeaponContainer");