新增个人喊荧光棒动画

master
chen 2021-12-06 14:55:24 +08:00
parent 5cc98a70a0
commit ee77f3fe4b
2 changed files with 93 additions and 101 deletions

View File

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

View File

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