Commit 02e2d983 authored by haiyoucuv's avatar haiyoucuv

1

parent d840db21
......@@ -2,11 +2,18 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="31be0130-d27d-4740-b668-956a8050e1bf" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/mock/miniTb/rule.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/mock/config.js" beforeDir="false" afterPath="$PROJECT_DIR$/mock/config.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Main.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/Main.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/TaoBaoNet.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/TaoBaoNet.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/panels/RulePanel.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/panels/RulePanel.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/panels/UnlockPanel.ts" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/parts/Game/GameLayer.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/parts/Game/GameLayer.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/parts/Game/Land.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/parts/Game/Land.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/parts/Game/Option.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/parts/Game/Option.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/scenes/GameScene.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/scenes/GameScene.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/parts/GameEle.ts" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/parts/MoveAni.ts" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/parts/UI/UILayer.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/parts/UI/UILayer.ts" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
......@@ -17,6 +24,7 @@
<option name="RECENT_TEMPLATES">
<list>
<option value="TypeScript File" />
<option value="JsonFile" />
</list>
</option>
</component>
......@@ -77,9 +85,9 @@
</configuration>
<recent_temporary>
<list>
<item itemvalue="npm.dev" />
<item itemvalue="npm.handleRes" />
<item itemvalue="npm.flushRes" />
<item itemvalue="npm.dev" />
</list>
</recent_temporary>
</component>
......@@ -95,30 +103,46 @@
<updated>1590749938444</updated>
<workItem from="1590749939792" duration="84000" />
<workItem from="1590976087296" duration="15316000" />
<workItem from="1590996860067" duration="7029000" />
<workItem from="1590996860067" duration="12763000" />
</task>
<task id="LOCAL-00001" summary="1">
<created>1591003912929</created>
<option name="number" value="00001" />
<option name="presentableId" value="LOCAL-00001" />
<option name="project" value="LOCAL" />
<updated>1591003912929</updated>
</task>
<option name="localTasksCounter" value="2" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="2" />
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="1" />
<option name="LAST_COMMIT_MESSAGE" value="1" />
</component>
<component name="WindowStateProjectService">
<state width="255" height="907" key="GridCell.Tab.0.bottom" timestamp="1591000059062">
<state x="466" y="108" key="CommitChangelistDialog2" timestamp="1591003912498">
<screen x="35" y="23" width="1645" height="1027" />
</state>
<state x="466" y="108" key="CommitChangelistDialog2/35.23.1645.1027/1680.-199.1920.1177@35.23.1645.1027" timestamp="1591003912498" />
<state width="255" height="543" key="GridCell.Tab.0.bottom" timestamp="1591005691603">
<screen x="35" y="23" width="1645" height="1027" />
</state>
<state width="255" height="907" key="GridCell.Tab.0.bottom/35.23.1645.1027/1680.-199.1920.1177@35.23.1645.1027" timestamp="1591000059062" />
<state width="255" height="907" key="GridCell.Tab.0.center" timestamp="1591000059061">
<state width="255" height="543" key="GridCell.Tab.0.bottom/35.23.1645.1027/1680.-199.1920.1177@35.23.1645.1027" timestamp="1591005691603" />
<state width="255" height="543" key="GridCell.Tab.0.center" timestamp="1591005691600">
<screen x="35" y="23" width="1645" height="1027" />
</state>
<state width="255" height="907" key="GridCell.Tab.0.center/35.23.1645.1027/1680.-199.1920.1177@35.23.1645.1027" timestamp="1591000059061" />
<state width="255" height="907" key="GridCell.Tab.0.left" timestamp="1591000059061">
<state width="255" height="543" key="GridCell.Tab.0.center/35.23.1645.1027/1680.-199.1920.1177@35.23.1645.1027" timestamp="1591005691600" />
<state width="255" height="543" key="GridCell.Tab.0.left" timestamp="1591005691596">
<screen x="35" y="23" width="1645" height="1027" />
</state>
<state width="255" height="907" key="GridCell.Tab.0.left/35.23.1645.1027/1680.-199.1920.1177@35.23.1645.1027" timestamp="1591000059061" />
<state width="255" height="907" key="GridCell.Tab.0.right" timestamp="1591000059062">
<state width="255" height="543" key="GridCell.Tab.0.left/35.23.1645.1027/1680.-199.1920.1177@35.23.1645.1027" timestamp="1591005691596" />
<state width="255" height="543" key="GridCell.Tab.0.right" timestamp="1591005691603">
<screen x="35" y="23" width="1645" height="1027" />
</state>
<state width="255" height="907" key="GridCell.Tab.0.right/35.23.1645.1027/1680.-199.1920.1177@35.23.1645.1027" timestamp="1591000059062" />
<state width="255" height="543" key="GridCell.Tab.0.right/35.23.1645.1027/1680.-199.1920.1177@35.23.1645.1027" timestamp="1591005691603" />
<state x="614" y="245" key="RollbackChangesDialog" timestamp="1590993046653">
<screen x="35" y="23" width="1645" height="1027" />
</state>
......@@ -127,9 +151,9 @@
<screen x="35" y="23" width="1645" height="1027" />
</state>
<state x="586" y="314" key="refactoring.ChangeSignatureDialog/35.23.1645.1027/1680.-199.1920.1177@35.23.1645.1027" timestamp="1590980819551" />
<state x="522" y="250" width="670" height="676" key="search.everywhere.popup" timestamp="1591001551518">
<state x="522" y="250" width="670" height="676" key="search.everywhere.popup" timestamp="1591014302210">
<screen x="35" y="23" width="1645" height="1027" />
</state>
<state x="522" y="250" width="670" height="676" key="search.everywhere.popup/35.23.1645.1027/1680.-199.1920.1177@35.23.1645.1027" timestamp="1591001551518" />
<state x="522" y="250" width="670" height="676" key="search.everywhere.popup/35.23.1645.1027/1680.-199.1920.1177@35.23.1645.1027" timestamp="1591014302210" />
</component>
</project>
\ No newline at end of file
......@@ -2,6 +2,9 @@ const path = require('path');
const config = {
'/ngame/new/datapash': {
data: './json/datapash.json'
},
'rule': {
data: './miniTb/rule.json'
}
}
......@@ -9,4 +12,4 @@ for (let item in config) {
if (config.hasOwnProperty(item))
config[item].path = path.resolve(__dirname, config[item].data);
}
module.exports = config;
\ No newline at end of file
module.exports = config;
{
"success": true,
"code": "1111",
"data": "1.哈哈哈哈哈\n2.哈哈哈哈哈\n3.哈哈哈哈哈\n4.哈哈哈哈哈\n5.哈哈哈哈哈\n6.哈哈哈哈哈\n7.哈哈哈哈哈\n8.哈哈哈哈哈\n9.哈哈哈哈哈\n10.哈哈哈哈哈\n11.哈哈哈哈哈\n12.哈哈哈哈哈\n13.哈哈哈哈哈\n14.哈哈哈哈哈\n15.哈哈哈哈哈\n16.哈哈哈哈哈\n17.哈哈哈哈哈\n18.哈哈哈哈哈\n19.哈哈哈哈哈\n20.哈哈哈哈哈\n21.哈哈哈哈哈\n"
}
import { Tool } from "./Tools";
import { layers, destroyLayers } from "../module/views/layers";
......@@ -20,6 +19,7 @@ export class Main {
stage: FYGE.Stage;
private requestID;
private _pause: boolean;
constructor(canvas: HTMLCanvasElement) {
var sysInfo;
//@ts-ignore 存在my就初始化
......@@ -49,6 +49,7 @@ export class Main {
var self = this;
// console.log(FYGE)
loop();
function loop() {
if (!self._pause) {
// stats.begin();
......@@ -74,6 +75,11 @@ export class Main {
//隐藏加载中
// if (document.getElementById("__loading__")) document.getElementById("__loading__").style.display = "none";
//打开开始场景
// 请求规则
sendTbNet(TbNetName.rule, {}, () => {
});
changeScene(GameScene);
//测试
// sendTbNet(TbNetName.aaa, {}, (s, res) => {
......@@ -96,6 +102,7 @@ export class Main {
run() {
this._pause = false
}
//在小程序隐藏时调用onHide
pause() {
this._pause = true
......@@ -115,6 +122,7 @@ export class Main {
GDispatcher.addEventListener(name, fun, thisObj)
}
}
/**
* 派发全局事件,用于小程序的交互调用
* @param name
......@@ -123,6 +131,7 @@ export class Main {
dispatchGlobalEvent(name: string, data?: any) {
GDispatcher.dispatchEvent(name, data)
}
/**
* 移除全局事件,用于小程序交互调用
* @param name
......
import { showToast, wait, clearWait } from "../module/ctrls";
//接口枚举,包括需要调用淘宝的api,用是否含有兑吧区分,或者单独区分
export enum TbNetName {
aaa = "aaa",
rule = "rule",
/**
* 查询积分
......@@ -17,7 +16,7 @@ export enum TbNetName {
startGame = "startGame",
/**
* 提交分数接口
* activityId,grade,score,type(0:解锁 1:提交), playId
* activityId,grade,score,type(0:解锁 1:提交), playId
*/
submit = "submit",
/**
......@@ -42,11 +41,13 @@ export enum TbNetName {
useTools = "useTools",
}
//返回数据类型,到时再调整
interface dataIn {
netName: TbNetName
data: any
}
//返回数据类型
interface dataOut {
success: boolean,
......@@ -54,6 +55,7 @@ interface dataOut {
code?: string,
message?: string
}
//记录数据
let dataRecord: {
[name: string]: any
......@@ -64,9 +66,9 @@ let fc;
/**
* 发送接口
* @param netName
* @param parameter
* @param callback
* @param netName
* @param parameter
* @param callback
*/
export function sendTbNet(netName: TbNetName, parameter: any, callback: Function, hideMsg: boolean = false) {
//网络超时
......@@ -82,13 +84,14 @@ export function sendTbNet(netName: TbNetName, parameter: any, callback: Function
//清除超时
clearWait(waitObj)
//记录数据
dataRecord[name] = data;
dataRecord[netName] = data;
//统一错误信息提示
if (!hideMsg && !data.success) showToast(data.message || "网络异常")
//回调
callback(data.success, data);
}, () => { })
return
}, () => {
});
return;
}
//@ts-ignore
if (!fc) fc = getApp().cloud.function;
......@@ -108,7 +111,7 @@ export function sendTbNet(netName: TbNetName, parameter: any, callback: Function
/**
* 获取数据
* @param netName
* @param netName
*/
export function getTbData(netName: TbNetName): dataOut {
return dataRecord[netName] || null;
......@@ -118,6 +121,7 @@ export function getTbData(netName: TbNetName): dataOut {
export function destroyNetData() {
dataRecord = {}
}
//webview里调用无效,用postMessage去调
// export const navigateToOutside = (url) => {
// my.call("navigateToOutside", {
......@@ -170,4 +174,4 @@ const codeMsg = {
"210025": "奖品已经过期",
"210026": "不能重复助力",
"210028": "请至我的奖品页重新领取",//重新领取
}
\ No newline at end of file
}
import { Panel } from "../../module/views/Panel";
import { Tool } from "../Tools";
import { getTbData, sendTbNet, TbNetName } from "../TaoBaoNet";
import Sprite = FYGE.Sprite;
import ScrollPage = FYGE.ScrollPage;
import TextField = FYGE.TextField;
......@@ -25,11 +26,10 @@ export class RulePanel extends Panel {
this.ruleLabel.size = 28;
this.ruleLabel.fillColor = '#c28b4c';
this.ruleLabel.text = "<p>哈哈哈哈哈哈</p>哈<p>djkahsdahsjjfda</p><p>规则</p><p>规则</p><p>规则</p>" +
"<p>规则</p><p>规则</p><p>规则</p><p>规则</p><p>规则</p>" +
"<p>规则</p><p>规则</p><p>规则</p><p>规则</p><p>规则</p>";
// 设置规则内容
this.ruleLabel.text = getTbData(TbNetName.rule).data;
// 滚动容器
this.scroll = this.addChild(new ScrollPage(430, 360, this.ruleLabel.textHeight));
this.scroll.position.set(170, 675);
this.scroll.view.addChild(this.ruleLabel);
......
import { Tool } from "../Tools";
import { Panel } from "../../module/views/Panel";
import { RES } from "../../module/RES";
import { Light } from "../parts/Light";
const foodData: {
[key: number]: { name: string, des: string }
} = {
8: { name: "爆浆麻薯150g*2袋", des: "" },
16: { name: "面筋卷120g*2袋", des: "" },
32: { name: "岩焗乳酪吐司500g", des: "" },
64: { name: "鱼豆腐170g", des: "" },
128: { name: "猪肉脯200g", des: "解锁后可在首页领取奖励哦~" },
256: { name: "卤藕168g*2袋", des: "解锁后可在首页领取奖励哦~" },
512: { name: "手撕面包1050g", des: "解锁后可在首页领取奖励哦~" },
1024: { name: "枣夹核桃700g", des: "解锁后可在首页领取奖励哦~" },
2048: { name: "甜辣鸭脖190g", des: "解锁后可在首页领取奖励哦~" },
}
/**
* 解锁弹框
*/
export class UnlockPanel extends Panel {
get groupNames() { return ["unlockPanel"] }
closeBtn:FYGE. Button;
data: {
grade: number,
closeFun:Function
}
initUi() {
//加光
this.addChild(new Light()).position.set(375, 735);
//背景
this.addChild(Tool.getSprite("unlockPanelBg.png"));
//关闭按钮
this.closeBtn = new FYGE.Button(RES.getRes("comCloseBtn.png"));
this.closeBtn.position.set(614, 460);
this.addChild(this.closeBtn);
//继续游戏
this.addChild(new FYGE.Button(RES.getRes("zailaiyiju.png")))
.once(FYGE.MouseEvent.CLICK, this.onClick_closeBtn, this)
.position.set((750 - 233) / 2, 938)
//标题文案
// this.addChild(new Title(this.data.grade))
//奖品图片 246;
this.addChild(new FYGE.Sprite(RES.getRes("unlock" + this.data.grade + ".png")))
.position.set((750 - 449) / 2-20, 580+20)
//名字
// this.addChild(Tool.addText(
// foodData[this.data.grade].name,
// 28,
// "#ffffff",
// undefined,
// 560,
// (750 - 560) / 2,
// 890
// ))
//描述
// this.addChild(Tool.addText(
// foodData[this.data.grade].des,
// 22,
// "#dac5fc",
// undefined,
// 560,
// (750 - 560) / 2,
// 931
// ))
}
start(data) {
super.start();
}
initEvents() {
this.closeBtn.addEventListener(FYGE.MouseEvent.CLICK,this.onClick_closeBtn, this)
}
onClick_closeBtn() {
this.data.closeFun()
this.hidePanel();
}
removeEvents() {
this.closeBtn.removeEventListener(FYGE.MouseEvent.CLICK,this.onClick_closeBtn, this)
}
}
class Title extends FYGE.Container {
grade: number
constructor(grade: number) {
super();
var msg = new FYGE.Sprite(RES.getRes("unlockMsg.png"))
this.addChild(msg);
var textures = {}
for (var i = 0; i < 10; i++)textures[i] = RES.getRes("n" + i + ".png");
var num = new FYGE.BitmapText(textures);
num.textAlign = FYGE.TEXT_ALIGN.LEFT;
num.text = grade + "";
this.addChild(num);
var w = msg.width + num.width;
msg.position.set((750 - w) / 2, 548);
num.position.set(msg.x + msg.width, 548 + 4)
}
}
\ No newline at end of file
......@@ -29,8 +29,6 @@ export default class GameLayer extends Container {
private constructor() {
super();
new FrameAni([]);
this.initLand();
// 种植列表
......@@ -46,6 +44,9 @@ export default class GameLayer extends Container {
}
/**
* 初始化土地
*/
private initLand() {
const pos = [
[99, 730],
......
......@@ -15,19 +15,28 @@ export enum LAND_STATE {
export class Land extends Container {
/**
* 当前激活的土地
* @static
* @type {Land}
*/
public static activeLand: Land = null;
/////////////
// private //
/////////////
// 田_初始.png 田_种植.png 田_选择.png
// 三个田的选择状态对应的 texture
private land_default_texture = RES.getRes('田_初始.png');
private land_choose_texture = RES.getRes('田_选择.png');
private land_plant_texture = RES.getRes('田_种植.png');
private landSprite = new Sprite();
private landSprite = new Sprite(); // 土地的精灵
private state: LAND_STATE;
private state: LAND_STATE; // 状态机
private option: Option;
private option: Option = null; // 当前显示的 Option
// id
private _id: number;
......@@ -39,12 +48,15 @@ export class Land extends Container {
return this._id;
}
/**
* @constructor
*/
constructor() {
super();
this.addChild(this.landSprite);
// 改写点击方法
// 重写点击的方法
this.landSprite.hitTestPoint = function(point, isMouseEvent = false) {
// |Ax*Th/2|+|Ay*Tw/2|=Th*Tw/4 时点是在菱形上的。>时在菱形区域外,<时在菱形内的。
if (!this.visible) return null;
......@@ -59,16 +71,21 @@ export class Land extends Container {
return judge ? this : null;
}.bind(this.landSprite);
// 加个监听
this.addEventListener(MouseEvent.CLICK, () => {
console.log(`点到了土地: ${this.id}`);
GameLayer.ins.plantList.show(this.id); // 显示种植列表
this.activate(); // 变成选中状态
});
// 修改默认的状态机
this.changeState(LAND_STATE.DEFAULT);
}
/**
* 状态机
* @param state
*/
public changeState(state) {
if (state === this.state) return;
......
import { RES } from "../../module/RES";
import { Tool } from "../Tools";
export class GameEle extends FYGE.Sprite {
private _type: number
get type() {
return this._type
}
set type(value: number) {
this._type = value;
this.texture = RES.getRes("ele" + value + ".png")
}
private _tempType: number = null;
get tempType() {
return this._tempType;
}
set tempType(value) {
this._tempType = value;
}
index: number;
get row() {
return Tool.indexToRc(this.index)[0]
}
get col() {
return Tool.indexToRc(this.index)[1]
}
constructor(type: number) {
super();
this.type = type;
this.anchorTexture.set(0.5, 0.5);
}
reset(type) {
this.type = type;
this.scale.set(1, 1)
}
}
\ No newline at end of file
import { GameEle } from "./GameEle";
import { Tool } from "../Tools";
import { RES } from "../../module/RES";
import { GPool } from "../../module/tools/GPool";
export interface MoveAniInt {
startEle1: GameEle,
startEle2?: GameEle,
endIndex: number,
}
/**
* 偷懒先用fun的试下,不然就动画独立
* @param callback 回调里计数完成用
* @param startEle1
* @param endIndex
* @param startEle2
*/
export function moveAni(
callback: () => void,
startEle1: GameEle,
endIndex: number,
startEle2?: GameEle,
) {
var endType: number = startEle1.type * 2;
var endP = Tool.getPositionByIndex(endIndex);
//移动动画
FYGE.Tween.get(startEle1)
.to({ x: endP[0], y: endP[1] }, 200)
.call(() => {
callback();
if (!startEle2) return;
//添加动画
// startEle1.parent.addChild(playDisAni(endType, startEle1.x, startEle1.y))
//第一个缩小
FYGE.Tween.get(startEle1)
.to({ scaleX: 0.1, scaleY: 0.1 }, 100)
.call(() => {
startEle1.type = endType;
startEle1.tempType = null;
})
.to({ scaleX: 1, scaleY: 1 }, 100, FYGE.Ease.backOut)
// .call(() => { callback() })
})
if (startEle2) {
FYGE.Tween.get(startEle2)
.to({ x: endP[0], y: endP[1] }, 200)
.call(() => {
//移除第二个
startEle2.parent.removeChild(startEle2);
GPool.recover("gameEle", startEle2)
})
}
}
// const disAniName = "disAniName"
// function playDisAni(type: number, x, y) {
// let mv: FYGE.MovieClip = GPool.takeOut(disAniName + type)
// if (!mv) {
// mv = new FYGE.MovieClip(RES.getRes("create" + type + ".svga"))
// }
// mv.position.set(x - 125, y - 125);
// mv.startAniRange(1, mv.totalFrames, 1, () => {
// if (mv.parent) {
// mv.parent.removeChild(mv);
// GPool.recover(disAniName + type, mv);
// }
// })
// return mv
// }
......@@ -57,7 +57,7 @@ export class UILayer extends Container {
console.log('点击了商店');
break;
case this.ruleBtn:
// console.log('点击了规则');
console.log('点击了规则');
PanelCtrl.instance.show(RulePanel);
break;
case this.adBtn:
......
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