Commit cba217ec authored by haiyoucuv's avatar haiyoucuv

1

parent fffaa963
No preview for this file type
This diff is collapsed.
No preview for this file type
......@@ -27,7 +27,7 @@
<body>
<div style="margin: auto;width: 100%;height: 100%;" class="egret-player" data-entry-class="Main"
data-orientation="auto" data-scale-mode="showAll" data-frame-rate="60" data-content-width="750"
data-content-height="1624" data-multi-fingered="2" data-show-fps="true" data-show-log="false"
data-content-height="1624" data-multi-fingered="2" data-show-fps="false" data-show-log="false"
data-show-fps-style="x:0,y:0,size:12,textColor:0xffffff,bgAlpha:0.9">
</div>
<img id="shareImg" />
......@@ -55,7 +55,7 @@
window['debug'] = true; // 是否是debug模式 是否打印debugLog
</script>
<script>
window['rule'] = '规则规则规则规则\n规则规则规则规则\n规则规则规则规则\n规则规则规则规则\n规则规则规则规则\n';
</script>
<script>
// 网鱼网咖图标额外奖励插件
......
......@@ -2382,7 +2382,7 @@ export class NetManager extends ABNetManager {
public queryPrizeInfo(callback: Function, ids) {
const net: INetData = {
name: NetName.QUERY_PRIZE_INFO,
uri: '/projectx/' + window['projectId'] + '/prize.query',
uri: '/projectx/{projectId}/prize.query',
type: 'get',
dataType: 'json',
param: {
......@@ -2530,18 +2530,16 @@ export class NetManager extends ABNetManager {
this.send(net);
}
public getSellInfo(callback: Function, spId, count) {
public getSellInfo(callback: Function) {
const net: INetData = {
name: NetName.GET_SELLINFO,
uri: '/projectx/{projectId}/join_4/saleinfo.do',
type: 'get',
dataType: 'json',
param: {
spId: spId,
count: count
},
callback: callback
};
name: NetName.GET_SELLINFO,
uri: '/projectx/{projectId}/join_4/saleinfo.do',
type: 'get',
dataType: 'json',
param: {},
callback: callback
}
;
this.send(net);
}
......
......@@ -20,6 +20,7 @@ class TuiaAutoUpload {
}
this.init();
}
init() {
var _this = this;
this.client = new OSS({
......@@ -40,6 +41,7 @@ class TuiaAutoUpload {
})
return this;
}
files() {
var _this = this;
if (this._files) return this._files;
......@@ -78,6 +80,7 @@ class TuiaAutoUpload {
fileDisplay(this.options.dir);
return this._files;
}
start() {
this.files().map((file, index) => {
let _this = this;
......@@ -121,7 +124,6 @@ class TuiaAutoUpload {
}
const configFileName = 'project.json';
if (!fs.existsSync(configFileName)) {
throw new Error(`${configFileName}不存在.`)
......
No preview for this file type
......@@ -21,7 +21,7 @@
"name": "index_ui"
},
{
"keys": "篱笆_png,plant_cattle_1_png,plant_cattle_2_png,plant_chicken_1_png,plant_chicken_2_png,plant_corn_1_png,plant_corn_2_png,plant_land_active_png,plant_land_animal_png,plant_land_none_png,plant_land_plant_png,plant_wheat_1_png,plant_wheat_2_png,食槽_png,_DS_Store,feed_png,feeding_png,hand_png,option_chicken_png,option_panel_png,option_wheat_png,water_png,watering_png",
"keys": "篱笆_png,plant_cattle_1_png,plant_cattle_2_png,plant_chicken_1_png,plant_chicken_2_png,plant_corn_1_png,plant_corn_2_png,plant_land_active_png,plant_land_animal_png,plant_land_none_png,plant_land_plant_png,plant_wheat_1_png,plant_wheat_2_png,食槽_png,_DS_Store,feed_png,feeding_png,hand_png,option_chicken_png,option_panel_png,option_wheat_png,water_png,watering_png,plant_cattle_3_png,plant_cattle_4_png,plant_chicken_3_png,plant_chicken_4_png,plant_corn_3_png,plant_wheat_3_png",
"name": "index_plant"
},
{
......@@ -45,8 +45,8 @@
"name": "selled_panel"
},
{
"name": "preload",
"keys": "plant_chicken_4_png,plant_chicken_3_png,plant_cattle_4_png,plant_cattle_3_png,plant_corn_3_png,plant_wheat_3_png"
"keys": "bar_bg_png,规则_png,路径 2_png",
"name": "bar"
}
],
"resources": [
......@@ -396,34 +396,49 @@
"name": "light_png"
},
{
"name": "plant_chicken_4_png",
"url": "assets/index_scene/planting/plant_cattle_3.png",
"type": "image",
"url": "assets/index_scene/planting/plant_chicken_4.png"
"name": "plant_cattle_3_png"
},
{
"name": "plant_chicken_3_png",
"url": "assets/index_scene/planting/plant_cattle_4.png",
"type": "image",
"url": "assets/index_scene/planting/plant_chicken_3.png"
"name": "plant_cattle_4_png"
},
{
"name": "plant_cattle_4_png",
"url": "assets/index_scene/planting/plant_chicken_3.png",
"type": "image",
"url": "assets/index_scene/planting/plant_cattle_4.png"
"name": "plant_chicken_3_png"
},
{
"name": "plant_cattle_3_png",
"url": "assets/index_scene/planting/plant_chicken_4.png",
"type": "image",
"url": "assets/index_scene/planting/plant_cattle_3.png"
"name": "plant_chicken_4_png"
},
{
"name": "plant_corn_3_png",
"url": "assets/index_scene/planting/plant_corn_3.png",
"type": "image",
"url": "assets/index_scene/planting/plant_corn_3.png"
"name": "plant_corn_3_png"
},
{
"name": "plant_wheat_3_png",
"url": "assets/index_scene/planting/plant_wheat_3.png",
"type": "image",
"url": "assets/index_scene/planting/plant_wheat_3.png"
"name": "plant_wheat_3_png"
},
{
"url": "assets/bar/bar_bg.png",
"type": "image",
"name": "bar_bg_png"
},
{
"url": "assets/bar/规则.png",
"type": "image",
"name": "规则_png"
},
{
"url": "assets/bar/路径 2.png",
"type": "image",
"name": "路径 2_png"
}
]
}
\ No newline at end of file
......@@ -7,13 +7,19 @@
"resource/skins/LoadingSceneSkin.exml",
"resource/skins/LoadingSkin.exml",
"resource/skins/RulePanelSkin.exml",
"resource/skins/SellPanelSkin.exml",
"resource/skins/SellRecordItemSkin.exml",
"resource/skins/SellRecordSkin.exml",
"resource/skins/TaskToastSkin.exml",
"resource/skins/TaskPanelSkin.exml",
"resource/skins/TaskItemSkin.exml",
"resource/skins/ToastPanelSkin.exml",
"resource/skins/WareHouseSkin.exml",
"resource/skins/TaskItemSkin.exml",
"resource/skins/Objs/OptionPanelSkin.exml",
"resource/skins/Objs/CropSkin.exml",
"resource/skins/Objs/LandSkin.exml",
"resource/skins/Component/BarSkin.exml",
"resource/skins/Component/ProgressNumSkin.exml",
"resource/skins/Component/TimeProgressBarSkin.exml",
"resource/skins/ui/IconButtonSkin.exml",
"resource/skins/ui/ProgressBarSkin.exml"
......
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="Bar" width="750" height="91" xmlns:e="http://ns.egret.com/eui" xmlns:w="http://ns.egret.com/wing">
<e:Image source="bar_bg_png" horizontalCenter="0" verticalCenter="0"/>
<e:Image id="back" source="路径 2_png" x="36" y="30"/>
<e:Image id="rule" source="规则_png" x="666" y="31.5"/>
<e:Label id="title" text="工行卡中心" y="31.5" textColor="0x333333" horizontalCenter="0"/>
</e:Skin>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="ProgressNum" width="300" height="50" xmlns:e="http://ns.egret.com/eui" xmlns:w="http://ns.egret.com/wing">
<e:Label id="numLabel" text="0" verticalCenter="0" left="270"/>
<e:Group id="touchGroup" x="0" top="0" bottom="0">
<e:Rect id="bar" width="250" height="10" fillColor="0xffffff" ellipseWidth="10" ellipseHeight="10" left="0" verticalCenter="0"/>
<e:Rect id="hand" width="30" height="30" x="0" ellipseWidth="50" ellipseHeight="50" verticalCenter="0"/>
</e:Group>
</e:Skin>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="Crop" width="276" height="240" xmlns:e="http://ns.egret.com/eui" xmlns:w="http://ns.egret.com/wing">
<e:Image id="cropImg" horizontalCenter="0" bottom="0" source=""/>
<e:Image id="optionImg" y="0" source="" left="93"/>
<e:Skin class="Crop" width="276" height="150" xmlns:e="http://ns.egret.com/eui" xmlns:w="http://ns.egret.com/wing">
<e:Group height="150" width="276" y="0" x="0"/>
</e:Skin>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="CreditsTip" width="750" height="1335" xmlns:e="http://ns.egret.com/eui" xmlns:w="http://ns.egret.com/wing">
<e:Button id="closeBtn" label="" y="967.52" horizontalCenter="0">
<e:Button id="closeBtn" label="" y="996.52" horizontalCenter="0.5">
<e:skinName>
<e:Skin states="up,down,disabled">
<e:Image width="100%" height="100%" source="closeBtn_png" source.down="closeBtn_png" source.disabled="closeBtn_png"/>
......@@ -8,8 +8,8 @@
</e:Skin>
</e:skinName>
</e:Button>
<e:Label text="活动说明" y="111" bold="true" horizontalCenter="0"/>
<e:Scroller y="176.97" anchorOffsetX="0" anchorOffsetY="0" height="750" width="628" horizontalCenter="0">
<e:Label text="活动说明" y="140" bold="true" horizontalCenter="0"/>
<e:Scroller y="205.97" anchorOffsetX="0" anchorOffsetY="0" height="750" width="628" horizontalCenter="0">
<e:Group anchorOffsetX="0" anchorOffsetY="0">
<e:Label id="ruleLabel" text="" anchorOffsetX="0" anchorOffsetY="0" scaleX="1" scaleY="1" width="628" y="0" lineSpacing="25" horizontalCenter="0" verticalAlign="justify"/>
</e:Group>
......
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="CreditsTip" width="501" height="50" xmlns:e="http://ns.egret.com/eui" xmlns:w="http://ns.egret.com/wing">
<e:Image source="sellRecord_outline_png" horizontalCenter="0" bottom="0"/>
<e:Label id="dateLabel" text="2019.12.3" textColor="0x855933" size="20" verticalCenter="0" left="0"/>
<e:Label id="cropLabel" text="2019.12.3" textColor="0x855933" size="20" verticalCenter="0" horizontalCenter="0"/>
<e:Label id="numLabel" text="2019.12.3" textColor="0x855933" size="20" verticalCenter="0" right="0"/>
<e:Label id="dateLabel" text="" textColor="0x855933" size="20" verticalCenter="0" left="0"/>
<e:Label id="cropLabel" text="" textColor="0x855933" size="20" verticalCenter="0" horizontalCenter="0"/>
<e:Label id="creditsLabel" text="" textColor="0x855933" size="20" verticalCenter="0" right="0"/>
</e:Skin>
\ No newline at end of file
......@@ -7,13 +7,15 @@
<e:Group id="cropGroup" x="43" y="274">
<e:Group id="egg_group" x="0" y="0">
<e:Image id="egg_bg" source="egg_bg_png" x="0" y="0"/>
<e:Image id="egg_btn" source="出售_png" x="89.5" y="240"/>
<e:Image id="egg_sell_btn" source="出售_png" x="12" y="240"/>
<e:Label id="egg_label" text="数量:0" x="113" y="195" size="24" textColor="0x9a9a9a"/>
<e:Image id="egg_ex_btn" source="兑换_png" x="164" y="240"/>
</e:Group>
<e:Group id="wheat_group" x="354" y="0">
<e:Image id="wheat_bg" source="wheat_bg_png" x="0" y="0"/>
<e:Image id="wheat_btn" source="出售_png" x="89.5" y="240"/>
<e:Image id="wheat_sell_btn" source="出售_png" x="12" y="240"/>
<e:Label id="wheat_label" text="数量:0" x="113" y="195" size="24" textColor="0x9A9A9A"/>
<e:Image id="wheat_ex_btn" source="兑换_png" x="161" y="240" scaleX="1" scaleY="1"/>
</e:Group>
</e:Group>
</e:Skin>
\ No newline at end of file
......@@ -12,8 +12,12 @@ import { Buried } from '../libs/tw/util/Buried';
import TopLayerCtrl from './ctrls/topLayerCtrl';
import { initstatistics } from "./comm/statistics";
import { docEvent } from "./comm/DocumentEvent";
import { NetManager } from "../libs/tw/manager/NetManager";
import { Panels, Scenes, Tops } from "./types/Scenes";
import Bar from "./components/Bar";
let MainStage:egret.Stage = null;
console.log(MainStage);
export { MainStage };
class Main extends eui.UILayer {
protected createChildren(): void {
......@@ -80,12 +84,15 @@ class Main extends eui.UILayer {
* Create scene interface
*/
protected createGameScene(): void {
MainStage = this.stage;
DataManager.ins.customCfgData = window["CFG"];
Buried.init();
// initstatistics(); // 页面停留时长(接口)
docEvent(); // document事件(显示,隐藏,重载)
let bar = new Bar();
this.addChild(bar);
this.getGameRes().then(() => {
SceneCtrl.instance.change(ModuleTypes.INDEX_SCENE);
});
......
......@@ -4,30 +4,34 @@ import { DataManager } from "../../../libs/tw/manager/DataManager";
import { NetName } from "../../../libs/tw/enum/NetName";
export default class RulePanel extends Panel {
public closeBtn: eui.Button;
public ruleLabel: eui.Label;
public closeBtn: eui.Button;
public ruleLabel: eui.Label;
public get skinKey() { return 'RulePanel' }
// public get groupName() { return 'prize_panel' }
constructor(data?) {
super(data);
public get skinKey() {
return 'RulePanel'
}
}
// public get groupName() { return 'prize_panel' }
constructor(data?) {
super(data);
protected onSkinComplete(): void {
super.onSkinComplete();
}
this.preLoadRes();
this.onLoad();
}
protected onSkinComplete(): void {
super.onSkinComplete();
protected onLoad(): void {
this.initUI();
}
this.preLoadRes();
this.onLoad();
private initUI(): void {
let rule = DataManager.ins.ajaxElementData.rule;
this.ruleLabel.textFlow = new HtmlTextParser().parse(rule);
}
}
protected onLoad(): void {
this.initUI();
}
private initUI(): void {
// let rule = DataManager.ins.ajaxElementData.rule;
let rule = window['rule'];
this.ruleLabel.textFlow = new HtmlTextParser().parse(rule);
}
}
\ No newline at end of file
import Panel from "../views/Panel";
import { getSkinPath } from "../utils";
import { spData } from "./WareHousePanel";
import { NetManager } from "../../libs/tw/manager/NetManager";
import { ProgressNum } from "../components/ProgressNum";
import { IndexDispatcher } from "../Scenes/IndexScene/IndexScene";
export default class SellPanel extends Panel {
public closeBtn:eui.Image;
public titleImg:eui.Image;
public nameLabel:eui.Label;
public infoLabel:eui.Label;
public totalLabel:eui.Label;
public sellBtn:eui.Button;
public closeBtn: eui.Image;
public titleImg: eui.Image;
public nameLabel: eui.Label;
public infoLabel: eui.Label;
public totalLabel: eui.Label;
public sellBtn: eui.Button;
private key; // 当前要卖的东西的id
private total = 0; // 总个数
private numBar: ProgressNum = null;
public get skinKey() {
return 'SellPanel'
......@@ -28,19 +35,62 @@ export default class SellPanel extends Panel {
egret.Tween.get(this).set({alpha: 0}).to({alpha: 1}, 233, egret.Ease.quadInOut);
}
protected getTapEvts(): any[] {
return super.getTapEvts().concat([
[this.sellBtn, this.doSell, this],
])
}
protected start() {
super.start();
this.initUI();
IndexDispatcher.addEvent('updateSellValue', this.updateSellValue, this);
}
private updateSellValue() {
let value = this.numBar.value;
this.sellBtn.enabled = (value > 0);
}
private initUI(): void {
this.y = 750 / window.innerWidth * window.innerHeight * 0.2;
this.getTaskInfo();
this.key = this.data.key;
this.total = this.data.total;
let d = spData[this.key];
this.infoLabel.text = `一${spData[this.key].numLabel}${spData[this.key].nameLabel}=50个欢趣豆`;
this.nameLabel.text = d.nameLabel;
this.titleImg.source = d.titleImg;
this.totalLabel.text = `共${this.data.total}${d.numLabel}`;
this.numBar = new ProgressNum({total: this.total});
this.addChild(this.numBar);
this.numBar.x = this.width / 2 - this.numBar.width / 2;
this.numBar.y = 400;
this.sellBtn.enabled = false;
}
private getTaskInfo() {
/// TODO 调用接口根据返回数据设置UI
/**
* 发起售卖
*/
private doSell() {
let count = this.numBar.value;
console.log(count);
NetManager.ins.doSell((success, res) => {
if(!success) {
return;
}
// PanelCtrl.instance.show(ModuleTypes.)
}, this.key, count);
}
destroy() {
this.numBar.destroy();
super.destroy();
}
}
import Panel from "../views/Panel";
import { getSkinPath } from "../utils";
import { NetManager } from "../../libs/tw/manager/NetManager";
export default class SellRecord extends Panel {
public list: eui.List;
......@@ -30,25 +31,33 @@ export default class SellRecord extends Panel {
private initUI(): void {
this.y = 750 / window.innerWidth * window.innerHeight * 0.1;
this.getTaskInfo();
this.getSellInfo();
}
private getTaskInfo() {
/// TODO 调用接口根据返回数据设置添加显示列表
this.list.useVirtualLayout = false;
this.list.itemRenderer = SellRecordItem;
this.list.dataProvider = new eui.ArrayCollection([1, 2, 3, 4, 5]);
private getSellInfo() {
NetManager.ins.getSellInfo((success, res) => {
if(!success) {
return;
}
const data = res.data;
this.list.useVirtualLayout = false;
this.list.itemRenderer = SellRecordItem;
this.list.dataProvider = new eui.ArrayCollection(data);
});
}
}
////////////////////////////////////////////////////////////////////////////////////////////////
/**
* 任务中心列表
*/
let spData = {
'sp_1': '个鸡蛋',
'sp_2': '袋小麦',
};
// 任务中心列表
class SellRecordItem extends eui.ItemRenderer {
public dateLabel: eui.Label;
public cropLabel: eui.Label;
public numLabel: eui.Label;
public creditsLabel: eui.Label;
constructor() {
super();
......@@ -56,13 +65,10 @@ class SellRecordItem extends eui.ItemRenderer {
}
dataChanged() {
console.log(this.data);
/**
* TODO 根据数据改变样式
* TODO 如果没有食物奖励则将foodGroup隐藏,并将waterGroup靠前
* TODO 如果没有奖励则隐藏prizeGroup
*/
let {date, spCount, sp, credits} = this.data;
let nd = new Date(date);
this.cropLabel.text = spCount + spData[sp];
this.dateLabel.text = `${nd.getFullYear()}.${nd.getMonth()}.${nd.getDay()}`;
this.creditsLabel.text = `${credits}个欢趣豆`;
}
}
......@@ -2,6 +2,7 @@ import Panel from "../views/Panel";
import { getSkinPath } from "../utils";
import TopLayerCtrl from "../ctrls/topLayerCtrl";
import { ModuleTypes } from "../types/sceneTypes";
import { NetManager } from "../../libs/tw/manager/NetManager";
export default class TaskPanel extends Panel {
public list: eui.List;
......@@ -36,6 +37,12 @@ export default class TaskPanel extends Panel {
private getTaskInfo() {
/// TODO 调用接口根据返回数据设置添加显示列表
NetManager.ins.getTaskInfo((success, res)=>{
if(!success){
return;
}
console.log(res);
});
this.list.useVirtualLayout = false;
this.list.itemRenderer = TaskItem;
this.list.dataProvider = new eui.ArrayCollection([1, 2, 3, 4, 5]);
......
import Panel from "../views/Panel";
import TopLayerCtrl from "../ctrls/topLayerCtrl";
import { ModuleTypes } from "../types/sceneTypes";
import { NetManager } from "../../libs/tw/manager/NetManager";
import { showToast } from "../comm/UtilsConst";
export let spData = {
'sp_1': { // 鸡蛋
key: 'sp_1',
name: 'egg',
nameLabel: '鸡蛋',
numLabel: '个',
titleImg: 'sellTitle_egg_png'
},
'sp_2': { // 麦粉
key: 'sp_2',
name: 'wheat',
nameLabel: '麦粉',
numLabel: '袋',
titleImg: 'sellTitle_wheat_png'
}
};
export default class WareHousePanel extends Panel {
public closeBtn: eui.Image;
public record_btn: eui.Image;
public noneImg: eui.Image;
public cropGroup: eui.Group;
public egg_group: eui.Group;
public egg_bg: eui.Image;
public egg_btn: eui.Image;
public egg_sell_btn: eui.Image;
public egg_label: eui.Label;
public egg_ex_btn: eui.Image;
public wheat_group: eui.Group;
public wheat_bg: eui.Image;
public wheat_btn: eui.Image;
public wheat_sell_btn: eui.Image;
public wheat_label: eui.Label;
public wheat_ex_btn: eui.Image;
public get skinKey() {
return 'WareHouse'
......@@ -37,28 +59,7 @@ export default class WareHousePanel extends Panel {
protected getTapEvts(): any[] {
return super.getTapEvts().concat([
[this.record_btn, this.onTap, this],
]).concat([
[this.egg_btn, this.goSell, this],
[this.wheat_btn, this.goSell, this],
]);
}
private goSell(e:egret.TouchEvent){
let key = '';
switch(e.target) {
case this.egg_btn: // 鸡蛋售卖
key = 'egg';
break;
case this.wheat_btn: // 小麦售卖
key = 'wheat';
break;
default:break;
}
TopLayerCtrl.instance.show(ModuleTypes.SELL_PANEL, key, .4);
])
}
private onTap(e: egret.TouchEvent) {
......@@ -84,6 +85,21 @@ export default class WareHousePanel extends Panel {
private getWareHouseInfo() {
/// TODO 调用接口根据返回数据设置添加显示列表
NetManager.ins.queryPrizeInfo((success, res) => {
if(!success) {
return;
}
const data = res.data;
console.log(data);
for(let v of data) {
this[`${spData[v.id].name}_label`].text = `数量:${v.stock}`;
this[`${spData[v.id].name}_sell_btn`].addEventListener(egret.TouchEvent.TOUCH_TAP, () => {
TopLayerCtrl.instance.show(ModuleTypes.SELL_PANEL, {key: v.id, total: v.stock}, .4);
});
this[`${spData[v.id].name}_ex_btn`].addEventListener(egret.TouchEvent.TOUCH_TAP, () => {
showToast('欢趣商店待开放,过段日子再来吧~');
});
}
}, '');
}
}
......@@ -6,22 +6,33 @@ import Dispatcher from "../../comm/Dispatcher";
import ProgressMgr from "./ProgressMgr";
////////////////// Instance //////////////////
let instance = null;
const IndexIns = function():IndexScene {
let instance: IndexScene = null;
const IndexIns = function(): IndexScene {
return instance;
};
const SetIndexInstance = function(ins:IndexScene) {
const SetIndexInstance = function(ins: IndexScene) {
instance = ins;
};
const DestroyIndexInstance = function() {
instance = null;
};
export { IndexIns };
let canUpdate = true;
const SetGameLayerUpdate = function(enable: boolean) {
instance.gameLayer.touchEnabled = enable;
instance.gameLayer.touchChildren = enable;
canUpdate = enable;
};
const CanUpdate = function() {
return canUpdate;
}
export { IndexIns, SetGameLayerUpdate, CanUpdate };
////////////////// Instance //////////////////
// Index场景的事件收发器
let IndexDispatcher = null;
let IndexDispatcher: Dispatcher = null;
export { IndexDispatcher };
const NewIndexDispatcher = function() {
......@@ -35,9 +46,9 @@ const DestroyDispatcher = function() {
* 主场景
*/
export default class IndexScene extends Scene {
public group:eui.Group;
public bg:eui.Image;
public gameLayer:eui.Group;
public group: eui.Group;
public bg: eui.Image;
public gameLayer: eui.Group;
private indexUI: IndexUI;
public optionPanel: OptionPanel;
......@@ -83,6 +94,7 @@ export default class IndexScene extends Scene {
DestroyDispatcher(); // 删除局部收发器
OptionPanel.destroy();
this.indexUI.destroy();
this.landMgr.destroy();
}
protected getTapEvts(): any[] {
......
import Land from "./Objs/Land";
import { IndexDispatcher, IndexIns } from "./IndexScene";
import { NetManager } from "../../../libs/tw/manager/NetManager";
import { GDispatcher } from "../../../libs/tc/util/GDispatcher";
const landPos = [ // 地块位置(注意顺序,影响层级)
{x: 190, y: 664},
......@@ -24,10 +25,27 @@ export default class LandMgr {
this.getLandInfo();
}
public destroy() {
IndexDispatcher.removeEvent('hideOption', this.reActiveAll, this);
GDispatcher.removeEvent('docVisible', this.updateLandInfo, this);
IndexDispatcher.removeEvent('updateIndex', this.updateLandInfo, this);
IndexDispatcher.removeEvent('plant', this.plant, this);
this.lands.forEach(v => v.destroy());
}
private initEvents() {
IndexDispatcher.addEvent('hideOption', this.reActiveAll, this);
GDispatcher.addEvent('docVisible', this.updateLandInfo, this);
IndexDispatcher.addEvent('updateIndex', this.updateLandInfo, this);
IndexDispatcher.addEvent('plant', this.plant, this);
}
private plant(data){
this.lands[data.landId].plant(data);
}
private reActiveAll() {
this.lands.forEach(v => v.reActive());
}
......@@ -51,4 +69,17 @@ export default class LandMgr {
this.addLand(res.data);
});
}
private updateLandInfo() {
console.log('Update Lands');
NetManager.ins.getLandInfo((success, res) => {
if(!success) {
return;
}
for(let i = 0; i < res.data.length; i++) {
let v = res.data[i];
this.lands[i].updateData({data: v, index: v.id, x: landPos[v.id - 1].x, y: landPos[v.id - 1].y});
}
});
}
}
\ No newline at end of file
This diff is collapsed.
import { getSkinPath } from "../../../utils";
import Crop from "./Crop";
import { IndexDispatcher, IndexIns } from "../IndexScene";
import TimeProgressBar from "../TimeProgressBar";
import { IndexDispatcher } from "../IndexScene";
enum LAND_STATE {
NONE = 'none', // 无
......@@ -34,7 +34,6 @@ export default class Land extends eui.Component {
this.x = data.x;
this.y = data.y;
this.setTouchOption(); // 设置点击参数
this.initEvents(); // 注册事件
this.changeState(LAND_STATE.NONE);
this.initUI(); // 设置显示
......@@ -47,12 +46,38 @@ export default class Land extends eui.Component {
this.state == LAND_STATE.ACTIVE && this.changeState(LAND_STATE.NONE);
}
public plant(data) {
this.crop.plant(data);
}
public updateData(data) {
this.data = data;
this.changeState(LAND_STATE.NONE);
const landData = this.data.data;
/// TODO 根据数据添加Crop 初始化状态
if(landData.petId != 0) {
if(landData.petId == 1) {
this.changeState(LAND_STATE.ANIMAL);
} else {
this.changeState(LAND_STATE.PLANT);
}
}
this.crop && this.crop.updateDate(this.data);
}
public destroy() {
this.land.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap, this);
this.crop && this.crop.destroy();
}
/**
* 设置点击参数
*/
private setTouchOption() {
this.touchEnabled = false; // 保证空白处不可点击,且子对象可点击
this.touchChildren = true;
this.land.touchEnabled = true;
this.land.pixelHitTest = true; // 保证透明像素不可点击
this.fence.touchEnabled = false; // 保证栅栏和食槽不可点击
this.trough.touchEnabled = false;
......@@ -74,39 +99,22 @@ export default class Land extends eui.Component {
}
private initUI() {
// petId 1:鸡,2:小麦
// level 当前鸡或小麦的等级
// canFeed 是否能喂食(浇水)
// feedLeftSeconds 下次喂食时间倒计时,单位秒
// canGather 是否可收获
/// TODO 根据数据改变状态
console.log(this.data);
this.setTouchOption(); // 设置点击参数
const landData = this.data.data;
/// TODO 根据数据添加Crop 初始化状态
if(landData.petId == 1) {
this.changeState(LAND_STATE.ANIMAL);
} else {
this.changeState(LAND_STATE.PLANT);
if(landData.petId != 0) {
if(landData.petId == 1) {
this.changeState(LAND_STATE.ANIMAL);
} else {
this.changeState(LAND_STATE.PLANT);
}
}
this.crop = new Crop(landData);
this.crop = new Crop(this.data);
this.addChildAt(this.crop, 2);
this.crop.y = 75;
}
private addProgress() {
/// TODO 根据数据添加进度条
IndexIns().progressMgr.addProgress({
index: this.index,
x: this.x + 88,
y: this.y + 193,
text: '鸡',
sTime: 1574684000000,
nTime: 1574684500000,
eTime: 1574685000000
})
}
// 改变状态积
private changeState(state: LAND_STATE) {
if(state == this.state) {
......
import { getSkinPath } from "../../../utils";
import { IndexDispatcher } from "../IndexScene";
import { GDispatcher } from "../../../../libs/tc/util/GDispatcher";
import { IndexDispatcher, SetGameLayerUpdate } from "../IndexScene";
import { NetManager } from "../../../../libs/tw/manager/NetManager";
// 触发Option隐藏
const GDispatchHideOption = function() {
......@@ -50,6 +49,7 @@ export default class OptionPanel extends eui.Component {
private showOption(data?) {
console.log(data);
this.data = data;
IndexDispatcher.dispatchEvent("hideOption"); // 先触发隐藏,保证地块正常显示
this.visible = true;
this.touchEnabled = true;
......@@ -93,6 +93,15 @@ export default class OptionPanel extends eui.Component {
egret.Tween.get(target).to({scaleX: 1.2, scaleY: 1.2}, 100, egret.Ease.quadIn).call(() => {
egret.Tween.get(target).to({scaleX: 1, scaleY: 1}, 100, egret.Ease.quadOut).call(() => {
IndexDispatcher.dispatchEvent('hideOption');
console.log(this.data.index, petId);
SetGameLayerUpdate(false);
NetManager.ins.doPlant((success, res) => {
if(!success) {
SetGameLayerUpdate(true);
return;
}
IndexDispatcher.dispatchEvent('plant', {landId: this.data.index, petId: petId});
}, this.data.index, petId);
})
})
}
......
......@@ -11,16 +11,22 @@ export default class ProgressMgr {
public addProgress(data) {
/// TODO 根据数据添加进度条
// this.progressBar && this.progressBar.stop();
let {x, y, index, text, sTime, nTime, eTime, state} = data;
let progressBar = new TimeProgressBar(index, text, sTime, nTime, eTime, state);
progressBar.x = x;
progressBar.y = y;
IndexIns().gameLayer.addChildAt(progressBar, 100);
this.progressBars[index] = progressBar;
return progressBar;
}
public removeProgress(index){
this.progressBars[index].stop();
public removeProgress(index) {
if(this.progressBars[index]) {
this.progressBars[index].destroy();
IndexIns().gameLayer.removeChild(this.progressBars[index]);
this.progressBars[index] = null;
delete this.progressBars[index];
}
}
}
\ No newline at end of file
import { getSkinPath } from "../../utils";
import { IndexDispatcher } from "./IndexScene";
import { CanUpdate, IndexDispatcher } from "./IndexScene";
export default class TimeProgressBar extends eui.Component {
public bg: eui.Rect;
......@@ -46,19 +46,19 @@ export default class TimeProgressBar extends eui.Component {
this.corpName.text = this.labelText;
this.setProgress();
this.cTime = this.endTime - (this.nowTime = this.nowTime - this.nowTime % 1000 + 1000); // 去除余数
this.cTime = this.nowTime + 3;
this.cutFun();
this._timer = new egret.Timer(1000, 0);
this._timer = new egret.Timer(1000, this.cTime);
this._timer.addEventListener(egret.TimerEvent.TIMER, this.cutFun, this);
this._timer.start();
}
private cutFun() {
let timer = this._convertTime(this.cTime -= 1000);
this.nowTime += 1000;
if(timer.hour === "00"
&& timer.min === "00"
&& timer.sec === "00") {
this.cTime -= 1;
let timer = this._convertTime(this.cTime + 60);
this.nowTime += 1;
// console.log(this.cTime);
if(this.cTime <= 0) {
this.stop();
}
let str = this.progressText;
......@@ -70,7 +70,16 @@ export default class TimeProgressBar extends eui.Component {
}
public stop() {
console.log('stop');
this._timer && this._timer.stop();
CanUpdate() && IndexDispatcher.dispatchEvent('updateIndex');
}
public destroy() {
if(this._timer) {
this._timer.stop();
this._timer = null;
}
}
/**
......@@ -87,14 +96,14 @@ export default class TimeProgressBar extends eui.Component {
}
/**
* 通过时间戳获取几时积分几秒 例:666666666 -> {hour: 18, min: 51, sec: 16}
* 通过时间戳获取几时积分几秒
* @param time 时间戳(毫秒)
* @private
*/
private _convertTime(time: number): { hour, min, sec } {
let hour = ~~(time / 3600000); // 小时
let min = ~~((time - hour * 3600000) / 60000); // 分
let sec = ~~((time - hour * 3600000 - min * 60000) / 1000); // 秒
let hour = ~~(time / 3600); // 小时
let min = ~~((time - hour * 3600) / 60); // 分
let sec = ~~((time - hour * 3600 - min * 60)); // 秒
return {
hour: this._prefixInteger(hour, 2),
......
import { getSkinPath } from "../utils";
import PanelCtrl from "../ctrls/panelCtrl";
import { ModuleTypes } from "../types/sceneTypes";
export default class Bar extends eui.Component {
public back:eui.Image;
public rule:eui.Image;
public title:eui.Label;
private data = null;
constructor(data?) {
super();
this.skinName = getSkinPath('Component/Bar');
this.data = data || null;
this.initEvents();
// this.title.text = '工行卡中心';
}
private initEvents() {
this.back.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap, this);
this.rule.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap, this);
}
/// TODO 定义详细的操作
private onTap(e: egret.TouchEvent) {
const target = e.target;
switch(target) {
case this.rule: // 规则
PanelCtrl.instance.show(ModuleTypes.RULE_PANEL);
break;
case this.back: // 返回
break;
default:
break;
}
}
}
\ No newline at end of file
import { getSkinPath } from "../utils";
import { MainStage } from "../Main";
import { IndexDispatcher } from "../Scenes/IndexScene/IndexScene";
export class ProgressNum extends eui.Component {
public numLabel: eui.Label;
public touchGroup: eui.Group;
public bar: eui.Image;
public hand: eui.Rect;
private canMove = false;
private data = null;
private total = 0; // 总个数
private number = 0; // 当前个数
public get value() {
return this.number;
}
constructor(data?) {
super();
this.skinName = getSkinPath('Component/ProgressNum');
this.data = data || null;
this.total = this.data.total;
this.numLabel.text = `${this.number}`;
this.initEvents();
this.hand.anchorOffsetX = this.hand.width / 2;
}
private initEvents() {
MainStage.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.groupTouchBegin, this);
MainStage.addEventListener(egret.TouchEvent.TOUCH_MOVE, this.groupTouchMEC, this);
MainStage.addEventListener(egret.TouchEvent.TOUCH_END, this.groupTouchMEC, this);
MainStage.addEventListener(egret.TouchEvent.TOUCH_CANCEL, this.groupTouchMEC, this);
}
private setHandX(x) {
let aWidth = this.bar.width / this.total;
let dx = x % aWidth; // 取余数
x = (~~(x / aWidth) + (dx >= (aWidth / 2) ? 1 : 0)) * aWidth; // 过半吸附
this.hand.x = x;
if(this.hand.x < 0) {
this.hand.x = 0;
} else if(this.hand.x > this.bar.width) {
this.hand.x = this.bar.width;
}
this.number = ~~(this.hand.x / this.bar.width * this.total);
this.numLabel.text = `${this.number}`;
IndexDispatcher.dispatchEvent('updateSellValue');
}
private groupTouchBegin(e: egret.TouchEvent) {
this.canMove = this.touchGroup.hitTestPoint(e.stageX, e.stageY);
if(this.canMove) {
this.setHandX(e.stageX - this.x);
}
}
private groupTouchMEC(e: egret.TouchEvent) {
if(!this.canMove) {
return;
}
this.setHandX(e.stageX - this.x);
}
public destroy() {
MainStage.removeEventListener(egret.TouchEvent.TOUCH_BEGIN, this.groupTouchBegin, this);
MainStage.removeEventListener(egret.TouchEvent.TOUCH_MOVE, this.groupTouchMEC, this);
MainStage.removeEventListener(egret.TouchEvent.TOUCH_END, this.groupTouchMEC, this);
MainStage.removeEventListener(egret.TouchEvent.TOUCH_CANCEL, this.groupTouchMEC, this);
}
}
\ No newline at end of file
export const getResPath = () => window['resPath'] || '';
export const getSkinPath = (key)=>`resource/skins/${key}Skin.exml`
\ No newline at end of file
export const getSkinPath = (key)=>`resource/skins/${key}Skin.exml`;
export const getSvga = (name)=> `resource/assets/svgas/${name}.svga`;
\ No newline at end of file
......@@ -270,6 +270,17 @@ const config = {
data: './json/rankInfo.json'
},
'/projectx/{projectId}/prize.query': { // 土地信息
data: './projectX/queryPrizeInfo.json'
},
// '/projectx/{projectId}/join_1/landInfo.do': { // 土地信息
// data: './joyousManor/getLandInfo.json'
// },
// '/projectx/{projectId}/join_1/landInfo.do': { // 土地信息
// data: './joyousManor/getLandInfo.json'
// },
// 欢趣庄园
'/projectx/{projectId}/join_1/landInfo.do': { // 土地信息
data: './joyousManor/getLandInfo.json'
......
......@@ -5,26 +5,26 @@
"data": [
{
"id": 1,
"petId": 1,
"level": 2,
"petId": 2,
"level": 1,
"canFeed": false,
"feedLeftSeconds": 120,
"feedLeftSeconds": 3,
"canGather": false
},
{
"id": 2,
"petId": 1,
"level": 1,
"canFeed": true,
"feedLeftSeconds": 0,
"canGather": false
"petId": 0,
"level": 4,
"canFeed": false,
"feedLeftSeconds": 4,
"canGather": true
},
{
"id": 3,
"petId": 2,
"level": 1,
"level": 2,
"canFeed": true,
"feedLeftSeconds": 0,
"feedLeftSeconds": 10,
"canGather": false
},
{
......
{
"data": [
{
"icon": "//yun.dui88.com/images/201907/xsit2cvmyl.jpeg",
"id": "sp_1",
"name": "实物111",
"refId": "49356",
"refType": "object",
"stock": 100,
"type": 2
},
{
"degree": "10",
"icon": "//yun.dui88.com/projectxh5/credits-250-250.png",
"id": "sp_2",
"name": "加10积分",
"refType": "increase-credits",
"stock": 3,
"type": 2
}
],
"success": true
}
\ 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