除GameData外,其他都已归类,GameData明日整理

This commit is contained in:
YZ\249929363 2024-06-13 19:25:42 +08:00
parent b991f12595
commit 5baf397627
189 changed files with 14020 additions and 12219 deletions

View File

@ -129,17 +129,17 @@
"_id": "78JbrAn9RBIr8Ujxy6eo6w"
},
{
"__type__": "f2f0bI5PsVI+o18xF6G+KVa",
"__type__": "179c44L0X9IhZh7hydovv0d",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"_id": "89UAK+FSRBh4q9PzKutGtE"
"_id": "5ekG2HL35EGppN64AQNDFD"
},
{
"__type__": "971c4vub4BJpqrSCLPJ8g1V",
"__type__": "58403/n16JCa5sZhNMjZzGo",
"_name": "",
"_objFlags": 0,
"node": {
@ -156,10 +156,7 @@
"audioWin": {
"__uuid__": "e70b3103-83f1-4c66-9093-1897c1a5d4ae"
},
"reward": false,
"finish": false,
"rewardCount": 0,
"_id": "dbb1mOJilJI5DAHXWGh8XU"
"_id": "08dy+OlqhPnqHAzPuL21rx"
},
{
"__type__": "cc.Node",
@ -350,14 +347,14 @@
"_id": "81GN3uXINKVLeW4+iKSlim"
},
{
"__type__": "3ffacOneORCf6Bc1LFhTCCQ",
"__type__": "5c9b8FZiaNLMrMDs9T3rByf",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 6
},
"_enabled": true,
"_id": "04sqPSc/FA3bLFQccgHxs/"
"_id": "82rBHh8bJIGKuGw03a3Yrd"
},
{
"__type__": "cc.Node",

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"ver": "1.1.0",
"uuid": "3ffac3a7-78e4-427f-a05c-d4b1614c2090",
"uuid": "5c9b8159-89a3-4b32-b303-b3d4f7ac1c9f",
"importer": "javascript",
"isPlugin": false,
"loadPluginInWeb": true,

View File

@ -1,8 +1,12 @@
// 主游戏控制类
const {ccclass, property} = cc._decorator;
import GameData from './GameData';
import { Notification } from './Notification';
import HttpUtil from './crypto/serverAPI';
import GameData from './module/Config/GameData';
import HttpUtil from './module/Crypto/HttpUtil';
import AudioManager from './module/Music/AudioManager';
import { Notifications } from './module/Notification/Notification';
import { GameTool } from './module/Tool/GameTool';
@ccclass
export default class GameManager extends cc.Component {
@property(cc.Node)
@ -235,11 +239,11 @@ export default class GameManager extends cc.Component {
clickSun(data){
if(this.begin == true){
this.clickCount += 1;
let clickTime = this.getTime();
let clickTime = GameTool.getTime();
this.time_Array.push((clickTime - this.timeStart))
this.timeStart = this.getTime();
this.timeStart = GameTool.getTime();
if(data == this.clickNow){
GameData._instance.AudioManager.playAudioButton();
AudioManager._instance.playAudioButton();
if(this.clickNow > 0){
this.createLine(cc.v2(this.ball_Array[this.clickNow-1].x,this.ball_Array[this.clickNow-1].y),
cc.v2(this.ball_Array[this.clickNow].x,this.ball_Array[this.clickNow].y),
@ -251,7 +255,7 @@ export default class GameManager extends cc.Component {
if(this.clickNow == this.now_Array.length){
this.pause = true;
GameData._instance.GM_INFO.total += this.clickNow;
this.overTime = this.getTime();
this.overTime = GameTool.getTime();
if(this.startTime > 0 && this.overTime > 0){
GameData._instance.GM_INFO.mean_Time += (this.overTime - this.startTime);
}
@ -262,7 +266,7 @@ export default class GameManager extends cc.Component {
else if(this.level >= 4) color = "yrb";
let win = this.node.getChildByName("Win");
win.active = true; win.setScale(0);
GameData._instance.AudioManager.playWin();
AudioManager._instance.playWin();
this.round += 1;
let sunArray = [];
if(this.moveArray.length > 0){
@ -333,9 +337,9 @@ export default class GameManager extends cc.Component {
}
//执行失败
setLoss(){
GameData._instance.AudioManager.playWarning();
AudioManager._instance.playWarning();
this.begin = false;
this.overTime = this.getTime();
this.overTime = GameTool.getTime();
if(this.startTime > 0 && this.overTime > 0){
GameData._instance.GM_INFO.mean_Time += (this.overTime - this.startTime);
}
@ -621,25 +625,11 @@ export default class GameManager extends cc.Component {
//每次重新开始新一轮儿游戏
beginGame(){
this.begin = true;
this.startTime = this.getTime();
this.timeStart = this.getTime();
this.startTime = GameTool.getTime();
this.timeStart = GameTool.getTime();
this.pause = false;
// this.node.getChildByName("showBtn").active = true;
}
//暂时作废
// getRandomArray(lastNumber){
// let num = parseInt(Math.random()*8 - 4 + "");
// let jg = num + lastNumber;
// if(num > 1 || num <-1){
// if( num == 0 || ( jg<0 || jg >= this.Pos_Array.length)){
// jg = this.getRandomArray(lastNumber);
// }
// }
// else{
// jg = this.getRandomArray(lastNumber);
// }
// return jg;
// }
//创建太阳所需数据
createSun(){
@ -869,26 +859,11 @@ export default class GameManager extends cc.Component {
if(this.over == false) this.startGame();
}, time1*1500);
}
//时间格式转换
getTimeMargin(second:number) {
let total = 0;
total = second;
let hour = 0;
hour = parseInt((total / 3600) + "");//计算整数小时数
let afterHour = total - hour * 60 * 60;//取得算出小时数后剩余的秒数
let min = parseInt((afterHour / 60)+"");//计算整数分
let m = "" + min;
if(min < 10) m = "0"+min;
let afterMin = total - hour * 60 * 60 - min * 60;//取得算出分后剩余的秒数
let miao = afterMin + "";
if(afterMin < 10) miao = "0" + afterMin;
return m + ':' + miao
}
//如果是倒计时 调用此方法
updateCountDownTime () {
if (this.countTime > 0 && this.pause == false) {
this.countTime -= 1;
this.time.string = this.getTimeMargin(this.countTime);
this.time.string = GameTool.getTimeMargin(this.countTime);
if(this.countTime < 5){
cc.tween(this.time.node)
.to(0.25,{scale:1.5,color:cc.color(255,0,0)})
@ -911,81 +886,17 @@ export default class GameManager extends cc.Component {
GameData._instance.GM_INFO.mean_Time = parseInt(time/100 + "");
GameData._instance.GM_INFO.mean_Time = GameData._instance.GM_INFO.mean_Time /10;
if(time > 10000) time = (Math.random()*10+5)*100;
this.setRank(time);
this.gameOver(time);
}
}
}
//上传每次操作数据
setData(){
GameData._instance.GAME_DATA = [];
GameData._instance.GAME_DATA.push(GameData._instance.CLICK_DATA);
GameData._instance.CLICK_init();
let data = GameData._instance.GAME_DATA;
let matchId = this.getMatchId();
console.log(matchId);
let postData = {
"matchId":matchId,
"data": data
};
console.log("上传数据:")
HttpUtil.uploadUserLogData(postData,function(){})
}
//获取matchId 用于上传每次点击数据里面记录id方便查询
getMatchId (){
let matchId = cc.sys.localStorage.getItem("matchId");
if(matchId == "undifend" || matchId==null){
matchId = this.setMatchId();
}
else{
if(this.containsNanana(matchId) == true){
matchId = this.setMatchId();
}
else{
let char = parseInt(matchId[10]);
if(this.round == 1){
char += 1;
}
matchId = matchId.slice(0, 10) + char + "";
GameData._instance.GM_INFO.matchId = matchId;
cc.sys.localStorage.setItem("matchId",matchId);
}
}
return matchId;
}
//检测matchId 如果有缓存以前的nanana数据清除
containsNanana(str) {
return /na/i.test(str);
}
//重新设置MatchId
setMatchId (){
// 定义包含可用字符的字符集
const characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
// 创建一个数组以保存随机字符
const uuidArray = [];
// 循环10次 生成10位的UUID
for (let i = 0; i < 10; i++) {
// 生成随机索引,范围是字符集的长度
const randomIndex = Math.floor(Math.random() * characters.length);
// 从字符集中获取随机字符
const randomChar = characters.charAt(randomIndex);
// 将字符添加到数组中
uuidArray.push(randomChar);
}
let data = uuidArray.join('') + 1 + "";
cc.sys.localStorage.setItem("matchNumber",1);
cc.sys.localStorage.setItem("matchId",data);
GameData._instance.GM_INFO.matchId = data;
return data;
GameTool.setGameData();
}
//上传排行榜数据
setRank(time){
let postData = {
"type":1,
"reactionTime": time,
"totalSunCount": GameData._instance.GM_INFO.total,
"success": GameData._instance.GM_INFO.success
};
HttpUtil.rankData(1,function(){},postData);
gameOver(time){
GameTool.setRank(time);
this.node.getChildByName("GameOver").active = true;
this.node.getChildByName("GameOver").opacity = 0;
cc.tween(this.node.getChildByName("GameOver"))
@ -1006,10 +917,10 @@ export default class GameManager extends cc.Component {
}
}
onEnable () {
Notification.on("clickSun", this.clickSun, this);
Notifications.on("clickSun", this.clickSun, this);
}
onDisable () {
Notification.off("clickSun", this.clickSun);
Notifications.off("clickSun", this.clickSun);
}
update (dt) {
}

View File

@ -1,15 +1,6 @@
// Learn TypeScript:
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
import GameData from "./GameData";
import List from "./ListView/List";
import HttpUtil from "./crypto/serverAPI";
import Rq from "./crypto/serverAPI";
import GameData from "./module/Config/GameData";
import { GameTool } from "./module/Tool/GameTool";
const {ccclass, property} = cc._decorator;
@ccclass
@ -62,35 +53,15 @@ export default class NewClass extends cc.Component {
}
//获取排行榜
getRank(){
let postData = {
"page":1,
"pageSize":100
};
HttpUtil.rankData(2,this.getRankData.bind(this),postData);
GameTool.getRank(5,data =>this.getRankData(data));
}
//设置排行信息
getRankData(data){
if(data){
this.listData = data.data.list;
this.selfData = data.data.info;
let rankData = [];
let self = false;
if(this.selfData.nickName.length > 4){
this.selfData.nickName= this.selfData.nickName.substring(0,4) + "..."
}
this.selfNode.getChildByName("name").getComponent(cc.Label).string = this.selfData.nickName;
this.selfNode.getChildByName("total").getComponent(cc.Label).string = this.selfData.totalSunCount;
this.setPic(this.selfNode.getChildByName("pic").getChildByName("icon"),this.selfData.pic);
for(let i=0;i<=this.listData.length-1;i++){
rankData.push({rank:(i+1), name:this.listData[i].nickName, total:this.listData[i].totalSunCount, pic:this.listData[i].pic});
if(GameData._instance.GM_INFO.userId == this.listData[i].userId){
self = true;
this.selfNode.getChildByName("rank").getComponent(cc.Label).string =(i+1) + "";
}
if(i == (this.listData.length-1) && self == false){
this.selfNode.getChildByName("rank").getComponent(cc.Label).string = "99+";
}
if(i<5) this.setRank(i,this.listData[i]);
GameTool.getRankData(data,this,4);
GameTool.setPic(this.selfNode.getChildByName("pic").getChildByName("icon"),this.selfData.pic);
for(let i=0;i<=4;i++){
this.setRank(i,this.listData[i]);
}
}
}
@ -114,42 +85,10 @@ export default class NewClass extends cc.Component {
}
if(hitNode){
hitNode.active = true;
if(data.nickName.length > 4){
data.nickName= data.nickName.substring(0,4) + "..."
}
GameTool.subName(data.nickName,4);
hitNode.getChildByName("name").getComponent(cc.Label).string = data.nickName;
hitNode.getChildByName("total").getComponent(cc.Label).string = data.totalSunCount;
this.setPic(hitNode.getChildByName("pic").getChildByName("icon"),data.pic);
GameTool.setPic(hitNode.getChildByName("pic").getChildByName("icon"),data.pic);
}
}
//设置头像
public setPic(node,pic){
node.active = false;
let url = pic;
setTimeout(() => {
fetch(url)
.then(response => {
return response.headers.get('Content-Length');
})
.then(errNo => {
if(errNo == "5093"){
node.active = true;
}
})
.catch(error => {
console.error('Error fetching X-Info:', error);
});
}, 100);
cc.assetManager.loadRemote(url, {ext:'.jpg'},(err, texture:cc.Texture2D) => {
if(texture){
node.active = true;
node.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture);
}
else{
console.log(err,texture)
}
})
}
}

View File

@ -1,6 +1,9 @@
//此页面为引导页面,后续更新成模板,暂时偷懒复制主游戏场景代码进来
import GameData from './GameData';
import { Notification } from './Notification';
import GameData from './module/Config/GameData';
import AudioManager from './module/Music/AudioManager';
import { Notifications } from './module/Notification/Notification';
const {ccclass, property} = cc._decorator;
@ccclass
export default class NewClass extends cc.Component {
@ -204,7 +207,7 @@ export default class NewClass extends cc.Component {
clickSun(data){
if(this.begin == true){
if(data == this.clickNow){
GameData._instance.AudioManager.playAudioButton();
AudioManager._instance.playAudioButton();
if(this.clickNow > 0){
this.createLine(cc.v2(this.ball_Array[this.clickNow-1].x,this.ball_Array[this.clickNow-1].y),
cc.v2(this.ball_Array[this.clickNow].x,this.ball_Array[this.clickNow].y),
@ -228,7 +231,7 @@ export default class NewClass extends cc.Component {
//失败事件
loseLevel(){
this.begin = false;
GameData._instance.AudioManager.playWarning();
AudioManager._instance.playWarning();
this.destroyLine();
let ball = this.ball_Array[0];
for(let k=1; k< this.ball_Array.length; k++){
@ -266,11 +269,7 @@ export default class NewClass extends cc.Component {
}
this.ball_Array = [];
}
//获取时间戳
getTime(){
const timestamp = new Date().getTime();
return timestamp;
}
//创造连线,参数起点,终点,连线时间
createLine(start,end,time){
let line = cc.instantiate(this.linePrefab);
@ -303,10 +302,10 @@ export default class NewClass extends cc.Component {
return -angle;
}
onEnable () {
Notification.on("clickSun", this.clickSun, this);
Notifications.on("clickSun", this.clickSun, this);
}
onDisable () {
Notification.off("clickSun", this.clickSun);
Notifications.off("clickSun", this.clickSun);
}
}

View File

@ -1,67 +1,16 @@
const {ccclass, property, requireComponent} = cc._decorator;
import GameData from "./GameData";
import { StorageMessage } from "./Storage";
import GameData from "./module/Config/GameData";
import { GameTool } from "./module/Tool/GameTool";
@ccclass
export default class NewClass extends cc.Component {
start () {
this.Authentication();
GameTool.Authentication();
}
//鉴权判断有无缓存userid,有的话判断是否过期没有的话重新获取userid 并且缓存上
private Authentication(){
let name = "user_" + GameData._instance.GM_INFO.gameId;
let data = StorageMessage.getStorage(name);
if(data == "undifend" || data==null || data == ""){
console.log("没缓存");
this.setUserId(name);
}
else{
console.log("有缓存");
let timestamp = parseInt(new Date().getTime()/1000 + "");
if((timestamp - data.time) > 86400){
console.log("缓存过期");
this.setUserId(name);
return;
}
GameData._instance.GM_INFO.userId = parseInt(data.userId);
}
}
//设置userId,链接有获取,没有跳转授权
private setUserId(name){
GameData._instance.GM_INFO.userId = this.getUserId();
if(GameData._instance.GM_INFO.userId == null){
console.log("链接没ID准备跳转");
let url = "http://api.sparkus.cn/api/user/auth/login?domain=hui32579WdYPsgYq&callback="+location.href;
window.location.href = url;
}
else{
let timestamp = parseInt(new Date().getTime()/1000 + "");
let idData = {
userId: GameData._instance.GM_INFO.userId + "",
time: timestamp
}
StorageMessage.setStorage(name,idData);
console.log("有ID",GameData._instance.GM_INFO.userId);
GameData._instance.GM_INFO.userId = parseInt(GameData._instance.GM_INFO.userId);
}
}
//获取user id 有参数为获取gameid userid 时间戳, 无参数为只获取链接尾缀上的userId
private getUserId() {
let pathStr = window.location.search;
let arr=pathStr.split("&");
if (pathStr.length>= 0&&arr.length>0) {
let arr2=[];
arr.map(item=>{
arr2.push(item.split("=")[1])
})
return arr2[0];
} else {
return null
}
}
//开始游戏,跳转至引导页面
startGame(){
cc.director.loadScene("GuideScene");

View File

@ -1,6 +1,8 @@
import GameData from "./GameData";
import List from "./ListView/List";
import HttpUtil from "./crypto/serverAPI";
import GameData from "./module/Config/GameData";
import List from "./module/RankList/List";
import { GameTool } from "./module/Tool/GameTool";
const { ccclass, property } = cc._decorator;
//排行榜
@ccclass
@ -38,55 +40,14 @@ export default class RankManager extends cc.Component {
}
//调用获取排行榜接口
getRank(){
let postData = {
"page":1,
"pageSize":100
};
//回调进getRankData
HttpUtil.rankData(2,this.getRankData.bind(this),postData);
GameTool.getRank(100,data =>this.getRankData(data));
}
//实际设置排行数据
getRankData(data){
if(data){
console.log(data);
this.listData = data.data.list;
this.selfData = data.data.info;
let rankData = [];
let self = false;
for(let i=0;i<=this.listData.length-1;i++){
rankData.push({rank:(i+1), name:this.listData[i].nickName, total:this.listData[i].totalSunCount, pic:this.listData[i].pic});
if(GameData._instance.GM_INFO.userId == this.listData[i].userId){
self = true;
this.rankNumber = i;
this.selfNode.getChildByName("rankLab").getComponent(cc.Label).string =(i+1) + "";
}
if(i == (this.listData.length-1) && self == false){
this.rankNumber = i;
this.selfNode.getChildByName("rankLab").getComponent(cc.Label).string = "99+";
}
}
this.rankList.setData(rankData);
if(this.selfData.nickName.length > 6){
this.selfData.nickName= this.selfData.nickName.substring(0,6) + "..."
}
this.selfNode.getChildByName("nameLab").getComponent(cc.Label).string = this.selfData.nickName;
this.selfNode.getChildByName("totalLab").getComponent(cc.Label).string = this.selfData.totalSunCount;
// console.log(data);
GameTool.getRankData(data,this,6);
this.setPic(this.selfData.pic);
if(this.selfNode.getChildByName("rankLab").getComponent(cc.Label).string == "1"){
this.selfNode.getChildByName("rank").getChildByName("one").active = true;
}
else if(this.selfNode.getChildByName("rankLab").getComponent(cc.Label).string == "2"){
this.selfNode.getChildByName("rank").getChildByName("two").active = true;
}
else if(this.selfNode.getChildByName("rankLab").getComponent(cc.Label).string == "3"){
this.selfNode.getChildByName("rank").getChildByName("three").active = true;
}
else{
// this.selfNode.getChildByName("four").active = true;
}
this.selfNode.opacity = 255;
if(this.selfData.totalSunCount == 0) this.selfNode.opacity = 0;
}
}
//返回按钮
@ -124,7 +85,7 @@ export default class RankManager extends cc.Component {
}, time*2000);
}
//设置头像
//设置头像 处理的逻辑比较多,不用公共类的了
public setPic(pic){
this.phone.node.parent.getChildByName("icon").active = false;
this.phone.node.active = false;

View File

@ -1,13 +1,6 @@
// Learn TypeScript:
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
const {ccclass, property} = cc._decorator;
import GameManager from './GameManager';
import { Notification } from './Notification';
import { Notifications } from './module/Notification/Notification';
@ccclass
export default class NewClass extends cc.Component {
@ -60,13 +53,13 @@ export default class NewClass extends cc.Component {
.start();
this.touch = false;
this.node.zIndex = -1;
Notification.emit("clickSun",this.id_Number);
Notifications.emit("clickSun",this.id_Number);
}
}
else{
this.touch = false;
this.node.zIndex = -1;
Notification.emit("clickSun",this.id_Number);
Notifications.emit("clickSun",this.id_Number);
}
}
@ -75,7 +68,7 @@ export default class NewClass extends cc.Component {
if( this.touch == true && this.node.parent.parent.getComponent("GuideManager").begin == true){
this.touch = false;
this.node.zIndex = -1;
Notification.emit("clickSun",this.id_Number);
Notifications.emit("clickSun",this.id_Number);
}
}
}

View File

@ -1,6 +1,6 @@
{
"ver": "1.1.3",
"uuid": "e8009432-4774-4831-a537-511de4498eee",
"uuid": "eaa8b84d-69d0-4170-9f7d-8179ea948cde",
"importer": "folder",
"isBundle": false,
"bundleName": "",

View File

@ -0,0 +1,13 @@
{
"ver": "1.1.3",
"uuid": "8848cd9b-8115-456d-a656-2abcda1dadbe",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

View File

@ -46,7 +46,7 @@ export default class GameData extends cc.Component {
total:0, //总共对的个数
currSeed: 203213, //用于随机数种子
gameId:'100009',
userId:200139,
userId:0,
guide:true, //是否有引导
url:"http://api.sparkus.cn",
success:false,

View File

@ -1,6 +1,6 @@
{
"ver": "1.1.0",
"uuid": "f2f0b239-3ec5-48fa-8d7c-c45e86f8a55a",
"uuid": "179c4e0b-d17f-4885-987b-872768befd1d",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,

View File

@ -0,0 +1,13 @@
{
"ver": "1.1.3",
"uuid": "13a0b173-d59e-4a9d-b5e3-4dbe4dc37cc1",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

View File

@ -1,34 +1,24 @@
// import CryptoJS from "crypto-js";
import GameData from '../GameData';
const {ccclass, property} = cc._decorator;
import CryptoJS = require('./crypto-js.min.js'); //引用AES源码js
// import axios from 'axios'
const {ccclass, property} = cc._decorator;
const BASE_URL = "http://api.sparkus.cn";
//只负责网络接口 次类只负责和后端交互,不负责处理数据 数据处理在GameTool
@ccclass
export default class HttpUtil extends cc.Component {
//排行榜type2为获取type1为上传
//排行榜
static async rankData(type,callback,data): Promise<any> {
data.gameId = GameData._instance.GM_INFO.gameId;
data.userId = GameData._instance.GM_INFO.userId;
const time = Math.floor((new Date().getTime()) / 1000)
const url = apiSign(`/api/get/rank/data?gameId=${config.gameId}&dataType=${type}&time=${time}`, data)
this.post(url,data,callback);
}
static async uploadUserLogData(data,callback): Promise<any> {
data.gameId = GameData._instance.GM_INFO.gameId;
data.userId = GameData._instance.GM_INFO.userId;
const url = '/log/collect/data';
this.get(url,callback);
this.post(url,data,callback);
}
//暂时用不到
static async getUserRecord(data,callback): Promise<any> {
data.gameId = GameData._instance.GM_INFO.gameId;
data.userId = GameData._instance.GM_INFO.userId;
const time = Math.floor((new Date().getTime()) / 1000)
const url = apiSign(`/api/get/user/data?gameId=${config.gameId}&time=${time}`, data)
this.post(url,data,callback);
@ -85,7 +75,6 @@ interface CrypotoType {
class Crypoto implements CrypotoType {
// 加密的向明值,自己根据项目实际情况定,需要跟后端开发保持一致
private keyHex = this.getHetKey()
private getHetKey() {
return CryptoJS.enc.Utf8.parse(config.EK);
}

View File

@ -1,7 +1,7 @@
{
"ver": "1.1.0",
"uuid": "971c4bee-6f80-49a6-aad2-08b3c9f20d55",
"importer": "javascript",
"uuid": "771a3d9a-4013-4654-a777-fbaea0c93280",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,

View File

@ -0,0 +1,13 @@
{
"ver": "1.1.3",
"uuid": "b4e113c6-a987-4133-bfa0-3355d8ab4bd1",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

View File

@ -0,0 +1,192 @@
window.initMgr = function() {
if(cc.fx)
{
return;
}
cc.fx = {};
console.log("初始化");
//基础状态信息
cc.fx.StateInfo = {
debugMode: true,
networkConnected: true, //网络状态
networkType: 'none', //网络类型
isOnForeground: true //当前是否是在前台
};
cc.fx.ShareInfo = {
queryId : -1 //分享id
};
/*
*
*/
cc.fx.BurialShareType = {
Default : "default", //默认分享类型,分享到群
Invite : "invite", // 邀请好友
DailyInviteRoomJoin:'invite_join_room', //邀请好友加入
DailyInviteFriend : 'invite_friend', // 日常邀请好友
DailyInviteGroup : 'invate_group', // 日常分享群
DailyInviteGroupAlive: 'invate_alive', //日常分享群复活
DailyInviteGroupReward: 'invate_rewared',//分享奖励翻倍
DailyInviteGroupBox: 'invate_box', //宝箱分享奖励
DailyInviteGroupBall: 'invate_ball', //分享领取球球
MatchResult : 'matchResult', // 比赛结算分享
MatchFix5: 'MatchFix5', // 5元红包赛
MatchFix20: 'MatchFix20', // 20元红包赛
MatchFix100: 'MatchFix100', // 100元红包赛
MatchFix500: 'MatchFix500', // 500元红包赛
NewerRedEnvelope: 'newerRedEnvelope', // 新手红包
CoinRoomResult: 'coinRoomResult', // 金币桌结算
HighRate : "highRate",//高倍分享
CoinRoomWinStreak: 'coinRoomWinStreak', // 连胜
CoinRoomBankruptcy1: 'coinRoomBankruptcy1', // 金币桌破产
CoinRoomBankruptcy2: 'coinRoomBankruptcy2', // 金币桌破产
CoinRoomBankruptcy3: 'coinRoomBankruptcy3', // 金币桌破产
};
cc.fx.BurialShareConfig = {
invite:{
oneGroupDayCount:1//同一个群一天最多分享次数:超过次数将不再向服务器获取奖励,并且提醒用户分享到不同的群
},
FetchGroupID:{
oneGroupDayCount:1//同一个群一天最多分享次数:超过次数将不再向服务器获取奖励,并且提醒用户分享到不同的群
},
SegmentUp:{
painting :true, //升星分享指定为截屏分享模式
},
RankNotify:{ //排行榜分享
painting :true,
},
FTResult:{ //朋友桌结算分享
painting :true,
},
highRate:{ //高倍分享
painting :true,
},
matchResult:{ // 比赛结算分享
painting :true,
},
MatchFix5: { // 比赛结算分享
painting :true,
},
MatchFix20: { // 比赛结算分享
painting :true,
},
MatchFix100: { // 比赛结算分享
painting :true,
},
MatchFix500: { // 比赛结算分享
painting :true,
},
coinRoomWinStreak: {
painting :true,
},
};
/*
* group frined all
*/
cc.fx.ShareWhereReward = {
Group :"group", //微信群
Friend : "friend",//好友
All : "all", //不区分
};
/**
* ,,
*/
cc.fx.OUTPUT_LOG = 1;
cc.fx.OUTPUT_INFO = 1 << 1;
cc.fx.OUTPUT_WARN = 1 << 2;
cc.fx.OUTPUT_ERR = 1 << 3;
cc.fx.OUTPUT_LV = cc.fx.OUTPUT_ERR | cc.fx.OUTPUT_WARN | cc.fx.OUTPUT_INFO | cc.fx.OUTPUT_LOG;
cc.fx.clickStatEventType = {
clickStatEventTypeVideoAD : 20173201,//视频播放完成
clickStatEventTypeClickAdVideo : 20173202,//视频播放为完成
clickStatEventTypeBannerAD : 20173203,//banner播放为完成
clickStatEventTypeUserFrom : 99990001,//用户来源
clickStatEventTypeShare : 99990002,//用户分享
clickStatEventTypeClickAdBtn : 99990007,//点击分流icon
clickStatEventTypeBannerAD2 : 67890033, // banner广告干预
clickStatEventTypeSubmitVersionInfo : 9999, //上报微信版本及基础库信息
clickStatEventTypeClickFirstAd : 99990003, //分流icon显示
clickStatEventTypeClickSecondAd : 99990004, //玩家点击分流按钮
clickStatEventTypeWxLoginStart : 10001,//微信登录开始
clickStatEventTypeWxLoginSuccess : 10002,//微信登录成功
clickStatEventTypeWxLoginFailed : 10003,//微信登录失败
clickStatEventTypeAuthorizationStart : 10003,//授权开始
clickStatEventTypeAuthorizationSuccess : 10004,//授权成功
clickStatEventTypeAuthorizationFailed : 10005,//授权失败
clickStatEventTypeLoginSDKStart : 10007,//登录SDK开始
clickStatEventTypeLoginSDKSuccess : 10008,//登录SDK成功
clickStatEventTypeLoginSDKFailed : 10009,//登录SDK时失败
clickStatEventTypeTCP_Start : 10009,//TCP连接开始
clickStatEventTypeTCP_Success : 10010,//TCP连接成功
clickStatEventTypeTCP_Failed : 10011,//TCP连接失败
};
//应用系统信息
// cc.fx.SystemInfo = require("../BallSDK/BallSystemInfo");
// cc.fx.SystemInfo.init();
// cc.fx.EventType = require("../BallSDK/BallEventType");
// cc.fx.UserInfo = require("../BallGame/UserInfo");
// cc.fx.OutPut = require("../BallUtil/LogOutPut");
// cc.fx.HttpUtil= require("../BallSDK/BallHttpUtil");
// cc.fx.EncodeDecode = require("../BallUtil/BallEncodeDecode");
// cc.fx.NotificationCenter = require("../BallUtil/BallNotificationCenter");
// cc.fx.Timer = require("../BallUtil/BallTimer");
// cc.fx.Util = require("../BallUtil/BallUtil");
// cc.fx.TCPMSG = require("../BallSDK/BallTCP_Msg");
// cc.fx.TCPRECEIVER = require("../BallSDK/BallTCP_Receiver");
// cc.fx.TCPRECEIVER.init();
// cc.fx.Loader = require("../BallUtil/BallLoader");
// cc.fx.PopWindowManager = require("../BallWindow/BallPopWindonwManager");
// cc.fx.PopWindowManager.preload();
// cc.fx.TipManager = require("../BallWindow/TipWindowManager");
// cc.fx.PayModel = require("../BallModel/BallPayModel");
// cc.fx.SceneManager = require("../BallUtil/BallSceneManager");
// cc.fx.MapCheckPoint = require("../BallUtil/MapCheckPointManager");
// cc.fx.MapCheckPoint.initMapCheckPointBallInfo();
// cc.fx.MapPointScore = require("../BallCheckPoint/CheckPointScore");
// cc.fx.Storage = require('../BallUtil/BallStorage');
// if (cc.sys.isBrowser) {
// cc.fx.Storage = require('../BallUtil/BallStorage');
// } else {
// cc.fx.Storage = require('../BallUtil/WeChatStorage');
// }
// cc.fx.Gift = require("../BallModel/BallGiftBox");
// cc.fx.Invite = require('../BallModel/BallInvite');
// cc.fx.ClientConf = require("../BallModel/BallClientConf");
};

View File

@ -1,7 +1,7 @@
{
"ver": "1.1.0",
"uuid": "61aff0f9-48ef-48a6-8d1f-1a621e4c54d9",
"importer": "javascript",
"uuid": "61d4c718-db3b-4b31-8221-f16bea3cf030",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,

View File

@ -0,0 +1,13 @@
{
"ver": "1.1.3",
"uuid": "0487cacb-b94a-4ab6-a301-b6402ab0ac5d",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

View File

@ -0,0 +1,237 @@
const {ccclass, property} = cc._decorator;
@ccclass
export default class AudioManager extends cc.Component {
static playWarning() {
throw new Error('Method not implemented.');
}
//背景音乐
@property(cc.AudioClip)
audioGameBgm0: cc.AudioClip = null;
//跳跃
@property(cc.AudioClip)
audioButtonClick: cc.AudioClip = null;
//落地上
@property(cc.AudioClip)
audioWarning: cc.AudioClip = null;
//碰撞
@property(cc.AudioClip)
audioWin: cc.AudioClip = null;
//落方块上
mAudioMap: {};
bgMusicVolume: number;
effectMusicVolume: number;
mMusicSwitch: number;
mEffectSwitch: number;
brickSound: any;
reward: boolean;
finish: boolean;
rewardCount: number;
mMusicKey: any;
static _instance: any;
ctor () {
this.mAudioMap = {};
/**
*
* @type {number}
*/
this.bgMusicVolume = 0.1;
this.effectMusicVolume = 1;
this.mMusicSwitch = 1;
this.mEffectSwitch = 1;
}
play (audioSource, loop, callback, isBgMusic) {
if (isBgMusic && !this.mMusicSwitch) return;
if (!isBgMusic && !this.mEffectSwitch) return;
var volume = isBgMusic ? this.bgMusicVolume : this.effectMusicVolume;
if (cc.sys.isBrowser) {
if(audioSource == this.brickSound){
volume = 0.1;
}
volume = 1;
var context = cc.audioEngine.play(audioSource, loop, volume);
if (callback){
cc.audioEngine.setFinishCallback(context, function(){
callback.call(this);
}.bind(this));
}
// cc.wwx.OutPut.log('play audio effect isBrowser: ' + context.src);
this.mAudioMap[audioSource] = context;
return audioSource;
} else {
return audioSource;
}
}
save () {
// cc.wwx.Storage.setItem(cc.wwx.Storage.Key_Setting_Music_Volume, this.mMusicSwitch);
// cc.wwx.Storage.setItem(cc.wwx.Storage.Key_Setting_Effect_Volume, this.mEffectSwitch);
}
onLoad() {
if (AudioManager._instance == null) {
AudioManager._instance = this;
cc.game.addPersistRootNode(this.node);
}
else {
this.node.destroy();
return;
}
this.reward = false;
this.finish = false;
this.rewardCount = 0;
this.ctor();
this.preload();
}
preload () {
if (!(cc.sys.platform === cc.sys.WECHAT_GAME)) { return; }
var musics = [
this.audioGameBgm0,
];
musics.forEach(function(path) {
// var musicPath = wxDownloader.REMOTE_SERVER_ROOT + path;
// if (musicPath != wxDownloader.REMOTE_SERVER_ROOT && musicPath.endsWith('.mp3')) {
// cc.loader.load(musicPath, function(err, remoteUrl) {
// if (err) {
// cc.error(err.message || err);
// return;
// }
// });
// }
})
}
getAudioMusicSwitch()
{
return this.mMusicSwitch;
}
getAudioEffectSwitch()
{
return this.mEffectSwitch;
}
trunAudioSound(on)
{
this.switchMusic(on);
this.switchEffect(on)
}
switchMusic (on) {
if (this.mMusicSwitch != (on?1:0))
{
this.mMusicSwitch = 1-this.mMusicSwitch;
// this.save();
}
if(on)
{
this.playMusicGame();
}
else
{
this.stopMusic();
}
}
switchEffect (on) {
if (this.mEffectSwitch != (on?1:0)){
this.mEffectSwitch = 1-this.mEffectSwitch;
// this.save();
}
}
onHide () {
cc.audioEngine.pauseAll();
}
onShow () {
cc.audioEngine.resumeAll();
}
playMusic (key, callback, loop) {
loop = typeof loop == 'undefined' || loop ? true : false;
this.stopMusic();
this.mMusicKey = this.play(key, loop, callback, true);
}
/**
*
*/
playMusicGame () {
this.playMusic(this.audioGameBgm0,{},true);
}
/**
*
*/
stopMusic () {
// cc.wwx.OutPut.log('stopMusic audio effect wx: ' + this.mMusicKey);
var context = this.mAudioMap[this.mMusicKey];
if (typeof(context) != 'undefined') {
if (cc.sys.isBrowser) {
cc.audioEngine.stop(context);
} else {
context.stop();
}
cc.audioEngine.stop(context);
}
}
// 炸弹、火箭爆炸音效
playWin () {
return this.play(this.audioWin, false,null,this.mEffectSwitch);
}
//激光音效
playWarning()
{
return this.play(this.audioWarning, false,null,this.mEffectSwitch);
}
/*
*
*
*/
playGameStart()
{
}
/*
*
*/
playGameOver()
{
}
/*
*
*/
playGameResultFailed()
{
}
/*
*
*/
playGameResultSuccess()
{
}
/**
*
*/
/**
*
*/
playAudioButton () {
return this.play(this.audioButtonClick, false,null,this.mEffectSwitch);
}
};
// export { AudioManager };

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "58403fe7-d7a2-426b-9b19-84d3236731a8",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,13 @@
{
"ver": "1.1.3",
"uuid": "ff6560d9-676d-42ad-8ec7-e44acb84ad9e",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

View File

@ -1,5 +1,5 @@
//全局通知
var Notification = {
var Notifications = {
_eventMap: [],
on: function (masgId, callback, target) {
if (this._eventMap[masgId] === undefined) {
@ -42,5 +42,4 @@ var Notification = {
}
}
};
export { Notification };
export { Notifications };

View File

@ -1,6 +1,6 @@
{
"ver": "1.1.0",
"uuid": "f2518fb4-2074-4639-8fae-788846b44780",
"uuid": "55403563-1a5a-4f2f-9eb8-82c762641837",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,

View File

@ -0,0 +1,13 @@
{
"ver": "1.1.3",
"uuid": "d3520299-33dc-43d2-b522-d424efb5575d",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

View File

@ -1,3 +1,4 @@
import { GameTool } from "../Tool/GameTool";
import List, { ListType } from "./List";
const { ccclass, property } = cc._decorator;
@ -11,9 +12,7 @@ export default class ItemRender extends cc.Component {
/**数据改变时调用 */
public dataChanged(){
if(this.data.name.length > 6){
this.data.name = this.data.name.substring(0,6) + "..."
}
GameTool.subName(this.data.name,6);
this.node.getChildByName("rankLab").getComponent(cc.Label).string = this.data.rank + "";
this.node.getChildByName("nameLab").getComponent(cc.Label).string = this.data.name + "";
this.node.getChildByName("totalLab").getComponent(cc.Label).string = this.data.total + "";

View File

@ -0,0 +1,13 @@
{
"ver": "1.1.3",
"uuid": "2af8f2ef-b8a0-43ad-a144-ef4a887f2fa9",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

View File

@ -1,6 +1,6 @@
{
"ver": "1.1.0",
"uuid": "7cf8c313-e732-40d1-9538-1a9d0970bf2f",
"uuid": "10029dfc-5454-4977-bd11-8809e8f48cac",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,

View File

@ -0,0 +1,13 @@
{
"ver": "1.1.3",
"uuid": "2a81f82d-8d16-44af-b947-44eea4dde54f",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

View File

@ -0,0 +1,245 @@
import GameData from "../Config/GameData";
import HttpUtil from "../Crypto/HttpUtil";
import { StorageMessage } from "../Storage/Storage";
//最大工具类 各种公共方法,以及处理上传,获取后端接口数据
var GameTool = {
_startTime: 0,
_endTime: 0,
_totalTime: 0,
//获取userId
Authentication(){
let name = "user_" + GameData._instance.GM_INFO.gameId;
var data = JSON.parse(localStorage.getItem(name));
if(data == "undifend" || data==null || data == ""){
let url = "http://api.sparkus.cn/api/user/auth/login?domain=hui32579WdYPsgYq&callback="+location.href;
window.location.href = url;
}
else{
StorageMessage.setStorage(name,data);
GameData._instance.GM_INFO.userId = parseInt(data.userId);
}
},
//埋点上传
setGameData(){
//GAME_DATA 初始化 每次清零
GameData._instance.GAME_DATA = [];
GameData._instance.GAME_DATA.push(GameData._instance.CLICK_DATA);
GameData._instance.CLICK_init();
let data = GameData._instance.GAME_DATA;
let matchId = this.getMatchId();
let postData = {
"gameId":GameData._instance.GM_INFO.gameId,
"userId":GameData._instance.GM_INFO.userId,
"matchId":matchId,
"data": data
};
// console.log("上传数据:")
HttpUtil.uploadUserLogData(postData,function(){})
},
//上传排行榜 type为1
setRank(data){
//GAME_DATA 初始化 每次清零
let postData = {
"gameId":GameData._instance.GM_INFO.gameId,
"userId":GameData._instance.GM_INFO.userId,
"type":1,
"reactionTime": data,
"totalSunCount": GameData._instance.GM_INFO.total,
"success": GameData._instance.GM_INFO.success
};
HttpUtil.rankData(1,function(){},postData);
},
//获取排行榜 type为2
getRank(rankLength,callback){
let postData = {
"gameId":GameData._instance.GM_INFO.gameId,
"userId":GameData._instance.GM_INFO.userId,
"page":1,
"pageSize":rankLength
};
//回调进getRankData
HttpUtil.rankData(2,data =>{callback(data)},postData);
},
//获取matchId 用于上传每次点击数据里面记录id方便查询
getMatchId (){
let matchId = cc.sys.localStorage.getItem("matchId");
if(matchId == "undifend" || matchId==null){
matchId = this.setMatchId();
}
else{
if(this.containsNanana(matchId) == true){
matchId = this.setMatchId();
}
else{
let char = parseInt(matchId[10]);
if(this.level == 1){
char += 1;
}
matchId = matchId.slice(0, 10) + char + "";
GameData._instance.GM_INFO.matchId = matchId;
cc.sys.localStorage.setItem("matchId",matchId);
}
}
return matchId;
},
//检测matchId 如果有缓存以前的nanana数据清除
containsNanana(str) {
return /na/i.test(str);
},
//重新设置MatchId
setMatchId (){
// 定义包含可用字符的字符集
const characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
// 创建一个数组以保存随机字符
const uuidArray = [];
// 循环10次 生成10位的UUID
for (let i = 0; i < 10; i++) {
// 生成随机索引,范围是字符集的长度
const randomIndex = Math.floor(Math.random() * characters.length);
// 从字符集中获取随机字符
const randomChar = characters.charAt(randomIndex);
// 将字符添加到数组中
uuidArray.push(randomChar);
}
let data = uuidArray.join('') + 1 + "";
cc.sys.localStorage.setItem("matchNumber",1);
cc.sys.localStorage.setItem("matchId",data);
GameData._instance.GM_INFO.matchId = data;
return data;
},
//截取名字
subName(name,length){
if(name.length > length){
name = name.substring(0,length) + "..."
}
return name;
},
//设置头像
setPic(node,pic){
node.active = false;
let url = pic;
setTimeout(() => {
fetch(url)
.then(response => {
return response.headers.get('Content-Length');
})
.then(errNo => {
if(errNo == "5093"){
node.active = true;
}
})
.catch(error => {
console.error('Error fetching X-Info:', error);
});
}, 100);
cc.assetManager.loadRemote(url, {ext:'.jpg'},(err, texture:cc.Texture2D) => {
if(texture){
node.active = true;
node.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture);
}
else{
console.log(err,texture)
}
})
},
//第一个参数把目标带进来处理,第二个参数为名字长度,不同场景不同需求
//名字4短小排行名字6长大排行
getRankData(data,target,nameLength){
target.listData = data.data.list;
target.selfData = data.data.info;
let rankData = [];
let self = false;
GameTool.setPic(target.selfNode.getChildByName("pic").getChildByName("icon"),target.selfData.pic);
for(let i=0;i<=target.listData.length-1;i++){
rankData.push({rank:(i+1), name:target.listData[i].nickName, total:target.listData[i].totalSunCount, pic:target.listData[i].pic});
if(GameData._instance.GM_INFO.userId == target.listData[i].userId){
self = true;
target.selfNode.getChildByName("rankLab").getComponent(cc.Label).string =(i+1) + "";
}
if(i == (target.listData.length-1) && self == false){
target.selfNode.getChildByName("rankLab").getComponent(cc.Label).string = "99+";
}
}
GameTool.subName(target.selfData.nickName,nameLength);
target.selfNode.getChildByName("nameLab").getComponent(cc.Label).string = target.selfData.nickName;
target.selfNode.getChildByName("totalLab").getComponent(cc.Label).string = target.selfData.totalSunCount;
switch(target.selfNode.getChildByName("rankLab").getComponent(cc.Label).string){
case "1":
target.selfNode.getChildByName("rank").getChildByName("one").active = true;
break;
case "2":
target.selfNode.getChildByName("rank").getChildByName("two").active = true;
break;
case "3":
target.selfNode.getChildByName("rank").getChildByName("three").active = true;
break;
}
//大排行
if(nameLength == 6){
target.rankList.setData(rankData);
target.selfNode.opacity = 255;
if(target.selfData.totalSunCount == 0) target.selfNode.opacity = 0;
}
},
getSetScreenResolutionFlag: function () {
let size = cc.winSize;
let width = size.width;
let height = size.height;
if ((height / width) > (16.2 / 9)) return false;
return true;
},
//判断全面屏适配
setFit: function (canvas) {
let flag = GameTool.getSetScreenResolutionFlag();
if (flag) {
// console.log("不是全面屏");
} else {
// console.log("是全面屏");
}
return flag;
},
//获取游戏信息
getGameInfo: function(node){
var jg = false;
return jg;
},
//设置游戏信息
setGameInfo: function(pd){
},
//输入秒,返回需要展示时间格式
getTimeMargin:(second) => {
let total = 0;
total = second;
let hour = 0;
hour = parseInt((total / 3600) + "");//计算整数小时数
let afterHour = total - hour * 60 * 60;//取得算出小时数后剩余的秒数
let min = parseInt((afterHour / 60)+"");//计算整数分
let m = "" + min;
if(min < 10) m = "0"+min;
let afterMin = total - hour * 60 * 60 - min * 60;//取得算出分后剩余的秒数
let miao = afterMin + "";
if(afterMin < 10) miao = "0" + afterMin;
return m + ':' + miao
},
//获取时间戳
getTime(){
const timestamp = new Date().getTime();
return timestamp;
},
pushLister:function () {
},
removeAllLister:function () {
},
};
export { GameTool };

View File

@ -1,6 +1,6 @@
{
"ver": "1.1.0",
"uuid": "ddac3642-fbda-4742-bd05-b3d208870e1a",
"uuid": "43bfc27a-ff6e-45b3-87c7-504d0f781397",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,

View File

@ -1,311 +0,0 @@
cc.Class({
extends: cc.Component,
properties:{
//背景音乐
audioGameBgm0:{
default:null,
type:cc.AudioClip
},
// 按钮点击
audioButtonClick:{
default:null,
type:cc.AudioClip
},
// 报警音效
audioWarning:{
default:null,
type:cc.AudioClip
},
//游戏开始音效
audioWin:{
default:null,
type:cc.AudioClip
},
reward: false,
finish: false,
rewardCount: 0
},
ctor: function () {
this.mAudioMap = {};
/**
* 默认音量大小
* @type {number}
*/
this.bgMusicVolume = 0.1;
this.effectMusicVolume = 1;
this.mMusicSwitch = 1;
this.mEffectSwitch = 1;
},
play : function(audioSource, loop, callback, isBgMusic) {
if (isBgMusic && !this.mMusicSwitch) return;
if (!isBgMusic && !this.mEffectSwitch) return;
var volume = isBgMusic ? this.bgMusicVolume : this.effectMusicVolume;
if (cc.sys.isBrowser) {
if(audioSource == this.brickSound){
volume = 0.1;
}
var context = cc.audioEngine.play(audioSource, loop, volume);
if (callback){
cc.audioEngine.setFinishCallback(context, function(){
callback.call(this);
}.bind(this));
}
this.mAudioMap[audioSource] = context;
return audioSource;
} else {
var context = wx.createInnerAudioContext();
context.autoplay = true;
context.loop = loop;
context.obeyMuteSwitch = true;
context.volume = volume;
if (callback) {
context.onEnded(function() {
callback.call(this);
}.bind(this));
} else {
context.offEnded();
}
// var audioPath = cc.url.raw("resources/BallMaster/sounds" + audioSource.name + ".mp3");
context.src = audioSource.nativeUrl;
context.play()
this.mAudioMap[audioSource] = context;
return audioSource;
}
},
save: function () {
// cc.wwx.Storage.setItem(cc.wwx.Storage.Key_Setting_Music_Volume, this.mMusicSwitch);
// cc.wwx.Storage.setItem(cc.wwx.Storage.Key_Setting_Effect_Volume, this.mEffectSwitch);
},
onLoad() {
// cc.wwx.Storage.getItem(cc.wwx.Storage.Key_Setting_Music_Volume, function(volume) {
// this.mMusicSwitch = parseInt(volume);
// }.bind(this), 1);
// cc.wwx.Storage.getItem(cc.wwx.Storage.Key_Setting_Effect_Volume, function(volume) {
// this.mEffectSwitch = parseInt(volume);
// }.bind(this), 1);
this.reward = false;
this.finish = false;
this.rewardCount = 0;
window.addEventListener('rewardCanUse', () => {
// 此时激励可用 游戏内部逻辑
this.reward = true;
});
'undefined' != typeof window['reward'] ?
window.dispatchEvent(window['reward']):""
this.preload();
},
preload : function() {
if (!(cc.sys.platform === cc.sys.WECHAT_GAME)) { return; }
var musics = [
this.audioGameBgm0,
];
musics.forEach(function(path) {
// var musicPath = wxDownloader.REMOTE_SERVER_ROOT + path;
// if (musicPath != wxDownloader.REMOTE_SERVER_ROOT && musicPath.endsWith('.mp3')) {
// cc.loader.load(musicPath, function(err, remoteUrl) {
// if (err) {
// cc.error(err.message || err);
// return;
// }
// });
// }
})
},
getAudioMusicSwitch()
{
return this.mMusicSwitch;
},
getAudioEffectSwitch()
{
return this.mEffectSwitch;
},
trunAudioSound(on)
{
this.switchMusic(on);
this.switchEffect(on)
},
switchMusic : function(on) {
if (this.mMusicSwitch != (on?1:0))
{
this.mMusicSwitch = 1-this.mMusicSwitch;
// this.save();
}
if(on)
{
this.playMusicGame();
}
else
{
this.stopMusic();
}
},
switchEffect : function(on) {
if (this.mEffectSwitch != (on?1:0)){
this.mEffectSwitch = 1-this.mEffectSwitch;
// this.save();
}
},
onHide () {
cc.audioEngine.pauseAll();
// if (CC_JSB) {
// } else {
// for (var key in this.mAudioMap) {
// if (key === this.mMusicKey) {
// this.mAudioMap[key].pause();
// } else {
// this.mAudioMap[key].stop();
// }
// }
// }
},
onShow () {
cc.audioEngine.resumeAll();
// if (CC_JSB) {
// } else {
// if (!this.mMusicSwitch) return;
// var context = this.mAudioMap[this.mMusicKey];
// if (context) {
// context.play();
// }
// }
},
playMusic : function(key, callback, loop) {
loop = typeof loop == 'undefined' || loop ? true : false;
this.stopMusic();
this.mMusicKey = this.play(key, loop, callback, true);
},
/**
* 游戏背景音乐
*/
playMusicGame () {
this.playMusic(this.audioGameBgm0);
},
/**
* 停止背景音乐播放
*/
stopMusic () {
// cc.wwx.OutPut.log('stopMusic audio effect wx: ' + this.mMusicKey);
var context = this.mAudioMap[this.mMusicKey];
if (typeof(context) != 'undefined') {
if (cc.sys.isBrowser) {
cc.audioEngine.stop(context);
} else {
context.stop();
}
cc.audioEngine.stop(context);
}
},
// 炸弹、火箭爆炸音效
playBomb () {
return this.play(this.audioBomb, false);
},
//激光音效
playJiGuang()
{
return this.play(this.audioJiGuang, false);
},
//技能音效
playItem1()
{
return this.play(this.audioItem1, false);
},
/*
* 游戏开始音效
*
*/
playGameStart()
{
return this.play(this.audioGameStart, false);
},
/*
* 失败的游戏结束
*/
playGameOver()
{
return this.play(this.audioGameOver,false);
},
/*
* 成功的游戏结束
*/
playGameResultFailed()
{
return this.play(this.audioGameResultFail,false);
},
/*
* 成功的游戏结束
*/
playGameResultSuccess()
{
return this.play(this.audioGameResultSuccess,false);
},
/**
* 报警的音效
*/
playWarning()
{
return this.play(this.audioWarning,false);
},
playWin()
{
return this.play(this.audioWin,false);
},
/*
* 方块碰撞的声音
*/
playBrick()
{
return this.play(this.brickSound,false);
},
//方块破碎的声音
brickBoom(){
return this.play(this.audioObj,false);
},
/**
* 按钮
*/
playAudioButton () {
return this.play(this.audioButtonClick, false);
},
playRandomMatch()
{
this.playMusic(this.randomMatchSound);
},
playMatchFoundSound()
{
this.stopMusic();
return this.play(this.matchFoundSound, false);
}
});

View File

@ -1,254 +0,0 @@
import GameData from "../GameData";
import { StorageMessage } from "./Storage";
//最大工具类
var GameTool = {
_startTime: 0,
_endTime: 0,
_totalTime: 0,
getSeedRandom: function (min, max) {//包含min 不包含max
max = max || 1;
min = min || 0;
GameData._instance.GM_INFO.currSeed = (GameData._instance.GM_INFO.currSeed * 9301 + 49297) % 233280;
let rnd = GameData._instance.GM_INFO.currSeed / 233280.0;
let tmp = min + rnd * (max - min);
return Math.floor(tmp);
},
getSetScreenResolutionFlag: function () {
let size = cc.winSize;
let width = size.width;
let height = size.height;
if ((height / width) > (16.2 / 9)) return false;
return true;
},
//判断全面屏适配
setFit: function (canvas) {
let flag = GameTool.getSetScreenResolutionFlag();
if (flag) {
// console.log("不是全面屏");
// canvas.fitWidth = false;
// canvas.fitHeight = true;
} else {
// console.log("是全面屏");
// canvas.fitWidth = true;
// canvas.fitHeight = false;
}
return flag;
},
getTip: function () {
let index = Math.floor(Math.random() * 4) + 1;
switch (index) {
case 1: {
return "根据小球的位置,合理晃动手机,确保小球不掉出木板。"
}
case 2: {
return "根据小球位置控制晃动幅度,过大或过小都不是个好选择。"
}
case 3: {
return "不要被天上掉落的障碍吓到,有时候它反而会帮你保持平衡。"
}
case 4: {
return "尝试着顶开掉落的障碍,是个很酷的玩法。"
}
}
},
beginTiming: function () {
this._startTime = new Date().getTime();
},
endTiming: function () {
this._endTime = new Date().getTime();
// this._totalTime = endTime - this._startTime;
},
//如果是判断时常的游戏 调用此方法
updateScoreTime: function () {
let endTime = new Date().getTime();
let tempTime = endTime - this._startTime;
if (tempTime < 0 || tempTime > 500) {
tempTime = Math.round(cc.director.getAnimationInterval() * 1000);
}
this._endTime += tempTime / 1000;
this._totalTime = this._endTime.toFixed(2);
GameData._instance.GM_INFO.currScore = this._totalTime;
this._startTime = endTime;
},
//倒计时调用此方法
countDown: function () {
this._endTime = new Date().getTime();
this._totalTime = Math.floor((this._endTime - this._startTime) / 1000);
GameData._instance.GM_INFO.remainingTime = GameData._instance.GM_INFO.totalTime - this._totalTime;
},
getGameInfo: function(node){
var jg = false;
return jg;
},
//根据服务器数据重置所需要所有数据
reset: function(){
console.log("本地数据丢失,重新启动游戏");
cc.director.loadScene('LoadScene');
},
setGameInfo: function(pd){
},
//输入秒,返回需要展示时间格式
getTimeMargin:(second) => {
let total = second;
let hour = Math.floor(total / (60 * 60));//计算整数小时数
let afterHour = total - hour * 60 * 60;//取得算出小时数后剩余的秒数
let min = Math.floor(afterHour / 60);//计算整数分
let afterMin = total - hour * 60 * 60 - min * 60;//取得算出分后剩余的秒数
return '剩余:' + hour + ':' + min + ':' + afterMin
},
getTimeMargin2:(second) => {
let total = second;
let min = null;
let afterMin = null;
let hour = Math.floor(total / (60 * 60));//计算整数小时数
let afterHour = total - hour * 60 * 60;//取得算出小时数后剩余的秒数
min = Math.floor(afterHour / 60);//计算整数分
if(min < 10) min = "0"+min;
afterMin = total - hour * 60 * 60 - min * 60;//取得算出分后剩余的秒数
if(afterMin < 10) afterMin = "0" + afterMin;
return '剩余:' + min + ':' + afterMin
},
setFrindBlock: function(userid){
},
//将时间转换为59:23
getTime: function(time){
var label = "";
var number_1 = null;
var number_2 = null;
number_1 = Math.floor(time/60)
number_2 = time-number_1*60;
if(number_1 < 10){
number_1 = "0"+number_1;
}
if(number_2 < 10){
number_2 = "0"+number_2;
}
label = number_1 + ":" + number_2;
return label;
},
//number 为传进来的数值,type为最多显示几位数
getNumber: function(number,type){
// console.log(type,"需要转换的数字为:",number);
var count = 1000;
var place = type - 3;
if(number > Math.pow(count,8)*Math.pow(10,place)){
if(number/Math.pow(count,8) < 100)
number = Math.floor(number/Math.pow(count,8)*10)/10+"S";
else
number = Math.floor(number/Math.pow(count,8))+"S";
}
else if(number > Math.pow(count,7)*Math.pow(10,place)){
if(number/Math.pow(count,7) < 100)
number = Math.floor(number/Math.pow(count,7)*10)/10+"s";
else
number = Math.floor(number/Math.pow(count,7))+"s";
}
else if(number > Math.pow(count,6)*Math.pow(10,place)){
if(number/Math.pow(count,6) < 100)
number = Math.floor(number/Math.pow(count,6)*10)/10+"Q";
else
number = Math.floor(number/Math.pow(count,6))+"Q";
}
else if(number > Math.pow(count,5)*Math.pow(10,place)){
if(number/Math.pow(count,5) < 100)
number = Math.floor(number/Math.pow(count,5)*10)/10+"q";
else
number = Math.floor(number/Math.pow(count,5))+"q";
}
else if(number > Math.pow(count,4)*Math.pow(10,place)){
if(number/Math.pow(count,4) < 100)
number = Math.floor(number/Math.pow(count,4)*10)/10+"t";
else
number = Math.floor(number/Math.pow(count,4))+"t";
}
else if(number > Math.pow(count,3)*Math.pow(10,place)){
if(number/Math.pow(count,3) < 100)
number = Math.floor(number/Math.pow(count,3)*10)/10+"b";
else
number = Math.floor(number/Math.pow(count,3))+"b";
}
else if(number > Math.pow(count,2)*Math.pow(10,place)){
if(number/Math.pow(count,2) < 100)
number = Math.floor(number/Math.pow(count,2)*10)/10+"m";
else
number = Math.floor(number/Math.pow(count,2))+"m";
}
else if(number > Math.pow(count,1)*Math.pow(10,place)){
if(number/Math.pow(count,1) < 100){
number = Math.floor(number/Math.pow(count,1)*10)/10+"k";
}
else
number = Math.floor(number/Math.pow(count,1))+"k";
}
else{
number = Math.floor(number/Math.pow(count,0))+"";
}
// console.log("结果为"+type+"位数",number);
return number;
},
begainTiming: function () {
this._startTime = new Date().getTime();
},
endTiming2: function () {
let endTime = new Date().getTime();
this._endTime = endTime;
this._totalTime = endTime - this._startTime;
},
getScoreTime: function () {
let endTime = new Date().getTime();
let tempTime = endTime - this._startTime;
if (tempTime < 0 || tempTime > 500) {
tempTime = Math.round(cc.director.getAnimationInterval() * 1000);
}
GameData._instance.GM_INFO.currScore += tempTime;
this._startTime = endTime;
},
getFormatTime: function (time) {
let date = new Date();
date.setTime(time);
let ms = date.getMilliseconds();
// let msString = date.getMilliseconds();
let msString = null;
let secondString = null;
let minString = null;
msString = Math.floor(ms / 10) % 100;
secondString = date.getSeconds();
minString = date.getMinutes();
if (msString < 10) {
msString = "0" + msString;
}
if (secondString < 10) {
secondString = "0" + secondString;
}
secondString = secondString + ":";
if (minString < 10) {
minString = "0" + minString;
}
minString = minString + ":";
return minString + secondString + msString;
},
pushLister:function () {
},
removeAllLister:function () {
},
};
export { GameTool };

View File

@ -1,45 +0,0 @@
/**
* 自定义抖动效果
*/
var Shake = cc.Class({
extends: cc.Component,
properties: {
//抖动时间
duration: 0,
//X轴抖动范围
shakeX: 0,
shakeY: 0,
},
shake: function (callback) {
if(this.shaking){
return;
}
this.callback = callback;
this.shaking = true;
this.dtCost = 0;
this.nodeInitialPos = this.node.getPosition();
this.unschedule(this.doSchedule);
this.schedule(this.doSchedule, 0, cc.macro.REPEAT_FOREVER, 0);
},
doSchedule: function (dt) {
var dt2 = dt * 50;
var randX = this.getRandomStrength(-this.shakeX, this.shakeX) * dt2;
var randY = this.getRandomStrength(-this.shakeY, this.shakeY) * dt2;
this.node.setPosition(cc.pAdd(this.nodeInitialPos, cc.v2(randX, randY)));
this.dtCost += dt;
if (this.dtCost >= this.duration) {
this.unschedule(this.doSchedule);
this.node.setPosition(this.nodeInitialPos);
this.shaking = false;
if(this.callback){
this.callback();
}
}
},
//获取两个数间的随机值
getRandomStrength: function (min, max) {
return Math.random() * (max - min + 1) + min;
},
});

Binary file not shown.

View File

@ -1 +1 @@
{"paths":{},"types":[],"uuids":["a2MjXRFdtLlYQ5ouAFv/+R","14K23Xm1ROrrsGMBKG1Ql4","29FYIk+N1GYaeWH/q1NxQO","2dL3kvpAxJu6GJ7RdqJG5J","37ND3actNCqZoLzr1NBiTF","4bnFp+xkVIpJrKXfOBzk71","4er1GLNexCYpKNTUl8Pygw","77SCm7Ej5ItpMOaz4CSRUG","9cCAYtTPFLbqi6SjiBzH59","d3OhOXdm5P4JNse7X8GMGe","e97GVMl6JHh5Ml5qEDdSGa","f0BIwQ8D5Ml7nTNQbh1YlS","02delMVqdBD70a/HSD99FK","08/X0iIrpGHbKJqlQlA512","0cF7COgzlFRKaDnaVJrOOt","13EQ5PNYdOa4gRDKFsrIFJ","167IfY0HdDyZdtlLDeaDkg","1fwAIEeM1Nn7i705Pdg5L5","23CIt+PSBBMJopNtpbffXh","27FeLB8OpGcaDrf9NiEDKz","28Gg0A8X1JHpYnbH9vZIzV","29G9ngwKpNW56EfZdKv0SX","2aJVC/rshLnpvG+lkallqC","2cyTcZvcZP7rjmchhWREEu","3aIyOI2NxPeaHqgvY4W3zi","3fgys9roZKo5OdfZn0T4Fo","432ND8vGNFM4/Pxt+hVLkb","48Foz8zQZDfLObHQegvteG","4cuYcoe7tPiIdp6gbSnrvF","4c7tzGCVNKE5yvOmzu4CXt","57X2D8NaxKHZ7D/uwxGBCK","59Sn0ZhhJHf7HX55ZqGeqE","5aBm0rBa9Gxr8lWEiz8nAb","5bsctimnBNw4onIGVsCfsU","5cO7kybDxGj4ipyMYdRYZB","5eUVg3ZQ5FhKCJ4qAl42w5","5f5dyqtRNNxaFmVzYns6FZ","61cyPdEfRN047sDK9rO0W5","61c+AvZ7lJH4DcNNAnJ//N","63m/tYswFOS7sCMuQGQ4kn","651MDCXIFPuZKQK1+nWOzk","6cyjAC9cJDE6x1PK28Td4v","6eoolBkxxPvof0z1pzKU+w","70mY8jP3NKVonyvxI9/f6z","71VhFCTINJM6/Ky3oX9nBT","818w6dGPRH+rXb8KDTjDgq","8cv+mgkU9OTIB7sHOwnyZ8","8eZObX1ehJkKU3GR/hPgya","8eo+QfsThNk7a0r8Ilro8q","93XHrCUNdAwJfBzyLGAOJ5","95AC/gHlpJ64LEYVdSIIPB","95viAf/CZABIBJ7iCjDOU4","96FRA8sCdIybKmTQHllKeE","99vgruzGRMmJOIRLdPaQYs","9bvaMerUlDyary99mJa6xp","9cBsd3MbFMC56GS/sJnS6r","9e4xLWF9hCBq5CM6vIyvlp","a5+/rf9ZlPEIXTSsUOhw7T","adR/bBScVC/bM24V3TdrfL","adULT7sm1JR6vTV/oW1JIb","adrVhydQhMD7nhiXljhNId","b4P/PCArtIdIH38t6mlw8Y","bcITWltAtAD4sUjinM7HdJ","c6VxSCRHRB+qS91aK866px","ceNMgtpZhCsKd8anXNKd7b","d1MjdySrJFJ70gUB/k+5cj","d608qFRoFHwbXd0Dap056i","d7kiZgBYNPyIwqRjgGX7l0","d8HsitJHxOYqo801xBk8ev","ddnWn8vDxCOZaOnG9OVNnP","deq5vhWmZCFJ97k3T54cZ0","e7CzEDg/FMZpCTGJfBpdSu","e8Ueib+qJEhL6mXAHdnwbi","ecpdLyjvZBwrvm+cedCcQy","eezChet5VG27PW9q3qdOpv","f1O5RoDlhGrI6+/w3NObrX","f7ZJEQGfdJraVAIIAn8NFW"],"scenes":{"db://assets/Scene/GameScene.fire":6,"db://assets/Scene/GuideScene.fire":7,"db://assets/Scene/LoadScene.fire":8,"db://assets/Scene/OverScene.fire":5,"db://assets/Scene/RankScene.fire":3},"redirect":[12,0,13,1,14,1,16,1,19,1,22,1,23,1,26,1,32,1,33,1,38,1,41,1,43,1,46,1,48,1,50,1,51,1,52,1,53,1,55,1,56,1,57,1,59,1,62,1,63,1,64,1,67,1,70,1,73,0,75,1],"deps":["internal","resources"],"packs":{"04d3bacdc":[17,21,27,37,39,40,44,49,60,61,66,68,72,74,76],"05b7e0d6d":[1,5,30],"05f3c1ca4":[4,7,0,65,9],"09db7c06c":[18,2,47,8,0,71,10,11],"0cd1ec7f1":[42,69],"0d7de01d8":[15,20,2,4,24,25,28,29,6,35,45,0,9,10,11],"0e0598680":[1,3,31,34,36,54,58]},"name":"main","importBase":"import","nativeBase":"native","debug":false,"isZip":false,"encrypted":false}
{"paths":{},"types":[],"uuids":["a2MjXRFdtLlYQ5ouAFv/+R","14K23Xm1ROrrsGMBKG1Ql4","29FYIk+N1GYaeWH/q1NxQO","2dL3kvpAxJu6GJ7RdqJG5J","37ND3actNCqZoLzr1NBiTF","4bnFp+xkVIpJrKXfOBzk71","4er1GLNexCYpKNTUl8Pygw","77SCm7Ej5ItpMOaz4CSRUG","9cCAYtTPFLbqi6SjiBzH59","d3OhOXdm5P4JNse7X8GMGe","e97GVMl6JHh5Ml5qEDdSGa","f0BIwQ8D5Ml7nTNQbh1YlS","02delMVqdBD70a/HSD99FK","08/X0iIrpGHbKJqlQlA512","0cF7COgzlFRKaDnaVJrOOt","13EQ5PNYdOa4gRDKFsrIFJ","167IfY0HdDyZdtlLDeaDkg","1fwAIEeM1Nn7i705Pdg5L5","23CIt+PSBBMJopNtpbffXh","27FeLB8OpGcaDrf9NiEDKz","28Gg0A8X1JHpYnbH9vZIzV","29G9ngwKpNW56EfZdKv0SX","2aJVC/rshLnpvG+lkallqC","2cyTcZvcZP7rjmchhWREEu","3aIyOI2NxPeaHqgvY4W3zi","3fgys9roZKo5OdfZn0T4Fo","432ND8vGNFM4/Pxt+hVLkb","48Foz8zQZDfLObHQegvteG","4cuYcoe7tPiIdp6gbSnrvF","4c7tzGCVNKE5yvOmzu4CXt","57X2D8NaxKHZ7D/uwxGBCK","59MsqY7oZEy71JeUeyyS/Z","59Sn0ZhhJHf7HX55ZqGeqE","5aBm0rBa9Gxr8lWEiz8nAb","5bsctimnBNw4onIGVsCfsU","5cO7kybDxGj4ipyMYdRYZB","5eUVg3ZQ5FhKCJ4qAl42w5","5f5dyqtRNNxaFmVzYns6FZ","61cyPdEfRN047sDK9rO0W5","61c+AvZ7lJH4DcNNAnJ//N","63m/tYswFOS7sCMuQGQ4kn","651MDCXIFPuZKQK1+nWOzk","6cyjAC9cJDE6x1PK28Td4v","6eoolBkxxPvof0z1pzKU+w","70mY8jP3NKVonyvxI9/f6z","71VhFCTINJM6/Ky3oX9nBT","818w6dGPRH+rXb8KDTjDgq","8cv+mgkU9OTIB7sHOwnyZ8","8eZObX1ehJkKU3GR/hPgya","8eo+QfsThNk7a0r8Ilro8q","93XHrCUNdAwJfBzyLGAOJ5","95AC/gHlpJ64LEYVdSIIPB","95viAf/CZABIBJ7iCjDOU4","99vgruzGRMmJOIRLdPaQYs","9bvaMerUlDyary99mJa6xp","9cBsd3MbFMC56GS/sJnS6r","9e4xLWF9hCBq5CM6vIyvlp","a5+/rf9ZlPEIXTSsUOhw7T","adR/bBScVC/bM24V3TdrfL","adULT7sm1JR6vTV/oW1JIb","adrVhydQhMD7nhiXljhNId","b4P/PCArtIdIH38t6mlw8Y","bcITWltAtAD4sUjinM7HdJ","c6VxSCRHRB+qS91aK866px","ceNMgtpZhCsKd8anXNKd7b","d1MjdySrJFJ70gUB/k+5cj","d608qFRoFHwbXd0Dap056i","d7kiZgBYNPyIwqRjgGX7l0","d8HsitJHxOYqo801xBk8ev","ddnWn8vDxCOZaOnG9OVNnP","deq5vhWmZCFJ97k3T54cZ0","e7CzEDg/FMZpCTGJfBpdSu","e8Ueib+qJEhL6mXAHdnwbi","e82yVDavlBc6NpbK/tA6Dr","ecpdLyjvZBwrvm+cedCcQy","eezChet5VG27PW9q3qdOpv","f1O5RoDlhGrI6+/w3NObrX","f7ZJEQGfdJraVAIIAn8NFW"],"scenes":{"db://assets/Scene/GameScene.fire":6,"db://assets/Scene/GuideScene.fire":7,"db://assets/Scene/LoadScene.fire":8,"db://assets/Scene/OverScene.fire":5,"db://assets/Scene/RankScene.fire":3},"redirect":[12,0,13,1,14,1,16,1,19,1,22,1,23,1,26,1,33,1,34,1,39,1,42,1,44,1,47,1,49,1,51,1,52,1,53,1,55,1,56,1,57,1,59,1,62,1,63,1,64,1,67,1,70,1,74,0,76,1],"deps":["internal","resources"],"packs":{"01587c953":[18,2,48,8,0,71,73,10,11],"03e4478d5":[17,21,27,31,38,40,41,45,50,60,61,66,68,72,75,77],"05b7e0d6d":[1,5,30],"05f3c1ca4":[4,7,0,65,9],"0cd1ec7f1":[43,69],"0d7de01d8":[15,20,2,4,24,25,28,29,6,36,46,0,9,10,11],"0e0598680":[1,3,32,35,37,54,58]},"name":"main","importBase":"import","nativeBase":"native","debug":false,"isZip":false,"encrypted":false}

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
{"type":"cc.Texture2D","data":"0,9729,9729,33071,33071,0,0,1|0,9729,9729,33071,33071,0,0,1|0,9729,9729,33071,33071,0,0,1|0,9729,9729,33071,33071,0,0,1|0,9729,9729,33071,33071,0,0,1|0,9729,9729,33071,33071,0,0,1|0,9729,9729,33071,33071,0,0,1|0,9729,9729,33071,33071,0,0,1|0,9729,9729,33071,33071,0,0,1|0,9729,9729,33071,33071,0,0,1|0,9729,9729,33071,33071,0,0,1|0,9729,9729,33071,33071,0,0,1|0,9729,9729,33071,33071,0,0,1|0,9729,9729,33071,33071,0,0,1|0,9729,9729,33071,33071,0,0,1"}
{"type":"cc.Texture2D","data":"0,9729,9729,33071,33071,0,0,1|0,9729,9729,33071,33071,0,0,1|0,9729,9729,33071,33071,0,0,1|0,9729,9729,33071,33071,0,0,1|0,9729,9729,33071,33071,0,0,1|0,9729,9729,33071,33071,0,0,1|0,9729,9729,33071,33071,0,0,1|0,9729,9729,33071,33071,0,0,1|0,9729,9729,33071,33071,0,0,1|0,9729,9729,33071,33071,0,0,1|0,9729,9729,33071,33071,0,0,1|0,9729,9729,33071,33071,0,0,1|0,9729,9729,33071,33071,0,0,1|0,9729,9729,33071,33071,0,0,1|0,9729,9729,33071,33071,0,0,1|0,9729,9729,33071,33071,0,0,1"}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

5
creator.d.ts vendored
View File

@ -3,7 +3,12 @@
The main namespace of Cocos2d-JS, all engine core classes, functions, properties and constants are defined in this namespace.
!#zh
Cocos */
interface Window {
initMgr: any;
android: any; //全局变量名
}
declare namespace cc {
export var fx: any;
/** The current version of Cocos2d being used.<br/>
Please DO NOT remove this String, it is an important flag for bug tracking.<br/>
If you post a bug to forum, please attach this flag. */

View File

@ -1,6 +1,6 @@
"use strict";
cc._RF.push(module, '7cf8cMT5zJA0ZU4Gp0JcL8v', 'Storage');
// Script/Storage.ts
cc._RF.push(module, '1002938VFRJd70RiAno9Iys', 'Storage');
// Script/module/Storage/Storage.ts
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

View File

@ -0,0 +1 @@
{"version":3,"sources":["assets\\Script\\module\\Storage\\Storage.ts"],"names":[],"mappings":";;;;;;;AAAA,SAAS;AACT,IAAI,cAAc,GAAG;IACjB,UAAU,EAAG,UAAS,GAAG;QACrB,IAAI,MAAM,GAAG,IAAI,CAAC;QAClB,IAAG,EAAE,CAAC,GAAG,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,EAAC;YAClC,IAAI,MAAM,GAAG,EAAE,CAAC,GAAG,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;SAC/C;QAED,IAAG,MAAM,EAAC;YACR,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;SAC7B;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;IACD,UAAU,EAAG,UAAS,GAAG,EAAC,KAAK;QAC3B,UAAU;QACV,IAAI,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACjC,EAAE,CAAC,GAAG,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;IAC1C,CAAC;IACD,aAAa,EAAG,UAAS,GAAG;QAC1B,UAAU;QACV,IAAG,EAAE,CAAC,GAAG,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,EAAC;YAClC,EAAE,CAAC,GAAG,CAAC,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;SACpC;IACH,CAAC;CACJ,CAAC;AAEO,wCAAc","file":"","sourceRoot":"/","sourcesContent":["//缓存浏览器数据\nvar StorageMessage = {\n getStorage : function(key){\n var result = null;\n if(cc.sys.localStorage.getItem(key)){\n var result = cc.sys.localStorage.getItem(key);\n }\n \n if(result){\n result = JSON.parse(result);\n }\n return result;\n },\n setStorage : function(key,value){\n //主动拉起分享接口\n var temp = JSON.stringify(value);\n cc.sys.localStorage.setItem(key, temp)\n },\n removeStorage : function(key){\n //主动删除消息接口\n if(cc.sys.localStorage.getItem(key)){\n cc.sys.localStorage.removeItem(key)\n }\n },\n};\n\nexport { StorageMessage };"]}

View File

@ -1,6 +1,6 @@
"use strict";
cc._RF.push(module, 'f2f0bI5PsVI+o18xF6G+KVa', 'GameData');
// Script/GameData.ts
cc._RF.push(module, '179c44L0X9IhZh7hydovv0d', 'GameData');
// Script/module/Config/GameData.ts
"use strict";
var __extends = (this && this.__extends) || (function () {
@ -56,7 +56,7 @@ var GameData = /** @class */ (function (_super) {
total: 0,
currSeed: 203213,
gameId: '100009',
userId: 200139,
userId: 0,
guide: true,
url: "http://api.sparkus.cn",
success: false,

File diff suppressed because one or more lines are too long

View File

@ -3,6 +3,7 @@ cc._RF.push(module, '3fd2fh6vHNJeISUizW09xat', 'GuideManager');
// Script/GuideManager.ts
"use strict";
//此页面为引导页面,后续更新成模板,暂时偷懒复制主游戏场景代码进来
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
@ -23,9 +24,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
//此页面为引导页面,后续更新成模板,暂时偷懒复制主游戏场景代码进来
var GameData_1 = require("./GameData");
var Notification_1 = require("./Notification");
var GameData_1 = require("./module/Config/GameData");
var AudioManager_1 = require("./module/Music/AudioManager");
var Notification_1 = require("./module/Notification/Notification");
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var NewClass = /** @class */ (function (_super) {
__extends(NewClass, _super);
@ -236,7 +237,7 @@ var NewClass = /** @class */ (function (_super) {
var _this = this;
if (this.begin == true) {
if (data == this.clickNow) {
GameData_1.default._instance.AudioManager.playAudioButton();
AudioManager_1.default._instance.playAudioButton();
if (this.clickNow > 0) {
this.createLine(cc.v2(this.ball_Array[this.clickNow - 1].x, this.ball_Array[this.clickNow - 1].y), cc.v2(this.ball_Array[this.clickNow].x, this.ball_Array[this.clickNow].y), 0.2);
}
@ -259,7 +260,7 @@ var NewClass = /** @class */ (function (_super) {
NewClass.prototype.loseLevel = function () {
var _this = this;
this.begin = false;
GameData_1.default._instance.AudioManager.playWarning();
AudioManager_1.default._instance.playWarning();
this.destroyLine();
var ball = this.ball_Array[0];
var _loop_2 = function (k) {
@ -301,11 +302,6 @@ var NewClass = /** @class */ (function (_super) {
}
this.ball_Array = [];
};
//获取时间戳
NewClass.prototype.getTime = function () {
var timestamp = new Date().getTime();
return timestamp;
};
//创造连线,参数起点,终点,连线时间
NewClass.prototype.createLine = function (start, end, time) {
var line = cc.instantiate(this.linePrefab);
@ -337,10 +333,10 @@ var NewClass = /** @class */ (function (_super) {
return -angle;
};
NewClass.prototype.onEnable = function () {
Notification_1.Notification.on("clickSun", this.clickSun, this);
Notification_1.Notifications.on("clickSun", this.clickSun, this);
};
NewClass.prototype.onDisable = function () {
Notification_1.Notification.off("clickSun", this.clickSun);
Notification_1.Notifications.off("clickSun", this.clickSun);
};
__decorate([
property(cc.Node)

File diff suppressed because one or more lines are too long

View File

@ -1 +0,0 @@
{"version":3,"sources":["assets\\Script\\tool\\DynamicAtlasManager.js"],"names":["cc","Class","Component","properties","onLoad","dynamicAtlasManager","enabled"],"mappings":";;;;;;AAAAA,EAAE,CAACC,KAAH,CAAS;AACL,aAASD,EAAE,CAACE,SADP;AAGLC,EAAAA,UAAU,EAAE,EAHP;AAMLC,EAAAA,MANK,oBAMK;AACNJ,IAAAA,EAAE,CAACK,mBAAH,CAAuBC,OAAvB,GAAiC,KAAjC;AACH;AARI,CAAT","sourceRoot":"/","sourcesContent":["cc.Class({\r\n extends: cc.Component,\r\n\r\n properties: {\r\n },\r\n\r\n onLoad () {\r\n cc.dynamicAtlasManager.enabled = false;\r\n },\r\n});\r\n"]}

View File

@ -0,0 +1,248 @@
"use strict";
cc._RF.push(module, '43bfcJ6/25Fs4fHUE0PeBOX', 'GameTool');
// Script/module/Tool/GameTool.ts
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.GameTool = void 0;
var GameData_1 = require("../Config/GameData");
var HttpUtil_1 = require("../Crypto/HttpUtil");
var Storage_1 = require("../Storage/Storage");
//最大工具类 各种公共方法,以及处理上传,获取后端接口数据
var GameTool = {
_startTime: 0,
_endTime: 0,
_totalTime: 0,
//获取userId
Authentication: function () {
var name = "user_" + GameData_1.default._instance.GM_INFO.gameId;
var data = JSON.parse(localStorage.getItem(name));
if (data == "undifend" || data == null || data == "") {
var url = "http://api.sparkus.cn/api/user/auth/login?domain=hui32579WdYPsgYq&callback=" + location.href;
window.location.href = url;
}
else {
Storage_1.StorageMessage.setStorage(name, data);
GameData_1.default._instance.GM_INFO.userId = parseInt(data.userId);
}
},
//埋点上传
setGameData: function () {
//GAME_DATA 初始化 每次清零
GameData_1.default._instance.GAME_DATA = [];
GameData_1.default._instance.GAME_DATA.push(GameData_1.default._instance.CLICK_DATA);
GameData_1.default._instance.CLICK_init();
var data = GameData_1.default._instance.GAME_DATA;
var matchId = this.getMatchId();
var postData = {
"gameId": GameData_1.default._instance.GM_INFO.gameId,
"userId": GameData_1.default._instance.GM_INFO.userId,
"matchId": matchId,
"data": data
};
// console.log("上传数据:")
HttpUtil_1.default.uploadUserLogData(postData, function () { });
},
//上传排行榜 type为1
setRank: function (data) {
//GAME_DATA 初始化 每次清零
var postData = {
"gameId": GameData_1.default._instance.GM_INFO.gameId,
"userId": GameData_1.default._instance.GM_INFO.userId,
"type": 1,
"reactionTime": data,
"totalSunCount": GameData_1.default._instance.GM_INFO.total,
"success": GameData_1.default._instance.GM_INFO.success
};
HttpUtil_1.default.rankData(1, function () { }, postData);
},
//获取排行榜 type为2
getRank: function (rankLength, callback) {
var postData = {
"gameId": GameData_1.default._instance.GM_INFO.gameId,
"userId": GameData_1.default._instance.GM_INFO.userId,
"page": 1,
"pageSize": rankLength
};
//回调进getRankData
HttpUtil_1.default.rankData(2, function (data) { callback(data); }, postData);
},
//获取matchId 用于上传每次点击数据里面记录id方便查询
getMatchId: function () {
var matchId = cc.sys.localStorage.getItem("matchId");
if (matchId == "undifend" || matchId == null) {
matchId = this.setMatchId();
}
else {
if (this.containsNanana(matchId) == true) {
matchId = this.setMatchId();
}
else {
var char = parseInt(matchId[10]);
if (this.level == 1) {
char += 1;
}
matchId = matchId.slice(0, 10) + char + "";
GameData_1.default._instance.GM_INFO.matchId = matchId;
cc.sys.localStorage.setItem("matchId", matchId);
}
}
return matchId;
},
//检测matchId 如果有缓存以前的nanana数据清除
containsNanana: function (str) {
return /na/i.test(str);
},
//重新设置MatchId
setMatchId: function () {
// 定义包含可用字符的字符集
var characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
// 创建一个数组以保存随机字符
var uuidArray = [];
// 循环10次 生成10位的UUID
for (var i = 0; i < 10; i++) {
// 生成随机索引,范围是字符集的长度
var randomIndex = Math.floor(Math.random() * characters.length);
// 从字符集中获取随机字符
var randomChar = characters.charAt(randomIndex);
// 将字符添加到数组中
uuidArray.push(randomChar);
}
var data = uuidArray.join('') + 1 + "";
cc.sys.localStorage.setItem("matchNumber", 1);
cc.sys.localStorage.setItem("matchId", data);
GameData_1.default._instance.GM_INFO.matchId = data;
return data;
},
//截取名字
subName: function (name, length) {
if (name.length > length) {
name = name.substring(0, length) + "...";
}
return name;
},
//设置头像
setPic: function (node, pic) {
node.active = false;
var url = pic;
setTimeout(function () {
fetch(url)
.then(function (response) {
return response.headers.get('Content-Length');
})
.then(function (errNo) {
if (errNo == "5093") {
node.active = true;
}
})
.catch(function (error) {
console.error('Error fetching X-Info:', error);
});
}, 100);
cc.assetManager.loadRemote(url, { ext: '.jpg' }, function (err, texture) {
if (texture) {
node.active = true;
node.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture);
}
else {
console.log(err, texture);
}
});
},
//第一个参数把目标带进来处理,第二个参数为名字长度,不同场景不同需求
//名字4短小排行名字6长大排行
getRankData: function (data, target, nameLength) {
target.listData = data.data.list;
target.selfData = data.data.info;
var rankData = [];
var self = false;
GameTool.setPic(target.selfNode.getChildByName("pic").getChildByName("icon"), target.selfData.pic);
for (var i = 0; i <= target.listData.length - 1; i++) {
rankData.push({ rank: (i + 1), name: target.listData[i].nickName, total: target.listData[i].totalSunCount, pic: target.listData[i].pic });
if (GameData_1.default._instance.GM_INFO.userId == target.listData[i].userId) {
self = true;
target.selfNode.getChildByName("rankLab").getComponent(cc.Label).string = (i + 1) + "";
}
if (i == (target.listData.length - 1) && self == false) {
target.selfNode.getChildByName("rankLab").getComponent(cc.Label).string = "99+";
}
}
GameTool.subName(target.selfData.nickName, nameLength);
target.selfNode.getChildByName("nameLab").getComponent(cc.Label).string = target.selfData.nickName;
target.selfNode.getChildByName("totalLab").getComponent(cc.Label).string = target.selfData.totalSunCount;
switch (target.selfNode.getChildByName("rankLab").getComponent(cc.Label).string) {
case "1":
target.selfNode.getChildByName("rank").getChildByName("one").active = true;
break;
case "2":
target.selfNode.getChildByName("rank").getChildByName("two").active = true;
break;
case "3":
target.selfNode.getChildByName("rank").getChildByName("three").active = true;
break;
}
//大排行
if (nameLength == 6) {
target.rankList.setData(rankData);
target.selfNode.opacity = 255;
if (target.selfData.totalSunCount == 0)
target.selfNode.opacity = 0;
}
},
getSetScreenResolutionFlag: function () {
var size = cc.winSize;
var width = size.width;
var height = size.height;
if ((height / width) > (16.2 / 9))
return false;
return true;
},
//判断全面屏适配
setFit: function (canvas) {
var flag = GameTool.getSetScreenResolutionFlag();
if (flag) {
// console.log("不是全面屏");
}
else {
// console.log("是全面屏");
}
return flag;
},
//获取游戏信息
getGameInfo: function (node) {
var jg = false;
return jg;
},
//设置游戏信息
setGameInfo: function (pd) {
},
//输入秒,返回需要展示时间格式
getTimeMargin: function (second) {
var total = 0;
total = second;
var hour = 0;
hour = parseInt((total / 3600) + ""); //计算整数小时数
var afterHour = total - hour * 60 * 60; //取得算出小时数后剩余的秒数
var min = parseInt((afterHour / 60) + ""); //计算整数分
var m = "" + min;
if (min < 10)
m = "0" + min;
var afterMin = total - hour * 60 * 60 - min * 60; //取得算出分后剩余的秒数
var miao = afterMin + "";
if (afterMin < 10)
miao = "0" + afterMin;
return m + ':' + miao;
},
//获取时间戳
getTime: function () {
var timestamp = new Date().getTime();
return timestamp;
},
pushLister: function () {
},
removeAllLister: function () {
},
};
exports.GameTool = GameTool;
cc._RF.pop();

File diff suppressed because one or more lines are too long

View File

@ -24,68 +24,15 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
};
Object.defineProperty(exports, "__esModule", { value: true });
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property, requireComponent = _a.requireComponent;
var GameData_1 = require("./GameData");
var Storage_1 = require("./Storage");
var GameData_1 = require("./module/Config/GameData");
var GameTool_1 = require("./module/Tool/GameTool");
var NewClass = /** @class */ (function (_super) {
__extends(NewClass, _super);
function NewClass() {
return _super !== null && _super.apply(this, arguments) || this;
}
NewClass.prototype.start = function () {
this.Authentication();
};
//鉴权判断有无缓存userid,有的话判断是否过期没有的话重新获取userid 并且缓存上
NewClass.prototype.Authentication = function () {
var name = "user_" + GameData_1.default._instance.GM_INFO.gameId;
var data = Storage_1.StorageMessage.getStorage(name);
if (data == "undifend" || data == null || data == "") {
console.log("没缓存");
this.setUserId(name);
}
else {
console.log("有缓存");
var timestamp = parseInt(new Date().getTime() / 1000 + "");
if ((timestamp - data.time) > 86400) {
console.log("缓存过期");
this.setUserId(name);
return;
}
GameData_1.default._instance.GM_INFO.userId = parseInt(data.userId);
}
};
//设置userId,链接有获取,没有跳转授权
NewClass.prototype.setUserId = function (name) {
GameData_1.default._instance.GM_INFO.userId = this.getUserId();
if (GameData_1.default._instance.GM_INFO.userId == null) {
console.log("链接没ID准备跳转");
var url = "http://api.sparkus.cn/api/user/auth/login?domain=hui32579WdYPsgYq&callback=" + location.href;
window.location.href = url;
}
else {
var timestamp = parseInt(new Date().getTime() / 1000 + "");
var idData = {
userId: GameData_1.default._instance.GM_INFO.userId + "",
time: timestamp
};
Storage_1.StorageMessage.setStorage(name, idData);
console.log("有ID", GameData_1.default._instance.GM_INFO.userId);
GameData_1.default._instance.GM_INFO.userId = parseInt(GameData_1.default._instance.GM_INFO.userId);
}
};
//获取user id 有参数为获取gameid userid 时间戳, 无参数为只获取链接尾缀上的userId
NewClass.prototype.getUserId = function () {
var pathStr = window.location.search;
var arr = pathStr.split("&");
if (pathStr.length >= 0 && arr.length > 0) {
var arr2_1 = [];
arr.map(function (item) {
arr2_1.push(item.split("=")[1]);
});
return arr2_1[0];
}
else {
return null;
}
GameTool_1.GameTool.Authentication();
};
//开始游戏,跳转至引导页面
NewClass.prototype.startGame = function () {

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -3,12 +3,6 @@ cc._RF.push(module, '4be67sdkexCyqLl0NHd9N1f', 'Sun');
// Script/Sun.ts
"use strict";
// Learn TypeScript:
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
@ -30,7 +24,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
};
Object.defineProperty(exports, "__esModule", { value: true });
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var Notification_1 = require("./Notification");
var Notification_1 = require("./module/Notification/Notification");
var NewClass = /** @class */ (function (_super) {
__extends(NewClass, _super);
function NewClass() {
@ -77,13 +71,13 @@ var NewClass = /** @class */ (function (_super) {
.start();
this.touch = false;
this.node.zIndex = -1;
Notification_1.Notification.emit("clickSun", this.id_Number);
Notification_1.Notifications.emit("clickSun", this.id_Number);
}
}
else {
this.touch = false;
this.node.zIndex = -1;
Notification_1.Notification.emit("clickSun", this.id_Number);
Notification_1.Notifications.emit("clickSun", this.id_Number);
}
}
}
@ -91,7 +85,7 @@ var NewClass = /** @class */ (function (_super) {
if (this.touch == true && this.node.parent.parent.getComponent("GuideManager").begin == true) {
this.touch = false;
this.node.zIndex = -1;
Notification_1.Notification.emit("clickSun", this.id_Number);
Notification_1.Notifications.emit("clickSun", this.id_Number);
}
}
};

File diff suppressed because one or more lines are too long

View File

@ -1,12 +1,12 @@
"use strict";
cc._RF.push(module, 'f2518+0IHRGOY+ueIhGtEeA', 'Notification');
// Script/Notification.ts
cc._RF.push(module, '55403VjGlpPL564gsdiZBg3', 'Notification');
// Script/module/Notification/Notification.ts
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Notification = void 0;
exports.Notifications = void 0;
//全局通知
var Notification = {
var Notifications = {
_eventMap: [],
on: function (masgId, callback, target) {
if (this._eventMap[masgId] === undefined) {
@ -47,6 +47,6 @@ var Notification = {
}
}
};
exports.Notification = Notification;
exports.Notifications = Notifications;
cc._RF.pop();

View File

@ -0,0 +1 @@
{"version":3,"sources":["assets\\Script\\module\\Notification\\Notification.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAM;AACN,IAAI,aAAa,GAAG;IAChB,SAAS,EAAE,EAAE;IACb,EAAE,EAAE,UAAU,MAAM,EAAE,QAAQ,EAAE,MAAM;QAClC,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,SAAS,EAAE;YACtC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;SAC/B;QACD,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACxE,CAAC;IAED,IAAI,EAAE,UAAU,MAAM,EAAE,SAAS;QAC7B,IAAI,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACnC,IAAI,KAAK,KAAK,SAAS;YAAE,OAAO;QAEhC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACnC,IAAI,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YACvB,IAAI,OAAO;gBAAE,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;SACjE;IACL,CAAC;IAED,GAAG,EAAE,UAAU,MAAM,EAAE,QAAQ;QAC3B,IAAI,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACnC,IAAI,KAAK,KAAK,SAAS;YAAE,OAAO;QAChC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACnC,IAAI,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YACvB,IAAI,OAAO,IAAI,OAAO,CAAC,QAAQ,KAAK,QAAQ,EAAE;gBAC1C,KAAK,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;gBACrB,MAAM;aACT;SACJ;IACL,CAAC;IAED,SAAS,EAAE,UAAU,MAAM;QACvB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;IACvC,CAAC;IAED,YAAY,EAAE;QACV,KAAK,IAAI,CAAC,IAAI,IAAI,CAAC,SAAS,EAAE;YAC1B,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE;gBACnB,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;aACrB;SACJ;IACL,CAAC;CACJ,CAAC;AACO,sCAAa","file":"","sourceRoot":"/","sourcesContent":["//全局通知\nvar Notifications = {\n _eventMap: [],\n on: function (masgId, callback, target) {\n if (this._eventMap[masgId] === undefined) {\n this._eventMap[masgId] = [];\n }\n this._eventMap[masgId].push({ callback: callback, target: target });\n },\n\n emit: function (masgId, parameter) {\n let array = this._eventMap[masgId];\n if (array === undefined) return;\n\n for (let i = 0; i < array.length; i++) {\n let element = array[i];\n if (element) element.callback.call(element.target, parameter);\n }\n },\n\n off: function (masgId, callback) {\n let array = this._eventMap[masgId];\n if (array === undefined) return;\n for (let i = 0; i < array.length; i++) {\n let element = array[i];\n if (element && element.callback === callback) {\n array[i] = undefined;\n break;\n }\n }\n },\n\n offMasgId: function (masgId) {\n this._eventMap[masgId] = undefined;\n },\n\n removeAllMsg: function () {\n for (let k in this._eventMap) {\n if (this._eventMap[k]) {\n this.offMasgId(k);\n }\n }\n }\n};\nexport { Notifications };"]}

View File

@ -0,0 +1,274 @@
"use strict";
cc._RF.push(module, '58403/n16JCa5sZhNMjZzGo', 'AudioManager');
// Script/module/Music/AudioManager.ts
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var AudioManager = /** @class */ (function (_super) {
__extends(AudioManager, _super);
function AudioManager() {
var _this = _super !== null && _super.apply(this, arguments) || this;
//背景音乐
_this.audioGameBgm0 = null;
//跳跃
_this.audioButtonClick = null;
//落地上
_this.audioWarning = null;
//碰撞
_this.audioWin = null;
return _this;
}
AudioManager_1 = AudioManager;
AudioManager.playWarning = function () {
throw new Error('Method not implemented.');
};
AudioManager.prototype.ctor = function () {
this.mAudioMap = {};
/**
* 默认音量大小
* @type {number}
*/
this.bgMusicVolume = 0.1;
this.effectMusicVolume = 1;
this.mMusicSwitch = 1;
this.mEffectSwitch = 1;
};
AudioManager.prototype.play = function (audioSource, loop, callback, isBgMusic) {
if (isBgMusic && !this.mMusicSwitch)
return;
if (!isBgMusic && !this.mEffectSwitch)
return;
var volume = isBgMusic ? this.bgMusicVolume : this.effectMusicVolume;
if (cc.sys.isBrowser) {
if (audioSource == this.brickSound) {
volume = 0.1;
}
volume = 1;
var context = cc.audioEngine.play(audioSource, loop, volume);
if (callback) {
cc.audioEngine.setFinishCallback(context, function () {
callback.call(this);
}.bind(this));
}
// cc.wwx.OutPut.log('play audio effect isBrowser: ' + context.src);
this.mAudioMap[audioSource] = context;
return audioSource;
}
else {
return audioSource;
}
};
AudioManager.prototype.save = function () {
// cc.wwx.Storage.setItem(cc.wwx.Storage.Key_Setting_Music_Volume, this.mMusicSwitch);
// cc.wwx.Storage.setItem(cc.wwx.Storage.Key_Setting_Effect_Volume, this.mEffectSwitch);
};
AudioManager.prototype.onLoad = function () {
if (AudioManager_1._instance == null) {
AudioManager_1._instance = this;
cc.game.addPersistRootNode(this.node);
}
else {
this.node.destroy();
return;
}
this.reward = false;
this.finish = false;
this.rewardCount = 0;
this.ctor();
this.preload();
};
AudioManager.prototype.preload = function () {
if (!(cc.sys.platform === cc.sys.WECHAT_GAME)) {
return;
}
var musics = [
this.audioGameBgm0,
];
musics.forEach(function (path) {
// var musicPath = wxDownloader.REMOTE_SERVER_ROOT + path;
// if (musicPath != wxDownloader.REMOTE_SERVER_ROOT && musicPath.endsWith('.mp3')) {
// cc.loader.load(musicPath, function(err, remoteUrl) {
// if (err) {
// cc.error(err.message || err);
// return;
// }
// });
// }
});
};
AudioManager.prototype.getAudioMusicSwitch = function () {
return this.mMusicSwitch;
};
AudioManager.prototype.getAudioEffectSwitch = function () {
return this.mEffectSwitch;
};
AudioManager.prototype.trunAudioSound = function (on) {
this.switchMusic(on);
this.switchEffect(on);
};
AudioManager.prototype.switchMusic = function (on) {
if (this.mMusicSwitch != (on ? 1 : 0)) {
this.mMusicSwitch = 1 - this.mMusicSwitch;
// this.save();
}
if (on) {
this.playMusicGame();
}
else {
this.stopMusic();
}
};
AudioManager.prototype.switchEffect = function (on) {
if (this.mEffectSwitch != (on ? 1 : 0)) {
this.mEffectSwitch = 1 - this.mEffectSwitch;
// this.save();
}
};
AudioManager.prototype.onHide = function () {
cc.audioEngine.pauseAll();
// if (CC_JSB) {
// } else {
// for (var key in this.mAudioMap) {
// if (key === this.mMusicKey) {
// this.mAudioMap[key].pause();
// } else {
// this.mAudioMap[key].stop();
// }
// }
// }
};
AudioManager.prototype.onShow = function () {
cc.audioEngine.resumeAll();
// if (CC_JSB) {
// } else {
// if (!this.mMusicSwitch) return;
// var context = this.mAudioMap[this.mMusicKey];
// if (context) {
// context.play();
// }
// }
};
AudioManager.prototype.playMusic = function (key, callback, loop) {
loop = typeof loop == 'undefined' || loop ? true : false;
this.stopMusic();
this.mMusicKey = this.play(key, loop, callback, true);
};
/**
* 游戏背景音乐
*/
AudioManager.prototype.playMusicGame = function () {
this.playMusic(this.audioGameBgm0, {}, true);
};
/**
* 停止背景音乐播放
*/
AudioManager.prototype.stopMusic = function () {
// cc.wwx.OutPut.log('stopMusic audio effect wx: ' + this.mMusicKey);
var context = this.mAudioMap[this.mMusicKey];
if (typeof (context) != 'undefined') {
if (cc.sys.isBrowser) {
cc.audioEngine.stop(context);
}
else {
context.stop();
}
cc.audioEngine.stop(context);
}
};
// 炸弹、火箭爆炸音效
AudioManager.prototype.playWin = function () {
return this.play(this.audioWin, false, null, this.mEffectSwitch);
};
//激光音效
AudioManager.prototype.playWarning = function () {
return this.play(this.audioWarning, false, null, this.mEffectSwitch);
};
/*
* 游戏开始音效
*
*/
AudioManager.prototype.playGameStart = function () {
};
/*
* 失败的游戏结束
*/
AudioManager.prototype.playGameOver = function () {
};
/*
* 成功的游戏结束
*/
AudioManager.prototype.playGameResultFailed = function () {
};
/*
* 成功的游戏结束
*/
AudioManager.prototype.playGameResultSuccess = function () {
};
/**
* 报警的音效
*/
/*
* 方块碰撞的声音
*/
AudioManager.prototype.playBrick = function () {
// return this.play(this.brickSound,false);
};
//方块破碎的声音
AudioManager.prototype.brickBoom = function () {
};
/**
* 按钮
*/
AudioManager.prototype.playAudioButton = function () {
return this.play(this.audioButtonClick, false, null, this.mEffectSwitch);
};
AudioManager.prototype.playRandomMatch = function () {
this.playMusic(this.audioGameBgm0, {}, true);
};
AudioManager.prototype.playMatchFoundSound = function () {
this.stopMusic();
// return this.play(this.matchFoundSound, false);
};
var AudioManager_1;
__decorate([
property(cc.AudioClip)
], AudioManager.prototype, "audioGameBgm0", void 0);
__decorate([
property(cc.AudioClip)
], AudioManager.prototype, "audioButtonClick", void 0);
__decorate([
property(cc.AudioClip)
], AudioManager.prototype, "audioWarning", void 0);
__decorate([
property(cc.AudioClip)
], AudioManager.prototype, "audioWin", void 0);
AudioManager = AudioManager_1 = __decorate([
ccclass
], AudioManager);
return AudioManager;
}(cc.Component));
exports.default = AudioManager;
;
// export { AudioManager };
cc._RF.pop();

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
"use strict";
cc._RF.push(module, '3ffacOneORCf6Bc1LFhTCCQ', 'DynamicAtlasManager');
// Script/tool/DynamicAtlasManager.js
cc._RF.push(module, '5c9b8FZiaNLMrMDs9T3rByf', 'DynamicAtlasManager');
// Script/DynamicAtlasManager.js
"use strict";

View File

@ -0,0 +1 @@
{"version":3,"sources":["assets\\Script\\DynamicAtlasManager.js"],"names":["cc","Class","Component","properties","onLoad","dynamicAtlasManager","enabled"],"mappings":";;;;;;AAAAA,EAAE,CAACC,KAAH,CAAS;AACL,aAASD,EAAE,CAACE,SADP;AAGLC,EAAAA,UAAU,EAAE,EAHP;AAMLC,EAAAA,MANK,oBAMK;AACNJ,IAAAA,EAAE,CAACK,mBAAH,CAAuBC,OAAvB,GAAiC,KAAjC;AACH;AARI,CAAT","sourceRoot":"/","sourcesContent":["cc.Class({\r\n extends: cc.Component,\r\n\r\n properties: {\r\n },\r\n\r\n onLoad () {\r\n cc.dynamicAtlasManager.enabled = false;\r\n },\r\n});\r\n"]}

View File

@ -1,54 +0,0 @@
"use strict";
cc._RF.push(module, '61affD5SO9Ipo0fGmIeTFTZ', 'Shake');
// Script/tool/Shake.js
"use strict";
/**
* 自定义抖动效果
*/
var Shake = cc.Class({
"extends": cc.Component,
properties: {
//抖动时间
duration: 0,
//X轴抖动范围
shakeX: 0,
shakeY: 0
},
shake: function shake(callback) {
if (this.shaking) {
return;
}
this.callback = callback;
this.shaking = true;
this.dtCost = 0;
this.nodeInitialPos = this.node.getPosition();
this.unschedule(this.doSchedule);
this.schedule(this.doSchedule, 0, cc.macro.REPEAT_FOREVER, 0);
},
doSchedule: function doSchedule(dt) {
var dt2 = dt * 50;
var randX = this.getRandomStrength(-this.shakeX, this.shakeX) * dt2;
var randY = this.getRandomStrength(-this.shakeY, this.shakeY) * dt2;
this.node.setPosition(cc.pAdd(this.nodeInitialPos, cc.v2(randX, randY)));
this.dtCost += dt;
if (this.dtCost >= this.duration) {
this.unschedule(this.doSchedule);
this.node.setPosition(this.nodeInitialPos);
this.shaking = false;
if (this.callback) {
this.callback();
}
}
},
//获取两个数间的随机值
getRandomStrength: function getRandomStrength(min, max) {
return Math.random() * (max - min + 1) + min;
}
});
cc._RF.pop();

View File

@ -1 +0,0 @@
{"version":3,"sources":["assets\\Script\\tool\\Shake.js"],"names":["Shake","cc","Class","Component","properties","duration","shakeX","shakeY","shake","callback","shaking","dtCost","nodeInitialPos","node","getPosition","unschedule","doSchedule","schedule","macro","REPEAT_FOREVER","dt","dt2","randX","getRandomStrength","randY","setPosition","pAdd","v2","min","max","Math","random"],"mappings":";;;;;;AAAA;AACA;AACA;AACA,IAAIA,KAAK,GAAGC,EAAE,CAACC,KAAH,CAAS;AACjB,aAASD,EAAE,CAACE,SADK;AAGjBC,EAAAA,UAAU,EAAE;AACR;AACAC,IAAAA,QAAQ,EAAE,CAFF;AAGR;AACAC,IAAAA,MAAM,EAAE,CAJA;AAKRC,IAAAA,MAAM,EAAE;AALA,GAHK;AAWjBC,EAAAA,KAAK,EAAE,eAAUC,QAAV,EAAoB;AACvB,QAAG,KAAKC,OAAR,EAAgB;AACZ;AACH;;AACD,SAAKD,QAAL,GAAgBA,QAAhB;AACA,SAAKC,OAAL,GAAe,IAAf;AACA,SAAKC,MAAL,GAAc,CAAd;AACA,SAAKC,cAAL,GAAsB,KAAKC,IAAL,CAAUC,WAAV,EAAtB;AACA,SAAKC,UAAL,CAAgB,KAAKC,UAArB;AACA,SAAKC,QAAL,CAAc,KAAKD,UAAnB,EAA+B,CAA/B,EAAkCf,EAAE,CAACiB,KAAH,CAASC,cAA3C,EAA2D,CAA3D;AACH,GArBgB;AAsBjBH,EAAAA,UAAU,EAAE,oBAAUI,EAAV,EAAc;AACtB,QAAIC,GAAG,GAAGD,EAAE,GAAG,EAAf;AACA,QAAIE,KAAK,GAAG,KAAKC,iBAAL,CAAuB,CAAC,KAAKjB,MAA7B,EAAqC,KAAKA,MAA1C,IAAoDe,GAAhE;AACA,QAAIG,KAAK,GAAG,KAAKD,iBAAL,CAAuB,CAAC,KAAKhB,MAA7B,EAAqC,KAAKA,MAA1C,IAAoDc,GAAhE;AACA,SAAKR,IAAL,CAAUY,WAAV,CAAsBxB,EAAE,CAACyB,IAAH,CAAQ,KAAKd,cAAb,EAA6BX,EAAE,CAAC0B,EAAH,CAAML,KAAN,EAAaE,KAAb,CAA7B,CAAtB;AACA,SAAKb,MAAL,IAAeS,EAAf;;AACA,QAAI,KAAKT,MAAL,IAAe,KAAKN,QAAxB,EAAkC;AAC9B,WAAKU,UAAL,CAAgB,KAAKC,UAArB;AACA,WAAKH,IAAL,CAAUY,WAAV,CAAsB,KAAKb,cAA3B;AACA,WAAKF,OAAL,GAAe,KAAf;;AACA,UAAG,KAAKD,QAAR,EAAiB;AACb,aAAKA,QAAL;AACH;AACJ;AACJ,GApCgB;AAqCjB;AACAc,EAAAA,iBAAiB,EAAE,2BAAUK,GAAV,EAAeC,GAAf,EAAoB;AACnC,WAAOC,IAAI,CAACC,MAAL,MAAiBF,GAAG,GAAGD,GAAN,GAAY,CAA7B,IAAkCA,GAAzC;AACH;AAxCgB,CAAT,CAAZ","sourceRoot":"/","sourcesContent":["/**\r\n * 自定义抖动效果\r\n */\r\nvar Shake = cc.Class({\r\n extends: cc.Component,\r\n\r\n properties: {\r\n //抖动时间\r\n duration: 0,\r\n //X轴抖动范围\r\n shakeX: 0,\r\n shakeY: 0,\r\n },\r\n\r\n shake: function (callback) {\r\n if(this.shaking){\r\n return;\r\n }\r\n this.callback = callback;\r\n this.shaking = true;\r\n this.dtCost = 0;\r\n this.nodeInitialPos = this.node.getPosition();\r\n this.unschedule(this.doSchedule);\r\n this.schedule(this.doSchedule, 0, cc.macro.REPEAT_FOREVER, 0);\r\n },\r\n doSchedule: function (dt) {\r\n var dt2 = dt * 50;\r\n var randX = this.getRandomStrength(-this.shakeX, this.shakeX) * dt2;\r\n var randY = this.getRandomStrength(-this.shakeY, this.shakeY) * dt2;\r\n this.node.setPosition(cc.pAdd(this.nodeInitialPos, cc.v2(randX, randY)));\r\n this.dtCost += dt;\r\n if (this.dtCost >= this.duration) {\r\n this.unschedule(this.doSchedule);\r\n this.node.setPosition(this.nodeInitialPos);\r\n this.shaking = false;\r\n if(this.callback){\r\n this.callback();\r\n }\r\n }\r\n },\r\n //获取两个数间的随机值\r\n getRandomStrength: function (min, max) {\r\n return Math.random() * (max - min + 1) + min;\r\n },\r\n});\r\n"]}

View File

@ -0,0 +1,159 @@
"use strict";
cc._RF.push(module, '61d4ccY2ztLMYIh8WvqPPAw', 'GameAppStart');
// Script/module/GameStart/GameAppStart.ts
window.initMgr = function () {
if (cc.fx) {
return;
}
cc.fx = {};
console.log("初始化");
//基础状态信息
cc.fx.StateInfo = {
debugMode: true,
networkConnected: true,
networkType: 'none',
isOnForeground: true //当前是否是在前台
};
cc.fx.ShareInfo = {
queryId: -1 //分享id
};
/*
* 客户端埋点分享类型
*/
cc.fx.BurialShareType = {
Default: "default",
Invite: "invite",
DailyInviteRoomJoin: 'invite_join_room',
DailyInviteFriend: 'invite_friend',
DailyInviteGroup: 'invate_group',
DailyInviteGroupAlive: 'invate_alive',
DailyInviteGroupReward: 'invate_rewared',
DailyInviteGroupBox: 'invate_box',
DailyInviteGroupBall: 'invate_ball',
MatchResult: 'matchResult',
MatchFix5: 'MatchFix5',
MatchFix20: 'MatchFix20',
MatchFix100: 'MatchFix100',
MatchFix500: 'MatchFix500',
NewerRedEnvelope: 'newerRedEnvelope',
CoinRoomResult: 'coinRoomResult',
HighRate: "highRate",
CoinRoomWinStreak: 'coinRoomWinStreak',
CoinRoomBankruptcy1: 'coinRoomBankruptcy1',
CoinRoomBankruptcy2: 'coinRoomBankruptcy2',
CoinRoomBankruptcy3: 'coinRoomBankruptcy3',
};
cc.fx.BurialShareConfig = {
invite: {
oneGroupDayCount: 1 //同一个群一天最多分享次数:超过次数将不再向服务器获取奖励,并且提醒用户分享到不同的群
},
FetchGroupID: {
oneGroupDayCount: 1 //同一个群一天最多分享次数:超过次数将不再向服务器获取奖励,并且提醒用户分享到不同的群
},
SegmentUp: {
painting: true,
},
RankNotify: {
painting: true,
},
FTResult: {
painting: true,
},
highRate: {
painting: true,
},
matchResult: {
painting: true,
},
MatchFix5: {
painting: true,
},
MatchFix20: {
painting: true,
},
MatchFix100: {
painting: true,
},
MatchFix500: {
painting: true,
},
coinRoomWinStreak: {
painting: true,
},
};
/*
* 分享到哪儿给奖励 group frined all
*/
cc.fx.ShareWhereReward = {
Group: "group",
Friend: "friend",
All: "all",
};
/**
* 日志相关方法,若不符合项目组标准,可自行进行扩展
*/
cc.fx.OUTPUT_LOG = 1;
cc.fx.OUTPUT_INFO = 1 << 1;
cc.fx.OUTPUT_WARN = 1 << 2;
cc.fx.OUTPUT_ERR = 1 << 3;
cc.fx.OUTPUT_LV = cc.fx.OUTPUT_ERR | cc.fx.OUTPUT_WARN | cc.fx.OUTPUT_INFO | cc.fx.OUTPUT_LOG;
cc.fx.clickStatEventType = {
clickStatEventTypeVideoAD: 20173201,
clickStatEventTypeClickAdVideo: 20173202,
clickStatEventTypeBannerAD: 20173203,
clickStatEventTypeUserFrom: 99990001,
clickStatEventTypeShare: 99990002,
clickStatEventTypeClickAdBtn: 99990007,
clickStatEventTypeBannerAD2: 67890033,
clickStatEventTypeSubmitVersionInfo: 9999,
clickStatEventTypeClickFirstAd: 99990003,
clickStatEventTypeClickSecondAd: 99990004,
clickStatEventTypeWxLoginStart: 10001,
clickStatEventTypeWxLoginSuccess: 10002,
clickStatEventTypeWxLoginFailed: 10003,
clickStatEventTypeAuthorizationStart: 10003,
clickStatEventTypeAuthorizationSuccess: 10004,
clickStatEventTypeAuthorizationFailed: 10005,
clickStatEventTypeLoginSDKStart: 10007,
clickStatEventTypeLoginSDKSuccess: 10008,
clickStatEventTypeLoginSDKFailed: 10009,
clickStatEventTypeTCP_Start: 10009,
clickStatEventTypeTCP_Success: 10010,
clickStatEventTypeTCP_Failed: 10011,
};
//应用系统信息
// cc.fx.SystemInfo = require("../BallSDK/BallSystemInfo");
// cc.fx.SystemInfo.init();
// cc.fx.EventType = require("../BallSDK/BallEventType");
// cc.fx.UserInfo = require("../BallGame/UserInfo");
// cc.fx.OutPut = require("../BallUtil/LogOutPut");
// cc.fx.HttpUtil= require("../BallSDK/BallHttpUtil");
// cc.fx.EncodeDecode = require("../BallUtil/BallEncodeDecode");
// cc.fx.NotificationCenter = require("../BallUtil/BallNotificationCenter");
// cc.fx.Timer = require("../BallUtil/BallTimer");
// cc.fx.Util = require("../BallUtil/BallUtil");
// cc.fx.TCPMSG = require("../BallSDK/BallTCP_Msg");
// cc.fx.TCPRECEIVER = require("../BallSDK/BallTCP_Receiver");
// cc.fx.TCPRECEIVER.init();
// cc.fx.Loader = require("../BallUtil/BallLoader");
// cc.fx.PopWindowManager = require("../BallWindow/BallPopWindonwManager");
// cc.fx.PopWindowManager.preload();
// cc.fx.TipManager = require("../BallWindow/TipWindowManager");
// cc.fx.PayModel = require("../BallModel/BallPayModel");
// cc.fx.SceneManager = require("../BallUtil/BallSceneManager");
// cc.fx.MapCheckPoint = require("../BallUtil/MapCheckPointManager");
// cc.fx.MapCheckPoint.initMapCheckPointBallInfo();
// cc.fx.MapPointScore = require("../BallCheckPoint/CheckPointScore");
// cc.fx.Storage = require('../BallUtil/BallStorage');
// if (cc.sys.isBrowser) {
// cc.fx.Storage = require('../BallUtil/BallStorage');
// } else {
// cc.fx.Storage = require('../BallUtil/WeChatStorage');
// }
// cc.fx.Gift = require("../BallModel/BallGiftBox");
// cc.fx.Invite = require('../BallModel/BallInvite');
// cc.fx.ClientConf = require("../BallModel/BallClientConf");
};
cc._RF.pop();

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,318 @@
"use strict";
cc._RF.push(module, '771a32aQBNGVKd3+66gyTKA', 'HttpUtil');
// Script/module/Crypto/HttpUtil.ts
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var GameData_1 = require("../Config/GameData");
var CryptoJS = require("./crypto-js.min.js"); //引用AES源码js
var BASE_URL = "http://api.sparkus.cn";
var HttpUtil = /** @class */ (function (_super) {
__extends(HttpUtil, _super);
function HttpUtil() {
return _super !== null && _super.apply(this, arguments) || this;
}
//排行榜type2为获取type1为上传
HttpUtil.rankData = function (type, callback, data) {
return __awaiter(this, void 0, Promise, function () {
var time, url;
return __generator(this, function (_a) {
data.gameId = GameData_1.default._instance.GM_INFO.gameId;
data.userId = GameData_1.default._instance.GM_INFO.userId;
time = Math.floor((new Date().getTime()) / 1000);
url = apiSign("/api/get/rank/data?gameId=" + config.gameId + "&dataType=" + type + "&time=" + time, data);
this.post(url, data, callback);
return [2 /*return*/];
});
});
};
HttpUtil.uploadUserLogData = function (data, callback) {
return __awaiter(this, void 0, Promise, function () {
var url;
return __generator(this, function (_a) {
data.gameId = GameData_1.default._instance.GM_INFO.gameId;
data.userId = GameData_1.default._instance.GM_INFO.userId;
url = '/log/collect/data';
this.post(url, data, callback);
return [2 /*return*/];
});
});
};
//暂时用不到
HttpUtil.getUserRecord = function (data, callback) {
return __awaiter(this, void 0, Promise, function () {
var time, url;
return __generator(this, function (_a) {
data.gameId = GameData_1.default._instance.GM_INFO.gameId;
data.userId = GameData_1.default._instance.GM_INFO.userId;
time = Math.floor((new Date().getTime()) / 1000);
url = apiSign("/api/get/user/data?gameId=" + config.gameId + "&time=" + time, data);
this.post(url, data, callback);
return [2 /*return*/];
});
});
};
HttpUtil.post = function (url, data, callback) {
return __awaiter(this, void 0, void 0, function () {
var response;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.fetchData(url, data, 'POST')];
case 1:
response = _a.sent();
callback && callback(response);
return [2 /*return*/];
}
});
});
};
HttpUtil.get = function (url, callback) {
return __awaiter(this, void 0, void 0, function () {
var response;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.fetchData(url, null, 'GET')];
case 1:
response = _a.sent();
callback && callback(response);
return [2 /*return*/];
}
});
});
};
HttpUtil.fetchData = function (url, data, method) {
return __awaiter(this, void 0, void 0, function () {
var fullUrl, headers, options, response, error_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
fullUrl = "" + BASE_URL + url;
headers = { 'Content-Type': 'application/json' };
options = {
method: method,
headers: headers,
body: data ? JSON.stringify(data) : null,
};
_a.label = 1;
case 1:
_a.trys.push([1, 4, , 5]);
return [4 /*yield*/, fetch(fullUrl, options)];
case 2:
response = _a.sent();
if (!response.ok) {
throw new Error("HTTP error! status: " + response.status);
}
return [4 /*yield*/, response.json()];
case 3: return [2 /*return*/, _a.sent()];
case 4:
error_1 = _a.sent();
console.error('Fetch error:', error_1);
return [2 /*return*/, null];
case 5: return [2 /*return*/];
}
});
});
};
HttpUtil = __decorate([
ccclass
], HttpUtil);
return HttpUtil;
}(cc.Component));
exports.default = HttpUtil;
function responseHandler(response) {
return response.data;
}
// 响应拦截器
// Rq.interceptors.response.use(responseHandler)
var config = {
gameId: "100009",
secretKey: "CMNhOzBA",
EK: "hui231%1"
};
var Crypoto = /** @class */ (function () {
function Crypoto() {
// 加密的向明值,自己根据项目实际情况定,需要跟后端开发保持一致
this.keyHex = this.getHetKey();
}
Crypoto.prototype.getHetKey = function () {
return CryptoJS.enc.Utf8.parse(config.EK);
};
/** DES加密 */
Crypoto.prototype.encryptByDES = function (message, secret) {
if (!message) {
return message;
}
var key = secret ? CryptoJS.enc.Utf8.parse(secret) : this.keyHex;
var encrypted = CryptoJS.DES.encrypt(message, key, {
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7
});
return encrypted.toString();
};
/** DES解密 */
Crypoto.prototype.decryptByDES = function (message, secret) {
var key = secret ? CryptoJS.enc.Utf8.parse(secret) : this.keyHex;
var decrypted = CryptoJS.DES.decrypt({
ciphertext: CryptoJS.enc.Base64.parse(message)
}, key, {
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7
});
return decrypted.toString(CryptoJS.enc.Utf8);
};
/** hmacSHA256加密 */
Crypoto.prototype.hmacSha256 = function (message, secret) {
var keyHex = secret ? CryptoJS.enc.Utf8.parse(secret) : this.keyHex;
var hash = CryptoJS.HmacSHA256(message, keyHex);
return hash.toString();
};
/** hmacSHA256验证 */
Crypoto.prototype.verifyHmacSha256 = function (message, signature) {
var hash = CryptoJS.HmacSHA256(message, this.keyHex);
return hash.toString() === signature;
};
/** CBC加密 */
Crypoto.prototype.encryptCBC = function (word) {
if (!word) {
return word;
}
var srcs = CryptoJS.enc.Utf8.parse(word);
var encrypted = CryptoJS.AES.encrypt(srcs, this.keyHex, {
iv: this.keyHex,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.ZeroPadding
});
return encrypted.toString();
};
/** CBC解密 */
Crypoto.prototype.decryptCBC = function (word) {
if (!word) {
return word;
}
var encryptedHexStr = CryptoJS.enc.Hex.parse(word);
var srcs = CryptoJS.enc.Base64.stringify(encryptedHexStr);
var decrypt = CryptoJS.AES.decrypt(srcs, this.keyHex, {
iv: this.keyHex,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.ZeroPadding
});
var decryptedStr = decrypt.toString(CryptoJS.enc.Utf8);
return decryptedStr.toString();
};
return Crypoto;
}());
var fxCry = new Crypoto();
function isEmpty(data) {
return data === "" || data === null || data === undefined || data.length === 0 || JSON.stringify(data) == "{}";
}
function getQueryString(obj) {
// 首先对对象的键进行排序并过滤空值
var sortedKeys = Object.keys(obj).sort();
var sortedObj = {};
for (var i = 0; i < sortedKeys.length; i++) {
if (isEmpty(obj[sortedKeys[i]])) {
continue;
}
sortedObj[sortedKeys[i]] = obj[sortedKeys[i]];
}
// 然后将排序后的对象转换为查询字符串
var params = [];
for (var key in sortedObj) {
params.push(encodeURIComponent(key) + "=" + encodeURIComponent(sortedObj[key]));
}
return params.join('&');
}
/**
* 组装签名字符串
* @param string url: 请求地址
* @param string postStr: post参数的a=1&b=2
* @returns
*/
function genSignStr(url, postStr) {
var lessUrl = url.replace('?', '');
lessUrl = lessUrl + "&" + postStr;
return encodeURIComponent(fxCry.hmacSha256(lessUrl));
}
// 对参数进行统一urlencode
function urlencode(url) {
var _a = url.split("?", 2), baseUrl = _a[0], queryString = _a[1];
var params = new URLSearchParams(queryString);
return baseUrl + "?" + params.toString();
}
/**
*
* @param url {string} 接口地址
* @param params {object} 需要加密的参数对象
*/
function apiSign(url, params) {
if (params === void 0) { params = {}; }
var convertUrl = url.trim();
if (convertUrl.indexOf('?') === -1) {
convertUrl += '?';
}
// 传入参数转换拼接字符串
var postStr = getQueryString(params);
var signedStr = genSignStr(convertUrl, postStr);
var encryptStr = "sign=" + signedStr;
var encryptSignStr = fxCry.encryptByDES(encryptStr, config.secretKey);
encryptSignStr = encodeURIComponent(encryptSignStr);
return urlencode(convertUrl) + "&_p=" + encryptSignStr;
}
cc._RF.pop();

File diff suppressed because one or more lines are too long

View File

@ -1 +0,0 @@
{"version":3,"sources":["assets\\Script\\Storage.ts"],"names":[],"mappings":";;;;;;;AAAA,SAAS;AACT,IAAI,cAAc,GAAG;IACjB,UAAU,EAAG,UAAS,GAAG;QACrB,IAAI,MAAM,GAAG,IAAI,CAAC;QAClB,IAAG,EAAE,CAAC,GAAG,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,EAAC;YAClC,IAAI,MAAM,GAAG,EAAE,CAAC,GAAG,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;SAC/C;QAED,IAAG,MAAM,EAAC;YACR,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;SAC7B;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;IACD,UAAU,EAAG,UAAS,GAAG,EAAC,KAAK;QAC3B,UAAU;QACV,IAAI,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACjC,EAAE,CAAC,GAAG,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;IAC1C,CAAC;IACD,aAAa,EAAG,UAAS,GAAG;QAC1B,UAAU;QACV,IAAG,EAAE,CAAC,GAAG,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,EAAC;YAClC,EAAE,CAAC,GAAG,CAAC,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;SACpC;IACH,CAAC;CACJ,CAAC;AAEO,wCAAc","file":"","sourceRoot":"/","sourcesContent":["//缓存浏览器数据\nvar StorageMessage = {\n getStorage : function(key){\n var result = null;\n if(cc.sys.localStorage.getItem(key)){\n var result = cc.sys.localStorage.getItem(key);\n }\n \n if(result){\n result = JSON.parse(result);\n }\n return result;\n },\n setStorage : function(key,value){\n //主动拉起分享接口\n var temp = JSON.stringify(value);\n cc.sys.localStorage.setItem(key, temp)\n },\n removeStorage : function(key){\n //主动删除消息接口\n if(cc.sys.localStorage.getItem(key)){\n cc.sys.localStorage.removeItem(key)\n }\n },\n};\n\nexport { StorageMessage };"]}

View File

@ -3,12 +3,6 @@ cc._RF.push(module, '805c6nf399HWZeuWnNB9CTH', 'GameOver');
// Script/GameOver.ts
"use strict";
// Learn TypeScript:
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
@ -29,8 +23,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var GameData_1 = require("./GameData");
var serverAPI_1 = require("./crypto/serverAPI");
var GameData_1 = require("./module/Config/GameData");
var GameTool_1 = require("./module/Tool/GameTool");
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var NewClass = /** @class */ (function (_super) {
__extends(NewClass, _super);
@ -76,36 +70,16 @@ var NewClass = /** @class */ (function (_super) {
};
//获取排行榜
NewClass.prototype.getRank = function () {
var postData = {
"page": 1,
"pageSize": 100
};
serverAPI_1.default.rankData(2, this.getRankData.bind(this), postData);
var _this = this;
GameTool_1.GameTool.getRank(5, function (data) { return _this.getRankData(data); });
};
//设置排行信息
NewClass.prototype.getRankData = function (data) {
if (data) {
this.listData = data.data.list;
this.selfData = data.data.info;
var rankData = [];
var self = false;
if (this.selfData.nickName.length > 4) {
this.selfData.nickName = this.selfData.nickName.substring(0, 4) + "...";
}
this.selfNode.getChildByName("name").getComponent(cc.Label).string = this.selfData.nickName;
this.selfNode.getChildByName("total").getComponent(cc.Label).string = this.selfData.totalSunCount;
this.setPic(this.selfNode.getChildByName("pic").getChildByName("icon"), this.selfData.pic);
for (var i = 0; i <= this.listData.length - 1; i++) {
rankData.push({ rank: (i + 1), name: this.listData[i].nickName, total: this.listData[i].totalSunCount, pic: this.listData[i].pic });
if (GameData_1.default._instance.GM_INFO.userId == this.listData[i].userId) {
self = true;
this.selfNode.getChildByName("rank").getComponent(cc.Label).string = (i + 1) + "";
}
if (i == (this.listData.length - 1) && self == false) {
this.selfNode.getChildByName("rank").getComponent(cc.Label).string = "99+";
}
if (i < 5)
this.setRank(i, this.listData[i]);
GameTool_1.GameTool.getRankData(data, this, 4);
GameTool_1.GameTool.setPic(this.selfNode.getChildByName("pic").getChildByName("icon"), this.selfData.pic);
for (var i = 0; i <= 4; i++) {
this.setRank(i, this.listData[i]);
}
}
};
@ -129,42 +103,12 @@ var NewClass = /** @class */ (function (_super) {
}
if (hitNode) {
hitNode.active = true;
if (data.nickName.length > 4) {
data.nickName = data.nickName.substring(0, 4) + "...";
}
GameTool_1.GameTool.subName(data.nickName, 4);
hitNode.getChildByName("name").getComponent(cc.Label).string = data.nickName;
hitNode.getChildByName("total").getComponent(cc.Label).string = data.totalSunCount;
this.setPic(hitNode.getChildByName("pic").getChildByName("icon"), data.pic);
GameTool_1.GameTool.setPic(hitNode.getChildByName("pic").getChildByName("icon"), data.pic);
}
};
//设置头像
NewClass.prototype.setPic = function (node, pic) {
node.active = false;
var url = pic;
setTimeout(function () {
fetch(url)
.then(function (response) {
return response.headers.get('Content-Length');
})
.then(function (errNo) {
if (errNo == "5093") {
node.active = true;
}
})
.catch(function (error) {
console.error('Error fetching X-Info:', error);
});
}, 100);
cc.assetManager.loadRemote(url, { ext: '.jpg' }, function (err, texture) {
if (texture) {
node.active = true;
node.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture);
}
else {
console.log(err, texture);
}
});
};
__decorate([
property(cc.Label)
], NewClass.prototype, "count", void 0);

File diff suppressed because one or more lines are too long

View File

@ -1,283 +0,0 @@
"use strict";
cc._RF.push(module, '971c4vub4BJpqrSCLPJ8g1V', 'AudioManager');
// Script/AudioManager.js
"use strict";
cc.Class({
"extends": cc.Component,
properties: {
//背景音乐
audioGameBgm0: {
"default": null,
type: cc.AudioClip
},
// 按钮点击
audioButtonClick: {
"default": null,
type: cc.AudioClip
},
// 报警音效
audioWarning: {
"default": null,
type: cc.AudioClip
},
//游戏开始音效
audioWin: {
"default": null,
type: cc.AudioClip
},
reward: false,
finish: false,
rewardCount: 0
},
ctor: function ctor() {
this.mAudioMap = {};
/**
* 默认音量大小
* @type {number}
*/
this.bgMusicVolume = 0.1;
this.effectMusicVolume = 1;
this.mMusicSwitch = 1;
this.mEffectSwitch = 1;
},
play: function play(audioSource, loop, callback, isBgMusic) {
if (isBgMusic && !this.mMusicSwitch) return;
if (!isBgMusic && !this.mEffectSwitch) return;
var volume = isBgMusic ? this.bgMusicVolume : this.effectMusicVolume;
if (cc.sys.isBrowser) {
if (audioSource == this.brickSound) {
volume = 0.1;
}
var context = cc.audioEngine.play(audioSource, loop, volume);
if (callback) {
cc.audioEngine.setFinishCallback(context, function () {
callback.call(this);
}.bind(this));
}
this.mAudioMap[audioSource] = context;
return audioSource;
} else {
var context = wx.createInnerAudioContext();
context.autoplay = true;
context.loop = loop;
context.obeyMuteSwitch = true;
context.volume = volume;
if (callback) {
context.onEnded(function () {
callback.call(this);
}.bind(this));
} else {
context.offEnded();
} // var audioPath = cc.url.raw("resources/BallMaster/sounds" + audioSource.name + ".mp3");
context.src = audioSource.nativeUrl;
context.play();
this.mAudioMap[audioSource] = context;
return audioSource;
}
},
save: function save() {// cc.wwx.Storage.setItem(cc.wwx.Storage.Key_Setting_Music_Volume, this.mMusicSwitch);
// cc.wwx.Storage.setItem(cc.wwx.Storage.Key_Setting_Effect_Volume, this.mEffectSwitch);
},
onLoad: function onLoad() {
var _this = this;
// cc.wwx.Storage.getItem(cc.wwx.Storage.Key_Setting_Music_Volume, function(volume) {
// this.mMusicSwitch = parseInt(volume);
// }.bind(this), 1);
// cc.wwx.Storage.getItem(cc.wwx.Storage.Key_Setting_Effect_Volume, function(volume) {
// this.mEffectSwitch = parseInt(volume);
// }.bind(this), 1);
this.reward = false;
this.finish = false;
this.rewardCount = 0;
window.addEventListener('rewardCanUse', function () {
// 此时激励可用 游戏内部逻辑
_this.reward = true;
});
'undefined' != typeof window['reward'] ? window.dispatchEvent(window['reward']) : "";
this.preload();
},
preload: function preload() {
if (!(cc.sys.platform === cc.sys.WECHAT_GAME)) {
return;
}
var musics = [this.audioGameBgm0];
musics.forEach(function (path) {// var musicPath = wxDownloader.REMOTE_SERVER_ROOT + path;
// if (musicPath != wxDownloader.REMOTE_SERVER_ROOT && musicPath.endsWith('.mp3')) {
// cc.loader.load(musicPath, function(err, remoteUrl) {
// if (err) {
// cc.error(err.message || err);
// return;
// }
// });
// }
});
},
getAudioMusicSwitch: function getAudioMusicSwitch() {
return this.mMusicSwitch;
},
getAudioEffectSwitch: function getAudioEffectSwitch() {
return this.mEffectSwitch;
},
trunAudioSound: function trunAudioSound(on) {
this.switchMusic(on);
this.switchEffect(on);
},
switchMusic: function switchMusic(on) {
if (this.mMusicSwitch != (on ? 1 : 0)) {
this.mMusicSwitch = 1 - this.mMusicSwitch; // this.save();
}
if (on) {
this.playMusicGame();
} else {
this.stopMusic();
}
},
switchEffect: function switchEffect(on) {
if (this.mEffectSwitch != (on ? 1 : 0)) {
this.mEffectSwitch = 1 - this.mEffectSwitch; // this.save();
}
},
onHide: function onHide() {
cc.audioEngine.pauseAll(); // if (CC_JSB) {
// } else {
// for (var key in this.mAudioMap) {
// if (key === this.mMusicKey) {
// this.mAudioMap[key].pause();
// } else {
// this.mAudioMap[key].stop();
// }
// }
// }
},
onShow: function onShow() {
cc.audioEngine.resumeAll(); // if (CC_JSB) {
// } else {
// if (!this.mMusicSwitch) return;
// var context = this.mAudioMap[this.mMusicKey];
// if (context) {
// context.play();
// }
// }
},
playMusic: function playMusic(key, callback, loop) {
loop = typeof loop == 'undefined' || loop ? true : false;
this.stopMusic();
this.mMusicKey = this.play(key, loop, callback, true);
},
/**
* 游戏背景音乐
*/
playMusicGame: function playMusicGame() {
this.playMusic(this.audioGameBgm0);
},
/**
* 停止背景音乐播放
*/
stopMusic: function stopMusic() {
// cc.wwx.OutPut.log('stopMusic audio effect wx: ' + this.mMusicKey);
var context = this.mAudioMap[this.mMusicKey];
if (typeof context != 'undefined') {
if (cc.sys.isBrowser) {
cc.audioEngine.stop(context);
} else {
context.stop();
}
cc.audioEngine.stop(context);
}
},
// 炸弹、火箭爆炸音效
playBomb: function playBomb() {
return this.play(this.audioBomb, false);
},
//激光音效
playJiGuang: function playJiGuang() {
return this.play(this.audioJiGuang, false);
},
//技能音效
playItem1: function playItem1() {
return this.play(this.audioItem1, false);
},
/*
* 游戏开始音效
*
*/
playGameStart: function playGameStart() {
return this.play(this.audioGameStart, false);
},
/*
* 失败的游戏结束
*/
playGameOver: function playGameOver() {
return this.play(this.audioGameOver, false);
},
/*
* 成功的游戏结束
*/
playGameResultFailed: function playGameResultFailed() {
return this.play(this.audioGameResultFail, false);
},
/*
* 成功的游戏结束
*/
playGameResultSuccess: function playGameResultSuccess() {
return this.play(this.audioGameResultSuccess, false);
},
/**
* 报警的音效
*/
playWarning: function playWarning() {
return this.play(this.audioWarning, false);
},
playWin: function playWin() {
return this.play(this.audioWin, false);
},
/*
* 方块碰撞的声音
*/
playBrick: function playBrick() {
return this.play(this.brickSound, false);
},
//方块破碎的声音
brickBoom: function brickBoom() {
return this.play(this.audioObj, false);
},
/**
* 按钮
*/
playAudioButton: function playAudioButton() {
return this.play(this.audioButtonClick, false);
},
playRandomMatch: function playRandomMatch() {
this.playMusic(this.randomMatchSound);
},
playMatchFoundSound: function playMatchFoundSound() {
this.stopMusic();
return this.play(this.matchFoundSound, false);
}
});
cc._RF.pop();

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
"use strict";
cc._RF.push(module, '98307M8uUtLYKaHXPmGgCWf', 'serverAPI');
// Script/crypto/serverAPI.ts
// Script/module/Crypto/serverAPI.ts
"use strict";
// import CryptoJS from "crypto-js";
@ -64,6 +64,7 @@ var GameData_1 = require("../GameData");
var CryptoJS = require("./crypto-js.min.js"); //引用AES源码js
// import axios from 'axios'
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var BASE_URL = "http://api.sparkus.cn";
var HttpUtil = /** @class */ (function (_super) {
__extends(HttpUtil, _super);
function HttpUtil() {
@ -78,7 +79,7 @@ var HttpUtil = /** @class */ (function (_super) {
data.userId = GameData_1.default._instance.GM_INFO.userId;
time = Math.floor((new Date().getTime()) / 1000);
url = apiSign("/api/get/rank/data?gameId=" + config.gameId + "&dataType=" + type + "&time=" + time, data);
this.httpPost(url, data, callback);
this.post(url, data, callback);
return [2 /*return*/];
});
});
@ -90,7 +91,7 @@ var HttpUtil = /** @class */ (function (_super) {
data.gameId = GameData_1.default._instance.GM_INFO.gameId;
data.userId = GameData_1.default._instance.GM_INFO.userId;
url = '/log/collect/data';
this.httpPost(url, data, callback);
this.get(url, callback);
return [2 /*return*/];
});
});
@ -104,61 +105,71 @@ var HttpUtil = /** @class */ (function (_super) {
data.userId = GameData_1.default._instance.GM_INFO.userId;
time = Math.floor((new Date().getTime()) / 1000);
url = apiSign("/api/get/user/data?gameId=" + config.gameId + "&time=" + time, data);
this.httpPost(url, data, callback);
this.post(url, data, callback);
return [2 /*return*/];
});
});
};
HttpUtil.httpPost = function (url, data, callBack) {
data.gameId = GameData_1.default._instance.GM_INFO.gameId;
data.userId = GameData_1.default._instance.GM_INFO.userId;
var urlData = "http://api.sparkus.cn" + url;
// console.log("params:",JSON.stringify(data));
var xhr = new XMLHttpRequest();
xhr.open('POST', urlData);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
var data = xhr.responseText;
if (!data) {
// console.log("初始化失败");
return;
HttpUtil.post = function (url, data, callback) {
return __awaiter(this, void 0, void 0, function () {
var response;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.fetchData(url, data, 'POST')];
case 1:
response = _a.sent();
callback && callback(response);
return [2 /*return*/];
}
var json = JSON.parse(data);
// console.log('http success:' + json);
callBack(json);
}
else {
// var json = JSON.parse(data);
// console.log('http fail:' + url);
callBack(json);
}
};
xhr.send(JSON.stringify(data));
});
});
};
HttpUtil.httpGet = function (url, callBack) {
var urlData = "http://api.sparkus.cn" + url;
console.log(urlData);
var xhr = new XMLHttpRequest();
xhr.open('GET', urlData);
xhr.setRequestHeader('Content-Type', 'text/plain');
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
var data = xhr.responseText;
if (data) {
var json = JSON.parse(data);
console.info('http success:' + json);
callBack(json);
HttpUtil.get = function (url, callback) {
return __awaiter(this, void 0, void 0, function () {
var response;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.fetchData(url, null, 'GET')];
case 1:
response = _a.sent();
callback && callback(response);
return [2 /*return*/];
}
else
callBack(data);
}
else {
console.info('http fail:' + url);
callBack(null);
}
};
xhr.send();
});
});
};
HttpUtil.fetchData = function (url, data, method) {
return __awaiter(this, void 0, void 0, function () {
var fullUrl, headers, options, response, error_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
fullUrl = "" + BASE_URL + url;
headers = { 'Content-Type': 'application/json' };
options = {
method: method,
headers: headers,
body: data ? JSON.stringify(data) : null,
};
_a.label = 1;
case 1:
_a.trys.push([1, 4, , 5]);
return [4 /*yield*/, fetch(fullUrl, options)];
case 2:
response = _a.sent();
if (!response.ok) {
throw new Error("HTTP error! status: " + response.status);
}
return [4 /*yield*/, response.json()];
case 3: return [2 /*return*/, _a.sent()];
case 4:
error_1 = _a.sent();
console.error('Fetch error:', error_1);
return [2 /*return*/, null];
case 5: return [2 /*return*/];
}
});
});
};
HttpUtil = __decorate([
ccclass

File diff suppressed because one or more lines are too long

View File

@ -130,17 +130,17 @@
"_id": "78JbrAn9RBIr8Ujxy6eo6w"
},
{
"__type__": "f2f0bI5PsVI+o18xF6G+KVa",
"__type__": "179c44L0X9IhZh7hydovv0d",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"_id": "89UAK+FSRBh4q9PzKutGtE"
"_id": "5ekG2HL35EGppN64AQNDFD"
},
{
"__type__": "971c4vub4BJpqrSCLPJ8g1V",
"__type__": "58403/n16JCa5sZhNMjZzGo",
"_name": "",
"_objFlags": 0,
"node": {
@ -157,10 +157,7 @@
"audioWin": {
"__uuid__": "e70b3103-83f1-4c66-9093-1897c1a5d4ae"
},
"reward": false,
"finish": false,
"rewardCount": 0,
"_id": "dbb1mOJilJI5DAHXWGh8XU"
"_id": "08dy+OlqhPnqHAzPuL21rx"
},
{
"__type__": "cc.Node",
@ -351,14 +348,14 @@
"_id": "81GN3uXINKVLeW4+iKSlim"
},
{
"__type__": "3ffacOneORCf6Bc1LFhTCCQ",
"__type__": "5c9b8FZiaNLMrMDs9T3rByf",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 6
},
"_enabled": true,
"_id": "04sqPSc/FA3bLFQccgHxs/"
"_id": "82rBHh8bJIGKuGw03a3Yrd"
},
{
"__type__": "cc.Node",

View File

@ -25,9 +25,10 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
Object.defineProperty(exports, "__esModule", { value: true });
// 主游戏控制类
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var GameData_1 = require("./GameData");
var Notification_1 = require("./Notification");
var serverAPI_1 = require("./crypto/serverAPI");
var GameData_1 = require("./module/Config/GameData");
var AudioManager_1 = require("./module/Music/AudioManager");
var Notification_1 = require("./module/Notification/Notification");
var GameTool_1 = require("./module/Tool/GameTool");
var GameManager = /** @class */ (function (_super) {
__extends(GameManager, _super);
function GameManager() {
@ -243,11 +244,11 @@ var GameManager = /** @class */ (function (_super) {
var _this = this;
if (this.begin == true) {
this.clickCount += 1;
var clickTime = this.getTime();
var clickTime = GameTool_1.GameTool.getTime();
this.time_Array.push((clickTime - this.timeStart));
this.timeStart = this.getTime();
this.timeStart = GameTool_1.GameTool.getTime();
if (data == this.clickNow) {
GameData_1.default._instance.AudioManager.playAudioButton();
AudioManager_1.default._instance.playAudioButton();
if (this.clickNow > 0) {
this.createLine(cc.v2(this.ball_Array[this.clickNow - 1].x, this.ball_Array[this.clickNow - 1].y), cc.v2(this.ball_Array[this.clickNow].x, this.ball_Array[this.clickNow].y), 0.2);
}
@ -257,7 +258,7 @@ var GameManager = /** @class */ (function (_super) {
if (this.clickNow == this.now_Array.length) {
this.pause = true;
GameData_1.default._instance.GM_INFO.total += this.clickNow;
this.overTime = this.getTime();
this.overTime = GameTool_1.GameTool.getTime();
if (this.startTime > 0 && this.overTime > 0) {
GameData_1.default._instance.GM_INFO.mean_Time += (this.overTime - this.startTime);
}
@ -272,7 +273,7 @@ var GameManager = /** @class */ (function (_super) {
var win_1 = this.node.getChildByName("Win");
win_1.active = true;
win_1.setScale(0);
GameData_1.default._instance.AudioManager.playWin();
AudioManager_1.default._instance.playWin();
this.round += 1;
var sunArray = [];
if (this.moveArray.length > 0) {
@ -343,9 +344,9 @@ var GameManager = /** @class */ (function (_super) {
};
//执行失败
GameManager.prototype.setLoss = function () {
GameData_1.default._instance.AudioManager.playWarning();
AudioManager_1.default._instance.playWarning();
this.begin = false;
this.overTime = this.getTime();
this.overTime = GameTool_1.GameTool.getTime();
if (this.startTime > 0 && this.overTime > 0) {
GameData_1.default._instance.GM_INFO.mean_Time += (this.overTime - this.startTime);
}
@ -647,8 +648,8 @@ var GameManager = /** @class */ (function (_super) {
//每次重新开始新一轮儿游戏
GameManager.prototype.beginGame = function () {
this.begin = true;
this.startTime = this.getTime();
this.timeStart = this.getTime();
this.startTime = GameTool_1.GameTool.getTime();
this.timeStart = GameTool_1.GameTool.getTime();
this.pause = false;
// this.node.getChildByName("showBtn").active = true;
};
@ -914,28 +915,11 @@ var GameManager = /** @class */ (function (_super) {
_this.startGame();
}, time1 * 1500);
};
//时间格式转换
GameManager.prototype.getTimeMargin = function (second) {
var total = 0;
total = second;
var hour = 0;
hour = parseInt((total / 3600) + ""); //计算整数小时数
var afterHour = total - hour * 60 * 60; //取得算出小时数后剩余的秒数
var min = parseInt((afterHour / 60) + ""); //计算整数分
var m = "" + min;
if (min < 10)
m = "0" + min;
var afterMin = total - hour * 60 * 60 - min * 60; //取得算出分后剩余的秒数
var miao = afterMin + "";
if (afterMin < 10)
miao = "0" + afterMin;
return m + ':' + miao;
};
//如果是倒计时 调用此方法
GameManager.prototype.updateCountDownTime = function () {
if (this.countTime > 0 && this.pause == false) {
this.countTime -= 1;
this.time.string = this.getTimeMargin(this.countTime);
this.time.string = GameTool_1.GameTool.getTimeMargin(this.countTime);
if (this.countTime < 5) {
cc.tween(this.time.node)
.to(0.25, { scale: 1.5, color: cc.color(255, 0, 0) })
@ -960,24 +944,13 @@ var GameManager = /** @class */ (function (_super) {
GameData_1.default._instance.GM_INFO.mean_Time = GameData_1.default._instance.GM_INFO.mean_Time / 10;
if (time > 10000)
time = (Math.random() * 10 + 5) * 100;
this.setRank(time);
this.gameOver(time);
}
}
};
//上传每次操作数据
GameManager.prototype.setData = function () {
GameData_1.default._instance.GAME_DATA = [];
GameData_1.default._instance.GAME_DATA.push(GameData_1.default._instance.CLICK_DATA);
GameData_1.default._instance.CLICK_init();
var data = GameData_1.default._instance.GAME_DATA;
var matchId = this.getMatchId();
console.log(matchId);
var postData = {
"matchId": matchId,
"data": data
};
console.log("上传数据:");
serverAPI_1.default.uploadUserLogData(postData, function () { });
GameTool_1.GameTool.setGameData();
};
//获取matchId 用于上传每次点击数据里面记录id方便查询
GameManager.prototype.getMatchId = function () {
@ -1027,14 +1000,8 @@ var GameManager = /** @class */ (function (_super) {
return data;
};
//上传排行榜数据
GameManager.prototype.setRank = function (time) {
var postData = {
"type": 1,
"reactionTime": time,
"totalSunCount": GameData_1.default._instance.GM_INFO.total,
"success": GameData_1.default._instance.GM_INFO.success
};
serverAPI_1.default.rankData(1, function () { }, postData);
GameManager.prototype.gameOver = function (time) {
GameTool_1.GameTool.setRank(time);
this.node.getChildByName("GameOver").active = true;
this.node.getChildByName("GameOver").opacity = 0;
cc.tween(this.node.getChildByName("GameOver"))
@ -1057,10 +1024,10 @@ var GameManager = /** @class */ (function (_super) {
}
};
GameManager.prototype.onEnable = function () {
Notification_1.Notification.on("clickSun", this.clickSun, this);
Notification_1.Notifications.on("clickSun", this.clickSun, this);
};
GameManager.prototype.onDisable = function () {
Notification_1.Notification.off("clickSun", this.clickSun);
Notification_1.Notifications.off("clickSun", this.clickSun);
};
GameManager.prototype.update = function (dt) {
};

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
"use strict";
cc._RF.push(module, 'ca0f9k0oBVDbpQC+OMNTF3m', 'ItemRender');
// Script/ListView/ItemRender.ts
// Script/module/RankList/ItemRender.ts
"use strict";
var __extends = (this && this.__extends) || (function () {

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
"use strict";
cc._RF.push(module, 'd5421HgLShFKIjj5f18m1mi', 'List');
// Script/ListView/List.ts
// Script/module/RankList/List.ts
"use strict";
// Learn TypeScript:

File diff suppressed because one or more lines are too long

View File

@ -1,247 +0,0 @@
"use strict";
cc._RF.push(module, 'ddac3ZC+9pHQr0Fs9IIhw4a', 'GameTool');
// Script/tool/GameTool.ts
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.GameTool = void 0;
var GameData_1 = require("../GameData");
//最大工具类
var GameTool = {
_startTime: 0,
_endTime: 0,
_totalTime: 0,
getSeedRandom: function (min, max) {
max = max || 1;
min = min || 0;
GameData_1.default._instance.GM_INFO.currSeed = (GameData_1.default._instance.GM_INFO.currSeed * 9301 + 49297) % 233280;
var rnd = GameData_1.default._instance.GM_INFO.currSeed / 233280.0;
var tmp = min + rnd * (max - min);
return Math.floor(tmp);
},
getSetScreenResolutionFlag: function () {
var size = cc.winSize;
var width = size.width;
var height = size.height;
if ((height / width) > (16.2 / 9))
return false;
return true;
},
//判断全面屏适配
setFit: function (canvas) {
var flag = GameTool.getSetScreenResolutionFlag();
if (flag) {
// console.log("不是全面屏");
// canvas.fitWidth = false;
// canvas.fitHeight = true;
}
else {
// console.log("是全面屏");
// canvas.fitWidth = true;
// canvas.fitHeight = false;
}
return flag;
},
getTip: function () {
var index = Math.floor(Math.random() * 4) + 1;
switch (index) {
case 1: {
return "根据小球的位置,合理晃动手机,确保小球不掉出木板。";
}
case 2: {
return "根据小球位置控制晃动幅度,过大或过小都不是个好选择。";
}
case 3: {
return "不要被天上掉落的障碍吓到,有时候它反而会帮你保持平衡。";
}
case 4: {
return "尝试着顶开掉落的障碍,是个很酷的玩法。";
}
}
},
beginTiming: function () {
this._startTime = new Date().getTime();
},
endTiming: function () {
this._endTime = new Date().getTime();
// this._totalTime = endTime - this._startTime;
},
//如果是判断时常的游戏 调用此方法
updateScoreTime: function () {
var endTime = new Date().getTime();
var tempTime = endTime - this._startTime;
if (tempTime < 0 || tempTime > 500) {
tempTime = Math.round(cc.director.getAnimationInterval() * 1000);
}
this._endTime += tempTime / 1000;
this._totalTime = this._endTime.toFixed(2);
GameData_1.default._instance.GM_INFO.currScore = this._totalTime;
this._startTime = endTime;
},
//倒计时调用此方法
countDown: function () {
this._endTime = new Date().getTime();
this._totalTime = Math.floor((this._endTime - this._startTime) / 1000);
GameData_1.default._instance.GM_INFO.remainingTime = GameData_1.default._instance.GM_INFO.totalTime - this._totalTime;
},
getGameInfo: function (node) {
var jg = false;
return jg;
},
//根据服务器数据重置所需要所有数据
reset: function () {
console.log("本地数据丢失,重新启动游戏");
cc.director.loadScene('LoadScene');
},
setGameInfo: function (pd) {
},
//输入秒,返回需要展示时间格式
getTimeMargin: function (second) {
var total = second;
var hour = Math.floor(total / (60 * 60)); //计算整数小时数
var afterHour = total - hour * 60 * 60; //取得算出小时数后剩余的秒数
var min = Math.floor(afterHour / 60); //计算整数分
var afterMin = total - hour * 60 * 60 - min * 60; //取得算出分后剩余的秒数
return '剩余:' + hour + ':' + min + ':' + afterMin;
},
getTimeMargin2: function (second) {
var total = second;
var min = null;
var afterMin = null;
var hour = Math.floor(total / (60 * 60)); //计算整数小时数
var afterHour = total - hour * 60 * 60; //取得算出小时数后剩余的秒数
min = Math.floor(afterHour / 60); //计算整数分
if (min < 10)
min = "0" + min;
afterMin = total - hour * 60 * 60 - min * 60; //取得算出分后剩余的秒数
if (afterMin < 10)
afterMin = "0" + afterMin;
return '剩余:' + min + ':' + afterMin;
},
setFrindBlock: function (userid) {
},
//将时间转换为59:23
getTime: function (time) {
var label = "";
var number_1 = null;
var number_2 = null;
number_1 = Math.floor(time / 60);
number_2 = time - number_1 * 60;
if (number_1 < 10) {
number_1 = "0" + number_1;
}
if (number_2 < 10) {
number_2 = "0" + number_2;
}
label = number_1 + ":" + number_2;
return label;
},
//number 为传进来的数值,type为最多显示几位数
getNumber: function (number, type) {
// console.log(type,"需要转换的数字为:",number);
var count = 1000;
var place = type - 3;
if (number > Math.pow(count, 8) * Math.pow(10, place)) {
if (number / Math.pow(count, 8) < 100)
number = Math.floor(number / Math.pow(count, 8) * 10) / 10 + "S";
else
number = Math.floor(number / Math.pow(count, 8)) + "S";
}
else if (number > Math.pow(count, 7) * Math.pow(10, place)) {
if (number / Math.pow(count, 7) < 100)
number = Math.floor(number / Math.pow(count, 7) * 10) / 10 + "s";
else
number = Math.floor(number / Math.pow(count, 7)) + "s";
}
else if (number > Math.pow(count, 6) * Math.pow(10, place)) {
if (number / Math.pow(count, 6) < 100)
number = Math.floor(number / Math.pow(count, 6) * 10) / 10 + "Q";
else
number = Math.floor(number / Math.pow(count, 6)) + "Q";
}
else if (number > Math.pow(count, 5) * Math.pow(10, place)) {
if (number / Math.pow(count, 5) < 100)
number = Math.floor(number / Math.pow(count, 5) * 10) / 10 + "q";
else
number = Math.floor(number / Math.pow(count, 5)) + "q";
}
else if (number > Math.pow(count, 4) * Math.pow(10, place)) {
if (number / Math.pow(count, 4) < 100)
number = Math.floor(number / Math.pow(count, 4) * 10) / 10 + "t";
else
number = Math.floor(number / Math.pow(count, 4)) + "t";
}
else if (number > Math.pow(count, 3) * Math.pow(10, place)) {
if (number / Math.pow(count, 3) < 100)
number = Math.floor(number / Math.pow(count, 3) * 10) / 10 + "b";
else
number = Math.floor(number / Math.pow(count, 3)) + "b";
}
else if (number > Math.pow(count, 2) * Math.pow(10, place)) {
if (number / Math.pow(count, 2) < 100)
number = Math.floor(number / Math.pow(count, 2) * 10) / 10 + "m";
else
number = Math.floor(number / Math.pow(count, 2)) + "m";
}
else if (number > Math.pow(count, 1) * Math.pow(10, place)) {
if (number / Math.pow(count, 1) < 100) {
number = Math.floor(number / Math.pow(count, 1) * 10) / 10 + "k";
}
else
number = Math.floor(number / Math.pow(count, 1)) + "k";
}
else {
number = Math.floor(number / Math.pow(count, 0)) + "";
}
// console.log("结果为"+type+"位数",number);
return number;
},
begainTiming: function () {
this._startTime = new Date().getTime();
},
endTiming2: function () {
var endTime = new Date().getTime();
this._endTime = endTime;
this._totalTime = endTime - this._startTime;
},
getScoreTime: function () {
var endTime = new Date().getTime();
var tempTime = endTime - this._startTime;
if (tempTime < 0 || tempTime > 500) {
tempTime = Math.round(cc.director.getAnimationInterval() * 1000);
}
GameData_1.default._instance.GM_INFO.currScore += tempTime;
this._startTime = endTime;
},
getFormatTime: function (time) {
var date = new Date();
date.setTime(time);
var ms = date.getMilliseconds();
// let msString = date.getMilliseconds();
var msString = null;
var secondString = null;
var minString = null;
msString = Math.floor(ms / 10) % 100;
secondString = date.getSeconds();
minString = date.getMinutes();
if (msString < 10) {
msString = "0" + msString;
}
if (secondString < 10) {
secondString = "0" + secondString;
}
secondString = secondString + ":";
if (minString < 10) {
minString = "0" + minString;
}
minString = minString + ":";
return minString + secondString + msString;
},
pushLister: function () {
},
removeAllLister: function () {
},
};
exports.GameTool = GameTool;
cc._RF.pop();

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
"use strict";
cc._RF.push(module, 'e64e1qXyT9CV6s0gDQdj/ed', 'crypto-js.min');
// Script/crypto/crypto-js.min.js
// Script/module/Crypto/crypto-js.min.js
"use strict";

File diff suppressed because one or more lines are too long

View File

@ -23,9 +23,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var GameData_1 = require("./GameData");
var List_1 = require("./ListView/List");
var serverAPI_1 = require("./crypto/serverAPI");
var List_1 = require("./module/RankList/List");
var GameTool_1 = require("./module/Tool/GameTool");
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
//排行榜
var RankManager = /** @class */ (function (_super) {
@ -56,55 +55,15 @@ var RankManager = /** @class */ (function (_super) {
};
//调用获取排行榜接口
RankManager.prototype.getRank = function () {
var postData = {
"page": 1,
"pageSize": 100
};
//回调进getRankData
serverAPI_1.default.rankData(2, this.getRankData.bind(this), postData);
var _this = this;
GameTool_1.GameTool.getRank(100, function (data) { return _this.getRankData(data); });
};
//实际设置排行数据
RankManager.prototype.getRankData = function (data) {
if (data) {
console.log(data);
this.listData = data.data.list;
this.selfData = data.data.info;
var rankData = [];
var self = false;
for (var i = 0; i <= this.listData.length - 1; i++) {
rankData.push({ rank: (i + 1), name: this.listData[i].nickName, total: this.listData[i].totalSunCount, pic: this.listData[i].pic });
if (GameData_1.default._instance.GM_INFO.userId == this.listData[i].userId) {
self = true;
this.rankNumber = i;
this.selfNode.getChildByName("rankLab").getComponent(cc.Label).string = (i + 1) + "";
}
if (i == (this.listData.length - 1) && self == false) {
this.rankNumber = i;
this.selfNode.getChildByName("rankLab").getComponent(cc.Label).string = "99+";
}
}
this.rankList.setData(rankData);
if (this.selfData.nickName.length > 6) {
this.selfData.nickName = this.selfData.nickName.substring(0, 6) + "...";
}
this.selfNode.getChildByName("nameLab").getComponent(cc.Label).string = this.selfData.nickName;
this.selfNode.getChildByName("totalLab").getComponent(cc.Label).string = this.selfData.totalSunCount;
// console.log(data);
GameTool_1.GameTool.getRankData(data, this, 6);
this.setPic(this.selfData.pic);
if (this.selfNode.getChildByName("rankLab").getComponent(cc.Label).string == "1") {
this.selfNode.getChildByName("rank").getChildByName("one").active = true;
}
else if (this.selfNode.getChildByName("rankLab").getComponent(cc.Label).string == "2") {
this.selfNode.getChildByName("rank").getChildByName("two").active = true;
}
else if (this.selfNode.getChildByName("rankLab").getComponent(cc.Label).string == "3") {
this.selfNode.getChildByName("rank").getChildByName("three").active = true;
}
else {
// this.selfNode.getChildByName("four").active = true;
}
this.selfNode.opacity = 255;
if (this.selfData.totalSunCount == 0)
this.selfNode.opacity = 0;
}
};
//返回按钮
@ -143,7 +102,7 @@ var RankManager = /** @class */ (function (_super) {
.getComponent(cc.Label).string = parseInt(time * 100 + "") + "%";
}, time * 2000);
};
//设置头像
//设置头像 处理的逻辑比较多,不用公共类的了
RankManager.prototype.setPic = function (pic) {
var _this = this;
this.phone.node.parent.getChildByName("icon").active = false;

File diff suppressed because one or more lines are too long

View File

@ -1 +0,0 @@
{"version":3,"sources":["assets\\Script\\Notification.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAM;AACN,IAAI,YAAY,GAAG;IACf,SAAS,EAAE,EAAE;IACb,EAAE,EAAE,UAAU,MAAM,EAAE,QAAQ,EAAE,MAAM;QAClC,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,SAAS,EAAE;YACtC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;SAC/B;QACD,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACxE,CAAC;IAED,IAAI,EAAE,UAAU,MAAM,EAAE,SAAS;QAC7B,IAAI,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACnC,IAAI,KAAK,KAAK,SAAS;YAAE,OAAO;QAEhC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACnC,IAAI,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YACvB,IAAI,OAAO;gBAAE,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;SACjE;IACL,CAAC;IAED,GAAG,EAAE,UAAU,MAAM,EAAE,QAAQ;QAC3B,IAAI,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACnC,IAAI,KAAK,KAAK,SAAS;YAAE,OAAO;QAChC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACnC,IAAI,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YACvB,IAAI,OAAO,IAAI,OAAO,CAAC,QAAQ,KAAK,QAAQ,EAAE;gBAC1C,KAAK,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;gBACrB,MAAM;aACT;SACJ;IACL,CAAC;IAED,SAAS,EAAE,UAAU,MAAM;QACvB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;IACvC,CAAC;IAED,YAAY,EAAE;QACV,KAAK,IAAI,CAAC,IAAI,IAAI,CAAC,SAAS,EAAE;YAC1B,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE;gBACnB,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;aACrB;SACJ;IACL,CAAC;CACJ,CAAC;AAEO,oCAAY","file":"","sourceRoot":"/","sourcesContent":["//全局通知\nvar Notification = {\n _eventMap: [],\n on: function (masgId, callback, target) {\n if (this._eventMap[masgId] === undefined) {\n this._eventMap[masgId] = [];\n }\n this._eventMap[masgId].push({ callback: callback, target: target });\n },\n\n emit: function (masgId, parameter) {\n let array = this._eventMap[masgId];\n if (array === undefined) return;\n\n for (let i = 0; i < array.length; i++) {\n let element = array[i];\n if (element) element.callback.call(element.target, parameter);\n }\n },\n\n off: function (masgId, callback) {\n let array = this._eventMap[masgId];\n if (array === undefined) return;\n for (let i = 0; i < array.length; i++) {\n let element = array[i];\n if (element && element.callback === callback) {\n array[i] = undefined;\n break;\n }\n }\n },\n\n offMasgId: function (masgId) {\n this._eventMap[masgId] = undefined;\n },\n\n removeAllMsg: function () {\n for (let k in this._eventMap) {\n if (this._eventMap[k]) {\n this.offMasgId(k);\n }\n }\n }\n};\n\nexport { Notification };"]}

File diff suppressed because one or more lines are too long

Some files were not shown because too many files have changed in this diff Show More