override public BT_Status UpdateAction()
    {
        timer_attack += Time.deltaTime;
        GameObject go = father_colliders.transform.GetChild((int)dir_collider).gameObject;

        if (!slash_done)
        {
            get_damage_collider.enabled = false;
            go.SetActive(true);
            BoxCollider2D col = go.GetComponent <BoxCollider2D>();
            player_detection_slash = Physics2D.OverlapBox(go.transform.position, col.size, 0, player_mask);

            if (timer_attack > time_to_make_slash)
            {
                timer_attack = 0.0f;
                slash_done   = true;
            }
        }
        else
        {
            go.SetActive(false);
            if (player_detection_slash != null)
            {
                Transform parent = player_detection_slash.transform.parent;

                if (parent != null)
                {
                    Player_Manager player_manager_scr = parent.GetComponent <Player_Manager>();

                    if (player_manager_scr != null)
                    {
                        player_manager_scr.GetDamage(transform);
                        slash_done             = false;
                        player_detection_slash = null;
                        BT_Kelpi kelpi_bt = ((BT_Kelpi)myBT);
                        if (kelpi_bt != null)
                        {
                            kelpi_bt.Set_Can_Make_Slash(false);
                        }
                    }
                }
            }
            else
            {
                //Stop
                get_damage_collider.enabled = true;
            }
            isFinish = true;
        }


        return(BT_Status.RUNNING);
    }
Exemple #2
0
    private void React_To_Slash()
    {
        //Debug.Log("Enemies detected: " + enemies_found.Length);
        cam_manager.Cam_Shake();

        foreach (Collider2D col in enemies_found)
        {
            Transform parent = col.transform.parent;
            if (parent != null)
            {
                //Detect enemy type
                BT_Soldier soldier = parent.GetComponent <BT_Soldier>();
                if (soldier != null)
                {
                    if (soldier.currentAction != null)
                    {
                        soldier.currentAction.isFinish = true;
                    }
                    soldier.Enemy_Live_Modification(-player_stats.Right_Hand_Object.damage);
                    Soldier_Blackboard bb_soldier = parent.GetComponent <Soldier_Blackboard>();
                    bb_soldier.is_enemy_hit.SetValue(true);
                }
                BT_Caorthannach Caorth = parent.GetComponent <BT_Caorthannach>();
                if (Caorth != null)
                {
                    if (Caorth.currentAction != null)
                    {
                        Caorth.currentAction.isFinish = true;
                    }
                    Caorth.Enemy_Live_Modification(-player_stats.Right_Hand_Object.damage);
                    Caorthannach_Blackboard bb_caorth = parent.GetComponent <Caorthannach_Blackboard>();
                    bb_caorth.is_enemy_hit.SetValue(true);
                }
                BT_Kelpi Kelpi = parent.GetComponent <BT_Kelpi>();
                if (Kelpi != null)
                {
                    /*if (Kelpi.currentAction != null)
                     * {
                     *  Kelpi.currentAction.isFinish = true;
                     * }*/
                    Kelpi.Enemy_Live_Modification(-player_stats.Right_Hand_Object.damage);
                    Kelpi_Blackboard bb_kelpi = parent.GetComponent <Kelpi_Blackboard>();
                    bb_kelpi.is_enemy_hit.SetValue(true);
                }
                BT_MacLir Maclir = parent.GetComponent <BT_MacLir>();
                if (Maclir != null)
                {
                    if (Maclir.currentAction != null)
                    {
                        Maclir.currentAction.isFinish = true;
                    }
                    Maclir.Enemy_Live_Modification(-player_stats.Right_Hand_Object.damage);
                    MacLir_Blackboard bb_maclir = parent.GetComponent <MacLir_Blackboard>();
                    bb_maclir.is_enemy_hit.SetValue(true);
                }
                BT_DearDug DearDug = parent.GetComponent <BT_DearDug>();
                if (DearDug != null)
                {
                    if (DearDug.currentAction != null)
                    {
                        DearDug.currentAction.isFinish = true;
                    }
                    DearDug.Enemy_Live_Modification(-player_stats.Right_Hand_Object.damage);
                    DearDug_Blackboard dearDugBB = parent.GetComponent <DearDug_Blackboard>();
                    dearDugBB.is_enemy_hit.SetValue(true);
                }
                BT_Banshee Banshee = parent.GetComponent <BT_Banshee>();
                if (Banshee != null)
                {
                    if (Banshee.currentAction != null)
                    {
                        Banshee.currentAction.isFinish = true;
                    }

                    Banshee_Blackboard bansheeBB = parent.GetComponent <Banshee_Blackboard>();
                    if (Banshee.myState == BT_Banshee.BansheeState.STUNNED_BANSHEE)
                    {
                        Banshee.Enemy_Live_Modification(-player_stats.Right_Hand_Object.damage);
                        bansheeBB.is_enemy_hit.SetValue(true);
                    }
                    else
                    {
                        bansheeBB.want_to_hit.SetValue(true);
                    }
                }
                BT_Dagda Dagda = parent.GetComponent <BT_Dagda>();
                if (Dagda != null)
                {
                    if (Dagda.currentAction != null)
                    {
                        Dagda.currentAction.isFinish = true;
                    }

                    Dagda_Blackboard dagdaBB = parent.GetComponent <Dagda_Blackboard>();
                    Dagda.Enemy_Live_Modification(-player_stats.Right_Hand_Object.damage);
                    dagdaBB.is_enemy_hit.SetValue(true);
                }
                BT_Dullahan Dullahan = parent.GetComponent <BT_Dullahan>();
                if (Dullahan != null)
                {
                    if (Dullahan.currentAction != null)
                    {
                        Dullahan.currentAction.isFinish = true;
                    }

                    Dullahan_Blackboard dullahanBB = parent.GetComponent <Dullahan_Blackboard>();
                    Dullahan.Enemy_Live_Modification(-player_stats.Right_Hand_Object.damage);
                    dullahanBB.is_enemy_hit.SetValue(true);
                }
                BT_Morrigan Morrigan = parent.GetComponent <BT_Morrigan>();
                if (Morrigan != null)
                {
                    if (Morrigan.currentAction != null)
                    {
                        Morrigan.currentAction.isFinish = true;
                    }

                    Morrigan_Blackboard morriganBB = parent.GetComponent <Morrigan_Blackboard>();
                    Morrigan.Enemy_Live_Modification(-player_stats.Right_Hand_Object.damage);
                    morriganBB.is_enemy_hit.SetValue(true);
                }
            }
            else
            {
                Debug.Log("Parent null _Slash_Attack");
            }
        }

        System.Array.Clear(enemies_found, 0, enemies_found.Length);
        //Call enemy damage function
    }