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