领舞者跟舞者不能共存,新增一起喊
parent
c7995c657c
commit
30fe15c2bd
58
js/custom.js
58
js/custom.js
|
@ -4,6 +4,8 @@ var timer = null;
|
|||
var actionTimer = null;
|
||||
var moveTimer = null;
|
||||
var dancerTimer = null;
|
||||
// 经过几秒关闭一起喊
|
||||
var allSayTimer = 5000;
|
||||
// 动作
|
||||
var actionArr = ['dancing-left','dancing-right','dancing-down','dancing-up','dancing-wobble','dancing-wobble-right'];
|
||||
// 人物位移动画
|
||||
|
@ -78,44 +80,50 @@ function peopleAction(id,aevent){
|
|||
}
|
||||
// 随机位移
|
||||
function moveEv(id){
|
||||
var typeMove = Math.floor(Math.random()*4);
|
||||
switch (typeMove){
|
||||
case 0:
|
||||
upMove(id);
|
||||
break;
|
||||
case 1:
|
||||
// upMove(id);
|
||||
downMove(id);
|
||||
break;
|
||||
case 2:
|
||||
leftMove(id);
|
||||
break;
|
||||
case 3:
|
||||
rightMove(id);
|
||||
break;
|
||||
}
|
||||
// var typeMove = Math.floor(Math.random()*4);
|
||||
// switch (typeMove){
|
||||
// case 0:
|
||||
// upMove(id);
|
||||
// break;
|
||||
// case 1:
|
||||
// downMove(id);
|
||||
// break;
|
||||
// case 2:
|
||||
// leftMove(id);
|
||||
// break;
|
||||
// case 3:
|
||||
// rightMove(id);
|
||||
// break;
|
||||
// }
|
||||
|
||||
}
|
||||
// 上
|
||||
function upMove(id){
|
||||
var odivu = document.getElementById(`${id}`);
|
||||
var upTimer = setInterval(()=>{
|
||||
if(odivu.offsetTop ==0){
|
||||
if(odivu.style.top <='1%' || odivu.style.top<30){
|
||||
// console.log('关闭了上走');
|
||||
clearInterval(upTimer);
|
||||
downMove(id);
|
||||
} else {
|
||||
odivu.style.top = odivu.offsetTop-speed+'px';
|
||||
// console.log('上走进来了');
|
||||
$(`#${id}`).animate({top:'0%'},20000);
|
||||
// odivu.style.top = odivu.offsetTop-speed+'px';
|
||||
}
|
||||
},10)
|
||||
},100)
|
||||
}
|
||||
// 下
|
||||
function downMove(id){
|
||||
var odivd = document.getElementById(`${id}`);
|
||||
downTimer = setInterval(()=>{
|
||||
if(odivd.offsetTop >500){
|
||||
if(odivd.style.top >='76%'){
|
||||
clearInterval(downTimer);
|
||||
upMove(id);
|
||||
} else {
|
||||
odivd.style.top = odivd.offsetTop+speed+'px';
|
||||
$(`#${id}`).animate({top:'80%'},10000);
|
||||
// odivd.style.top = odivd.offsetTop+speed+'px';
|
||||
}
|
||||
},10)
|
||||
}
|
||||
|
@ -154,14 +162,20 @@ function sayIng(index){
|
|||
closeSay(index);
|
||||
},6000)
|
||||
}
|
||||
// 一起喊
|
||||
function allSay(val){
|
||||
$(`.dance-people .speak`).removeClass("dn");
|
||||
$(`.dance-people .speak`).html(val);
|
||||
setTimeout(()=>{
|
||||
$(`.dance-people .speak`).addClass("dn");
|
||||
},allSayTimer)
|
||||
}
|
||||
// 退出广场
|
||||
function exitEv(id){
|
||||
$(`${id}`).remove();
|
||||
}
|
||||
// 进入广场
|
||||
function peopleObj(name,uid,say,action){
|
||||
// 开始说话
|
||||
sayIng(peopleId);
|
||||
let yspHtml = '';
|
||||
let yspData = [
|
||||
{
|
||||
|
@ -190,6 +204,8 @@ function peopleObj(name,uid,say,action){
|
|||
moveEv(uid);
|
||||
// 随机舞
|
||||
randomDancing(peopleId);
|
||||
// 开始说话
|
||||
sayIng(peopleId);
|
||||
peopleId++
|
||||
// 执行退出事件
|
||||
// exitEv(`#peopleId${peopleId-1}`)
|
||||
|
|
42
js/handle.js
42
js/handle.js
|
@ -4,10 +4,13 @@ var musicList = []
|
|||
|
||||
// 领舞人领舞时间 秒
|
||||
let leaderTime = 15*60
|
||||
|
||||
// 何时添加镜头
|
||||
var addJingTime = 2000;//2秒
|
||||
// 事件列表-中文
|
||||
let eventTextList = ['切歌', '跳', '向左', '向右', '左抖腿', '右抖腿', '抖动', '一起喊', '镜头']
|
||||
// 领舞者喊的集体舞
|
||||
let allEventList = ['切歌', '一起跳', '一起向左', '一起向右', '一起左抖腿', '一起右抖腿', '一起抖动', '一起喊', '镜头']
|
||||
// 镜头列表
|
||||
let list = ['scale-left', 'scale-right', 'scale-bottom-left', 'scale-bottom-right']
|
||||
// 根据事件文字 获取事件名
|
||||
function getEvent(name) {
|
||||
|
@ -108,8 +111,8 @@ function receiveMessage(event)
|
|||
if (data.ct === '') {
|
||||
return false
|
||||
}
|
||||
adminList = ['内有猛犬小心','热心市民阿狄呐','流域_墨绿绿'];
|
||||
// adminList = ['饺子吃肉肉'];
|
||||
// adminList = ['内有猛犬小心','热心市民阿狄呐','流域_墨绿绿'];
|
||||
adminList = ['饺子吃肉肉'];
|
||||
// 大航海列表
|
||||
if (adminList.length > 0) {
|
||||
// 获取当前领舞人
|
||||
|
@ -166,7 +169,6 @@ function receiveMessage(event)
|
|||
let dm = {text: data.danmaku, uid: data.uid, uname: data.uname,
|
||||
event: getEvent(getFirstEventKeyword(data.danmaku)),
|
||||
is_new: isNew, is_admin: 0, is_exit: random2, is_leader: isLeader}
|
||||
// console.log(dm,"")//
|
||||
// TODO 测试后 删除领舞随机
|
||||
// let leaderRandomEvent = getEvent(getFirstEventKeyword(data.danmaku+randomEvent))
|
||||
let leader = {
|
||||
|
@ -179,55 +181,63 @@ function receiveMessage(event)
|
|||
leader.text = dm.text
|
||||
leader.event = dm.event
|
||||
}
|
||||
|
||||
// console.log(leader, '当前领舞')
|
||||
// console.log(leaderRandomEvent, '领舞随机事件')
|
||||
// let actionIndex = Math.floor(Math.random()*actionArr.length);
|
||||
// let moveIndex = Math.floor(Math.random()*moveArr.length);
|
||||
// 新用户
|
||||
if(dm.is_new==1){
|
||||
if(dm.uname!=leader.uname){//如果弹幕的人的名字不等于领舞者的名字,就创建一个人物
|
||||
peopleObj(dm.uname,dm.uid,dm.text,dm.event);
|
||||
}
|
||||
} else {
|
||||
// 老用户
|
||||
$(`#${dm.uid} .speak`).html(dm.text);
|
||||
$(`#${dm.uid} .speak`).removeClass("dn");
|
||||
setTimeout(()=>{
|
||||
$(`#${dm.uid} .speak`).addClass("dn");
|
||||
},3000)
|
||||
// 舞者喊舞
|
||||
if(peopleHan(dm.text)){
|
||||
peopleAction(`${dm.uid}`,dm.event);
|
||||
}
|
||||
// if(dm.uid=='380050580'){
|
||||
// }
|
||||
}
|
||||
num++;
|
||||
|
||||
// 显示领舞的昵称
|
||||
$('.lingname').text(leader.uname);
|
||||
if(leader.event=='scale-left' || leader.event=='scale-right' || leader.event=='scale-bottom-left' || leader.event=='scale-bottom-right'){
|
||||
// 镜头
|
||||
// 领舞喊镜头
|
||||
list.forEach(item=>{
|
||||
var haveDan = $(`.ground-bg`).is(`.${item}`);
|
||||
// 如果之前有镜头,删除镜头
|
||||
if(haveDan) {
|
||||
$('.ground-bg').removeClass(item);
|
||||
}
|
||||
})
|
||||
// 各几秒重新添加镜头
|
||||
setTimeout(()=>{
|
||||
$('.ground-bg').addClass(leader.event);
|
||||
},2000)
|
||||
},addJingTime)
|
||||
} else {
|
||||
// 显示领舞说话
|
||||
if (leader.text.length>0) {
|
||||
$('.speak-pink').text(leader.text);
|
||||
$('.speak-pink').fadeIn();
|
||||
}
|
||||
setTimeout(()=>{//关闭领舞说话
|
||||
//关闭领舞说话
|
||||
setTimeout(()=>{
|
||||
$('.speak-pink').fadeOut();
|
||||
},3000)
|
||||
}
|
||||
// 领舞说切歌
|
||||
if(leader.text=="切歌"){
|
||||
changeMusic();
|
||||
}
|
||||
// 领舞喊一起喊
|
||||
if(leader.text=="一起喊"){
|
||||
allSay(dm.text);
|
||||
}
|
||||
// 领舞自己喊跳舞
|
||||
if(peopleHan(dm.text)){
|
||||
clearInterval(dancerTimer);
|
||||
dancerOwn(leader.event);
|
||||
}
|
||||
// 领舞喊集体跳舞
|
||||
if(dancer(leader.text)){
|
||||
allDancing(leader.event);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue