示例#1
0
function play_ending_speaker(speaker) {
    for (var i = 0; i < _playlist_spks.length; i++) {
        var spk = _playlist_spks[i];
        if (m_sfx.is_playing(spk))
            m_sfx.duck(spk, 0, 1);
    }
    m_sfx.duck(_intro_spk, 0, 1);
    setTimeout(function() {
                    m_sfx.clear_playlist();
                    _disable_plalist = true;
                    m_sfx.play_def(_end_spk)
               },
               1000);
}
示例#2
0
文件: golems.js 项目: D504/Blend4Web
function perform_attack(golem_wrapper) {

    var golem_empty = golem_wrapper.empty;
    var at_pt       = golem_wrapper.attack_point;
    var trans       = _vec3_tmp;
    var cur_dir     = _vec3_tmp_2;

    golem_wrapper.attack_done = false;
    set_state(golem_wrapper, m_conf.GS_ATTACKING)

    m_trans.get_translation(golem_empty, trans);
    m_vec3.scaleAndAdd(trans, cur_dir, m_conf.GOLEM_ATTACK_DIST, at_pt);
    at_pt[2] += 0.3; // raise attack point a bit

    if (m_sfx.is_playing(golem_wrapper.walk_speaker))
        m_sfx.stop(golem_wrapper.walk_speaker);

    m_sfx.play_def(golem_wrapper.attack_speaker);
}
示例#3
0
文件: golems.js 项目: D504/Blend4Web
function translate(golem_wrapper, elapsed) {
    var trans     = _vec3_tmp;
    var cur_dir   = _vec3_tmp_2;
    var cur_rot_q = _quat4_tmp;

    var empty = golem_wrapper.empty;
    var walk_speaker = golem_wrapper.walk_speaker;

    m_trans.get_rotation(empty, cur_rot_q);
    m_trans.get_translation(empty, trans);

    m_vec3.transformQuat(m_util.AXIS_MY, cur_rot_q, cur_dir);
    m_vec3.scaleAndAdd(trans, cur_dir, m_conf.GOLEM_SPEED * elapsed, trans);
    m_trans.set_translation_v(empty, trans);

    if (!m_sfx.is_playing(walk_speaker)) {
        m_sfx.play_def(walk_speaker);
        m_sfx.cyclic(walk_speaker, true);
    }
}
示例#4
0
    var burst_cb = function(obj, id, pulse) {
        var time = m_ctl.get_sensor_value(obj, id, 0);
        if (time - _burst_time > BURST_LISER_TIME) {
            m_ctl.set_custom_sensor(_burst_fire_sensor, 0);

            var speaker_strike = _cockpit.speaker_strike;
            if (speaker_strike && m_sfx.is_playing(speaker_strike))
                m_sfx.stop(speaker_strike);
        }

        var cross_pos = m_trans.get_translation(obj, _vec3_tmp);
        var cross_view = m_trans.get_rotation(obj, _quat_tmp);
        var forward = m_vec3.transformQuat(m_util.AXIS_MY, cross_view,
                _vec3_tmp2);
        forward = m_vec3.scale(forward, MAX_LASER_LENGTH, _vec3_tmp2);
        forward = m_vec3.add(forward, cross_pos, forward);

        var elapsed = m_ctl.get_sensor_value(obj, id, 1);
        var ray_test_cb = function(id, hit_fract, obj_hit, hit_time) {
            damage_asteroid(obj_hit, elapsed * LASER_DAMAGE);
        }
        var id = m_phy.append_ray_test(null, cross_pos, forward,
                "crash", ray_test_cb, true);
    }
示例#5
0
    var crash_cb = function(obj, id, pulse) {
        var time = m_ctl.get_sensor_value(obj, id, 1);
        if (time - last_crash< 1)
            return;

        last_crash = time;
        _cockpit.hp -= ASTEROID_DAMAGE;

        var cockpit_mesh_obj = _cockpit.cockpit_mesh_obj;
        if (cockpit_mesh_obj)
            m_obj.set_nodemat_value(cockpit_mesh_obj, ["screen", "life"],
                    1 - 0.8 * _cockpit.hp / COCKPIT_MAX_HP);

        if (_cockpit.hp > 0) {
            var payload = m_ctl.get_sensor_payload(obj, id, 0);

            var coll_obj = payload.coll_obj;
            if (coll_obj) {
                if (cockpit_mesh_obj) {
                    m_anim.apply(cockpit_mesh_obj, "cockpit_shader_alarm", m_anim.SLOT_0);
                    m_anim.apply(cockpit_mesh_obj, "screen_shader_alarm", m_anim.SLOT_1);
                    m_anim.play(cockpit_mesh_obj, null, m_anim.SLOT_ALL);
                }

                var cockpit_light = _cockpit.cockpit_light;
                if (cockpit_light) {
                    m_anim.apply(cockpit_light, "cockpit_light_alarm");
                    m_anim.play(cockpit_light);
                }

                var speaker_alarm = _cockpit.speaker_alarm;
                if (speaker_alarm) {
                    if (m_sfx.is_playing(speaker_alarm))
                        m_sfx.stop(speaker_alarm);
                    m_sfx.play_def(speaker_alarm);
                }

                var speaker_ast_hit = _cockpit.speaker_ast_hit;
                if (speaker_ast_hit)
                    m_sfx.play_def(speaker_ast_hit);

                var name = m_scs.get_object_name_hierarchy(coll_obj)[0];
                var asteroid = get_asteroid_by_name(name);
                if (asteroid)
                    init_asteroid_transform(asteroid);

                m_ctl.set_custom_sensor(_shake_sensor, 1);
                _start_shake_time = time;
            }
        } else {
            m_print.log("PLAYERS HP IS LESS 0. RESTART GAME.");
            // restart game
            for (var i = 0; i < _asteroid_list.length; i++)
                init_asteroid_transform(_asteroid_list[i]);

            _env_speed = 0;
            _asteroid_speed = ASTEROID_DEFAULT_SPEED;
            _spawn_delay = ASTEROID_DEFAULT_SPAWN_DELAY;
            m_ctl.remove_sensor_manifold(cam_obj, "CRASH");
            m_ctl.remove_sensor_manifold(cam_obj, "ASTEROID_SPAWN");
            start_game();
        }
    }