using System.Collections.Generic; using Godot; using Godot.Collections; public partial class Menu : Node2D { private Timer _timer; private AudioStreamPlayer2D _thunderclap; private AnimationPlayer _animationPlayer; private Array _translations = new Array{"en", "ru"}; private int _languagesCount; private int _currentLanguage = 0; private Resource _cursorTexture; public override void _Ready() { TranslationServer.SetLocale("en"); _languagesCount = _translations.Count; _timer = (Timer)FindChild("Timer"); _thunderclap = (AudioStreamPlayer2D)FindChild("Thunderclap"); _animationPlayer = (AnimationPlayer)FindChild("AnimationPlayer"); GameManager.IsPlaying = false; _animationPlayer.Play("intro_animation"); } public override void _Input(InputEvent @event) { if (@event.IsActionPressed("ui_confirm") && _timer.IsStopped()) { _animationPlayer.Play("thunder"); _thunderclap.Play(); _timer.Start(); DisplayServer.MouseSetMode(DisplayServer.MouseMode.Hidden); } else if (@event.IsActionPressed("ui_change_language")) { _currentLanguage++; if (_currentLanguage >= _languagesCount) _currentLanguage = 0; TranslationServer.SetLocale(_translations[_currentLanguage]); } } public void ChangeScene() { GetTree().ChangeSceneToFile("res://scenes/main_scene.tscn"); } }