Ejemplo n.º 1
0
        public void SetSplitAttributes(string mathExpression)
        {
            if (mathExpression.Equals("") || mathExpression.Length <= 0)
            {
                return;
            }
            float answer = (float)MathParser.ProcessEquation(mathExpression, AttributeProperty.Split, 1, 0, 0f);

            this.splitPrefabFactor = answer;
        }
Ejemplo n.º 2
0
        public void SetDirectAttackCooldownAttribute(string mathExpression)
        {
            float previousAnswer = 0f;

            for (int i = 0; i < this.tiers.Count; i++)
            {
                float answer = (float)MathParser.ProcessEquation(mathExpression, AttributeProperty.AttackCooldown, i, i - 1, previousAnswer);
                previousAnswer = answer;
                TierUpgrade tier = this.tiers[i];
                tier.attackCooldown = answer;
                this.tiers[i]       = tier;
            }
        }
Ejemplo n.º 3
0
        public void UpdateLevelInfo(int toggleValue, string equation)
        {
            try {
                float previousAnswer = 0f;
                float answer         = 0f;
                for (int i = 0; i < Attributes.MAX_NUM_OF_LEVELS; i++)
                {
                    switch (toggleValue)
                    {
                    default:
                        Debug.LogError("Invalid toggle value: " + toggleValue + ". Please check.");
                        return;

                    case 0:
                        answer = (float)MathParser.ProcessEquation(equation, AttributeProperty.Health, i + 1, i, previousAnswer);
                        break;

                    case 1:
                        answer = (float)MathParser.ProcessEquation(equation, AttributeProperty.Attack, i + 1, i, previousAnswer);
                        break;

                    case 2:
                        answer = (float)MathParser.ProcessEquation(equation, AttributeProperty.Speed, i + 1, i, previousAnswer);
                        break;

                    case 3:
                        answer = (float)MathParser.ProcessEquation(equation, AttributeProperty.Split, i + 1, i, previousAnswer);
                        break;

                    case 4:
                        answer = (float)MathParser.ProcessEquation(equation, AttributeProperty.Merge, i + 1, i, previousAnswer);
                        break;

                    case 5:
                        answer = (float)MathParser.ProcessEquation(equation, AttributeProperty.AttackCooldown, i + 1, i, previousAnswer);
                        break;
                    }
                    UpdateLevelInfoIteration(i, answer, previousAnswer);
                    previousAnswer = answer;
                }
            }
            catch (System.Exception) {
                this.equationInputField.text = "[Invalid Equation.]";
            }
        }
Ejemplo n.º 4
0
        public void SetMergeAttribute(string mathExpression)
        {
            if (mathExpression.Equals("") || mathExpression.Length <= 0)
            {
                return;
            }
            List <LevelRate> mergeList      = this.aiLevelRateHandler.allAttributes[Category.Merge.value];
            float            previousAnswer = 0f;

            for (int i = 0; i < Attributes.MAX_NUM_OF_LEVELS; i++)
            {
                if (i < mergeList.Count)
                {
                    float answer = (float)MathParser.ProcessEquation(mathExpression, AttributeProperty.Merge, i, i - 1, previousAnswer);
                    previousAnswer = answer;
                    LevelRate rate = mergeList[i];
                    rate.rate  = answer;
                    rate.level = i + 1;
                    if (i > 0)
                    {
                        float rateDiff = rate.rate - mergeList[i - 1].rate;
                        if (rateDiff < 0)
                        {
                            rate.isIncreasing = -1;
                        }
                        else if (rateDiff > 0)
                        {
                            rate.isIncreasing = 1;
                        }
                        else
                        {
                            rate.isIncreasing = 0;
                        }
                    }
                    mergeList[i] = rate;
                }
                if (i < this.tiers.Count)
                {
                    TierUpgrade tier = this.tiers[i];
                    tier.merge    = mergeList[i].rate;
                    this.tiers[i] = tier;
                }
            }
        }
Ejemplo n.º 5
0
        public void SetAttackCooldownAttributes(string mathExpression)
        {
            if (mathExpression.Equals("") || mathExpression.Length <= 0)
            {
                return;
            }
            if (this.attackCooldownPrefabList.Count > 0)
            {
                this.attackCooldownPrefabList.Clear();
            }
            float previousAnswer = 0f;

            for (int i = 0; i < Attributes.MAX_NUM_OF_LEVELS; i++)
            {
                float answer = (float)MathParser.ProcessEquation(mathExpression, AttributeProperty.AttackCooldown, i + 1, i, previousAnswer);
                this.attackCooldownPrefabList.Add(answer);
                previousAnswer = answer;
            }
        }
Ejemplo n.º 6
0
    public void UpdateAttributes(AttributeProperty property)
    {
        float previousAnswer = 0f;

        for (int level = 0; level < MAX_NUM_OF_LEVELS; level++)
        {
            float answer = (float)MathParser.ProcessEquation(this.equationInputField.text, property, level + 1, level, previousAnswer);
            previousAnswer = answer;

            if (this.debugFlag)
            {
                Debug.Log("DEBUG 8");
            }

            GameObject panel      = this.prefabList[level];
            Title      titlePanel = panel.GetComponentInChildren <Title>();

            if (this.debugFlag)
            {
                Debug.Log("DEBUG 9");
            }

            if (titlePanel != null)
            {
                titlePanel.titleText.text = "Level " + (level + 1).ToString();
            }

            if (this.debugFlag)
            {
                Debug.Log("DEBUG 10");
            }

            Number numberPanel = panel.GetComponentInChildren <Number>();
            if (numberPanel != null)
            {
                if (this.unitAttributes != null)
                {
                    switch (property)
                    {
                    case AttributeProperty.Health:
                        this.unitAttributes.healthPrefabList[level] = answer;
                        numberPanel.numberText.text = answer.ToString();
                        break;

                    case AttributeProperty.Attack:
                        this.unitAttributes.attackPrefabList[level] = answer;
                        numberPanel.numberText.text = answer.ToString();
                        break;

                    case AttributeProperty.Speed:
                        this.unitAttributes.speedPrefabList[level] = answer;
                        numberPanel.numberText.text = answer.ToString();
                        break;

                    case AttributeProperty.Merge:
                        this.unitAttributes.mergePrefabList[level] = answer;
                        numberPanel.numberText.text = answer.ToString();
                        break;

                    case AttributeProperty.AttackCooldown:
                        this.unitAttributes.attackCooldownPrefabList[level] = answer;
                        numberPanel.numberText.text = answer.ToString();
                        break;

                    case AttributeProperty.Split:
                        if (level <= 0)
                        {
                            this.unitAttributes.splitPrefabFactor = answer;
                            numberPanel.numberText.text           = answer.ToString();
                        }
                        else
                        {
                            numberPanel.numberText.text = "N/A";
                        }
                        level = 10;
                        break;

                    default:
                    case AttributeProperty.Invalid:
                        throw new ArgumentException("Attribute property is invalid.");
                    }
                }
            }

            if (this.debugFlag)
            {
                Debug.Log("DEBUG 11");
            }

            if (this.debugFlag)
            {
                Debug.Log("DEBUG 12");
            }
        }
    }