Ejemplo n.º 1
0
function set_state(golem_wrapper, state) {
    var golem_rig = golem_wrapper.rig;
    switch (state) {
    case m_conf.GS_WALKING:
        m_anim.apply(golem_rig, "golem_walk")
        m_anim.set_behavior(golem_rig, m_anim.AB_CYCLIC);
        m_anim.play(golem_rig);
        break;
    case m_conf.GS_ATTACKING:
        var rand = Math.floor(3 * Math.random()) + 1;
        m_anim.apply(golem_rig, "golem_atack_0" + rand);
        m_anim.play(golem_rig, function() {
            if (golem_wrapper.state != m_conf.GS_NONE)
                set_state(golem_wrapper, m_conf.GS_WALKING);
        });
        break;
    case m_conf.GS_GETTING_OUT:
        m_anim.apply(golem_rig, "golem_getout");
        m_anim.play(golem_rig, function() {
            if (golem_wrapper.state != m_conf.GS_NONE)
                set_state(golem_wrapper, m_conf.GS_WALKING)
        });
        break;
    }
    golem_wrapper.state = state;
}
Ejemplo n.º 2
0
function kill(golem_wrapper) {
    var golem = golem_wrapper.empty;
    var golem_death_empty = m_scs.get_object_by_name(m_conf.GOLEMS_DEATH_EMPTY);
    var golem_death = m_scs.get_object_by_dupli_name(m_conf.GOLEMS_DEATH_EMPTY,
                                                     m_conf.GOLEMS_DEATH_RIG);
    var golem_death_blow = m_scs.get_object_by_dupli_name(m_conf.GOLEMS_DEATH_EMPTY,
                                                          m_conf.GOLEMS_DEATH_BLOW);
    var trans = _vec3_tmp;
    var quat = _quat4_tmp;

    m_trans.get_translation(golem, trans);
    m_trans.get_rotation(golem, quat);
    m_trans.set_translation_v(golem_death_empty, trans);
    m_trans.set_rotation_v(golem_death_empty, quat);

    m_anim.apply(golem_death, "golem_death");
    m_anim.set_behavior(golem_death, m_anim.AB_FINISH_STOP);
    m_anim.play(golem_death);

    m_anim.play(golem_death_blow);
    m_sfx.stop(golem_wrapper.walk_speaker);

    m_trans.set_translation_v(golem, m_conf.DEFAULT_POS);
    m_gems.spawn(trans);

    golem_wrapper.island_id = -1;
    golem_wrapper.hp = 100;
    set_state(golem_wrapper, m_conf.GS_NONE)

    m_obelisks.change_gems_num(golem_wrapper.island_id, 0);
}
Ejemplo n.º 3
0
function apply_anim_cycle(cessna_arm, cessna_spk, pilot) {
    m_sfx.speaker_stride(cessna_spk);

    m_anim.set_first_frame(cessna_arm);
    m_anim.play(cessna_arm, finish_anim_callback);

    m_anim.stop(pilot);
    m_anim.set_first_frame(pilot);
    m_anim.play(pilot);
}
Ejemplo n.º 4
0
function damage_asteroid(asteroid, damage) {
    var name = m_scs.get_object_name_hierarchy(asteroid)[0];
    var dupli_name = m_scs.get_object_name_hierarchy(asteroid)[1];

    var asteroid = get_asteroid_by_name(name);
    if (asteroid && !asteroid.is_destroyed) {
        asteroid.strength -= damage;
        if (asteroid.strength < 0) {
            m_vec3.set(0, 0, 0, asteroid.velosity);
            m_quat.identity(asteroid.angular_velosity);

            var ast_arm = asteroid.ast_arm;
            if (ast_arm) {
                m_anim.apply(ast_arm, dupli_name + "_disruption");
                m_anim.play(ast_arm, compile_asteroid);
            }

            var ast_copy_mesh_obj = asteroid.ast_copy_mesh_obj;
            if (ast_copy_mesh_obj) {
                m_anim.apply(ast_copy_mesh_obj, "asteroid_fading");
                m_anim.play(ast_copy_mesh_obj);
            }

            var lighting = _cockpit.lighting;
            if (lighting) {
                m_anim.apply(lighting, "asteroid_burst");
                m_anim.play(lighting);
            }

            var emitter = asteroid.ast_emitter_obj;
            if (emitter) {
                var trans = m_trans.get_translation(asteroid.ast_obj, _vec3_tmp);
                m_trans.set_translation_v(emitter, trans);
                m_anim.apply(emitter, "explosion")
                m_anim.play(emitter);
            }

            var speaker = asteroid.ast_speaker;
            if (speaker) {
                var trans = m_trans.get_translation(asteroid.ast_obj, _vec3_tmp);
                m_trans.set_translation_v(speaker, trans);
                m_sfx.play_def(speaker);
            }

            asteroid.is_destroyed = true;
        }
    }
}
Ejemplo n.º 5
0
/**
 * callback executed when the scene is loaded
 */
function load_cb(data_id) {
  m_game_ui.close_load_screen(true);
  m_app.enable_controls();
  m_app.enable_camera_controls();

  // place your code here
  m_notifications.setupIcons(3);
  charTom = m_scenes.get_object_by_name("Tom_Office");
  m_animation.apply(charTom,"Tom_EnterX_B4W_BAKED");
  m_animation.set_behavior(charTom, m_animation.AB_FINISH_STOP);
  m_animation.play(charTom, function(){
    m_animation.apply(charTom,"Tom_idleXX_B4W_BAKED");
    m_animation.set_behavior(charTom, m_animation.AB_CYCLIC);
    m_animation.play(charTom);
  });

  m_scene_mouse.set_hover_cursor(m_scenes.get_object_by_name("Level_2"), "pointer");
  m_scene_mouse.set_hover_cursor(m_scenes.get_object_by_name("Exit"), "pointer");
  m_scene_mouse.set_hover_cursor(m_scenes.get_object_by_name("Plant"), "pointer");

  var canvas = m_container.get_canvas();
  canvas.addEventListener("mouseup", on_mouse_up);
  canvas.addEventListener("mousedown", on_mouse_down);
  if (m_main.is_paused())
    m_main.resume();
  m_game_ui.set_game_hidden(false);
  document.getElementById('mod_header').style.animationPlayState = 'running';
  document.getElementById('quiz_wrapper').style.display = 'block';
  start_quiz();
}
Ejemplo n.º 6
0
 m_animation.play(charSue, function(){
   m_animation.apply(charSue,"dmt_sue_idle_B4W_BAKED");
   m_animation.set_behavior(charSue, m_animation.AB_CYCLIC);
   m_animation.play(charSue);
   submitted = false;
   // m_scene_mouse.enable_cursor_hover();
 });
Ejemplo n.º 7
0
/**
 * callback executed when the scene is loaded
 */
function load_cb(data_id) {
  m_game_ui.close_load_screen(true);
  m_app.enable_controls();
  m_app.enable_camera_controls();

  //m_cfg.set("enable_outlining",true);

  // place your code here
  m_notifications.setupIcons(4);
  charPizza = m_scenes.get_object_by_name("Pizza_Arm");
  charSue = m_scenes.get_object_by_name("Sue_Office");
  charWater = m_scenes.get_object_by_name("water_rig");
  m_animation.apply(charSue,"dmt_sue_idle_B4W_BAKED");
  m_animation.set_behavior(charSue, m_animation.AB_CYCLIC);
  m_animation.play(charSue);

  m_scene_mouse.set_hover_cursor(m_scenes.get_object_by_name("Toaster"), "pointer");
  m_scene_mouse.set_hover_cursor(m_scenes.get_object_by_name("Counter_Basin"), "pointer");
  m_scene_mouse.set_hover_cursor(m_scenes.get_object_by_name("Pizza_Box"), "pointer");
  m_scene_mouse.set_hover_cursor(m_scenes.get_object_by_name("Light_Switch"), "pointer");

  var canvas = m_container.get_canvas();
  canvas.addEventListener("mouseup", on_mouse_up);
  canvas.addEventListener("mousedown", on_mouse_down);

  m_line_speed.freeze();
  if (qs["skip_intro"] == "1")
    end_cutscene();
  else
    play_cutscene(true);
}
Ejemplo n.º 8
0
function apply_shield() {
    m_anim.set_behavior(_char_wrapper.body, m_anim.AB_FINISH_STOP, m_anim.SLOT_2);
    m_anim.play(_char_wrapper.body, null, m_anim.SLOT_2);
    m_obj.set_nodemat_value(_char_wrapper.lava_shield_prot,
                            ["lava_shield_prot", "shield_switcher"],
                            1);
}
Ejemplo n.º 9
0
    function anim_cb(obj, id, pulse) {
        if (_char_wrapper.state == m_conf.CH_ATTACK)
            return;

        var on_ground = m_ctl.get_sensor_value(obj, id, 0);

        var cur_anim = m_anim.get_current_anim_name(_char_wrapper.rig);
        var required_anim = m_conf.CHAR_IDLE_ANIM;

        if (_char_wrapper.state == m_conf.CH_JUMP) {
            var required_anim = m_conf.CHAR_JUMP_ANIM;
        } else if (move_state.forw_back == 1) {
            var required_anim = m_conf.CHAR_RUN_ANIM;
        } else if (move_state.forw_back == -1) {
            var required_anim = m_conf.CHAR_RUN_ANIM;
            m_anim.set_speed(_char_wrapper.rig, -1);
        } else if (move_state.left_right == 1) {
            var required_anim = m_conf.CHAR_STRAFE;
            m_anim.set_speed(_char_wrapper.rig, -1);
        } else if (move_state.left_right == -1) {
            var required_anim = m_conf.CHAR_STRAFE;
        }

        if (cur_anim != required_anim) {
            m_anim.apply(_char_wrapper.rig, required_anim);
            m_anim.play(_char_wrapper.rig);
            m_anim.set_behavior(_char_wrapper.rig, m_anim.AB_CYCLIC);
        }
    }
Ejemplo n.º 10
0
    var damage_enemies_cb = function(obj, id, pulse) {

        if (_char_wrapper.state != m_conf.CH_ATTACK)
            return;

        if (!char_attack_done) {
            var frame = m_anim.get_frame(_char_wrapper.rig);
            if (frame >= m_conf.CHAR_ATTACK_ANIM_FRAME) {
                var trans     = _vec3_tmp;
                var cur_dir   = _vec3_tmp_2;
                var at_pt     = _vec3_tmp_3;
                var cur_rot_q = _quat4_tmp;
                var at_dst = m_conf.CHAR_ATTACK_DIST;

                m_trans.get_translation(_char_wrapper.phys_body, trans);
                m_trans.get_rotation(_char_wrapper.phys_body, cur_rot_q);
                m_vec3.transformQuat(m_util.AXIS_Z, cur_rot_q, cur_dir);

                m_vec3.scaleAndAdd(trans, cur_dir, at_dst, at_pt);
                if (m_combat.process_attack_on_enemies(at_pt, at_dst)) {
                    m_sfx.play_def(_char_hit_spk);
                    m_anim.play(_char_wrapper.hitsparks);
                }
                char_attack_done = true;
            }
        }
    }
Ejemplo n.º 11
0
function kill() {

    disable_controls()
    if (_level_conf.MUSIC_SPEAKERS) {
        m_sfx.clear_playlist();
        var intro_spk = m_scs.get_object_by_dupli_name("enviroment",
                                                       _level_conf.MUSIC_INTRO_SPEAKER);
        m_sfx.stop(intro_spk);

        var end_spk = m_scs.get_object_by_dupli_name("enviroment",
                                                     _level_conf.MUSIC_END_SPEAKER);
        m_sfx.play_def(end_spk);
    }

    var char_death_spk = m_scs.get_object_by_dupli_name(m_conf.CHAR_EMPTY,
                                                     m_conf.CHAR_DEATH_SPEAKER);
    m_sfx.play_def(char_death_spk);

    var anim_id = Math.floor(_char_death_anims.length * Math.random());
    var death_anim = _char_death_anims[anim_id];
    m_anim.apply(_char_wrapper.rig, death_anim);
    m_anim.set_behavior(_char_wrapper.rig, m_anim.AB_FINISH_STOP);
    m_anim.play(_char_wrapper.rig);

    m_interface.show_replay_button(1);

    if (_char_wrapper.gem_slot)
        remove_gem();

    if (m_bonuses.shield_time_left() > 0)
        remove_shield();

    if (m_bonuses.lava_protect_time_left() > 0)
        remove_lava_protect();
}
Ejemplo n.º 12
0
    function finish_attack_cb(obj) {
        m_anim.apply(_char_wrapper.rig, m_conf.CHAR_IDLE_ANIM);
        m_anim.set_behavior(_char_wrapper.rig, m_anim.AB_CYCLIC);
        m_anim.play(_char_wrapper.rig);

        _char_wrapper.state = m_conf.CH_STILL;
    }
Ejemplo n.º 13
0
 function ray_cb(id, fract, obj, time, pos, norm) {
     var spawned = m_bonuses.spawn(pos);
     if (spawned) {
         m_trans.set_translation_v(sphere_empty, pos);
         m_anim.play(bonus_spawn_sphere);
     }
 }
Ejemplo n.º 14
0
function kill_character() {
    m_anim.apply(_character_rig, "character_death");
    m_anim.play(_character_rig);
    m_anim.set_behavior(_character_rig, m_anim.AB_FINISH_STOP);
    m_phy.set_character_move_dir(_character, 0, 0);
    m_ctl.remove_sensor_manifolds(_character);
}
Ejemplo n.º 15
0
 function select_anim_cb(obj, id, pulse) {
     if (pulse > 0)
         m_anim.play(obj);
     else {
         m_anim.stop(obj);
         m_anim.set_first_frame(obj);
     }
 }
Ejemplo n.º 16
0
exports.stretch = function() {
  if (state == "stretch")
    return false;
  state = "stretch";
  m_anim.apply(keani, "Keani_Chairpos_Stretch_B4W_BAKED");
  m_anim.set_behavior(keani, m_anim.AB_FINISH_STOP);
  m_anim.play(keani);
}
Ejemplo n.º 17
0
exports.start_typing = function() {
  if (state == "start_typing")
    return false;
  state = "start_typing";
  m_anim.apply(keani, "Keani_Chairpos_Type_Start_B4W_BAKED");
  m_anim.set_behavior(keani, m_anim.AB_FINISH_STOP);
  m_anim.play(keani, exports.typing_loop);
}
Ejemplo n.º 18
0
function demo_link_click(e) {
    m_data.activate_media();
    var letters_arm = m_scs.get_object_by_name('beads_armature');
    var spk = m_scs.get_object_by_name("Speaker");

    m_sfx.play_def(spk);
    m_anim.apply(letters_arm, "flying_letters");
    m_anim.play(letters_arm, letters_obj_cb);
}
Ejemplo n.º 19
0
exports.unreach = function() {
  if (state == "unreach")
    return false;
  state = "unreach";
  m_anim.apply(keani, "Keani_Chairpos_Reach_B4W_BAKED");
  m_anim.set_behavior(keani, m_anim.AB_FINISH_STOP);
  m_anim.set_last_frame(keani);
  m_anim.set_speed(keani, -1.0);
  m_anim.play(keani);
}
Ejemplo n.º 20
0
function create_sensors() {
    for (var i = 0; i < _ev_tracks.length; i++) {

        var ev_track = _ev_tracks[i];

        create_track_ray_sensors(ev_track);
        create_track_collision_sensors(ev_track);

        if (ev_track.rig && m_anim.get_current_action(ev_track.rig))
            m_anim.play(ev_track.rig);
    }
}
Ejemplo n.º 21
0
function play_anims(node) {
    var obj = node.payload.anim_obj;
    var anim = node.payload.anim;
    var inst = node.instances[_gs.ro_sm_node_state.instance_id];
    for (var i = 0; i < anim.length; i++) {
        if (inst.anim) {
            var slot_num = inst.anim[anim.name];
            if (!slot_num)
                slot_num = anim[i].slot;
            m_anim.play(obj, null, slot_num);
        }
    }
}
Ejemplo n.º 22
0
//==============================================================================
// SETUP SHOOTING LOGIC
//==============================================================================
function shoot(time) {
    if (time - _last_shoot_time > SHOOT_LISER_DELAY) {
        m_ctl.set_custom_sensor(_burst_fire_sensor, 1);
        var laser_obj = _cockpit.laser_obj;
        if (laser_obj) {
            m_anim.apply(laser_obj, "laser_strike");
            m_anim.play(laser_obj);
            m_anim.set_behavior(laser_obj, m_anim.AB_FINISH_STOP);
        }
        _last_shoot_time = time;
        _burst_time = time;

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

        var lighting = _cockpit.lighting;
        if (lighting) {
            m_anim.apply(lighting, "laser_strike_lighting");
            m_anim.play(lighting);
        }
    }
}
Ejemplo n.º 23
0
function action_rails() {
    if (!_rocket_num)
        return;

    _canvas_elem.removeEventListener("mousedown", get_clicked_object);
    _canvas_elem.removeEventListener("touchstart", get_clicked_object);

    m_sfx.stop(_button_spk);
    m_sfx.play_def(_button_spk);

    m_anim.apply(_control_box_button, "press_button_Action");
    m_anim.set_behavior(_control_box_button, m_anim.AB_FINISH_STOP);
    m_anim.play(_control_box_button);

    m_anim.set_speed(_rockets_box, -1);

    m_anim.play(_rockets_box, function() {
        m_anim.apply(_bm_13_Armature, "bm_13_Armature_rotate_-37_Action");
        m_anim.set_first_frame(_bm_13_Armature);
        m_anim.set_behavior(_bm_13_Armature, m_anim.AB_FINISH_STOP);
        m_anim.play(_bm_13_Armature, action_camera);
    });
}
Ejemplo n.º 24
0
function load_cb(data_id) {
    _character = m_scs.get_first_character();
    _character_rig = m_scs.get_object_by_dupli_name("character",
                                                    "character_rig");
    setup_movement();
    setup_rotation();
    setup_jumping();

    m_anim.apply(_character_rig, "character_idle_01");
    m_anim.play(_character_rig);
    m_anim.set_behavior(_character_rig, m_anim.AB_CYCLIC);

    setup_camera();
}
function load_cb(root) {
	//m_app.enable_camera_controls();
	
	_character_rig = m_scenes.get_object_by_name("character_armature");
	
	setup_anime()
	
	m_anim.apply(_character_rig, "stand_001");
	m_anim.play(_character_rig);
	m_anim.set_behavior(_character_rig, m_anim.AB_CYCLIC);


	m_main.append_loop_cb(main_loop_callback)

}
Ejemplo n.º 26
0
 return function(callback) {
   if (ANIM_MODES.indexOf(mode) == -1)
     mode = m_anim.AB_FINISH_STOP;
   m_anim.apply(obj, anim_name);
   if (mode === exports.PINGPONG) {
     pingpong(obj, false, callback);
   }
   else {
     m_anim.set_behavior(obj, mode);
     if (speed < 0)
       m_anim.set_last_frame(obj);
     m_anim.set_speed(obj, speed);
     m_anim.play(obj, callback);
   }
 }
Ejemplo n.º 27
0
    var jump_cb = function(obj, id, pulse) {
        if (pulse == 1 && _char_wrapper.state != m_conf.CH_ATTACK) {
            _char_wrapper.state = m_conf.CH_JUMP;
            m_phy.character_jump(obj);

            var id = Math.floor(_char_jump_spks.length * Math.random());
            m_sfx.play_def(_char_jump_spks[id]);

            m_anim.apply(_char_wrapper.rig, m_conf.CHAR_JUMP_ANIM);
            m_anim.set_behavior(_char_wrapper.rig, m_anim.AB_FINISH_STOP);
            m_anim.play(_char_wrapper.rig);

            _char_wrapper.move_state.forw_back = 0;
            _char_wrapper.move_state.left_right = 0;
        }
    }
Ejemplo n.º 28
0
    var attack_cb = function(obj, id, pulse) {
        if (pulse == 1 && _char_wrapper.state != m_conf.CH_ATTACK) {
            _char_wrapper.state = m_conf.CH_ATTACK;
            _char_wrapper.move_state.forw_back = 0;
            _char_wrapper.move_state.left_right = 0;
            var anim_id = Math.floor(_char_attack_anims.length * Math.random());
            var attack_anim = _char_attack_anims[anim_id];
            m_anim.apply(_char_wrapper.rig, attack_anim);
            m_anim.set_behavior(_char_wrapper.rig, m_anim.AB_FINISH_STOP);
            m_anim.play(_char_wrapper.rig, finish_attack_cb);

            m_phy.set_character_move_dir(_char_wrapper.phys_body, 0, 0);
            char_attack_done = false;

            process_attack_speakers();
        }
    }
Ejemplo n.º 29
0
function setup_movement(up_arrow, down_arrow) {
    var key_w     = m_ctl.create_keyboard_sensor(m_ctl.KEY_W);
    var key_s     = m_ctl.create_keyboard_sensor(m_ctl.KEY_S);
    var key_up    = m_ctl.create_keyboard_sensor(m_ctl.KEY_UP);
    var key_down  = m_ctl.create_keyboard_sensor(m_ctl.KEY_DOWN);

    var move_array = [
        key_w, key_up, up_arrow,
        key_s, key_down, down_arrow
    ];

    var forward_logic  = function(s){return (s[0] || s[1] || s[2])};
    var backward_logic = function(s){return (s[3] || s[4] || s[5])};

    function move_cb(obj, id, pulse) {
        if (pulse == 1) {
            switch(id) {
            case "FORWARD":
                var move_dir = 1;
                m_anim.apply(_character_rig, "character_run");
                break;
            case "BACKWARD":
                var move_dir = -1;
                m_anim.apply(_character_rig, "character_run");
                break;
            }
        } else {
            var move_dir = 0;
            m_anim.apply(_character_rig, "character_idle_01");
        }

        m_phy.set_character_move_dir(obj, move_dir, 0);

        m_anim.play(_character_rig);
        m_anim.set_behavior(_character_rig, m_anim.AB_CYCLIC);
    };

    m_ctl.create_sensor_manifold(_character, "FORWARD", m_ctl.CT_TRIGGER,
        move_array, forward_logic, move_cb);
    m_ctl.create_sensor_manifold(_character, "BACKWARD", m_ctl.CT_TRIGGER,
        move_array, backward_logic, move_cb);

    m_anim.apply(_character_rig, "character_idle_01");
    m_anim.play(_character_rig);
    m_anim.set_behavior(_character_rig, m_anim.AB_CYCLIC);
}
Ejemplo n.º 30
0
 var anim_sensor_cb = function(obj, id, pulse) {
     var up = m_ctl.get_sensor_value(obj, id, 0)
             || m_ctl.get_sensor_value(obj, id, 3)
             || m_ctl.get_sensor_value(obj, id, 5);
     var down = m_ctl.get_sensor_value(obj, id, 1)
             || m_ctl.get_sensor_value(obj, id, 4)
             || m_ctl.get_sensor_value(obj, id, 6);
     var vert = m_ctl.get_sensor_value(obj, id, 2);
     if (pulse == 1) {
         if (up || vert < 0)
             m_anim.set_speed(obj, ANIM_SPEED, m_anim.SLOT_0);
         if (down || vert > 0)
             m_anim.set_speed(obj, -ANIM_SPEED, m_anim.SLOT_0);
         m_anim.play(obj, m_anim.SLOT_0);
     } else
         m_anim.stop(obj, m_anim.SLOT_0);
 }