1、清理仓库

This commit is contained in:
贝密游戏
2017-12-21 23:04:13 +08:00
parent eeb1c9e07b
commit b52d442381
1317 changed files with 138642 additions and 0 deletions
@@ -0,0 +1,6 @@
{
"ver": "1.0.1",
"uuid": "1730b47d-3d7e-49a6-a329-0f1eb994184a",
"isGroup": false,
"subMetas": {}
}
@@ -0,0 +1,57 @@
var beiMiCommon = require("BeiMiCommon");
cc.Class({
extends: beiMiCommon,
properties: {
qrgraphics:{
default : null ,
type : cc.Node
},
roomid:{
default : null ,
type : cc.Label
}
},
// use this for initialization
onLoad: function() {
},
init:function(data){
if(data!=null && data != ""){
this.roomid.string = "让好友扫描加入房间,房间号:"+data ;
}
var qrcode = new QRCode(6, QRErrorCorrectLevel.H);
qrcode.addData(data);
qrcode.make();
let size = this.qrgraphics.width;
let num = qrcode.getModuleCount();
var ctx = this.qrgraphics.getComponent(cc.Graphics);
ctx.clear();
ctx.fillColor = cc.Color.BLACK;
// compute tileW/tileH based on node width and height
var tileW = size / num;
var tileH = size / num;
// draw in the Graphics
for (var row = 0; row < num; row++) {
for (var col = 0; col < num; col++) {
if (qrcode.isDark(row, col)) {
// cc.log(row, col)
// ctx.fillColor = cc.Color.BLACK;
var w = (Math.ceil((col + 1) * tileW) - Math.floor(col * tileW));
var h = (Math.ceil((row + 1) * tileW) - Math.floor(row * tileW));
ctx.rect(Math.round(col * tileW), size - tileH - Math.round(row * tileH), w, h);
ctx.fill();
} else {
// ctx.fillColor = cc.Color.WHITE;
}
// var w = (Math.ceil((col + 1) * tileW) - Math.floor(col * tileW));
// var h = (Math.ceil((row + 1) * tileW) - Math.floor(row * tileW));
// ctx.rect(Math.round(col * tileW), Math.round(row * tileH), w, h);
// ctx.fill();
}
}
}
});
@@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "cfbb8c37-51b5-4e03-8414-50a1ae0974bc",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
@@ -0,0 +1,65 @@
cc.Class({
extends: cc.Component,
properties: {
// foo: {
// default: null, // The default value will be used only when the component attaching
// to a node for the first time
// url: cc.Texture2D, // optional, default is typeof default
// serializable: true, // optional, default is true
// visible: true, // optional, default is true
// displayName: 'Foo', // optional
// readonly: false, // optional, default is false
// },
// ...
},
// use this for initialization
onLoad: function () {
},
/**
* @param self 调用的源
* @param timernode 计时器所在的节点
* @param atlas 计时器图集
* @param timer_first 计时器首个计时字母
* @param timer_sec 计时器第二个数字
* @param times 计时器执行次数
*/
runtimer:function(source , timernode , atlas, timer_first , timer_sec , times){
let self = this ;
this.remaining = times ;
timer_first.string = times ;
if(timernode){
timernode.active = true ;
}
this.timersrc = function() {
self.remaining = self.remaining - 1 ;
if(self.remaining < 0){
source.unschedule(this);
timernode.active = false ;
}else{
timer_first.string = self.remaining ;
}
} ;
source.schedule(this.timersrc, 1 , times , 0);
return this.timersrc ;
},
stoptimer:function(source , timernode , timer){
if(timernode){
timernode.active = false ;
}
let self = this ;
this.remaining = 0;
if(timer){
source.unscheduleAllCallbacks();
}
}
// called every frame, uncomment this function to activate update callback
// update: function (dt) {
// },
});
@@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "35465b59-1680-4ab0-a2ff-af9ae4ad2e02",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
@@ -0,0 +1,370 @@
var beiMiCommon = require("BeiMiCommon");
cc.Class({
extends: beiMiCommon,
properties: {
// foo: {
// default: null, // The default value will be used only when the component attaching
// to a node for the first time
// url: cc.Texture2D, // optional, default is typeof default
// serializable: true, // optional, default is true
// visible: true, // optional, default is true
// displayName: 'Foo', // optional
// readonly: false, // optional, default is false
// },
// ...
username: {
default: null,
type: cc.Label
},
goldcoins: {
default: null,
type: cc.Label
},
dizhu: {
default: null,
type: cc.Node
},
pokertag: {
default: null,
type: cc.Node
},
pokercards: {
default: null,
type: cc.Label
},
timer:{
default: null,
type: cc.Node
},
jsq:{
default: null,
type: cc.Node
},
headimg:{
default: null,
type: cc.Node
},
atlas: {
default: null,
type: cc.SpriteAtlas
},
timer_num:{
default: null,
type: cc.Label
},
result:{
default: null,
type: cc.Node
},
lastcards:{
default: null,
type: cc.Node
},
cannot:{
default: null,
type: cc.Node
},
donot:{
default: null,
type: cc.Node
}
},
// use this for initialization
onLoad: function () {
this.cardcount = 0 ;
this.cardslist = new Array();
this.isRight = false ;
},
initplayer:function(data , isRight){
this.username.string = data.username ;
this.userid = data.id ;
if(isRight == true){
this.pokertag.x = this.pokertag.x * -1;
this.timer.x = this.timer.x * -1;
this.headimg.x = this.headimg.x * -1
this.result.x = this.result.x * -1
this.cannot.x = this.cannot.x * -1
this.donot.x = this.donot.x * -1
this.jsq.x = this.jsq.x * -1
this.dizhu.x = this.dizhu.x * -1
//this.lastcards.x = this.lastcards.x * -1
this.lastcards.getComponent(cc.Layout).horizontalDirection = 0 ;
this.isRight = isRight ;
}
if(this.goldcoins){
if(data.goldcoins > 10000){
var num = this.goldcoins / 10000 ;
this.goldcoins.string = num.toFixed(2) + '万';
}else{
this.goldcoins.string = data.goldcoins;
}
}
if(this.dizhu){
this.dizhu.active = false ;
}
if(this.jsq){
this.jsq.active = false ;
}
if(this.result){
this.result.active = false ;
}
if(this.cannot){
this.cannot.active = false ;
}
if(this.donot){
this.donot.active = false ;
}
if(this.takecards){
this.takecards.active = false ;
}
},
countcards:function(cards){
this.cardcount = this.cardcount + cards ;
this.pokercards.string = this.cardcount ;
},
resetcards:function(cards){
this.cardcount = cards ;
if(this.pokercards != null){
this.pokercards.string = this.cardcount ;
}
},
catchtimer:function(times){
if(this.jsq){
this.jsq.active = true ;
}
if(this.result){
this.result.active = false ;
}
if(this.cannot){
this.cannot.active = false ;
}
if(this.donot){
this.donot.active = false ;
}
let self = this ;
var gameTimer = require("GameTimer");
this.beimitimer = new gameTimer();
this.timesrc = this.beimitimer.runtimer(this , this.jsq , this.atlas , this.timer_num , this.timer_num , times);
},
catchresult:function(data){
if(this.beimitimer){
this.beimitimer.stoptimer(this , this.jsq , this.timesrc);
var dograb = this.atlas.getSpriteFrame('提示_抢地主');
var docatch = this.atlas.getSpriteFrame('提示_不抢');
if(data.grab){
//抢地主
if(this.result){
this.result.getComponent(cc.Sprite).spriteFrame = dograb;
this.result.active = true ;
}
if(this.cannot){
this.cannot.active = false ;
}
if(this.donot){
this.donot.active = false ;
}
}else{
//叫地主
if(this.result){
this.result.getComponent(cc.Sprite).spriteFrame = docatch;
this.result.active = true ;
}
if(this.cannot){
this.cannot.active = false ;
}
if(this.donot){
this.donot.active = false ;
}
}
}
},
hideresult:function(){
if(this.result){
this.result.active = false ;
}
if(this.cannot){
this.cannot.active = false ;
}
if(this.donot){
this.donot.active = false ;
}
},
lasthands:function(self, game ,data){ //所有玩家共用的
this.hideresult();
if(this.beimitimer && this.timesrc) {
this.beimitimer.stoptimer(this, this.jsq, this.timesrc);
}
if(this.userid == data.userid){//设置地主
if(this.pokercards){
this.countcards(3) ;
}
/**
* 开始计时
*/
this.playtimer(game , 25) ;
}
this.setDizhuFlag(data);
},
setDizhuFlag:function(data){
if(this.userid == data.userid){//设置地主
this.dizhu.active = true ;
}else{
this.dizhu.active = false ;
}
},
lasttakecards:function(game , self , cardsnum ,cards ,data) {
if (this.beimitimer && this.timesrc) {
this.beimitimer.stoptimer(this, this.jsq, this.timesrc);
}
if (this.result) {
this.result.active = false;
}
if (this.cannot) {
this.cannot.active = false;
}
if (this.donot) {
this.donot.active = false;
}
if (this.jsq) {
this.jsq.active = false;
}
if (this.lastcards) {
this.lastcards.active = true;
}
if(this.cardslist.length > 0){
for (var i = 0; i < this.cardslist.length; i++) {
game.minpokerpool.put(this.cardslist[i]);//回收回去
}
this.cardslist.splice(0, this.cardslist.length);//删除数组里的所有内容
}
if (data.donot == false || data.finished == true) {
this.resetcards(cardsnum);
for (var i = 0; i < cards.length; i++) {
this.playcards(game, i, cards[i] , cards);
}
this.layout(this.lastcards , function(fir , sec){
return fir.zIndex - sec.zIndex ;
});
}else{
if(data.sameside == "1"){
self.getPlayer(data.userid).tipdonot();
}else{
self.getPlayer(data.userid).tipcannot();
}
}
},
tipcannot:function(){
if(this.result){
this.result.active = false ;
}
if(this.cannot){
this.cannot.active = true ;
}
if(this.donot){
this.donot.active = false ;
}
},
tipdonot:function(){
if(this.result){
this.result.active = false ;
}
if(this.cannot){
this.cannot.active = false ;
}
if(this.donot){
this.donot.active = true ;
}
},
playcards:function(game , index, card , cards){
let currpoker = game.minpokerpool.get() ;
currpoker.x = index * 30 - 30 ;
// if(this.isRight == true){
// currpoker.zIndex = 100 - index;
// }else{
// currpoker.zIndex = index;
// }
let zIndex = this.countcard(card , cards) ;
currpoker.zIndex = 4 - zIndex ;
currpoker.parent = this.lastcards ;
this.cardslist.push(currpoker) ;
let beiMiCard = currpoker.getComponent("BeiMiCard");
beiMiCard.setCard(card) ;
beiMiCard.order();
},
/**
* 按照张数最大的牌排序
* @param card
* @param lastcards
* @returns {number}
*/
countcard:function(card , lastcards){
let value = parseInt(card / 4);
let count = 0 ;
for(var i = 0 ;i<lastcards.length ; i++){
let temp = parseInt(lastcards[i] / 4) ;
if(value == temp){
count = count + 1 ;
}
}
return count ;
},
playtimer:function(game , times){
if(this.result){
this.result.active = false ;
}
if(this.cannot){
this.cannot.active = false ;
}
if(this.donot){
this.donot.active = false ;
}
if(this.lastcards){
this.lastcards.active = false ;
}
for(var i=0 ; i<this.cardslist.length ; i++){
game.minpokerpool.put(this.cardslist[i]) ;//回收回去
}
let self = this ;
var gameTimer = require("GameTimer");
this.beimitimer = new gameTimer();
this.timesrc = this.beimitimer.runtimer(this , this.jsq , this.atlas , this.timer_num , this.timer_num , times);
},
clean:function(game){
for (var i = 0; i < this.cardslist.length; i++) {
game.minpokerpool.put(this.cardslist[i]);//回收回去
}
this.resetcards(0) ;
if(this.dizhu){
this.dizhu.active = false ;
}
if(this.jsq){
this.jsq.active = false ;
}
if(this.result){
this.result.active = false ;
}
if(this.cannot){
this.cannot.active = false ;
}
if(this.donot){
this.donot.active = false ;
}
if(this.takecards){
this.takecards.active = false ;
}
}
// called every frame, uncomment this function to activate update callback
// update: function (dt) {
// },
});
@@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "04f1967d-0671-460b-9284-352e2445cd12",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
@@ -0,0 +1,6 @@
{
"ver": "1.0.1",
"uuid": "56a98759-c6f4-4a84-8113-475a1dfeba46",
"isGroup": false,
"subMetas": {}
}
@@ -0,0 +1,156 @@
var beiMiCommon = require("BeiMiCommon");
cc.Class({
extends: beiMiCommon,
properties: {
// foo: {
// default: null, // The default value will be used only when the component attaching
// to a node for the first time
// url: cc.Texture2D, // optional, default is typeof default
// serializable: true, // optional, default is true
// visible: true, // optional, default is true
// displayName: 'Foo', // optional
// readonly: false, // optional, default is false
// },
// ...
card : cc.Integer,
initcard : {
default: null,
type: cc.Node
},
normal: {
default: null,
type: cc.Node
},
lefttop: {
default: null,
type: cc.Node
},
leftcolor: {
default: null,
type: cc.Node
},
rightbottom: {
default: null,
type: cc.Node
},
rightcolor: {
default: null,
type: cc.Node
},
kingbg:{
default: null,
type: cc.Node
},
king: {
default: null,
type: cc.Node
},
atlas: {
default: null,
type: cc.SpriteAtlas
}
},
proxy:function(data){
this.game = data ;
},
// use this for initialization
onLoad: function () {
this.initcard.active = true ;
this.normal.active = false;
this.selected = false ;
this.kingbg.active = false ;
},
setCard:function(card){
this.card = card ;
this.normal.y = 0;
this.normal.active = false;
this.kingbg.y = 0 ;
this.kingbg.active = false ;
},
unselected:function(){
if(this.selected){
if(this.card >= 52){
this.kingbg.y = 0;
}else{
this.normal.y = 0;
}
}
this.selected = false ;
},
doselect:function(){
if(this.selected == false){
if(this.card >= 52) {
this.kingbg.y = this.kingbg.y + 30;
}else{
this.normal.y = this.normal.y + 30;
}
this.selected = true ;
}else{
this.unselected();
}
},
order:function(){
let self = this ;
var frame , cardframe ;
if(self.card < 52){
var cardvalue = self.card+1 ;
if(cardvalue % 4 == 0){
frame = this.atlas.getSpriteFrame('方片');
}else if(cardvalue % 4 == 1){
frame = this.atlas.getSpriteFrame('黑桃');
}else if(cardvalue % 4 == 2){
frame = this.atlas.getSpriteFrame('红心');
}else if(cardvalue % 4 == 3){
frame = this.atlas.getSpriteFrame('梅花');
}
var src = (self.card - self.card % 4 ) / 4 + 1 + 2;
if(src == 14){
src = 1 ;
}else if(src == 15){
src = 2 ;
}
if(self.card % 2 == 0){
cardframe = this.atlas.getSpriteFrame(src);
}else{
cardframe = this.atlas.getSpriteFrame('r'+src);
}
this.leftcolor.getComponent(cc.Sprite).spriteFrame = frame;
this.lefttop.getComponent(cc.Sprite).spriteFrame = cardframe;
this.rightcolor.getComponent(cc.Sprite).spriteFrame = frame;
this.rightbottom.getComponent(cc.Sprite).spriteFrame = cardframe;
this.initcard.active = false ;
this.normal.active = true ;
this.kingbg.active = false ;
this.normal.y = 0 ;
}else if(self.card == 52){
frame = this.atlas.getSpriteFrame('小王_大');
this.king.getComponent(cc.Sprite).spriteFrame = frame;
this.initcard.active = false ;
this.normal.active = false;
this.kingbg.active = true ;
this.kingbg.y = 0 ;
}else if(self.card == 53){
frame = this.atlas.getSpriteFrame('大王_大');
this.king.getComponent(cc.Sprite).spriteFrame = frame;
this.initcard.active = false ;
this.normal.active = false;
this.kingbg.active = true ;
this.kingbg.y = 0 ;
}
},
reset:function(){
this.normal.y = 0;
this.kingbg.y = 0;
this.normal.active = false;
this.kingbg.active = false;
}
// called every frame, uncomment this function to activate update callback
// update: function (dt) {
// },
});
@@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "985648d8-743e-4b14-9594-8d3399259610",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
@@ -0,0 +1,315 @@
cc.Class({
extends: cc.Component,
properties: {
// foo: {
// default: null, // The default value will be used only when the component attaching
// to a node for the first time
// url: cc.Texture2D, // optional, default is typeof default
// serializable: true, // optional, default is true
// visible: true, // optional, default is true
// displayName: 'Foo', // optional
// readonly: false, // optional, default is false
// },
// ...
},
// use this for initialization
onLoad: function () {
cc.beimi.room_callback = null ; //加入房间回调函数
},
ready:function(){
var check = false ;
if(cc.beimi){
check = true ;
}else{
this.scene("login" , this) ;
}
return check ;
},
connect:function(){
let self = this ;
/**
* 登录成功后,创建 Socket链接,
*/
if(cc.beimi.socket != null){
cc.beimi.socket.disconnect();
cc.beimi.socket = null ;
}
cc.beimi.socket = window.io.connect(cc.beimi.http.wsURL + '/bm/game',{"reconnection":true});
var param = {
token:cc.beimi.authorization,
orgi:cc.beimi.user.orgi
} ;
cc.game.on(cc.game.EVENT_HIDE, function(event) {
//self.alert("HIDE TRUE");
});
cc.game.on(cc.game.EVENT_SHOW, function(event) {
console.log("SHOW TRUE");
//self.alert("SHOW TRUE");
});
cc.beimi.socket.on('connect', function (data) {
console.log("connected to server");
//self.alert("connected to server");
});
cc.beimi.socket.on('disconnect', function (data) {
console.log("disconnected from server");
//self.alert("disconnected from server");
});
cc.beimi.socket.emit("gamestatus" , JSON.stringify(param));
cc.beimi.socket.on("gamestatus" , function(result){
if(result!=null) {
var data = self.parse(result) ;
if(cc.beimi.extparams !=null){
if(data.gamestatus == "playing" && data.gametype != null){
/**
* 修正重新进入房间后 玩法被覆盖的问题,从服务端发送过来的 玩法数据是 当前玩家所在房间的玩法,是准确的
*/
if(cc.beimi.extparams!=null){
cc.beimi.extparams.playway = data.playway ;
cc.beimi.extparams.gametype = data.gametype ;
if(data.cardroom!=null && data.cardroom == true){
cc.beimi.extparams.gamemodel = "room";
}
}
self.scene(data.gametype , self) ;
}else if(data.gamestatus == "timeout"){ //会话过期,退出登录 , 会话时间由后台容器提供控制
cc.beimi.sessiontimeout = true ;
self.alert("登录已过期,请重新登录") ;
}else{
self.scene(cc.beimi.extparams.gametype , self) ;
}
}
cc.beimi.gamestatus = data.gamestatus;
}
});
/**
* 加入房卡模式的游戏类型 , 需要校验是否是服务端发送的消息
*/
cc.beimi.socket.on("searchroom" , function(result){
//result 是 GamePlayway数据,如果找到了 房间数据,则进入房间,如果未找到房间数据,则提示房间不存在
if(result!=null && cc.beimi.room_callback!=null) {
cc.beimi.room_callback(result , self);
}
});
return cc.beimi.socket ;
},
disconnect:function(){
if(cc.beimi.socket != null){
cc.beimi.socket.disconnect();
cc.beimi.socket = null ;
}
},
registercallback:function(callback){
cc.beimi.room_callback = callback ;
},
cleancallback:function(){
cc.beimi.room_callback = null ;
},
getCommon:function(common){
var object = cc.find("Canvas/script/"+common) ;
return object.getComponent(common);
},
loadding:function(){
if(cc.beimi.loadding.size() > 0){
this.loaddingDialog = cc.beimi.loadding.get();
this.loaddingDialog.parent = cc.find("Canvas");
this._animCtrl = this.loaddingDialog.getComponent(cc.Animation);
var animState = this._animCtrl.play("loadding");
animState.wrapMode = cc.WrapMode.Loop;
}
},
alert:function(message){
if(cc.beimi.dialog.size() > 0){
this.alertdialog = cc.beimi.dialog.get();
this.alertdialog.parent = cc.find("Canvas");
let node = this.alertdialog.getChildByName("message") ;
if(node!=null && node.getComponent(cc.Label)){
node.getComponent(cc.Label).string = message ;
}
}
this.closeloadding();
},
closeloadding:function(){
if(cc.find("Canvas/loadding")){
cc.beimi.loadding.put(cc.find("Canvas/loadding"));
}
},
closeOpenWin:function(){
if(cc.beimi.openwin != null){
cc.beimi.openwin.destroy();
cc.beimi.openwin = null ;
}
},
pvalistener:function(context , func){
cc.beimi.listener = func ;
cc.beimi.context = context ;
},
cleanpvalistener:function(){
cc.beimi.listener = null ;
cc.beimi.context = null ;
},
pva:function(pvatype , balance){ //客户端资产变更(仅显示,多个地方都会调用 pva方法)
if(pvatype != null){
if(pvatype == "gold"){
cc.beimi.user.goldcoins = balance ;
}else if(pvatype == "cards"){
cc.beimi.user.cards = balance ;
}else if(pvatype == "diamonds"){
cc.beimi.user.diamonds = balance ;
}
}
},
updatepva:function(){
if(cc.beimi.listener != null && cc.beimi.context != null){
cc.beimi.listener(cc.beimi.context);
}
},
resize:function(){
let win = cc.director.getWinSize() ;
cc.view.setDesignResolutionSize(win.width, win.height, cc.ResolutionPolicy.EXACT_FIT);
},
closealert:function(){
if(cc.find("Canvas/alert")){
cc.beimi.dialog.put(cc.find("Canvas/alert"));
}
},
scene:function(name , self){
cc.director.preloadScene(name, function () {
if(cc.beimi){
self.closeloadding(self.loaddingDialog);
}
cc.director.loadScene(name);
});
},
preload:function(extparams , self){
this.loadding();
/**
*切换游戏场景之前,需要先检查是否 是在游戏中,如果是在游戏中,则直接进入该游戏,如果不在游戏中,则执行 新场景游戏
*/
cc.beimi.extparams = extparams ;
/**
* 发送状态查询请求,如果玩家当前在游戏中,则直接进入游戏回复状态,如果玩家不在游戏中,则创建新游戏场景
*/
var param = {
token:cc.beimi.authorization,
orgi:cc.beimi.user.orgi
} ;
cc.beimi.socket.emit("gamestatus" , JSON.stringify(param));
},
root:function(){
return cc.find("Canvas");
},
decode:function(data){
var cards = new Array();
if(!cc.sys.isNative) {
var dataView = new DataView(data);
for(var i= 0 ; i<data.byteLength ; i++){
cards[i] = dataView.getInt8(i);
}
}else{
var Base64 = require("Base64");
var strArray = Base64.decode(data) ;
if(strArray && strArray.length > 0){
for(var i= 0 ; i<strArray.length ; i++){
cards[i] = strArray[i];
}
}
}
return cards ;
},
parse:function(result){
var data ;
if(!cc.sys.isNative){
data = result;
}else{
data = JSON.parse(result) ;
}
return data ;
},
reset:function(data , result){
//放在全局变量
cc.beimi.authorization = data.token.id ;
cc.beimi.user = data.data ;
cc.beimi.games = data.games ;
cc.beimi.gametype = data.gametype ;
cc.beimi.data = data ;
cc.beimi.playway = null ;
this.io.put("userinfo" ,result );
},
logout:function(){
this.closeOpenWin();
cc.beimi.authorization = null ;
cc.beimi.user = null ;
cc.beimi.games = null ;
cc.beimi.playway = null ;
this.disconnect();
},
socket:function(){
let socket = cc.beimi.socket ;
if(socket == null){
socket = this.connect();
}
return socket ;
},
map:function(command, callback){
if(cc.beimi!=null && cc.beimi.routes[command] == null){
cc.beimi.routes[command] = callback || function(){};
}
},
cleanmap:function(){
if(cc.beimi!=null && cc.beimi.routes != null){
//cc.beimi.routes.splice(0 , cc.beimi.routes.length) ;
for(var p in cc.beimi.routes){
delete cc.beimi.routes[p];
}
}
},
route:function(command){
return cc.beimi.routes[command] || function(){};
},
/**
* 解决Layout的渲染顺序和显示顺序不一致的问题
* @param target
* @param func
*/
layout:function(target , func){
if(target != null){
let temp = new Array() ;
let children = target.children ;
for(var inx = 0 ; inx < children.length ; inx++){
temp.push(children[inx]) ;
}
for(var inx = 0 ; inx < temp.length ; inx++){
target.removeChild(temp[inx]) ;
}
temp.sort(func) ;
for(var inx =0 ; inx<temp.length ; inx++){
temp[inx].parent = target ;
}
temp.splice(0 , temp.length) ;
}
}
// called every frame, uncomment this function to activate update callback
// update: function (dt) {
// },
});
@@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "4442a2ef-0137-4342-aaaa-f62850d903fb",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
@@ -0,0 +1,44 @@
var beiMiCommon = require("BeiMiCommon");
cc.Class({
extends: beiMiCommon,
properties: {
// foo: {
// default: null, // The default value will be used only when the component attaching
// to a node for the first time
// url: cc.Texture2D, // optional, default is typeof default
// serializable: true, // optional, default is true
// visible: true, // optional, default is true
// displayName: 'Foo', // optional
// readonly: false, // optional, default is false
// },
// ...
},
// use this for initialization
onLoad: function () {
this.node.on(cc.Node.EventType.TOUCH_START, function(e){
e.stopPropagation();
});
/**
* 关闭ALERT的回调动作
*/
this.node.on("close", function (event) {
if(cc.beimi!=null && cc.beimi.sessiontimeout == true){
cc.beimi.sessiontimeout = null;
self.scene("login" , self) ;
}
event.stopPropagation();
});
},
onClose:function(){
let dialog = cc.find("Canvas/alert") ;
cc.beimi.dialog.put(dialog);
this.node.dispatchEvent( new cc.Event.EventCustom("close", true) );
}
// called every frame, uncomment this function to activate update callback
// update: function (dt) {
// },
});
@@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "7c2f5ff0-b70e-4fd0-bcb3-b8a13357674f",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
@@ -0,0 +1,45 @@
var beiMiCommon = require("BeiMiCommon");
cc.Class({
extends: beiMiCommon,
properties: {
// foo: {
// // ATTRIBUTES:
// default: null, // The default value will be used only when the component attaching
// // to a node for the first time
// type: cc.SpriteFrame, // optional, default is typeof default
// serializable: true, // optional, default is true
// },
// bar: {
// get () {
// return this._bar;
// },
// set (value) {
// this._bar = value;
// }
// },
playway:{
default : null ,
type : cc.Node
}
},
// LIFE-CYCLE CALLBACKS:
onLoad :function() {},
onClick : function() {
if(this.playway!=null){
let script = this.playway.getComponent("RoomPlayway") ;
let roomplayway = cc.instantiate(script.roomoption) ;
cc.beimi.openwin = roomplayway ;
cc.beimi.openwin.parent = this.root();
let roomoption = roomplayway.getComponent("RoomOption") ;
if(roomoption!=null){
roomoption.init(script.data);
}
}
},
// update (dt) {},
});
@@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "214d0307-482e-4372-8138-b126657f2cf6",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
@@ -0,0 +1,48 @@
var beiMiCommon = require("BeiMiCommon");
cc.Class({
extends: beiMiCommon,
properties: {
// foo: {
// default: null, // The default value will be used only when the component attaching
// to a node for the first time
// url: cc.Texture2D, // optional, default is typeof default
// serializable: true, // optional, default is true
// visible: true, // optional, default is true
// displayName: 'Foo', // optional
// readonly: false, // optional, default is false
// },
// ...
text: {
default: null,
type: cc.Label
}
},
// use this for initialization
onLoad: function () {
},
init:function(text , time , target){
let self = this ;
this.remaining = time ;
this.text.string = text +""+ this.remaining +"" ;
this.schedule(function() {
this.remaining = this.remaining - 1 ;
if(this.remaining < 0){
self.unschedule(this);
}else{
self.text.string = text +""+ this.remaining +"" ;
}
}, 1 , time);
},
stop:function(target){
this.remaining = 0 ;
target.destroy();
}
// called every frame, uncomment this function to activate update callback
// update: function (dt) {
// },
});
@@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "392560b4-7794-4b5d-ab5e-8fb1939bdfea",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
@@ -0,0 +1,28 @@
cc.Class({
extends: cc.Component,
properties: {
// foo: {
// default: null, // The default value will be used only when the component attaching
// to a node for the first time
// url: cc.Texture2D, // optional, default is typeof default
// serializable: true, // optional, default is true
// visible: true, // optional, default is true
// displayName: 'Foo', // optional
// readonly: false, // optional, default is false
// },
// ...
},
// use this for initialization
onLoad: function () {
this.node.on(cc.Node.EventType.TOUCH_START, function(e){
e.stopPropagation();
});
},
// called every frame, uncomment this function to activate update callback
// update: function (dt) {
// },
});
@@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "ac9b4bce-4e2f-4e2a-a43a-f0aba3ebea13",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
@@ -0,0 +1,33 @@
cc.Class({
extends: cc.Component,
properties: {
// foo: {
// default: null, // The default value will be used only when the component attaching
// to a node for the first time
// url: cc.Texture2D, // optional, default is typeof default
// serializable: true, // optional, default is true
// visible: true, // optional, default is true
// displayName: 'Foo', // optional
// readonly: false, // optional, default is false
// },
// ...
},
// use this for initialization
statics:{
get:function(key){
return cc.sys.localStorage.getItem(key) ;
},
put:function(key , value){
cc.sys.localStorage.setItem(key, value) ;
},
remove:function(key){
cc.sys.localStorage.removeItem(key) ;
}
}
// called every frame, uncomment this function to activate update callback
// update: function (dt) {
// },
});
@@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "396105fa-1841-4796-b4c6-01d77759c7ab",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
@@ -0,0 +1,34 @@
var beiMiCommon = require("BeiMiCommon") ;
cc.Class({
extends: beiMiCommon,
properties: {
// foo: {
// default: null, // The default value will be used only when the component attaching
// to a node for the first time
// url: cc.Texture2D, // optional, default is typeof default
// serializable: true, // optional, default is true
// visible: true, // optional, default is true
// displayName: 'Foo', // optional
// readonly: false, // optional, default is false
// },
// .
},
// use this for initialization
onLoad: function () {
this.node.on(cc.Node.EventType.TOUCH_START, function(e){
e.stopPropagation();
});
},
onCloseClick:function(){
/**
* * 对象池返回, 释放资源 , 同时 解除 事件绑定
*
* */
let common = this.getCommon("common");
if(common!=null){
common.loginFormPool.put(common.dialog) ;
}
}
});
@@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "6a4c7f80-496c-4fcd-bf3e-5fd139b54fda",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
@@ -0,0 +1,6 @@
{
"ver": "1.0.1",
"uuid": "5157d97e-c77d-4ddb-8a74-4a2fb69816d1",
"isGroup": false,
"subMetas": {}
}
@@ -0,0 +1,98 @@
cc.Class({
extends: cc.Component,
properties: {
// foo: {
// default: null, // The default value will be used only when the component attaching
// to a node for the first time
// url: cc.Texture2D, // optional, default is typeof default
// serializable: true, // optional, default is true
// visible: true, // optional, default is true
// displayName: 'Foo', // optional
// readonly: false, // optional, default is false
// },
// ...
bgVolume:1.0, // 背景音量
deskVolume:1.0, // 房间 房间音量
bgAudioID:-1 // 背景 音乐 id
},
// use this for initialization
init: function () {
var t = cc.sys.localStorage.getItem("bgVolume");
if(t != null){
this.bgVolume = parseFloat(t);
}
var t = cc.sys.localStorage.getItem("deskVolume");
if(t != null){
this. deskVolume = parseFloat(t);
}
cc.game.on(cc.game.EVENT_HIDE, function () {
cc.audioEngine.pauseAll();
});
cc.game.on(cc.game.EVENT_SHOW, function () {
cc.audioEngine.resumeAll();
});
},
// called every frame, uncomment this function to activate update callback
// update: function (dt) {
// },
getUrl:function(url){
return cc.url.raw("resources/sounds/" + url);
},
playBGM:function(url){
var audioUrl = this.getUrl(url);
if(this.bgAudioID >= 0){
cc.audioEngine.stop(this.bgAudioID);
}
this.bgAudioID = cc.audioEngine.play(audioUrl,true,this.bgVolume);
},
playSFX:function(url){
var audioUrl = this.getUrl(url);
if(this.sfxVolume > 0){
var audioId = cc.audioEngine.play(audioUrl,false,this.deskVolume);
}
},
setSFXVolume:function(v){
if(this.sfxVolume != v){
cc.sys.localStorage.setItem("deskVolume",v);
this.deskVolume = v;
}
},
getState:function(){
return cc.audioEngine.getState(this.bgAudioID);
},
setBGMVolume:function(v,force){
if(this.bgAudioID >= 0){
if(v > 0 && cc.audioEngine.getState(this.bgAudioID) === cc.audioEngine.AudioState.PAUSED){
cc.audioEngine.resume(this.bgAudioID);
}else if(v == 0){
cc.audioEngine.pause(this.bgAudioID);
}
}
if(this.bgVolume != v || force){
cc.sys.localStorage.setItem("bgVolume",v);
this.bgmVolume = v;
cc.audioEngine.setVolume(this.bgAudioID,v);
}
},
pauseAll:function(){
cc.audioEngine.pauseAll();
},
resumeAll:function(){
cc.audioEngine.resumeAll();
}
});
@@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "d983b1b1-aeb6-47b7-a57f-fdb08e9eb497",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
@@ -0,0 +1,137 @@
cc.Class({
extends: cc.Component,
properties: {
// foo: {
// default: null, // The default value will be used only when the component attaching
// to a node for the first time
// url: cc.Texture2D, // optional, default is typeof default
// serializable: true, // optional, default is true
// visible: true, // optional, default is true
// displayName: 'Foo', // optional
// readonly: false, // optional, default is false
// },
// ...
},
statics:{
decode : function(_base64Str){
var BASE64_MAPPING = [
'A','B','C','D','E','F','G','H',
'I','J','K','L','M','N','O','P',
'Q','R','S','T','U','V','W','X',
'Y','Z','a','b','c','d','e','f',
'g','h','i','j','k','l','m','n',
'o','p','q','r','s','t','u','v',
'w','x','y','z','0','1','2','3',
'4','5','6','7','8','9','+','/'
];
var _len = _base64Str.length;
var extra_Zero_Count = 0;
/**
*计算在进行BASE64编码的时候,补了几个0
*/
if(_base64Str.charAt(_len-1) == '='){
//alert(_base64Str.charAt(_len-1));
//alert(_base64Str.charAt(_len-2));
if(_base64Str.charAt(_len-2) == '='){//两个等号说明补了4个0
extra_Zero_Count = 4;
_base64Str = _base64Str.substring(0 , _len-2);
}else{//一个等号说明补了2个0
extra_Zero_Count = 2;
_base64Str = _base64Str.substring(0 , _len - 1);
}
}
var binaryArray = [];
for(var i = 0 , len = _base64Str.length; i < len ; ++i){
var c = _base64Str.charAt(i);
for(var j = 0 , size = BASE64_MAPPING.length ; j < size ; ++j){
if(c == BASE64_MAPPING[j]){
var _tmp = this._toBinary(j);
/*不足6位的补0*/
var _tmpLen = _tmp.length;
if(6-_tmpLen > 0){
for(var k = 6-_tmpLen ; k > 0 ; --k){
_tmp.unshift(0);
}
}
binaryArray = binaryArray.concat(_tmp);
break;
}
}
}
if(extra_Zero_Count > 0){
binaryArray = binaryArray.slice(0 , binaryArray.length - extra_Zero_Count);
}
var unicode = [];
var unicodeBinary = [];
for(var i = 0 , len = binaryArray.length ; i < len ; ){
if(binaryArray[i] == 0){
unicode=unicode.concat(this._toDecimal(binaryArray.slice(i,i+8)));
i += 8;
}else{
var sum = 0;
while(i < len){
if(binaryArray[i] == 1){
++sum;
}else{
break;
}
++i;
}
unicodeBinary = unicodeBinary.concat(binaryArray.slice(i+1 , i+8-sum));
i += 8 - sum;
while(sum > 1){
unicodeBinary = unicodeBinary.concat(binaryArray.slice(i+2 , i+8));
i += 8;
--sum;
}
unicode = unicode.concat(this._toDecimal(unicodeBinary));
unicodeBinary = [];
}
}
return unicode;
},
_toBinary : function(ascii){
var binary = new Array();
while(ascii > 0){
var b = ascii%2;
ascii = Math.floor(ascii/2);
binary.push(b);
}
/*
var len = binary.length;
if(6-len > 0){
for(var i = 6-len ; i > 0 ; --i){
binary.push(0);
}
}*/
binary.reverse();
return binary;
},
_toDecimal : function(binary){
var dec = 0;
var p = 0;
for(var i = binary.length-1 ; i >= 0 ; --i){
var b = binary[i];
if(b == 1){
dec += Math.pow(2 , p);
}
++p;
}
return dec;
}
},
// use this for initialization
onLoad: function () {
},
// called every frame, uncomment this function to activate update callback
// update: function (dt) {
// },
});
@@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "8a9bc3e8-e066-4bd9-a62e-a92e466ecf3f",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
@@ -0,0 +1,112 @@
cc.VERSION = 2017061001;
var HTTP = cc.Class({
extends: cc.Component,
properties: {
// foo: {
// default: null, // The default value will be used only when the component attaching
// to a node for the first time
// url: cc.Texture2D, // optional, default is typeof default
// serializable: true, // optional, default is true
// visible: true, // optional, default is true
// displayName: 'Foo', // optional
// readonly: false, // optional, default is false
// },
// ...
},
statics: {
baseURL:"http://192.168.1.155",
wsURL : "http://192.168.1.155:9081",
authorization: null,
httpGet: function (url , success , error , object) {
var xhr = cc.loader.getXMLHttpRequest();
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
if(xhr.status >= 200 && xhr.status < 300){
var respone = xhr.responseText;
if(success){
success(respone , object);
}
}else{
if(error){
error(object);
}
}
}
};
xhr.open("GET", HTTP.baseURL+url, true);
if(HTTP.authorization != null){
xhr.setRequestHeader("authorization", HTTP.authorization) ;
}
if (cc.sys.isNative) {
xhr.setRequestHeader("Accept-Encoding", "gzip,deflate");
}
//超时回调
xhr.ontimeout = function(event){
error(object);
};
xhr.onerror = function(event){
error(object);
};
// note: In Internet Explorer, the timeout property may be set only after calling the open()
// method and before calling the send() method.
xhr.timeout = 3000;// 5 seconds for timeout
xhr.send();
},
encodeFormData : function(data)
{
var pairs = [];
var regexp = /%20/g;
for (var name in data){
var value = data[name].toString();
var pair = encodeURIComponent(name).replace(regexp, "+") + "=" +
encodeURIComponent(value).replace(regexp, "+");
pairs.push(pair);
}
return pairs.join("&");
},
httpPost: function (url, params, success , error , object) {
var xhr = cc.loader.getXMLHttpRequest();
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
if(xhr.status >= 200 && xhr.status < 300){
var respone = xhr.responseText;
if(success){
success(respone , object);
}
}else{
if(error){
error(object);
}
}
}
};
xhr.open("POST", HTTP.baseURL+url, true);
if(HTTP.authorization !== null){
xhr.setRequestHeader("authorization", HTTP.authorization) ;
}
if (cc.sys.isNative) {
xhr.setRequestHeader("Accept-Encoding", "gzip,deflate");
}
xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
// note: In Internet Explorer, the timeout property may be set only after calling the open()
// method and before calling the send() method.
xhr.timeout = 5000;// 5 seconds for timeout
xhr.send( HTTP.encodeFormData(params));
}
},
// use this for initialization
onLoad: function () {
},
});
@@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "bf727d78-b7e3-4048-9a7e-2757b9c2fd08",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "32da8e05-13e1-4f5f-b6c5-0eced61d4a7b",
"isPlugin": true,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
File diff suppressed because one or more lines are too long
@@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "83e71045-b4c1-4751-9f2f-79f2fc631979",
"isPlugin": false,
"loadPluginInWeb": false,
"loadPluginInNative": false,
"loadPluginInEditor": false,
"subMetas": {}
}