示例#1
0
    public static Node LobbyMenu()
    {
        Node      menuInstance = Session.Instance("res://Scenes/Prefabs/Menus/LobbyMenu.tscn");
        LobbyMenu menu         = (LobbyMenu)menuInstance;

        Session.session.AddChild(menu);
        menu.Init();
        return(menuInstance);
    }
    public void Init()
    {
        gameManager  = CoreTools.GetManager <GameManager>();
        pool         = CoreTools.GetManager <RegulatoryPools>();
        timerManager = CoreTools.GetManager <TimerManager>();
        inputManager = CoreTools.GetManager <InputManager>();

        FindCamera();
        DefiningScreenBoundaries();
        AddEventSystem();
        CreatePools();

        state = GameState.Start;

        gameCanvas = GameObject.Instantiate(gameManager.GameCanvasPrefab);
        gameUi     = gameCanvas.GetComponent <GameUI>();
        gameUi.Init();
        gameCanvas.SetActive(false);

        lobbyCanvas = GameObject.Instantiate(gameManager.LobbyCanvasPrefab);
        lobbyMenu   = lobbyCanvas.GetComponent <LobbyMenu>();
        lobbyMenu.Init();
        lobbyCanvas.SetActive(false);

        SetInput(inputManager.CurrentType);
        inputManager.GetInput().SetActive(false);

        gameManager.sceneRightEdge  = sceneRightEdge;
        gameManager.sceneLeftEdge   = sceneLeftEdge;
        gameManager.sceneTopEdge    = sceneTopEdge;
        gameManager.sceneBottomEdge = sceneBottomEdge;
        gameManager.sceneWidth      = sceneWidth;
        gameManager.sceneHeight     = sceneHeight;

        startAsteroidCount = gameManager.StartAsteroidsCount;

        player = GameObject.Instantiate(gameManager.PlayerPrefab);
        ship   = player.GetComponent <Ship>();
        ship.Init();
        player.SetActive(false);

        Ufo = GameObject.Instantiate(gameManager.UfoPrefab);
        ufo = Ufo.GetComponent <UFO>();
        ufo.Init();
        Ufo.SetActive(false);

        EnteringGameMenu();
    }