Exemple #1
0
 public void aiRefreshAttributes(AIAttributeManager attributeManager)
 {
     foreach (Category cat in this.aiCategoryContentObject.items)
     {
         if (cat.name.Equals(this.aiCategoryContentObject.selectedToggle))
         {
             List <LevelRate> tempRate = this.aiLevelingRatesObject.allAttributes[cat.value];
             for (int i = 0; i < Attributes.MAX_NUM_OF_LEVELS; i++)
             {
                 TierUpgrade tier = attributeManager.tiers[i];
                 LevelRate   rate = tempRate[i];
                 if (cat.value == Category.Health.value)
                 {
                     rate.rate = tier.health;
                 }
                 else if (cat.value == Category.Attack.value)
                 {
                     rate.rate = tier.attack;
                 }
                 else if (cat.value == Category.AttackCooldown.value)
                 {
                     rate.rate = tier.attackCooldown;
                 }
                 else if (cat.value == Category.Speed.value)
                 {
                     rate.rate = tier.speed;
                 }
                 else if (cat.value == Category.Split.value)
                 {
                     rate.rate = tier.split;
                 }
                 else if (cat.value == Category.Merge.value)
                 {
                     rate.rate = tier.merge;
                 }
                 tempRate[i] = rate;
             }
             this.aiLevelingRatesObject.allAttributes[cat.value] = tempRate;
             break;
         }
     }
     this.aiLevelingRatesObject.UpdateAllPanelItems(this.aiCategoryContentObject.selectedToggle);
 }
Exemple #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();
    }
        public void UpdateEquation()
        {
            try {
                string equation = this.equationInputField.text;
                Debug.Log("Equation is: " + equation);

                AIAttributeManager AIManager = null;
                int index;
                if (this.isEditingYellowTeam)
                {
                    AIManager = this.yellowTeamAttributes;
                    index     = 0;
                }
                else
                {
                    AIManager = this.blueTeamAttributes;
                    index     = 1;
                }

                Toggle attributeToggle = this.unitAttributeToggleGroup.GetSingleActiveToggle();
                if (attributeToggle != null)
                {
                    EnumToggle toggle = attributeToggle.GetComponent <EnumToggle>();
                    if (toggle != null)
                    {
                        switch (toggle.value)
                        {
                        default:
                            Debug.LogError("Wrong toggle value: " + toggle.value + ". Please check.");
                            return;

                        case 0:
                            AIManager.SetDirectHealthAttribute(equation);
                            this.teamEquations[index].health = equation;
                            break;

                        case 1:
                            AIManager.SetDirectAttackAttribute(equation);
                            this.teamEquations[index].attack = equation;
                            break;

                        case 2:
                            AIManager.SetDirectSpeedAttribute(equation);
                            this.teamEquations[index].speed = equation;
                            break;

                        case 3:
                            AIManager.SetDirectSplitAttribute(equation);
                            this.teamEquations[index].split = equation;
                            break;

                        case 4:
                            AIManager.SetDirectMergeAttribute(equation);
                            this.teamEquations[index].merge = equation;
                            break;

                        case 5:
                            AIManager.SetDirectAttackCooldownAttribute(equation);
                            this.teamEquations[index].attackCooldown = equation;
                            break;
                        }

                        UpdateLevelInfo(toggle.value, equation);
                    }
                }
                this.simulationStarter.StopSimulation();
                this.simulationStarter.ClearSimulation();
                this.simulationStarter.InitializeSimulation();
            }
            catch (System.Exception) {
                this.equationInputField.text = "[Invalid Equation.]";
            }
        }
 public void aiRefreshAttributes(AIAttributeManager attributeManager)
 {
     foreach (Category cat in this.aiCategoryContentObject.items) {
         if (cat.name.Equals(this.aiCategoryContentObject.selectedToggle)) {
             List<LevelRate> tempRate = this.aiLevelingRatesObject.allAttributes[cat.value];
             for (int i = 0; i < Attributes.MAX_NUM_OF_LEVELS; i++) {
                 TierUpgrade tier = attributeManager.tiers[i];
                 LevelRate rate = tempRate[i];
                 if (cat.value == Category.Health.value) {
                      rate.rate = tier.health;
                 }
                 else if (cat.value == Category.Attack.value) {
                     rate.rate = tier.attack;
                 }
                 else if (cat.value == Category.AttackCooldown.value) {
                     rate.rate = tier.attackCooldown;
                 }
                 else if (cat.value == Category.Speed.value) {
                     rate.rate = tier.speed;
                 }
                 else if (cat.value == Category.Split.value) {
                     rate.rate = tier.split;
                 }
                 else if (cat.value == Category.Merge.value) {
                     rate.rate = tier.merge;
                 }
                 tempRate[i] = rate;
             }
             this.aiLevelingRatesObject.allAttributes[cat.value] = tempRate;
             break;
         }
     }
     this.aiLevelingRatesObject.UpdateAllPanelItems(this.aiCategoryContentObject.selectedToggle);
 }
Exemple #5
0
        public void AIFinishedEditing()
        {
            try {
                GameObject obj = GameObject.FindGameObjectWithTag("AIAttributeManager");
                if (obj != null)
                {
                    AIAttributeManager aiAttributeManager = obj.GetComponent <AIAttributeManager>();
                    if (aiAttributeManager != null)
                    {
                        foreach (Category cat in Category.Values)
                        {
                            if (cat.name.Equals(this.aiCategoryContentObject.selectedToggle))
                            {
                                int catValue = cat.value;
                                switch (catValue)
                                {
                                default:
                                case 0:
                                    aiAttributeManager.SetHealthAttribute(this.aiEquationTextObject.text);
                                    break;

                                case 1:
                                    aiAttributeManager.SetAttackAttribute(this.aiEquationTextObject.text);
                                    break;

                                case 2:
                                    aiAttributeManager.SetAttackCooldownAttribute(this.aiEquationTextObject.text);
                                    break;

                                case 3:
                                    aiAttributeManager.SetSpeedAttribute(this.aiEquationTextObject.text);
                                    break;

                                case 4:
                                    aiAttributeManager.SetSplitAttribute(this.aiEquationTextObject.text);
                                    break;

                                case 5:
                                    aiAttributeManager.SetMergeAttribute(this.aiEquationTextObject.text);
                                    break;
                                }
                                List <LevelRate> tempList = this.aiLevelingRatesObject.allAttributes[catValue];
                                for (int i = 0; i < tempList.Count; i++)
                                {
                                    bool      flag = i > 0;
                                    LevelRate rate = tempList[i];
                                    switch (cat.value)
                                    {
                                    default:
                                    case 0:
                                        rate.rate = aiAttributeManager.tiers[i].health;
                                        if (flag)
                                        {
                                            rate.isIncreasing = rate.rate > aiAttributeManager.tiers[i - 1].health ? 1 : -1;
                                        }
                                        break;

                                    case 1:
                                        rate.rate = aiAttributeManager.tiers[i].attack;
                                        if (flag)
                                        {
                                            rate.isIncreasing = rate.rate > aiAttributeManager.tiers[i - 1].attack ? 1 : -1;
                                        }
                                        break;

                                    case 2:
                                        rate.rate = aiAttributeManager.tiers[i].attackCooldown;
                                        if (flag)
                                        {
                                            rate.isIncreasing = rate.rate > aiAttributeManager.tiers[i - 1].attackCooldown ? 1 : -1;
                                        }
                                        break;

                                    case 3:
                                        rate.rate = aiAttributeManager.tiers[i].speed;
                                        if (flag)
                                        {
                                            rate.isIncreasing = rate.rate > aiAttributeManager.tiers[i - 1].speed ? 1 : -1;
                                        }
                                        break;

                                    case 4:
                                        if (i == 0)
                                        {
                                            rate.rate         = aiAttributeManager.tiers[i].split;
                                            rate.isIncreasing = 0;
                                        }
                                        else
                                        {
                                            rate.rate         = 0f;
                                            rate.isIncreasing = 0;
                                        }
                                        break;

                                    case 5:
                                        rate.rate = aiAttributeManager.tiers[i].merge;
                                        if (flag)
                                        {
                                            rate.isIncreasing = rate.rate > aiAttributeManager.tiers[i - 1].merge ? 1 : -1;
                                        }
                                        break;
                                    }
                                    tempList[i] = rate;
                                }
                                this.aiLevelingRatesObject.allAttributes[cat.value] = tempList;
                                break;
                            }
                        }
                        this.aiLevelingRatesObject.UpdateAllPanelItems(this.aiCategoryContentObject.selectedToggle);
                    }
                }
            }
            catch (System.Exception) {
                this.equationInputField.text = "[Invalid Equation.]";
            }
        }