Exemplo n.º 1
0
    public void Attack_Perform(int a)
    {
        if (UI_values.Step == UI_Manager_script.StepType.ReadyAttack)
        {
            //Random function
            float random_value = 0f;
            //Success value
            float success_value = 0f;

            GameObject Attacker = ElementA;
            GameObject Attacked = ElementB;
            //Attacker loses 1 ammo
            switch (WhatKindOfObjectIsThisOne(ElementA))
            {
            case TokenType.Default:
                Debug.Log("ElementA Type cannot be defined");
                break;

            case TokenType.Unit:
                Unit_script UnitValues = ElementA.GetComponent <Unit_script>();
                //Call function reducing ammo
                UnitValues.Change_Ammo_stock(-1f);
                break;

            case TokenType.Building:
                Batiment_script BuildingValues = ElementA.GetComponent <Batiment_script>();
                //Call function reducing ammo
                BuildingValues.Change_Ammo_stock(-1f);
                break;

            case TokenType.Case:
                Debug.Log("Case cannot attack / No function available");
                break;
            }
            //Attacked might loses 1 health
            if (random_value >= success_value)
            {
                switch (WhatKindOfObjectIsThisOne(ElementB))
                {
                case TokenType.Default:
                    Debug.Log("Object Type cannot be defined");
                    break;

                case TokenType.Unit:
                    Unit_script UnitValues = ElementB.GetComponent <Unit_script>();
                    //Call function reducing ammo
                    UnitValues.Change_Health_stock(-1f);
                    break;

                case TokenType.Building:
                    Batiment_script BuildingValues = ElementA.GetComponent <Batiment_script>();
                    //Call function reducing ammo
                    BuildingValues.Change_Health_stock(-1f);
                    break;

                case TokenType.Case:
                    Debug.Log("Case cannot be attacked / No function available");
                    break;
                }
            }
            Attack_cancel(1);
        }
    }