Inheritance: UnityEngine.MonoBehaviour
Exemple #1
0
 public void SetAIAttributes()
 {
     if (this.aiAttributeManager == null) {
         GameObject obj = GameObject.FindGameObjectWithTag("AIAttributeManager");
         if (obj != null) {
             this.aiAttributeManager = obj.GetComponent<AIAttributeManager>();
         }
     }
     if (this.aiAttributeManager != null && this.dropdown != null) {
         int itemValue = this.dropdown.value;
         string attackCooldownExpression = "y=0.9*x";
         switch (itemValue) {
             default:
             case 0:
                 break;
             case 1:
             case 2:
             case 3:
                 Debug.Log("Setting expressions for AI: " + this.dropdown.options[itemValue].text);
                 string expression = this.dropdown.options[itemValue].text;
                 this.aiAttributeManager.SetHealthAttribute(expression);
                 this.aiAttributeManager.SetAttackAttribute(expression);
                 this.aiAttributeManager.SetAttackCooldownAttribute(attackCooldownExpression);
                 this.aiAttributeManager.SetSpeedAttribute(expression);
                 this.aiAttributeManager.SetSplitAttribute(expression);
                 this.aiAttributeManager.SetMergeAttribute(expression);
                 this.aiEnableDisableUI.DisableCustomEquations();
                 break;
             case 4:
                 this.aiAttributeManager.SetHealthAttribute("y=2*x");
                 string otherExpression = "y=1.414*x";
                 this.aiAttributeManager.SetAttackAttribute(otherExpression);
                 this.aiAttributeManager.SetSpeedAttribute(otherExpression);
                 this.aiAttributeManager.SetSplitAttribute(otherExpression);
                 this.aiAttributeManager.SetMergeAttribute(otherExpression);
                 this.aiAttributeManager.SetAttackCooldownAttribute(attackCooldownExpression);
                 this.aiEnableDisableUI.DisableCustomEquations();
                 break;
             case 5:
                 string zero = "y=0";
                 this.aiAttributeManager.SetHealthAttribute(zero);
                 this.aiAttributeManager.SetAttackAttribute(zero);
                 this.aiAttributeManager.SetAttackCooldownAttribute(zero);
                 this.aiAttributeManager.SetSpeedAttribute(zero);
                 this.aiAttributeManager.SetSplitAttribute(zero);
                 this.aiAttributeManager.SetMergeAttribute(zero);
                 this.aiEnableDisableUI.EnableCustomEquations();
                 break;
         }
         this.aiAttributePanelUI.aiRefreshAttributes(this.aiAttributeManager);
     }
     else {
         Debug.Log("Cannot obtain AI attribute manager. Please check.");
     }
 }
Exemple #2
0
        public void SetAIAttributes()
        {
            if (this.aiAttributeManager == null)
            {
                GameObject obj = GameObject.FindGameObjectWithTag("AIAttributeManager");
                if (obj != null)
                {
                    this.aiAttributeManager = obj.GetComponent <AIAttributeManager>();
                }
            }
            if (this.aiAttributeManager != null && this.dropdown != null)
            {
                int    itemValue = this.dropdown.value;
                string attackCooldownExpression = "y=0.9*x";
                switch (itemValue)
                {
                default:
                case 0:
                    break;

                case 1:
                case 2:
                case 3:
                    Debug.Log("Setting expressions for AI: " + this.dropdown.options[itemValue].text);
                    string expression = this.dropdown.options[itemValue].text;
                    this.aiAttributeManager.SetHealthAttribute(expression);
                    this.aiAttributeManager.SetAttackAttribute(expression);
                    this.aiAttributeManager.SetAttackCooldownAttribute(attackCooldownExpression);
                    this.aiAttributeManager.SetSpeedAttribute(expression);
                    this.aiAttributeManager.SetSplitAttribute(expression);
                    this.aiAttributeManager.SetMergeAttribute(expression);
                    this.aiEnableDisableUI.DisableCustomEquations();
                    break;

                case 4:
                    this.aiAttributeManager.SetHealthAttribute("y=2*x");
                    string otherExpression = "y=1.414*x";
                    this.aiAttributeManager.SetAttackAttribute(otherExpression);
                    this.aiAttributeManager.SetSpeedAttribute(otherExpression);
                    this.aiAttributeManager.SetSplitAttribute(otherExpression);
                    this.aiAttributeManager.SetMergeAttribute(otherExpression);
                    this.aiAttributeManager.SetAttackCooldownAttribute(attackCooldownExpression);
                    this.aiEnableDisableUI.DisableCustomEquations();
                    break;

                case 5:
                    string zero = "y=0";
                    this.aiAttributeManager.SetHealthAttribute(zero);
                    this.aiAttributeManager.SetAttackAttribute(zero);
                    this.aiAttributeManager.SetAttackCooldownAttribute(zero);
                    this.aiAttributeManager.SetSpeedAttribute(zero);
                    this.aiAttributeManager.SetSplitAttribute(zero);
                    this.aiAttributeManager.SetMergeAttribute(zero);
                    this.aiEnableDisableUI.EnableCustomEquations();
                    break;
                }
                this.aiAttributePanelUI.aiRefreshAttributes(this.aiAttributeManager);
            }
            else
            {
                Debug.Log("Cannot obtain AI attribute manager. Please check.");
            }
        }
Exemple #3
0
        public void Start()
        {
            bool initialStateFlag = false;

            if (this.unitManager != null)
            {
                AIAttributeManager aiAttributeManager = this.unitManager.aiAttributeManager;
                if (aiAttributeManager.tiers != null)
                {
                    TierUpgrade firstTier = aiAttributeManager.tiers[0];
                    this.maxHealth            = (int)(firstTier.health);
                    this.currentHealth        = this.maxHealth;
                    this.attackFactor         = firstTier.attack;
                    this.attackCooldownFactor = firstTier.attackCooldown;
                    this.speedFactor          = firstTier.speed;
                    this.splitFactor          = firstTier.split;
                    this.mergeFactor          = firstTier.merge;

                    initialStateFlag = true;
                }
            }

            this.currentState          = State.Idle;
            this.level                 = 1;
            this.previousLevel         = 1;
            this.isSplitting           = false;
            this.splitCounter          = 0f;
            this.mergeCounter          = 0f;
            this.attackCooldownCounter = 1f;
            this.recoveryCounter       = 1f;

            if (!initialStateFlag)
            {
                this.speedFactor = 1f;
                if (this.attackFactor == 0f)
                {
                    this.attackFactor = 1f;
                }
                if (this.splitFactor == 0f)
                {
                    this.splitFactor = 1f;
                }
                if (this.mergeFactor == 0f)
                {
                    this.mergeFactor = 1f;
                }
                if (this.attackCooldownFactor == 0f)
                {
                    this.attackCooldownFactor = 1f;
                }
                this.currentHealth = this.maxHealth;
            }
            if (this.lineOfSight == null)
            {
                this.lineOfSight = this.GetComponentInChildren <AILineOfSight>();
                if (this.lineOfSight == null)
                {
                    Debug.LogError("Cannot find Line of Sight component for the AI unit.");
                }
            }
            if (this.attackRange == null)
            {
                this.attackRange = this.GetComponentInChildren <AIAttackRange>();
                if (this.attackRange == null)
                {
                    Debug.LogError("Cannot find Attack Range component for the AI unit.");
                }
            }
            this.agent = this.GetComponent <NavMeshAgent>();
            if (this.agent != null)
            {
                this.agent.stoppingDistance = 1.5f;
                if (!initialStateFlag)
                {
                    this.agent.speed = this.speedFactor;
                }
            }

            GameObject minimapObject = GameObject.FindGameObjectWithTag("Minimap");

            if (minimapObject != null)
            {
                Camera camera = minimapObject.GetComponent <Camera>();
                this.minimapCameraRect = camera.rect;
            }
            else
            {
                minimapObject = GameObject.FindGameObjectWithTag("Menu");
                if (minimapObject != null)
                {
                    Image image = minimapObject.GetComponent <Image>();
                    this.minimapCameraRect = image.rectTransform.rect;
                }
            }
        }