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

View File

@@ -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) {
// },
});

View File

@@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "985648d8-743e-4b14-9594-8d3399259610",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@@ -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) {
// },
});

View File

@@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "4442a2ef-0137-4342-aaaa-f62850d903fb",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@@ -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) {
// },
});

View File

@@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "7c2f5ff0-b70e-4fd0-bcb3-b8a13357674f",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@@ -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) {},
});

View File

@@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "214d0307-482e-4372-8138-b126657f2cf6",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@@ -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) {
// },
});

View File

@@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "392560b4-7794-4b5d-ab5e-8fb1939bdfea",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@@ -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) {
// },
});

View File

@@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "ac9b4bce-4e2f-4e2a-a43a-f0aba3ebea13",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@@ -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) {
// },
});

View File

@@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "396105fa-1841-4796-b4c6-01d77759c7ab",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@@ -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) ;
}
}
});

View File

@@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "6a4c7f80-496c-4fcd-bf3e-5fd139b54fda",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}