Example #1
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;
            }
        }
    }
Example #2
0
function process_attack(golem_wrapper) {
    if (!golem_wrapper.attack_done) {
        var frame = m_anim.get_frame(golem_wrapper.rig);
        if (frame >= m_conf.GOLEM_ATTACK_ANIM_FRAME) {
            if (golem_wrapper.last_target == m_conf.GT_CHAR)
                process_golem_char_attack(golem_wrapper);
            else if (golem_wrapper.last_target == m_conf.GT_OBELISK)
                process_golem_obelisk_attack(golem_wrapper);
            golem_wrapper.attack_done = true;
        }
    }
}
Example #3
0
 /**
 * Gets the current frame of the object's animation, based on FPS defined in blender.
 * @return {Number} [Current frame]
 */
 function get_frame(){
   frame = parseInt(m_anim.get_frame(properties, 0), 10);
   return frame;
 }