Пример #1
0
    void RandomAttack(int rand_number, uint next_tile_x, uint next_tile_y)
    {
        bool attack_ready = attack_timer >= attack_cooldown;

        if (attack_ready)
        {
            attack_timer = 0.0f;
            state        = AI_STATE.AI_ATTACKING;
            SpearAttack_Action action = GetComponent <SpearAttack_Action>();

            int distance = GetDistanceInRange();


            action.IsMeleeAttack(true);


            action.SetDamage(attack_damage);
            current_action = action;
            current_action.ActionStart();

            GetComponent <Separate_Action>().SetTileDestinySeparate(next_tile_x, next_tile_y);
            next_action = GetComponent <Separate_Action>();
            return;
        }
        else
        {
            state          = AI_STATE.AI_IDLE;
            current_action = GetComponent <IdleAttack_Action>();
            current_action.ActionStart();
            return;
        }
    }
Пример #2
0
    protected override void InCombatDecesion()
    {
        Debug.Log("In Combat Decision");
        int tiles_to_player = GetDistanceInRange();

        if (tiles_to_player == 1)
        {
            if (!GetComponent <Movement_Action>().LookingAtPlayer())
            {
                current_action.Interupt();
                next_action = GetComponent <FacePlayer_Action>();
                return;
            }

            //We need the direction to know if behind of the enemy there is
            //a tile wakable to make our separate or not.
            Movement_Action.Direction current_dir = GetComponent <Movement_Action>().SetDirection();

            uint next_tile_x = 0;
            uint next_tile_y = 0;

            if (CanISeparate(current_dir, out next_tile_x, out next_tile_y))
            {
                int attack_type_value = rand.Next(1, 10);
                RandomAttack(attack_type_value, next_tile_x, next_tile_y);
                return;
            }
            else
            {
                bool attack_ready = attack_timer >= attack_cooldown;
                if (attack_ready)
                {
                    attack_timer = 0.0f;
                    state        = AI_STATE.AI_ATTACKING;
                    SpearAttack_Action action = GetComponent <SpearAttack_Action>();
                    action.IsMeleeAttack(true);
                    action.SetDamage(attack_damage);
                    current_action = action;
                    current_action.ActionStart();
                    return;
                }
                else
                {
                    state          = AI_STATE.AI_IDLE;
                    current_action = GetComponent <IdleAttack_Action>();
                    current_action.ActionStart();
                    return;
                }
            }
        }
        else if (tiles_to_player == 2)
        {
            if (!GetComponent <Movement_Action>().LookingAtPlayer())
            {
                current_action.Interupt();
                next_action = GetComponent <FacePlayer_Action>();
                return;
            }

            bool attack_ready = attack_timer >= attack_cooldown;
            if (attack_ready)
            {
                attack_timer = 0.0f;
                state        = AI_STATE.AI_ATTACKING;
                SpearAttack_Action action = GetComponent <SpearAttack_Action>();
                action.IsMeleeAttack(false);
                action.SetDamage(attack_damage);
                current_action = action;
                current_action.ActionStart();
                return;
            }
            else
            {
                state          = AI_STATE.AI_IDLE;
                current_action = GetComponent <IdleAttack_Action>();
                current_action.ActionStart();
                return;
            }
        }

        if (player_detected == true && Disable_Movement_Gameplay_Debbuger == false)
        {
            GetComponent <ChasePlayer_Action>().ActionStart();
            current_action = GetComponent <ChasePlayer_Action>();
            return;
        }
    }