master
cp 2021-12-06 15:10:50 +08:00
parent ee77f3fe4b
commit c5fcb3d64e
2 changed files with 101 additions and 93 deletions

View File

@ -10,8 +10,6 @@ var allSayTimer = 5000;
var actionArr = ['dancing-left','dancing-right','dancing-down','dancing-up','dancing-wobble','dancing-wobble-right']; var actionArr = ['dancing-left','dancing-right','dancing-down','dancing-up','dancing-wobble','dancing-wobble-right'];
// 人物位移动画 // 人物位移动画
var moveArr = ['run-right','run-left','run-right-top','run-left-top','run-right-bottom','run-left-bottom']; var moveArr = ['run-right','run-left','run-right-top','run-left-top','run-right-bottom','run-left-bottom'];
// 随机荧光棒动画
var fluoArr = ['stick-go','stickcome'];
var peopleId = 0; var peopleId = 0;
// 窗体宽度 // 窗体宽度
var winWidth = $(window).width(); var winWidth = $(window).width();
@ -26,8 +24,6 @@ var dancingTime = 6000;
var runTime = 6000; var runTime = 6000;
// 随机移动的定时器 // 随机移动的定时器
var upTimer = null; var upTimer = null;
// 荧光棒关闭时间
var fluoTime = 6000//默认6秒关闭
// 集体舞ji // 集体舞ji
function allDancing(dangcing){ function allDancing(dangcing){
if(dangcing!=''){ if(dangcing!=''){
@ -56,16 +52,17 @@ function allDancing(dangcing){
},10000) },10000)
} }
} }
// 创建人物时随机分配 // 随机舞
function randomDancing(id){ function randomDancing(id){
$(`.data${id} .people-img`).addClass(actionArr[Math.floor(Math.random()*actionArr.length)]); actionArr.forEach((item,index)=>{
} var haveDan = $(`.data${id} .people-img`).is(`.${item}`);
// 荧光棒动画事件 if(haveDan){
function fluoEv(id,fluoEvent){ $(`.data${id} .people-img`).removeClass(item);
$(`#${id} .stick`).addClass(fluoEvent); $(`.data${id} .people-img`).addClass(actionArr[Math.floor(Math.random()*actionArr.length)]);
setTimeout(()=>{ } else {
$(`#${id} .stick`).removeClass(fluoEvent); $(`.data${id} .people-img`).addClass(actionArr[Math.floor(Math.random()*actionArr.length)]);
},fluoTime) }
})
} }
// 个人动作舞 // 个人动作舞
function peopleAction(id,aevent){ function peopleAction(id,aevent){
@ -79,13 +76,55 @@ function peopleAction(id,aevent){
} }
}) })
} }
// 位移事件 //
function upMove(id){ function upMove(id){
var odivu = document.getElementById(`${id}`); var odivu = document.getElementById(`${id}`);
upTimer = setInterval(()=>{ upTimer = setInterval(()=>{
$(`#${id}`).animate({top:`${Math.floor(Math.random()*90)}%`,left:`${Math.floor(Math.random()*90)}%`},Math.floor(Math.random()*40000+10000)); // if(parseInt(odivu.style.top) <=10){
// // clearInterval(upTimer);
// // downMove(id);
// $(`#${id}`).animate({top:`${Math.floor(Math.random()*90)}%`,left:`${Math.floor(Math.random()*90)}%`},Math.floor(Math.random()*40000+10000));
// } else {
$(`#${id}`).animate({top:`${Math.floor(Math.random()*90)}%`,left:`${Math.floor(Math.random()*90)}%`},Math.floor(Math.random()*40000+10000));
// }
},runTime) },runTime)
} }
// // 下
// function downMove(id){
// var odivd = document.getElementById(`${id}`);
// var downTimer = setInterval(()=>{
// if(parseInt(odivd.style.top) >=86){
// clearInterval(downTimer);
// upMove(id);
// } else {
// $(`#${id}`).animate({top:`${Math.floor(Math.random()*90)}%`,left:`${Math.floor(Math.random()*90)}%`},Math.floor(Math.random()*40000+10000));
// }
// },10)
// }
// // 左
// function leftMove(id){
// var odivl = document.getElementById(`${id}`);
// var leftTimer = setInterval(()=>{
// if(odivl.offsetLeft < 10){
// clearInterval(leftTimer);
// rightMove(id);
// } else {
// $(`#${id}`).animate({top:`${Math.floor(Math.random()*90)}%`,left:`${Math.floor(Math.random()*90)}%`},Math.floor(Math.random()*40000+10000));
// }
// },10)
// }
// // 右
// function rightMove(id){
// var odivr = document.getElementById(`${id}`);
// var rightTimer = setInterval(()=>{
// if(odivr.offsetLeft >= 86){
// clearInterval(rightTimer);
// leftMove(id);
// } else {
// $(`#${id}`).animate({top:`${Math.floor(Math.random()*90)}%`,left:`${Math.floor(Math.random()*90)}%`},Math.floor(Math.random()*40000+10000));
// }
// },10)
// }
// 随机位移 // 随机位移
function moveEv(id){ function moveEv(id){
upMove(id); upMove(id);

View File

@ -16,21 +16,19 @@ let leaderTime = 15*60
// 何时添加镜头 // 何时添加镜头
var addJingTime = 2000;//2秒 var addJingTime = 2000;//2秒
// 事件列表-中文 // 事件列表-中文
let eventTextList = ['切歌', '跳', '向左', '向右', '左抖腿', '右抖腿', '抖动', '一起喊', '镜头','击剑','起飞'] let eventTextList = ['切歌', '跳', '向左', '向右', '左抖腿', '右抖腿', '抖动', '一起喊', '镜头']
// 个人---荧光棒列表-中文
let fluoTextList = ['击剑','起飞'];
// 领舞---荧光棒列表-中文
let leaderFluoList = ['一起击剑','一起起飞'];
// 领舞者喊的集体舞 // 领舞者喊的集体舞
let allEventList = ['切歌', '一起跳', '一起向左', '一起向右', '一起左抖腿', '一起右抖腿', '一起抖动', '一起喊', '镜头'] let allEventList = ['切歌', '一起跳', '一起向左', '一起向右', '一起左抖腿', '一起右抖腿', '一起抖动', '一起喊', '镜头']
// 镜头列表 // 镜头列表
let list = ['scale-left', 'scale-right', 'scale-bottom-left', 'scale-bottom-right'] let list = ['scale-left', 'scale-right', 'scale-bottom-left', 'scale-bottom-right']
// 烟花次数 // 烟花次数
let firTimes = 0; let firTimes = 0;
// 个人喊舞:根据事件文字 获取事件名 // 根据事件文字 获取事件名
function getEvent(name) { function getEvent(name) {
let map = { let map = {
'烟花':'fireworks', '烟花':'fireworks',
'一起击剑':'stickcome',
'起飞':'stickgo',
'切歌' : 'change_song', '切歌' : 'change_song',
'跳' : 'dancing-down', '跳' : 'dancing-down',
'向左' : 'dancing-left', '向左' : 'dancing-left',
@ -45,10 +43,12 @@ function getEvent(name) {
return map[name] ? map[name] : '' return map[name] ? map[name] : ''
} }
// 领舞者:根据事件文字 获取事件名 // 根据事件文字 获取领舞者事件名
function getLeaderEvent(name) { function getLeaderEvent(name) {
let map = { let map = {
'烟花':'fireworks', '烟花':'fireworks',
'一起击剑':'stickcome',
'起飞':'stickgo',
'切歌' : 'change_song', '切歌' : 'change_song',
'一起跳' : 'dancing-down', '一起跳' : 'dancing-down',
'一起向左' : 'dancing-left', '一起向左' : 'dancing-left',
@ -62,29 +62,22 @@ function getLeaderEvent(name) {
return map[name] ? map[name] : '' return map[name] ? map[name] : ''
} }
//
function getLeaderFluoEvent(name) {
let leadMap = {
'一起击剑':'stickcome',
'一起起飞':'stick-go'
}
return leadMap[name] ? leadMap[name] : ''
}
// 随机选择镜头 // 随机选择镜头
function scale() { function scale() {
return list[Math.floor(Math.random() * 3)]; return list[Math.floor(Math.random() * 3)];
} }
// 字符串包含的事件 (仅取第一个) // 字符串包含的事件 (仅取第一个)
// function getFirstEventKeyword(name) { function getFirstEventKeyword(name) {
// let event = '' let event = ''
// $.each(eventTextList, function (index, item) { $.each(eventTextList, function (index, item) {
// if (name.toString().indexOf(item) != -1) { if (name.toString().indexOf(item) != -1) {
// event = item event = item
// return false return false
// } }
// }) })
// return event return event
// } }
function music() { function music() {
$.get(musicUrl, function (res) { $.get(musicUrl, function (res) {
@ -111,18 +104,6 @@ function changeMusic() {
function peopleHan(val){ function peopleHan(val){
return eventTextList.includes(val); return eventTextList.includes(val);
} }
// 领舞者:根据事件文字 获取事件名
function getFluoEvent(name) {
let fluoMap = {
'击剑':'stickcome',
'起飞':'stick-go'
}
return fluoMap[name] ? fluoMap[name] : ''
}
// 个人喊荧光棒
function peopleFluo(val){
return fluoTextList.includes(val);
}
// 领舞喊舞 // 领舞喊舞
function dancer(val){ function dancer(val){
return allEventList.includes(val); return allEventList.includes(val);
@ -175,12 +156,12 @@ function receiveMessage(event)
// 领舞信息 目前为领舞名称 // 领舞信息 目前为领舞名称
let leaderInfo = '' let leaderInfo = ''
// 高能榜第一位设为领舞 // 高能榜第一位设为领舞
if (highList!=undefined && highList.length > 0) { if (highList.length > 0) {
leaderInfo = highList[0] leaderInfo = highList[0]
} }
leaderInfo = '内有猛犬小心' // leaderInfo = '内有猛犬小心'
// leaderInfo = '饺子吃肉肉'
// uid是否存在 不存在则存入uidObj // uid是否存在 不存在则存入uidObj
let isNew = 0 let isNew = 0
@ -217,6 +198,7 @@ function receiveMessage(event)
leader.text = dm.text leader.text = dm.text
leader.event = eventName ? eventName : leaderEvent leader.event = eventName ? eventName : leaderEvent
} }
// 新用户 // 新用户
if(dm.is_new==1){ if(dm.is_new==1){
// if(dm.uname!=leader.uname){//如果弹幕的人的名字不等于领舞者的名字,就创建一个人物 // if(dm.uname!=leader.uname){//如果弹幕的人的名字不等于领舞者的名字,就创建一个人物
@ -232,17 +214,13 @@ function receiveMessage(event)
// 舰长添加大宝剑 // 舰长添加大宝剑
$(`#${dm.uid} .stick`).addClass("stick-swing-big-tow"); $(`#${dm.uid} .stick`).addClass("stick-swing-big-tow");
} }
setTimeout(()=>{//关闭当前说话 setTimeout(()=>{
$(`#${dm.uid} .speak`).addClass("dn"); $(`#${dm.uid} .speak`).addClass("dn");
},3000) },3000)
// 舞者喊舞---动作舞 // 舞者喊舞
if(peopleHan(dm.text)){ if(peopleHan(dm.text)){
peopleAction(`${dm.uid}`,dm.event); peopleAction(`${dm.uid}`,dm.event);
} }
// 舞者喊舞---荧光棒
if(peopleFluo(dm.text)){
fluoEv(`${dm.uid}`,getFluoEvent(dm.text));
}
} }
num++; num++;
@ -293,29 +271,29 @@ function receiveMessage(event)
} }
} }
//领舞起飞 //领舞起飞
// if(leader.text==="起飞"){ if(leader.text==="起飞"){
// if(firTimes==0){ if(firTimes==0){
// firTimes++; firTimes++;
// $('.stick').removeClass('stick-swing'); $('.stick').removeClass('stick-swing');
// $('.stick').addClass('stick-go'); $('.stick').addClass('stick-go');
// setTimeout(()=>{ setTimeout(()=>{
// $('.stick').removeClass('stick-go'); $('.stick').removeClass('stick-go');
// $('.stick').addClass('stick-swing'); $('.stick').addClass('stick-swing');
// firTimes = 0; firTimes = 0;
// },6000) },6000)
// } }
// } }
//一起击剑 //一起击剑
// if(leader.text==="一起击剑"){ if(leader.text==="一起击剑"){
// if(firTimes==0){ if(firTimes==0){
// firTimes++; firTimes++;
// $('.stick').addClass('stickcome'); $('.stick').addClass('stickcome');
// setTimeout(()=>{ setTimeout(()=>{
// $('.stick').removeClass('stickcome'); $('.stick').removeClass('stickcome');
// firTimes = 0; firTimes = 0;
// },6000) },6000)
// } }
// } }
// 领舞喊一起喊 // 领舞喊一起喊
if (leader.text.length >= 4) { if (leader.text.length >= 4) {
@ -323,6 +301,7 @@ function receiveMessage(event)
allSay(leader.text.slice(4)); allSay(leader.text.slice(4));
} }
} }
// 领舞自己喊跳舞 // 领舞自己喊跳舞
if(peopleHan(dm.text)){ if(peopleHan(dm.text)){
clearInterval(dancerTimer); clearInterval(dancerTimer);
@ -332,16 +311,6 @@ function receiveMessage(event)
if(dancer(leader.text)){ if(dancer(leader.text)){
allDancing(leader.event); allDancing(leader.event);
} }
// 领舞喊荧光棒事件
if(getLeaderFluoEvent(leader.text)!=''){
if(firTimes==0){//防多次说话
firTimes++;
console.log(getLeaderFluoEvent(leader.text));
setTimeout(()=>{
firTimes = 0;
},5000)
}
}
} }
// -------------------- 每条弹幕处理 end ----------------------- // -------------------- 每条弹幕处理 end -----------------------
} }