コード例 #1
0
    public override void _Notification(int what)
    {
        // When exit the game
        if (what == MainLoop.NotificationWmQuitRequest)
        {
            Nucleus_Utils.Finalize_Utils();

            GetTree().Quit(); // default behavior
        }
    }
コード例 #2
0
    /// <summary>
    /// Initialize the State Machine node reference in Utils (will be used by the States)
    /// </summary>
    private void _Init_StateMachine(string pGroupName)
    {
        Node node = Nucleus_Utils.FindNode_BasedOnGroup(this, pGroupName);

        if (node != null)
        {
            Nucleus_Utils.StateMachine_Template = (StateMachine_Template)node;
            RootNode = (KinematicBody2D)Owner;

            base.Initialize(InitialState);
        }
        else
        {
            //GD.Print("ERROR (in States.cs) - State Machine node is null (Class : " + this.GetType() + ")");
            Nucleus_Utils.Error($"State Machine node is null (Groupname : {pGroupName}", new NullReferenceException(), GetType().Name, MethodBase.GetCurrentMethod().Name);

            GetTree().Quit();      // Quit game
        }
    }
コード例 #3
0
//*-------------------------------------------------------------------------*//

    #region USER METHODS

    /// <summary>
    /// Load an existing scene in the Spawn_Factory  (can be used to spawn random instance of different scene)
    /// </summary>
    /// <param name="pPath">the path to the scene (eg : ""res://src/Enemy.tscn")</param>
    /// <returns>True if no errors occurs</returns>
    public bool Load_NewScene(string pPath)
    {
        if (pPath != "")
        {
            try
            {
                PackedScene scene = (PackedScene)ResourceLoader.Load(pPath);
                ListScenes.Add(scene);
                return(true);
            }
            catch (System.Exception ex)
            {
                Nucleus_Utils.Error($"Error while loading Path = {pPath}", ex, GetType().Name, MethodBase.GetCurrentMethod().Name);
                return(false);
            }
        }
        else
        {
            Nucleus_Utils.Error("Path is empty", new CustomAttributeFormatException(), GetType().Name, MethodBase.GetCurrentMethod().Name);
        }

        return(false);
    }
コード例 #4
0
ファイル: SceneManager.cs プロジェクト: cvionnet/Godot-Csharp
    /// <summary>
    /// (From SceneTransition)
    /// </summary>
    /// <returns></returns>
    private void _onSceneTransition_Finished()
    {
        PackedScene scene = GD.Load <PackedScene>($"res://src/scenes/{_nextScene}.tscn");

        if (scene != null)
        {
            // If exists, unload the actual scene
            if (_actualScene != null)
            {
                _actualScene.QueueFree();
            }

            // Load the new scene + connect to its signal
            _actualScene = scene.Instance();
            AddChild(_actualScene);
            MoveChild(_actualScene, 0);    // To display the transition scene before this scene
            _actualScene.Connect("Generic_TransitionScene", this, nameof(_onCall_TransitionScene));
        }
        else
        {
            //GD.PrintErr($"SceneManager._onSceneTransition_Finished - The scene {_nextScene} does not exists");
            Nucleus_Utils.Error($"The scene {_nextScene} does not exists !", new TargetException(), GetType().Name, MethodBase.GetCurrentMethod().Name);
        }
    }
コード例 #5
0
//*-------------------------------------------------------------------------*//

    #region SIGNAL CALLBACKS

    #endregion

//*-------------------------------------------------------------------------*//

    #region USER METHODS

    private void Initialize_Main()
    {
        Nucleus_Utils.Initialize_Utils(GetViewport());
        Nucleus_Utils.State_Manager = GetNode <StateManager>("/root/StateManager");
    }