Пример #1
0
    public void Start()
    {
        align    = gameObject.GetComponent <Align_Steering>();
        movement = gameObject.GetComponent <Movement_Action>();

        if (gameObject.GetComponent <EnemySword_BT>() != null)
        {
            bt = gameObject.GetComponent <EnemySword_BT>();
        }
        else if (gameObject.GetComponent <EnemySpear_BT>() != null)
        {
            Debug.Log("SPEAR ENEMY!", Department.IA, Color.PINK);
            bt = gameObject.GetComponent <EnemySpear_BT>();
        }
        else if (gameObject.GetComponent <EnemyShield_BT>() != null)
        {
            bt = gameObject.GetComponent <EnemyShield_BT>();
        }

        if (bt != null)
        {
            bt.current_hp      = total_hp;
            bt.total_hp        = total_hp;
            bt.attack_damage   = attack_damage;
            bt.attack_cooldown = attack_cooldown;
        }
    }
    void Start()
    {
        map    = GetLinkedObject("map");
        player = GetLinkedObject("player");

        align          = GetComponent <Align_Steering>();
        arrive         = GetComponent <Arrive_Steering>();
        seek           = GetComponent <Seek_Steering>();
        anim_comp      = GetComponent <CompAnimation>();
        transform_comp = GetComponent <Transform>();
        audio_comp     = GetComponent <CompAudio>();

        player_t = GetLinkedObject("player_obj");

        BT bt = GetComponent <EnemySword_BT>();

        if (bt == null)
        {
            bt = GetComponent <EnemyShield_BT>();
        }
        if (bt == null)
        {
            bt = GetComponent <EnemySpear_BT>();
        }
        if (bt == null)
        {
            bt = GetComponent <Boss_BT>();
        }

        float interpolation = bt.GetCurrentInterpolation();

        current_max_vel       = hurt_max_vel + (max_vel - hurt_max_vel) * interpolation;
        current_max_accel     = hurt_accel + (max_accel - hurt_accel) * interpolation;
        current_max_rot_vel   = hurt_max_rot_vel + (max_rot_vel - hurt_max_rot_vel) * interpolation;
        current_max_rot_accel = hurt_max_rot_accel + (max_rot_accel - hurt_max_rot_accel) * interpolation;

        Vector3 fw = transform_comp.GetForwardVector();

        path = new List <PathNode>();

        //Set Occupied tile in Pathfinder
        tile = new PathNode(0, 0);
        tile.SetCoords((int)(transform_comp.position.x / tile_size + Mathf.Epsilon), (int)(transform_comp.position.z / tile_size + Mathf.Epsilon));
        map.GetComponent <Pathfinder>().UpdateOccupiedTiles(gameObject.GetName(), tile);

        //Set direction
        SetDirection();

        //Sideways animation speeds
        anim_comp.SetClipDuration("WalkRight", sideways_anim_speed);
        anim_comp.SetClipDuration("WalkLeft", sideways_anim_speed);
        anim_comp.SetClipDuration("WalkBack", sideways_anim_speed);
        anim_comp.SetClipDuration("WalkFront", sideways_anim_speed);

        blocking = false;

        path.Clear();
    }