예제 #1
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();
    }