Commit e0fcb941 authored by zjz1994's avatar zjz1994

代码暂存

parent bf6a5999
...@@ -96,19 +96,19 @@ ...@@ -96,19 +96,19 @@
"assets": [ "assets": [
{ {
"name": "bg1", "name": "bg1",
"url": "//yun.duiba.com.cn/aurora/assets/b2c76b2a753317e5ea935bab22097a43a4c9f7cb.png", "url": "//yun.duiba.com.cn/aurora/assets/e6ab7c1e191d30a2b068fa4a0e867040b9396226.png",
"uuid": "bg1", "uuid": "bg1",
"ext": ".png" "ext": ".png"
}, },
{ {
"name": "bg2", "name": "bg2",
"url": "//yun.duiba.com.cn/aurora/assets/7f8261a9dd7b83cdc3b95b6f3f385e7a91e49682.png", "url": "//yun.duiba.com.cn/aurora/assets/a2d611fa5af2b26ffd57a24ff524d2a0a4fe1564.png",
"uuid": "bg2", "uuid": "bg2",
"ext": ".png" "ext": ".png"
}, },
{ {
"name": "bg3", "name": "bg3",
"url": "//yun.duiba.com.cn/aurora/assets/872c688f9c2f495fe234277256923804df2ab75e.png", "url": "//yun.duiba.com.cn/aurora/assets/89258aed59e36471a4136ce7fbc4ca7e300caf07.png",
"uuid": "bg3", "uuid": "bg3",
"ext": ".png" "ext": ".png"
}, },
...@@ -120,13 +120,13 @@ ...@@ -120,13 +120,13 @@
}, },
{ {
"name": "yindao1", "name": "yindao1",
"url": "//yun.duiba.com.cn/aurora/assets/f21d5429dbd947e66613bd6c5d864fdcfd104bd4.png", "url": "//yun.duiba.com.cn/aurora/assets/4449285320882460ae0dd0b59b3c73e0bb92def6.png",
"uuid": "yindao1", "uuid": "yindao1",
"ext": ".png" "ext": ".png"
}, },
{ {
"name": "yindao2", "name": "yindao2",
"url": "//yun.duiba.com.cn/aurora/assets/7ece2d8c438ec06004f7f40d9798ab72f0e6a244.png", "url": "//yun.duiba.com.cn/aurora/assets/1c914031834736b93e9b2a94a4e8a643871795f7.png",
"uuid": "yindao2", "uuid": "yindao2",
"ext": ".png" "ext": ".png"
}, },
......
This diff is collapsed.
...@@ -97,19 +97,19 @@ ...@@ -97,19 +97,19 @@
"assets": [ "assets": [
{ {
"name": "bg1", "name": "bg1",
"url": "//yun.duiba.com.cn/aurora/assets/b2c76b2a753317e5ea935bab22097a43a4c9f7cb.png", "url": "//yun.duiba.com.cn/aurora/assets/e6ab7c1e191d30a2b068fa4a0e867040b9396226.png",
"uuid": "bg1", "uuid": "bg1",
"ext": ".png" "ext": ".png"
}, },
{ {
"name": "bg2", "name": "bg2",
"url": "//yun.duiba.com.cn/aurora/assets/7f8261a9dd7b83cdc3b95b6f3f385e7a91e49682.png", "url": "//yun.duiba.com.cn/aurora/assets/a2d611fa5af2b26ffd57a24ff524d2a0a4fe1564.png",
"uuid": "bg2", "uuid": "bg2",
"ext": ".png" "ext": ".png"
}, },
{ {
"name": "bg3", "name": "bg3",
"url": "//yun.duiba.com.cn/aurora/assets/872c688f9c2f495fe234277256923804df2ab75e.png", "url": "//yun.duiba.com.cn/aurora/assets/89258aed59e36471a4136ce7fbc4ca7e300caf07.png",
"uuid": "bg3", "uuid": "bg3",
"ext": ".png" "ext": ".png"
}, },
...@@ -121,13 +121,13 @@ ...@@ -121,13 +121,13 @@
}, },
{ {
"name": "yindao1", "name": "yindao1",
"url": "//yun.duiba.com.cn/aurora/assets/f21d5429dbd947e66613bd6c5d864fdcfd104bd4.png", "url": "//yun.duiba.com.cn/aurora/assets/4449285320882460ae0dd0b59b3c73e0bb92def6.png",
"uuid": "yindao1", "uuid": "yindao1",
"ext": ".png" "ext": ".png"
}, },
{ {
"name": "yindao2", "name": "yindao2",
"url": "//yun.duiba.com.cn/aurora/assets/7ece2d8c438ec06004f7f40d9798ab72f0e6a244.png", "url": "//yun.duiba.com.cn/aurora/assets/1c914031834736b93e9b2a94a4e8a643871795f7.png",
"uuid": "yindao2", "uuid": "yindao2",
"ext": ".png" "ext": ".png"
}, },
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* Created by renjianfeng on 2020-03-13. * Created by renjianfeng on 2020-03-13.
*/ */
const customId = 'food-fell'; const customId = 'xiaoxiaole';
(async function () { (async function () {
let customModule = await fetch(`../meta.json`); let customModule = await fetch(`../meta.json`);
...@@ -45,23 +45,9 @@ function launchWithCustomModule(customModule) { ...@@ -45,23 +45,9 @@ function launchWithCustomModule(customModule) {
}, 100); }, 100);
setTimeout(() => { setTimeout(() => {
engine.globalEvent.dispatchEvent('food-fell-reset', { engine.globalEvent.dispatchEvent('game-init');
"goodsProbability": [0.8,0.1,0.1],
"countDown": 30,
"acceleratedSpeed":0.1
});
engine.globalEvent.dispatchEvent('food-fell-start');
}, 500); }, 500);
}); });
engine.globalEvent.addEventListener('food-fell-time-update', (e) => {
console.log(e.type, e.data);
});
engine.globalEvent.addEventListener('food-fell-score-update', (e) => {
console.log(e.type, e.data);
});
engine.globalEvent.addEventListener('food-fell-game-over', (e) => {
console.log(e.type, e.data);
});
} }
function getAssetByUUID(uuid) { function getAssetByUUID(uuid) {
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>美食从天而降</title> <title>消消乐</title>
<meta name="viewport" <meta name="viewport"
content="width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no"/> content="width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no"/>
<meta name="apple-mobile-web-app-capable" content="yes"/> <meta name="apple-mobile-web-app-capable" content="yes"/>
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
height: 100%; height: 100%;
overflow: hidden; overflow: hidden;
position: absolute; position: absolute;
background-color: red; /* background-color: red; */
} }
</style> </style>
</head> </head>
......
This diff is collapsed.
This diff is collapsed.
...@@ -6,16 +6,64 @@ ...@@ -6,16 +6,64 @@
}, },
"assets": [ "assets": [
{ {
"name": "玩家icon", "name": "底图",
"url": "//yun.duiba.com.cn/aurora/assets/50a7212a113175fa18c866b005d98f07c558dc77.png", "url": "//yun.duiba.com.cn/aurora/assets/109e30fa662276e0ee4f2e2c35b85bee6f300050.png",
"uuid": "66f23d13-82a5-4cec-9496-301ec240d087", "uuid": "map",
"ext": ".png"
},
{
"name": "房子",
"url": "//yun.duiba.com.cn/aurora/assets/df155804a46c708a714365b7247141ba0add45e5.png",
"uuid": "home",
"ext": ".png"
},
{
"name": "白虎",
"url": "//yun.duiba.com.cn/aurora/assets/b486b4a72c58850bbd1930b994e08802e34fb3e3.png",
"uuid": "btiger",
"ext": ".png"
},
{
"name": "雌虎",
"url": "//yun.duiba.com.cn/aurora/assets/c41afceb285432ed2c17c643df96efc20893adc8.png",
"uuid": "gtiger",
"ext": ".png"
},
{
"name": "猴子",
"url": "//yun.duiba.com.cn/aurora/assets/ef7bc5d1fc38267adba71e07d517330f249d23ba.png",
"uuid": "monkey",
"ext": ".png"
},
{
"name": "鸟",
"url": "//yun.duiba.com.cn/aurora/assets/9ad18dfa34e1729e9893ac362975f9e062263f70.png",
"uuid": "bird",
"ext": ".png"
},
{
"name": "树熊",
"url": "//yun.duiba.com.cn/aurora/assets/277aa43d9f1bf3dd7a18e627335a166f0509684c.png",
"uuid": "koala",
"ext": ".png"
},
{
"name": "选中框",
"url": "//yun.duiba.com.cn/aurora/assets/a3ce52a41ed53ccfa7ce404dbc10102961c4a805.png",
"uuid": "selected",
"ext": ".png" "ext": ".png"
} }
], ],
"events": { "events": {
"in": { "in": {
"game-init":{
"alias": "初始化第一关",
"data": {
}
},
"game-reset": { "game-reset": {
"alias": "重置", "alias": "关卡通过重玩之类的重置关卡",
"data": { "data": {
} }
......
This diff is collapsed.
...@@ -7,12 +7,25 @@ import {injectProps} from "../props"; ...@@ -7,12 +7,25 @@ import {injectProps} from "../props";
export class GameWrapper extends engine.Container { export class GameWrapper extends engine.Container {
private _status;
private _gameView: GameView; private _gameView: GameView;
constructor() { constructor() {
super(); super();
let gameView = this._gameView = new GameView(); this._gameView = new GameView();
this.addChild(gameView); this.addChild(this._gameView);
engine.globalEvent.addEventListener('game-init',this.init,this);
engine.globalEvent.addEventListener('game-reset',this.reset,this);
engine.globalEvent.addEventListener('game-start',this.start,this);
}
init(){
this._gameView.init();
}
reset(){
this._gameView.reset();
}
start(){
this._gameView.start();
} }
} }
import Element from "./ele/Element";
export enum ElementType{
btiger = 1,
gtiger,
monkey,
bird,
koala
}
export enum GameEvent{
SelectEle = "SelectEle",
}
export default class MapData{
//单格大小
static itemsize = 129;
//
static paddingb = 10;
static paddingi = 5;
//
static row = 5;
static col = 5;
//行-列,对应位置
static posData = {
};
static eleidx = 1;
static elePool = [];
static getRy(r){
return this.paddingb+r*(this.itemsize+this.paddingi);
}
static getCx(c){
return this.paddingb+c*(this.itemsize+this.paddingi);
}
static getRCPos(r,c){
let x = this.getCx(c);
let y = this.getRy(r);
return [x,y];
}
static adaptElePos(pos,wid,hei){
let x = pos[0]+(this.itemsize-wid)/2;
let y = pos[1]+(this.itemsize-hei)/2;
return [x,y];
}
static getEtypeImgName(type:ElementType){
let ename:string;
switch(type){
case ElementType.btiger:
ename = "白虎";
break;
case ElementType.gtiger:
ename = "雌虎";
break;
case ElementType.monkey:
ename = "猴子";
break;
case ElementType.bird:
ename = "鸟";
break;
case ElementType.koala:
ename = "树熊";
break;
default:
console.error("未定义元素类型");
break;
}
return ename;
}
static getRandEtype(){
let eletypeArr = [ElementType.btiger,ElementType.gtiger,ElementType.monkey,ElementType.bird,ElementType.koala];
let etype = eletypeArr[Math.floor(Math.random()*eletypeArr.length)];
return etype;
}
static getOneEle(type:ElementType):Element{
let ele:Element;
if(this.elePool.length>0){
ele = this.elePool.shift();
}else{
ele = new Element();
}
ele.name = "ele_"+this.eleidx;
this.eleidx += 1;
ele.init(type)
return ele;
}
static recoverEle(ele:Element){
this.elePool.push(ele);
}
static getDistance(p1,p2){
let p1x = p1[0];
let p1y = p1[1];
let p2x = p2[0];
let p2y = p2[1];
let dis = Math.sqrt(Math.pow(p1x-p2x,2)+Math.pow(p1y-p2y,2));
return dis;
}
}
\ No newline at end of file
import MapData, { ElementType, GameEvent } from "../MapData";
import { getTextureByName } from "../utils";
export default class Element extends engine.Container{
type:ElementType;
eimage:engine.Image;
inrow;
incol;
set touch(touch){
this.mouseEnabled = touch;
this.mouseChildren = touch;
}
constructor(){
super();
this.width = MapData.itemsize;
this.height = MapData.itemsize;
this.eimage = new engine.Image();
this.addChild(this.eimage);
this.touch = true;
this.addEventListener(engine.MouseEvent.CLICK,this.selectele,this);
}
init(type:ElementType){
this.scaleX = 1;
this.scaleY = 1;
this.type = type;
let ename = MapData.getEtypeImgName(type);
this.eimage.texture = getTextureByName(ename);
let imgwid = this.eimage.texture.width;
let imghei = this.eimage.texture.height;
// console.log("大小",imgwid,imghei);
this.eimage.x = (this.width - imgwid)/2;
this.eimage.y = (this.height-imghei)/2;
}
setrc(r,c){
this.inrow = r;
this.incol = c;
}
selectele(e:engine.MouseEvent){
engine.globalEvent.dispatchEvent(GameEvent.SelectEle,{
r:this.inrow,
c:this.incol
})
}
//飞到小屋
flyToHome(){
}
changePos(){
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment