Commit 6784ddbf authored by Edwise's avatar Edwise 🍷

Merge remote-tracking branch 'refs/remotes/origin/jiaoneiqunuan' into jiaoneiqunuan

parents fa33a7d5 5040cb22
{
"exclude": [
"server/**"
]
}
......@@ -628,10 +628,10 @@ letter-spacing: 3rpx;
}
@keyframes aniscale{
from{
transform: scale(0);
transform: translateX(411rpx)
}
to{
transform: scale(1);
transform: translateX(0rpx)
}
}
.gamemain .gamembot .gameinfogro .gameminfo {
......
......@@ -69,8 +69,8 @@
<image class="gamemtask1" onTap="openTask" src={{resList['578cb214-b8d4-4d91-b57a-9477ec61933e'].url}} />
<image class="gamemtask2" src={{resList['d9ce0594-e262-4e9a-adfc-0b5b2a16d9c5'].url}} />
</view>
<scroll-view class="gameinfogro" scroll-y={{true}} scroll-animation-duration={{300}} scroll-with-animation={{true}} scroll-top={{(attionlist.length)*130}} disable-scroll={{false}} >
<view class="gameminfo{{index==(attionlist.length-1)?' aninfo':''}}" a:for="{{showattionlist}}" a:key="*this" style="top:{{index*130+'rpx;'}}">
<scroll-view class="gameinfogro" scroll-y={{true}} scroll-animation-duration={{300}} scroll-with-animation={{true}} scroll-top={{(showattionlist.length-1)*130}} disable-scroll={{false}} >
<view class="gameminfo{{index==(showattionlist.length-1)?' aninfo':''}}" a:for="{{showattionlist}}" a:key="*this" style="top:{{index*130+'rpx;'}}">
<image class="gameminfobg" src={{resList['f1611c59-e6ba-4e4d-8aeb-50d3c794e98b'].url}} />
<label class="gameminfotxt">{{item.txt}}</label>
</view>
......
......@@ -18,7 +18,7 @@ const {
} = tbcc.tb;
let updateact = 1;//请求
let gameatime = 100;//活动倒计时,100,
const toolwarm = 1;//升温道具+温度值
const toolwarm = 10;//升温道具+温度值
const taskwarm = 1;//任务+温度值
const invitewarm = 1;//邀请+温度值
let gtoolcd = 5;//
......@@ -37,6 +37,7 @@ Page({
gametime: 100,//活动倒计时,s
gametimeshow: "05:00",
roomdata: [],//房间所有人温度信息
roomtdata: [],//房间预期抵达温度
roomnums: 3,//房间人数
myidx: 1,//我的位置
tooltime: 5,//升温工具倒计时
......@@ -129,7 +130,7 @@ Page({
});
}
console.log("新手", isnew, query);
// console.log("新手", isnew, query);
let { end, gl, start, step, toolcd } = query;
step = Number(step);
// step = 3;
......@@ -181,56 +182,199 @@ Page({
if (this.data.isnew > 0 && this.data.isnew < 7) {
return;
}
console.log("游戏开始逻辑");
// console.log("游戏开始逻辑==canwin", this.data.canwin);
let attiontxt1 = "游戏开始啦,共有" + this.data.roomnums + "名玩家加入游戏,快来升温队伍拿奖励吧。";
this.addAttionTxt(attiontxt1);
this.updateAct();
this.newAiControl();
setTimeout(() => {
this.newAiControl("invite", 1);
}, 4000);
},
//新ai逻辑
newAiControl() {
//新ai逻辑,tool==使用道具,task==任务,invite==邀请人
async newAiControl(type = "tool", ainum = 1) {
let canwin = this.data.canwin;
let roomnums = this.data.roomnums - 1;
let roomdata = this.data.roomdata;
let myidx = this.data.myidx - 1;
let mywd = roomdata[myidx].wd;
let havechao = false;
//玩家使用道具,机器大概率使用道具,玩家任务,机器任务+邀请,玩家邀请,机器邀请,
//正序,反序随机来
let fromedir = Math.random();
if (fromedir < 0.5) {
for (let i = 0; i < roomdata.length; i++) {
havechao = this.newAiControl1(i, canwin, roomnums, roomdata, myidx, mywd, havechao, type, ainum);
}
} else {
for (let i = roomdata.length - 1; i > -1; i--) {
havechao = this.newAiControl1(i, canwin, roomnums, roomdata, myidx, mywd, havechao, type, ainum);
}
}
},
newAiControl1(i, canwin, roomnums, roomdata, myidx, mywd, havechao, type = "tool", ainum = 1) {
if (i == myidx) {
} else {
let idata = this.data.roomdata[i];
let iwd = idata.wd;
let doact = false;
if (canwin) {// 机器不用操作
doact = false;
} else {//机器使用道具
doact = true;
let cando = [];//可使用升温方式
let bido = [];//必使用升温方式
let chawd = iwd - mywd;
if (canwin) {// 玩家胜利,机器可操作,可不操作,操作的话,+能量少
if (chawd < 0) {
if (type == "tool") {
if (chawd + toolwarm < 0) {
cando.push(["tool", 1]);
}
let i = 0;
if (doact) {
let isfirst = this.data.isfirst;
if (isfirst) {
this.setData({
isfirst: false
});
let itxt = "玩家" + (i + 1) + "使用道具获得了" + toolwarm + "温度值";
}
if (type == "task") {
if (chawd + taskwarm < 0) {
let maxadd = Math.floor((-1 - chawd) / taskwarm);
if (maxadd > 0) {
if (maxadd > ainum) {
maxadd = ainum;
}
cando.push(["task", Math.round(Math.random() * maxadd)]);
}
}
if (chawd + invitewarm < 0) {
let maxadd = Math.floor((-1 - chawd) / invitewarm);
if (maxadd > 0) {
cando.push(["invite", Math.round(Math.random() * maxadd)]);
}
}
}
if (type == "invite") {
if (chawd + invitewarm < 0) {
let maxadd = Math.floor((-1 - chawd) / invitewarm);
if (maxadd > 0) {
cando.push(["invite", Math.round * (Math.random() * maxadd)]);
}
}
}
} else {//机器不操作
}
} else {//机器胜利
if (chawd < 1) {//机器必操作
let idoact = true;
if (havechao) {//已经有超过的了,可操作
let math1 = Math.random();
// console.log("已经有超过得了,可选使用", math1);
if (math1 < 0.8 && type != "tool") {
idoact = false;
}
} else {//必操作
}
// console.log(idoact, i, "443");
if (idoact) {
if (type == "tool") {
// if (chawd + toolwarm > 0) {
bido.push(["tool", 1]);
// }
}
if (type == "task") {
let chatask = (1 - chawd);
let chanum = Math.floor(chatask / taskwarm);
if (chanum > ainum) {
chanum = ainum;
}
let tonum = chanum * taskwarm + iwd;
if (tonum <= mywd) {
let randivite1 = Math.round(Math.random() * 1) + 1 + Math.ceil((mywd - tonum) / invitewarm);
if (randivite1 > 0) {
bido.push(["invite", randivite1]);
}
}
if (chanum > 0) {
bido.push(["task", chanum]);
}
}
if (type == "invite") {
let chainvite = (1 - chawd);
let chanum = Math.ceil(chainvite / invitewarm);
if (chanum > 0) {
bido.push(["invite", chanum]);
}
}
}
} else {//可不使用
havechao = true;
let randadd = Math.random();
if (randadd < 0.3) {
let randinvite = Math.round(Math.random() * 2);
if (randinvite > 0) {
cando.push(["invite", randinvite]);
}
}
}
}
//bido==必定做,cando,选择做一个
// console.error("区别2333============》",i,bido,cando);
let ifromwd = this.data.roomdata
for (let d1 = 0; d1 < bido.length; d1++) {
let d1data = bido[d1];
// console.log("bido=====》", i, d1data[0], d1data[1]);
this.addOneAiWarm(d1data, i);
}
let randcando = Math.floor(Math.random() * cando.length);
let randcandata = cando[randcando];
if (randcandata) {
// console.log("cando=====》", i, randcandata[0], randcandata[1]);
this.addOneAiWarm(randcandata, i);
}
let niwd = this.data.roomdata[i].wd;
let nmwd = this.data.roomdata[this.data.myidx - 1].wd;
if (niwd > nmwd) {
havechao = true;
}
}
return havechao;
},
addOneAiWarm(data, i) {
let type = data[0];
let nums = data[1];
if (type == "tool") {
let itxt = "玩家" + (i + 1) + "使用道具一次获得了" + toolwarm + "温度值";
this.addAttionTxt(itxt);
let inroomidx = i + 1;
let inroomidx = i;
let inwd = this.data.roomdata[inroomidx]["wd"];
inwd += toolwarm;
this.updateRolewd(i + 2, inwd);
} else {
//任务,或是邀请人
let randfrom = Math.random();
if (randfrom < 0.3) {//任务
let itxt = "玩家" + (i + 1) + "完成了一个任务,获得了" + taskwarm + "温度值";
this.updateRolewd(i + 1, inwd);
} else if (type == "task") {
let itxt = "玩家" + (i + 1) + "完成了" + nums + "个任务,获得了" + taskwarm * nums + "温度值";
this.addAttionTxt(itxt);
let inroomidx = i + 1;
let inroomidx = i;
let inwd = this.data.roomdata[inroomidx]["wd"];
inwd += taskwarm;
this.updateRolewd(i + 2, inwd);
} else {//邀请人
let itxt = "玩家" + (i + 1) + "邀请了一位好友,获得了" + invitewarm + "温度值";
inwd += taskwarm * nums;
this.updateRolewd(i + 1, inwd);
} else if (type == "invite") {
let itxt = "玩家" + (i + 1) + "邀请了" + nums + "位好友,获得了" + invitewarm * nums + "温度值";
this.addAttionTxt(itxt);
let inroomidx = i + 1;
let inroomidx = i;
let inwd = this.data.roomdata[inroomidx]["wd"];
inwd += invitewarm;
this.updateRolewd(i + 2, inwd);
}
inwd += invitewarm * nums;
this.updateRolewd(i + 1, inwd);
}
},
getToWarm(data, i, inwd) {
let type = data[0];
let nums = data[1];
if (type == "tool") {
inwd += toolwarm;
} else if (type == "task") {
inwd += taskwarm * nums;
} else if (type == "invite") {
inwd += invitewarm * nums;
}
return inwd;
},
aiUseOneTool() {
let roomnums = this.data.roomnums - 1;
......@@ -255,7 +399,7 @@ Page({
* 邀请人+1,
*/
let roomnums = this.data.roomnums - 1;
console.log("aicontrol==============>", roomnums);
// console.log("aicontrol==============>", roomnums);
for (let i = 0; i < roomnums; i++) {
let chatime = Math.ceil(Math.random() * 5) + 2;
let itime1 = Number((Math.random() * chatime).toFixed(2)) * 1000;
......@@ -263,7 +407,7 @@ Page({
//ai邀请
let inviterange = [0, 5];
let invitenums = Math.round(Math.random() * inviterange[1]) + inviterange[0];
console.log("邀请的温度值", invitenums);
// console.log("邀请的温度值", invitenums);
this.ainvite(invitenums, i);
//ai任务
let taskrange = [1, 5];
......@@ -274,7 +418,7 @@ Page({
//机器使用道具
aiuseTool(time, i, chatime) {
setTimeout(() => {
console.log("ai" + i + "使用道具升温度");
// console.log("ai" + i + "使用道具升温度");
let itxt = "玩家" + (i + 1) + "使用道具获得了" + toolwarm + "温度值";
this.addAttionTxt(itxt);
let inroomidx = i + 1;
......@@ -298,9 +442,9 @@ Page({
let i1start = i1 * chatime;
let i1end = (i1 + 1) * chatime - 5000;
let rangetime = Math.floor(Math.random() * (i1end - i1start)) + i1start;
console.log(rangetime);
// console.log(rangetime);
setTimeout(() => {
console.log("ai" + i + "邀请好友升温度");
// console.log("ai" + i + "邀请好友升温度");
let itxt = "玩家" + (i + 1) + "邀请了一位好友,获得了" + invitewarm + "温度值";
this.addAttionTxt(itxt);
let inroomidx = i + 1;
......@@ -329,7 +473,8 @@ Page({
}
},
onShow() {
if ((this.data.isnew > 0 && this.data.isnew < 7) || this.data.show_v != 2) {
let ngametime = this.data.gametime;
if ((this.data.isnew > 0 && this.data.isnew < 7) || this.data.show_v != 2 || ngametime <= 0) {
return;
}
this.updateActInfo();
......@@ -427,7 +572,7 @@ Page({
const { success, data } = overdata;
if (success) {
const { warms, isWin, prize, unLockStep } = data;
console.log("over", data)
// console.log("over", data)
if (isWin) {
if (prize && prize.image && prize.image.length > 0) {
this.setData({
......@@ -524,10 +669,13 @@ Page({
},
//升温
updateRolewd(ridx, rwd) {
let mv = paples[ridx - 1]
for (let i = 0; i < paples.length; i++) {
let mv = paples[i]
if (mv && rwd) {
mv.gotoAndPlay(1);
}
}
this.data.roomdata[ridx - 1]["wd"] = rwd;
let ndata = this.data.roomdata;
......@@ -597,17 +745,7 @@ Page({
if (total > nwd) {
this.updateRolewd(ridx, total);
}
// let addattion = [];
if (invite) {
let txt1 = this.solveAttionTxt(invite, this.data.linvite, "invite");
if (txt1.length > 0) {
this.addAttionTxt(txt1);
this.setData({
linvite: invite
});
}
}
//使用道具的单独来
if (tool) {
let txt2 = this.solveAttionTxt(tool, this.data.ltool, "tool");
if (txt2.length > 0) {
......@@ -615,44 +753,88 @@ Page({
this.setData({
ltool: tool
});
this.newAiControl("tool");
}
}
let taskcount = 0;
let taskwarm = 0;
//任务的统一计算
if (follow) {
let txt3 = this.solveAttionTxt(follow, this.data.lfollow, "follow");
if (txt3.length > 0) {
this.addAttionTxt(txt3);
// let txt3 = this.solveAttionTxt(follow, this.data.lfollow, "follow");
// if (txt3.length > 0) {
// this.addAttionTxt(txt3);
// }
let followdata = this.solveAttionTxt(follow, this.data.lfollow, "follow");
if (followdata.length > 0) {
taskcount += followdata[0];
taskwarm += followdata[1];
this.setData({
lfollow: follow
});
}
}
if (sign) {
let txt4 = this.solveAttionTxt(sign, this.data.lsign, "sign");
if (txt4.length > 0) {
this.addAttionTxt(txt4);
// let txt4 = this.solveAttionTxt(sign, this.data.lsign, "sign");
// if (txt4.length > 0) {
// this.addAttionTxt(txt4);
// }
let signdata = this.solveAttionTxt(sign, this.data.lsign, "sign");
if (signdata.length > 0) {
taskcount += signdata[0];
taskwarm += signdata[1];
this.setData({
lsign: sign
});
}
}
if (collect) {
let txt5 = this.solveAttionTxt(collect, this.data.lcollect, "collect");
if (txt5.length > 0) {
this.addAttionTxt(txt5);
// let txt5 = this.solveAttionTxt(collect, this.data.lcollect, "collect");
// if (txt5.length > 0) {
// this.addAttionTxt(txt5);
// }
let collectdata = this.solveAttionTxt(collect, this.data.lcollect, "collect");
if (collectdata.length > 0) {
taskcount += collectdata[0];
taskwarm += collectdata[1];
this.setData({
lcollect: collect
});
}
}
if (browseGoods) {
let txt6 = this.solveAttionTxt(browseGoods, this.data.lbrowseGoods, "browseGoods");
if (txt6.length > 0) {
this.addAttionTxt(txt6);
// let txt6 = this.solveAttionTxt(browseGoods, this.data.lbrowseGoods, "browseGoods");
// if (txt6.length > 0) {
// this.addAttionTxt(txt6);
// }
let browsdata = this.solveAttionTxt(browseGoods, this.data.lbrowseGoods, "browseGoods");
if (browsdata.length > 0) {
taskcount += browsdata[0];
taskwarm += browsdata[1];
this.setData({
lbrowseGoods: browseGoods
});
}
}
if (taskcount > 0 && taskwarm > 0) {
this.newAiControl("task", taskcount);
let tasktxt = "完成了" + taskcount + "个任务,获得了" + taskwarm + "温度值";
this.addAttionTxt(tasktxt);
}
//邀请的单独来
// let addattion = [];
if (invite) {
let txt1 = this.solveAttionTxt(invite, this.data.linvite, "invite");
if (txt1.length > 0) {
this.addAttionTxt(txt1);
this.setData({
linvite: invite
});
this.newAiControl("invite");
}
}
}
},
......@@ -679,13 +861,17 @@ Page({
} else if (type == "tool") {
iattiontxt = "使用道具" + chacount + "次" + "获得了" + chawarm + "温度值";
} else if (type == "follow") {
iattiontxt = "完成任务follow" + chacount + "次" + "获得了" + chawarm + "温度值";
return [chacount, chawarm];
// iattiontxt = "完成任务follow" + chacount + "次" + "获得了" + chawarm + "温度值";
} else if (type == "sign") {
iattiontxt = "完成任务sign" + chacount + "次" + "获得了" + chawarm + "温度值";
return [chacount, chawarm];
// iattiontxt = "完成任务sign" + chacount + "次" + "获得了" + chawarm + "温度值";
} else if (type == "collect") {
iattiontxt = "完成任务collect" + chacount + "次" + "获得了" + chawarm + "温度值";
return [chacount, chawarm];
// iattiontxt = "完成任务collect" + chacount + "次" + "获得了" + chawarm + "温度值";
} else if (type == "browseGoods") {
iattiontxt = "完成任务browseGoods" + chacount + "次" + "获得了" + chawarm + "温度值";
return [chacount, chawarm];
// iattiontxt = "完成任务browseGoods" + chacount + "次" + "获得了" + chawarm + "温度值";
}
if (iattiontxt.length > 0) {
return iattiontxt;
......@@ -840,12 +1026,10 @@ Page({
})
},
canvasOnReady() {
console.log("onCanvas Ready")
this.createMain();
},
/**添加canvas,用来显示svga */
async createMain() {
console.log(123)
var canvas = await new Promise((r) => {
my.createCanvas({
id: 'canvas',
......@@ -859,7 +1043,6 @@ Page({
}
})
})
console.log(111)
FYGE.initedByCanvas(canvas)
var sysInfo = my.getSystemInfoSync()
//建舞台
......@@ -878,11 +1061,11 @@ Page({
SvgaParser.loadSvga(
paple1,
(v) => {
console.log("svga" + v);
var mv = stage.addChild(new FYGE.MovieClip(v));
mv.x = 383;
// mv.y = 390;
mv.y = 465;
console.log("svgmv", mv)
// console.log("svgmv", mv)
paples[0] = mv;
mv.gotoAndStop(1);
mv.addEventListener(FYGE.Event.END_FRAME, () => {
......@@ -896,11 +1079,11 @@ Page({
SvgaParser.loadSvga(
paple2,
(v) => {
console.log("svga" + v);
var mv = stage.addChild(new FYGE.MovieClip(v));
mv.x = 83;
// mv.y = 420;
mv.y = 495;
console.log("svgmv", mv);
// console.log("svgmv", mv);
paples[1] = mv;
mv.gotoAndStop(1);
mv.addEventListener(FYGE.Event.END_FRAME, () => {
......@@ -916,11 +1099,11 @@ Page({
SvgaParser.loadSvga(
paple3,
(v) => {
console.log("svga" + v);
var mv = stage.addChild(new FYGE.MovieClip(v));
mv.x = 232;
// mv.y = 510;
mv.y = 585;
console.log("svgmv", mv)
// console.log("svgmv", mv)
paples[2] = mv;
mv.gotoAndStop(1);
mv.addEventListener(FYGE.Event.END_FRAME, () => {
......@@ -936,11 +1119,10 @@ Page({
SvgaParser.loadSvga(
paple4,
(v) => {
console.log("svga" + v);
var mv = stage.addChild(new FYGE.MovieClip(v));
mv.x = 420;
// mv.y = 560;
mv.y = 635;
console.log("svgmv", mv)
paples[3] = mv;
mv.gotoAndStop(1);
mv.addEventListener(FYGE.Event.END_FRAME, () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment