Пример #1
0
    //NOTE(Thompson): This is equivalent to SetClientReady().
    public void SetLANHostReady()
    {
        this.LANHost.SetActive(false);

        GameMetricLogger.EnableLoggerHotkey();

        PostRenderer renderer = Camera.main.GetComponent <PostRenderer>();

        if (renderer != null)
        {
            renderer.enabled = true;
        }

        Canvas         canvas = GameObject.FindObjectOfType <Canvas>();
        TooltipLocator loc    = canvas.GetComponent <TooltipLocator>();

        if (loc != null)
        {
            loc.tooltip.SetToolTipHidden(true);
        }
    }
Пример #2
0
    public void SingleStartHost()
    {
        DropdownFix[] fixes  = GameObject.FindObjectsOfType <DropdownFix>();
        int           values = 0;

        for (int i = 0; i < fixes.Length; i++)
        {
            values += fixes[i].value;
        }
        if (values <= 0)
        {
            //Start Game button is now interactable only when player hasn't chosen a preset.
            return;
        }
        //Note(Thompson): Player is always index 1.
        //Note(Thompson): Obtain the A.I. level difficulty.
        GameMetricLogger.instance.levelDifficulty = fixes[0].value;
        //Note(Thompson): Check if the Player dropdown value is 5. If not, and is above 0, return difficulty equation used. Else, return a full range of custom equations used.
        GameMetricLogger.SetDifficultyEquation(ConvertCustomToEquations(fixes[1].value, fixes[1].options[fixes[1].value].text));
        GameMetricLogger.SetPlayerName("Player");


        if (this.attributePanelGroup != null)
        {
            this.attributePanelGroup.alpha          = 0f;
            this.attributePanelGroup.blocksRaycasts = false;
            this.attributePanelGroup.interactable   = false;
        }

        GameObject minimapCameraObject = GameObject.FindGameObjectWithTag("Minimap");
        Camera     minimapCamera       = minimapCameraObject.GetComponent <Camera>();

        if (minimapCamera != null && !minimapCamera.enabled)
        {
            minimapCamera.enabled = true;
        }

        if (this.playerObject != null)
        {
            this.playerObject.SetActive(true);
        }

        if (this.AIPlayer != null)
        {
            //AI attribute manager.
            AIAttributeManager attributeManager = this.AIPlayer.GetComponentInChildren <AIAttributeManager>();
            if (attributeManager != null)
            {
                Debug.Log("It works!");
            }

            //AI Unit spawning.
            GameObject obj = MonoBehaviour.Instantiate(this.AIUnitPrefab) as GameObject;
            obj.transform.SetParent(this.AIUnits.transform);
            obj.transform.position = this.GetStartPosition().position;
            AIUnit unit = obj.GetComponent <AIUnit>();

            //AI manager spawning.
            AIManager AImanager = this.AIPlayer.GetComponentInChildren <AIManager>();
            if (AImanager != null)
            {
                unit.unitManager = AImanager;

                if (attributeManager != null && attributeManager.attributePanelUI != null)
                {
                    DifficultyGroup group = attributeManager.attributePanelUI.aiCalibrationDifficulty;
                    AImanager.UpdateDifficulty(group.GetDifficulty());
                }

                unit.SetTeam(AImanager.teamFaction);
                AImanager.Activate();
            }
        }

        this.playerUmbrellaObject = GameObject.FindGameObjectWithTag("Player");
        if (this.playerUmbrellaObject != null)
        {
            this.HumanPlayer = this.playerUmbrellaObject;
            Transform unitUmbrellaTransform = this.playerUmbrellaObject.transform.GetChild(0);
            this.HumanUnits = unitUmbrellaTransform.gameObject;
        }

        SetupPlayerUnits();

        if (!this.isNetworkActive)
        {
            this.StartHost();
        }

        this.enablePauseGameMenu = true;
        this.notReady            = false;

        if (Taskbar.Instance != null)
        {
            Taskbar.Instance.ShowTaskbar(true);
        }

        GameMetricLogger.SetGameLogger(GameLoggerOptions.StartGameMetrics);
        GameMetricLogger.SetGameLogger(GameLoggerOptions.GameIsPlaying);
        GameMetricLogger.EnableLoggerHotkey();
    }
Пример #3
0
    public void SetClientReady()
    {
        if (!ClientScene.ready)
        {
            if (ClientScene.Ready(this.networkManager.client.connection))
            {
                Camera       cam      = Camera.main.GetComponent <Camera>();
                PostRenderer renderer = cam.GetComponent <PostRenderer>();
                if (renderer != null)
                {
                    renderer.enabled = true;
                }
                MinimapStuffs stuffs = GameObject.FindObjectOfType <MinimapStuffs>();
                if (stuffs != null)
                {
                    Camera minimapCamera = stuffs.GetComponent <Camera>();
                    minimapCamera.enabled      = true;
                    stuffs.playerCameraPanning = Camera.main.GetComponent <CameraPanning>();
                }
                this.LANClientReady.SetActive(false);
                this.LANClientNotReady.SetActive(false);

                GameMetricLogger.EnableLoggerHotkey();

                NewSpawner[] spawners = GameObject.FindObjectsOfType <NewSpawner>();
                foreach (NewSpawner spawn in spawners)
                {
                    if (spawn != null && spawn.hasAuthority)
                    {
                        NewSpawner.Instance.CmdSetReadyFlag(ClientScene.ready && !NetworkServer.active);
                    }
                }

                GameMetricLogger.SetGameLogger(GameLoggerOptions.StartGameMetrics);
            }
            else
            {
                this.LANClientReady.SetActive(false);
                this.LANClientNotReady.SetActive(true);
            }
            if (ClientScene.localPlayers.Count == 0)
            {
                ClientScene.AddPlayer(0);
            }
        }
        else
        {
            this.LANClientReady.SetActive(false);
            this.LANClientNotReady.SetActive(false);

            Camera       cam      = Camera.main.GetComponent <Camera>();
            PostRenderer renderer = cam.GetComponent <PostRenderer>();
            if (renderer != null)
            {
                renderer.enabled = true;
            }
            MinimapStuffs stuffs = GameObject.FindObjectOfType <MinimapStuffs>();
            if (stuffs != null)
            {
                Camera minimapCamera = stuffs.GetComponent <Camera>();
                minimapCamera.enabled      = true;
                stuffs.playerCameraPanning = Camera.main.GetComponent <CameraPanning>();
            }

            this.LANClientReady.SetActive(false);
            this.LANClientNotReady.SetActive(false);

            string name = this.playerNameField.text;
            if (name.Length > 0)
            {
                GameMetricLogger.instance.playerName = name;
            }
            else
            {
                GameMetricLogger.instance.playerName = "Player";
            }
            GameMetricLogger.instance.difficultyEquations = this.difficultyDropdown.options[this.difficultyDropdown.value].text;
            GameMetricLogger.EnableLoggerHotkey();

            NewSpawner[] spawners = GameObject.FindObjectsOfType <NewSpawner>();
            foreach (NewSpawner spawn in spawners)
            {
                if (spawn != null && spawn.hasAuthority)
                {
                    NewSpawner.Instance.CmdSetReadyFlag(ClientScene.ready && !NetworkServer.active);
                }
            }

            GameMetricLogger.SetGameLogger(GameLoggerOptions.StartGameMetrics);
        }

        Canvas         canvas = GameObject.FindObjectOfType <Canvas>();
        TooltipLocator loc    = canvas.GetComponent <TooltipLocator>();

        if (loc != null)
        {
            loc.tooltip.SetToolTipHidden(true);
        }
    }