override public BT_Status UpdateAction() { Vector3 dist_to_arrive = point_to_follow - transform.position; float step = Time.deltaTime * velocity; if (dist_to_arrive.magnitude < 0.1f) { //To change sprite Direction dir = follow_player_scr.DetectDirection(transform.position, player.transform.position); collider_enemy.enabled = true; col_detect_player.enabled = true; inmortalGO.SetActive(false); if (myBT.enemy_type == Enemy_type.MACLIR_ENEMY) { BT_MacLir mac_lir_bt = GetComponent <BT_MacLir>(); mac_lir_bt.Set_Invoke_State(true); myAnimator.SetBool("goin_to_invoke", false); } else if (myBT.enemy_type == Enemy_type.MORRIGAN_ENEMY) { myBT.myBB.SetParameter("invokedCrows", false); } isFinish = true; } else { if (myBT.enemy_type == Enemy_type.MACLIR_ENEMY) { bool fliped = GetComponent <SpriteRenderer>().flipX; if (point_to_follow.x > transform.position.x && fliped == true) { GetComponent <SpriteRenderer>().flipX = false; } if (point_to_follow.x < transform.position.x && fliped == false) { GetComponent <SpriteRenderer>().flipX = true; } } else { if (point_to_follow.x < transform.position.x && flip == false) { Debug.Log("Flipp"); GetComponent <SpriteRenderer>().flipX = true; flip = true; } else { if (point_to_follow.x > transform.position.x && flip == true) { Debug.Log(" no Flipp"); GetComponent <SpriteRenderer>().flipX = false; } } } transform.position = Vector3.MoveTowards(transform.position, point_to_follow, step); } return(BT_Status.RUNNING); }
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 }