Commit f2ca6358 authored by haiyoucuv's avatar haiyoucuv

1

parent 5a93cefd
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ChangeListManager">
<list default="true" id="31be0130-d27d-4740-b668-956a8050e1bf" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/src/const/OptionPool.ts" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/parts/Game/Option.ts" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/parts/UI/UILayer.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/libs/fyge.min.js" beforeDir="false" afterPath="$PROJECT_DIR$/libs/fyge.min.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/output.js" beforeDir="false" afterPath="$PROJECT_DIR$/output.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/released/resource/common/common.json" beforeDir="false" afterPath="$PROJECT_DIR$/released/resource/common/common.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/released/resource/common/common.png" beforeDir="false" afterPath="$PROJECT_DIR$/released/resource/common/common.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/released/resource/gameScene/gameScene.json" beforeDir="false" afterPath="$PROJECT_DIR$/released/resource/gameScene/gameScene.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/released/resource/gameScene/gameScene.png" beforeDir="false" afterPath="$PROJECT_DIR$/released/resource/gameScene/gameScene.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/released/resource/res.json" beforeDir="false" afterPath="$PROJECT_DIR$/released/resource/res.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resource/gameScene/game_收获.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/resource/gameScene/game_浇水.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/resource/gameScene/game_种植.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/resource/gameScene/田_初始.png" beforeDir="false" afterPath="$PROJECT_DIR$/resource/gameScene/田_初始.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resource/gameScene/田_选择.png" beforeDir="false" afterPath="$PROJECT_DIR$/resource/gameScene/田_选择.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resource/res.json" beforeDir="false" afterPath="$PROJECT_DIR$/resource/res.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/ResJson.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/ResJson.ts" afterDir="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/PlantList.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/parts/Game/PlantList.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/scenes/GameScene.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/scenes/GameScene.ts" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="TypeScript File" />
</list>
</option>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="ProjectId" id="1cZxVM0mqsG9P42nucl4FAQPyH1" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"> <component name="PropertiesComponent">
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/src/panels" />
<property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" /> <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
<property name="nodejs_npm_path_reset_for_default_project" value="true" /> <property name="nodejs_npm_path_reset_for_default_project" value="true" />
<property name="nodejs_package_manager_path" value="npm" />
<property name="settings.editor.selected.configurable" value="editor.preferences.fonts.default" /> <property name="settings.editor.selected.configurable" value="editor.preferences.fonts.default" />
<property name="ts.external.directory.path" value="$PROJECT_DIR$/node_modules/typescript/lib" />
</component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/src/panels" />
</key>
</component>
<component name="RunManager" selected="npm.dev">
<configuration name="dev" type="js.build_tools.npm" temporary="true" nameIsGenerated="true">
<package-json value="$PROJECT_DIR$/package.json" />
<command value="run" />
<scripts>
<script value="dev" />
</scripts>
<node-interpreter value="project" />
<envs />
<method v="2" />
</configuration>
<configuration name="flushRes" type="js.build_tools.npm" temporary="true" nameIsGenerated="true">
<package-json value="$PROJECT_DIR$/package.json" />
<command value="run" />
<scripts>
<script value="flushRes" />
</scripts>
<node-interpreter value="project" />
<envs />
<method v="2" />
</configuration>
<configuration name="handleRes" type="js.build_tools.npm" temporary="true" nameIsGenerated="true">
<package-json value="$PROJECT_DIR$/package.json" />
<command value="run" />
<scripts>
<script value="handleRes" />
</scripts>
<node-interpreter value="project" />
<envs />
<method v="2" />
</configuration>
<recent_temporary>
<list>
<item itemvalue="npm.handleRes" />
<item itemvalue="npm.flushRes" />
<item itemvalue="npm.dev" />
</list>
</recent_temporary>
</component>
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="31be0130-d27d-4740-b668-956a8050e1bf" name="Default Changelist" comment="" />
<created>1590749938444</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1590749938444</updated>
<workItem from="1590749939792" duration="84000" />
<workItem from="1590976087296" duration="15316000" />
<workItem from="1590996860067" duration="2879000" />
</task>
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="2" />
</component>
<component name="WindowStateProjectService">
<state width="255" height="907" key="GridCell.Tab.0.bottom" timestamp="1590998229565">
<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="1590998229565" />
<state width="255" height="907" key="GridCell.Tab.0.center" timestamp="1590998229563">
<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="1590998229563" />
<state width="255" height="907" key="GridCell.Tab.0.left" timestamp="1590998229560">
<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="1590998229560" />
<state width="255" height="907" key="GridCell.Tab.0.right" timestamp="1590998229564">
<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="1590998229564" />
<state x="614" y="245" key="RollbackChangesDialog" timestamp="1590993046653">
<screen x="35" y="23" width="1645" height="1027" />
</state>
<state x="614" y="245" key="RollbackChangesDialog/35.23.1645.1027/1680.-199.1920.1177@35.23.1645.1027" timestamp="1590993046653" />
<state x="586" y="314" key="refactoring.ChangeSignatureDialog" timestamp="1590980819551">
<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="1590998043497">
<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="1590998043497" />
</component> </component>
</project> </project>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
{ {
"closeBtn.png": {
"x": 164,
"y": 134,
"w": 60,
"h": 60,
"ox": 0,
"oy": 0,
"sw": 60,
"sh": 60,
"ro": false
},
"comCloseBtn.png": { "comCloseBtn.png": {
"x": 646, "x": 284,
"y": 60, "y": 134,
"w": 48, "w": 48,
"h": 48, "h": 48,
"ox": 0, "ox": 0,
...@@ -11,7 +22,7 @@ ...@@ -11,7 +22,7 @@
"ro": false "ro": false
}, },
"toastBg.png": { "toastBg.png": {
"x": 184, "x": 164,
"y": 2, "y": 2,
"w": 460, "w": 460,
"h": 130, "h": 130,
...@@ -30,11 +41,11 @@ ...@@ -30,11 +41,11 @@
"oy": 0, "oy": 0,
"sw": 160, "sw": 160,
"sh": 180, "sh": 180,
"ro": true "ro": false
}, },
"waitingRot.png": { "waitingRot.png": {
"x": 646, "x": 226,
"y": 2, "y": 134,
"w": 56, "w": 56,
"h": 56, "h": 56,
"ox": 0, "ox": 0,
......
released/resource/common/common.png

1.08 KB | W: | H:

released/resource/common/common.png

1.76 KB | W: | H:

released/resource/common/common.png
released/resource/common/common.png
released/resource/common/common.png
released/resource/common/common.png
  • 2-up
  • Swipe
  • Onion skin
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
"sh": 133, "sh": 133,
"ro": false "ro": false
}, },
"game_鏀惰幏.png": { "game_get.png": {
"x": 3246, "x": 3246,
"y": 97, "y": 97,
"w": 82, "w": 82,
...@@ -65,7 +65,7 @@ ...@@ -65,7 +65,7 @@
"sh": 93, "sh": 93,
"ro": true "ro": true
}, },
"game_娴囨按.png": { "game_plant.png": {
"x": 3154, "x": 3154,
"y": 2, "y": 2,
"w": 90, "w": 90,
...@@ -76,7 +76,7 @@ ...@@ -76,7 +76,7 @@
"sh": 101, "sh": 101,
"ro": false "ro": false
}, },
"game_绉嶆.png": { "game_water.png": {
"x": 3062, "x": 3062,
"y": 2, "y": 2,
"w": 90, "w": 90,
......
{ {
"groups": [ "groups": [
{ {
"keys": "comCloseBtn.png,toastBg.png,waitingBg.png,waitingRot.png", "keys": "closeBtn.png,comCloseBtn.png,toastBg.png,waitingBg.png,waitingRot.png",
"name": "common", "name": "common",
"atlas": "common.json" "atlas": "common.json"
}, },
{ {
"keys": "btn_仓库.png,btn_兑换记录.png,btn_商店.png,btn_规则.png,btn_领水滴.png,game_bg.jpg,game_收获.png,game_浇水.png,game_种植.png,广告.png,用户_bg.png,用户_头像.png,用户_水.png,田_初始.png,田_种植.png,田_选择.png,种植框_bg.png,种植框_left.png,种植框_right.png,种植框_山核桃.png,种植框_开心果.png,种植框_板栗.png,种植框_瓜子.png,种植框_腰果.png,种植框_花生.png,种植框_袋子.png,进度_bg.png,进度_fill.png", "keys": "btn_仓库.png,btn_兑换记录.png,btn_商店.png,btn_规则.png,btn_领水滴.png,game_bg.jpg,game_get.png,game_plant.png,game_water.png,广告.png,用户_bg.png,用户_头像.png,用户_水.png,田_初始.png,田_种植.png,田_选择.png,种植框_bg.png,种植框_left.png,种植框_right.png,种植框_山核桃.png,种植框_开心果.png,种植框_板栗.png,种植框_瓜子.png,种植框_腰果.png,种植框_花生.png,种植框_袋子.png,进度_bg.png,进度_fill.png",
"name": "gameScene", "name": "gameScene",
"atlas": "gameScene.json" "atlas": "gameScene.json"
},
{
"keys": "rule_bg.png",
"name": "rulePanel",
"atlas": "rulePanel.json"
} }
], ],
"path": "./resource/" "path": "./resource/"
......
{
"rule_bg.png": {
"x": 2,
"y": 2,
"w": 560,
"h": 584,
"ox": 95,
"oy": 519,
"sw": 750,
"sh": 1624,
"ro": true
}
}
\ No newline at end of file
resource/gameScene/田_初始.png

17.2 KB | W: | H:

resource/gameScene/田_初始.png

21.8 KB | W: | H:

resource/gameScene/田_初始.png
resource/gameScene/田_初始.png
resource/gameScene/田_初始.png
resource/gameScene/田_初始.png
  • 2-up
  • Swipe
  • Onion skin
resource/gameScene/田_选择.png

17.1 KB | W: | H:

resource/gameScene/田_选择.png

19.9 KB | W: | H:

resource/gameScene/田_选择.png
resource/gameScene/田_选择.png
resource/gameScene/田_选择.png
resource/gameScene/田_选择.png
  • 2-up
  • Swipe
  • Onion skin
{ {
"groups": [ "groups": [
{ {
"keys": "comCloseBtn.png,toastBg.png,waitingBg.png,waitingRot.png", "keys": "closeBtn.png,comCloseBtn.png,toastBg.png,waitingBg.png,waitingRot.png",
"name": "common" "name": "common"
}, },
{ {
"keys": "btn_仓库.png,btn_兑换记录.png,btn_商店.png,btn_规则.png,btn_领水滴.png,game_bg.jpg,game_收获.png,game_浇水.png,game_种植.png,广告.png,用户_bg.png,用户_头像.png,用户_水.png,田_初始.png,田_种植.png,田_选择.png,种植框_bg.png,种植框_left.png,种植框_right.png,种植框_山核桃.png,种植框_开心果.png,种植框_板栗.png,种植框_瓜子.png,种植框_腰果.png,种植框_花生.png,种植框_袋子.png,进度_bg.png,进度_fill.png", "keys": "btn_仓库.png,btn_兑换记录.png,btn_商店.png,btn_规则.png,btn_领水滴.png,game_bg.jpg,game_get.png,game_plant.png,game_water.png,广告.png,用户_bg.png,用户_头像.png,用户_水.png,田_初始.png,田_种植.png,田_选择.png,种植框_bg.png,种植框_left.png,种植框_right.png,种植框_山核桃.png,种植框_开心果.png,种植框_板栗.png,种植框_瓜子.png,种植框_腰果.png,种植框_花生.png,种植框_袋子.png,进度_bg.png,进度_fill.png",
"name": "gameScene" "name": "gameScene"
},
{
"keys": "rule_bg.png",
"name": "rulePanel"
} }
], ],
"path": "./resource/" "path": "./resource/"
......
export const ResJson = { export const ResJson = {
"groups": [ "groups": [
{ {
"keys": "comCloseBtn.png,toastBg.png,waitingBg.png,waitingRot.png", "keys": "closeBtn.png,comCloseBtn.png,toastBg.png,waitingBg.png,waitingRot.png",
"name": "common" "name": "common"
}, },
{ {
"keys": "btn_仓库.png,btn_兑换记录.png,btn_商店.png,btn_规则.png,btn_领水滴.png,game_bg.jpg,game_收获.png,game_浇水.png,game_种植.png,广告.png,用户_bg.png,用户_头像.png,用户_水.png,田_初始.png,田_种植.png,田_选择.png,种植框_bg.png,种植框_left.png,种植框_right.png,种植框_山核桃.png,种植框_开心果.png,种植框_板栗.png,种植框_瓜子.png,种植框_腰果.png,种植框_花生.png,种植框_袋子.png,进度_bg.png,进度_fill.png", "keys": "btn_仓库.png,btn_兑换记录.png,btn_商店.png,btn_规则.png,btn_领水滴.png,game_bg.jpg,game_get.png,game_plant.png,game_water.png,广告.png,用户_bg.png,用户_头像.png,用户_水.png,田_初始.png,田_种植.png,田_选择.png,种植框_bg.png,种植框_left.png,种植框_right.png,种植框_山核桃.png,种植框_开心果.png,种植框_板栗.png,种植框_瓜子.png,种植框_腰果.png,种植框_花生.png,种植框_袋子.png,进度_bg.png,进度_fill.png",
"name": "gameScene" "name": "gameScene"
},
{
"keys": "rule_bg.png",
"name": "rulePanel"
} }
], ],
"path": "./resource/" "path": "./resource/"
......
import Option from "../parts/Game/Option";
/**
* option的类型枚举
*/
export enum OPTION_TYPE {
PLANT = 'plant',
WATER = 'water',
GET = 'get'
}
/**
* option的池
*/
export default class OptionPool {
// 单例
private static _ins: OptionPool;
public static get ins(): OptionPool {
return OptionPool._ins || (OptionPool._ins = new OptionPool());
}
// 缓存池
private pool = {
plant: [],
water: [],
get: [],
}
private constructor() {
// 先加一些缓存起来
[1, 2, 3, 4].forEach(() => {
this.pool.plant.push(new Option(OPTION_TYPE.PLANT));
this.pool.water.push(new Option(OPTION_TYPE.WATER));
this.pool.get.push(new Option(OPTION_TYPE.GET));
});
}
public takeOut(type: OPTION_TYPE) {
return this.pool[type].splice(0, 1)[0] || new Option(type);
}
public takeIn(option: Option) {
option.reset();
this.pool[option.type].push(option);
}
}
import { Panel } from "../../module/views/Panel";
import { Tool } from "../Tools";
import Sprite = FYGE.Sprite;
import ScrollPage = FYGE.ScrollPage;
import TextField = FYGE.TextField;
import TEXT_lINETYPE = FYGE.TEXT_lINETYPE;
export class RulePanel extends Panel {
get groupNames() {
return ["rulePanel"];
}
closeBtn: Sprite;
scroll: ScrollPage;
ruleLabel: TextField;
initUi() {
this.addChild(Tool.getSprite("rule_bg.png"));
this.closeBtn = this.addChild(Tool.getSprite('closeBtn.png'));
this.closeBtn.position.set(600, 350);
this.ruleLabel = new TextField();
this.ruleLabel.textWidth = 430;
this.ruleLabel.lineType = TEXT_lINETYPE.MULTI;
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.scroll = this.addChild(new ScrollPage(430, 360, this.ruleLabel.textHeight));
this.scroll.position.set(170, 675);
this.scroll.view.addChild(this.ruleLabel);
}
start(data) {
super.start();
}
initEvents() {
this.closeBtn.addEventListener(FYGE.MouseEvent.CLICK, this.hidePanel, this)
}
removeEvents() {
this.closeBtn.removeEventListener(FYGE.MouseEvent.CLICK, this.hidePanel, this)
}
}
import Container = FYGE.Container; import Container = FYGE.Container;
import { Land } from "./Land";
import PlantList from "./PlantList";
import FrameAni = FYGE.FrameAni;
export default class GameLayer extends Container{
constructor() { /**
* GameLayer
* @instance 单例
*/
export default class GameLayer extends Container {
// 单例
private static _ins: GameLayer;
public static get ins() {
return GameLayer._ins || (GameLayer._ins = new GameLayer());
}
public destroy() {
super.destroy();
this.removeEvent();
GameLayer._ins = null; // 一定要清除单例
}
private landList = []; // 土地列表
public plantList: PlantList; // 种植列表
private constructor() {
super(); super();
new FrameAni([]);
this.initLand();
// 种植列表
this.plantList = this.addChild(new PlantList());
}
// 取消所有土地的选中状态
public deactivateAllLand() {
this.landList.forEach((v) => {
v.deactivate();
});
}
public initEvent() {
}
public removeEvent() {
}
private initLand() {
const pos = [
[99, 730],
[334, 875],
[13, 939],
[248, 1083]
];
[1, 2, 3, 4].forEach((v) => {
let newLand = this.addChild(new Land());
newLand.position.set(pos[v - 1][0], pos[v - 1][1]);
newLand.id = v;
this.landList.push(newLand);
});
} }
} }
import Container = FYGE.Container; import Container = FYGE.Container;
import { RES } from "../../../module/RES";
import Sprite = FYGE.Sprite;
import DisplayObject = FYGE.DisplayObject;
import MouseEvent = FYGE.MouseEvent;
import GameLayer from "./GameLayer";
class Land extends Container { export enum LAND_STATE {
DEFAULT = 'default',
CHOOSE = 'choose',
PLANT = 'plant',
}
export class Land extends Container {
// 田_初始.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 state;
// id
private _id;
public set id(id: number) {
this._id = id;
}
public get id(): number {
return this._id;
}
constructor() { constructor() {
super(); 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;
if (isMouseEvent && !this.mouseEnable) return null;
let p = point;
if (isMouseEvent) {
p = this.globalToLocal(point, DisplayObject._bp);
}
p.x -= this.width / 2;
p.y -= this.height / 2;
let judge = Math.abs(p.x * this.height / 2) + Math.abs(p.y * this.width / 2) <= this.width * this.height / 4;
return judge ? this : null;
}.bind(this.landSprite);
this.addEventListener(MouseEvent.CLICK, () => {
console.log(`点到了土地: ${this.id}`);
GameLayer.ins.plantList.show(this.id); // 显示种植列表
GameLayer.ins.deactivateAllLand();
this.activate(); // 变成选中状态
});
this.changeState(LAND_STATE.DEFAULT);
}
public changeState(state) {
if (state == this.state) return;
this.state = state;
this.landSprite.texture = this[`land_${this.state}_texture`];
}
/**
* 在不是种植状态的基础上改变为选中状态
*/
public activate() {
// 如果是已经是选中状态或种植状态则啥都干
if (LAND_STATE.CHOOSE === this.state || LAND_STATE.PLANT === this.state) return;
this.changeState(LAND_STATE.CHOOSE);
}
/**
* 在不是种植状态的基础上改变为默认状态
*/
public deactivate() {
// 如果是已经是默认状态或种植状态则啥都干
if (LAND_STATE.DEFAULT === this.state || LAND_STATE.PLANT === this.state) return;
this.changeState(LAND_STATE.DEFAULT);
} }
} }
import Sprite = FYGE.Sprite;
import { RES } from "../../../module/RES";
import { OPTION_TYPE } from "../../const/OptionPool";
import Tween = FYGE.Tween;
import Ease = FYGE.Ease;
export default class Option extends Sprite {
private _type: OPTION_TYPE;
public get type(): OPTION_TYPE {
return this._type;
}
constructor(type: OPTION_TYPE) {
super(RES.getRes(`game_${type}.png`));
this._type = type;
this.anchor.set(this.width / 2, this.height);
this.scale.set(0, 0);
}
/**
* 播放这个Option的动画
*/
public play() {
this.stop(); // 先stop
Tween.get(this)
.set({scaleX: 0, scaleY: 0})
.to({scaleX: 1, scaleY: 1}, 200, Ease.quadInOut)
.call(() => {
const _y = this.y;
Tween.get(this, {loop: true})
.to({y: _y - 10}, 200, Ease.quadInOut)
.to({y: _y}, 200, Ease.quadInOut);
});
}
/**
* 停止这个Option的动画
*/
public stop() {
Tween.removeTweens(this);
}
/**
* 重置这个Option的动画
*/
public reset() {
this.stop(); // 先停止
this.scale.set(0, 0);
this.removeAllEventListener();
}
}
...@@ -8,8 +8,83 @@ import TEXT_ALIGN = FYGE.TEXT_ALIGN; ...@@ -8,8 +8,83 @@ import TEXT_ALIGN = FYGE.TEXT_ALIGN;
import VERTICAL_ALIGN = FYGE.VERTICAL_ALIGN; import VERTICAL_ALIGN = FYGE.VERTICAL_ALIGN;
import Sprite = FYGE.Sprite; import Sprite = FYGE.Sprite;
import { RES } from "../../../module/RES"; import { RES } from "../../../module/RES";
import Tween = FYGE.Tween;
import Ease = FYGE.Ease;
import GameLayer from "./GameLayer";
export default class PlantList extends Container {
private scrollList: ScrollList;
// 对应哪个土地,即点击哪个土地来显示这个列表
private _bindId = -1;
public get bindId() {
return this._bindId;
}
constructor() {
super();
// bg
this.addChild(Tool.getSprite('种植框_bg.png'));
// tip: left and right
this.addChild(Tool.getSprite('种植框_left.png'))
.position.set(15, (this.height - 34) / 2);
this.addChild(Tool.getSprite('种植框_right.png'))
.position.set(this.width - 33, (this.height - 34) / 2);
// 列表
this.scrollList = this.addChild(new ScrollList(ListPlant, 123, 160, 500, 160, false));
const data = [];
for (let k in PLANT) {
if (k == PLANT.NONE) continue;
data.push(PLANT[k]);
}
this.scrollList.updateData(data);
this.scrollList.x = (this.width - 500) / 2;
this.x = (750 - this.width) / 2;
this.y = 500;
this.visible = false;
}
/**
* 显示种植列表
* @param landId 对应的是哪块土地
*/
public show(landId) {
this._bindId = landId;
if (this.visible) return;
this.visible = true;
Tween.removeTweens(this);
Tween.get(this)
.set({alpha: 0})
.to({alpha: 1}, 300, Ease.quadInOut);
};
public hidden() {
this._bindId = -1;
if (!this.visible) return;
Tween.removeTweens(this);
Tween.get(this)
.to({alpha: 0}, 300, Ease.quadInOut)
.set({visible: false});
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* 种植列表里的植物
*/
class ListPlant extends Container implements IScrollListItem { class ListPlant extends Container implements IScrollListItem {
id: number; id: number;
data: number; data: number;
...@@ -71,45 +146,9 @@ class ListPlant extends Container implements IScrollListItem { ...@@ -71,45 +146,9 @@ class ListPlant extends Container implements IScrollListItem {
this.img = this.addChild(new Sprite()); this.img = this.addChild(new Sprite());
this.addEventListener(FYGE.MouseEvent.CLICK, () => { this.addEventListener(FYGE.MouseEvent.CLICK, () => {
console.log(`点到了: ${this.key} ${s_PlantData[this.key].name}`); const bindId = GameLayer.ins.plantList.bindId;
console.log(`点到了: ${this.key} ${s_PlantData[this.key].name}, 土地Id: ${bindId}`);
}); });
} }
} }
export default class PlantList extends Container {
private scrollList: ScrollList;
constructor() {
super();
this.width = 609;
this.height = 106;
// bg
this.addChild(Tool.getSprite('种植框_bg.png'));
// tip: left and right
this.addChild(Tool.getSprite('种植框_left.png'))
.position.set(15, (this.height - 34) / 2);
this.addChild(Tool.getSprite('种植框_right.png'))
.position.set(this.width - 33, (this.height - 34) / 2);
// 列表
this.scrollList = this.addChild(new ScrollList(ListPlant, 128, 160, 500, 160, false));
let data = [];
for (let k in PLANT) {
if (k == PLANT.NONE) continue;
data.push(PLANT[k]);
}
this.scrollList.updateData(data);
this.scrollList.x = (this.width - 500) / 2;
this.x = 100;
this.y = 400;
}
}
import Container = FYGE.Container;
import { UserInfoGroup } from "./UserInfoGroup";
import Sprite = FYGE.Sprite;
import { Tool } from "../../Tools";
import { getAdjustBottomHeight, getAdjustTopHeight } from "../../const/myLab";
import MouseEvent = FYGE.MouseEvent;
import PanelCtrl from "../../../module/ctrls/panelCtrl";
import { RulePanel } from "../../panels/RulePanel";
export class UILayer extends Container {
// 顶部
private userInfoGroup: UserInfoGroup; // 用户信息
private ruleBtn: Sprite; // 规则按钮
// 底部
private taskBtn: Sprite; // 任务按钮
private wareHouseBtn: Sprite; // 仓库按钮
private storeBtn: Sprite; // 商店按钮
// 广告按钮
private adBtn: Sprite; // 广告按钮
constructor() {
super();
this.initUILayer();
}
public initEvents() {
[this.ruleBtn, this.taskBtn, this.wareHouseBtn, this.storeBtn, this.adBtn].forEach((v) => {
v.addEventListener(MouseEvent.CLICK, this.touchBtn, this);
});
}
public removeEvents() {
[this.ruleBtn, this.taskBtn, this.wareHouseBtn, this.storeBtn, this.adBtn].forEach((v) => {
v.removeEventListener(MouseEvent.CLICK, this.touchBtn, this);
});
}
/**
* 按钮的点击事件
* @param e
*/
private touchBtn(e) {
console.log(e.target.name);
switch (e.target) {
case this.taskBtn:
console.log('点击了任务');
break;
case this.wareHouseBtn:
console.log('点击了仓库');
break;
case this.storeBtn:
console.log('点击了商店');
break;
case this.ruleBtn:
// console.log('点击了规则');
PanelCtrl.instance.show(RulePanel);
break;
case this.adBtn:
console.log('点击了广告');
break;
}
}
private initUILayer() {
// 底部
let bottomGroup = this.addChild(new Container());
this.taskBtn = bottomGroup.addChild(Tool.getSprite('btn_领水滴.png'))
this.taskBtn.x = 750 / 6 - this.taskBtn.width / 2;
this.taskBtn.name = '任务';
this.wareHouseBtn = bottomGroup.addChild(Tool.getSprite('btn_仓库.png'))
this.wareHouseBtn.x = 750 / 2 - this.wareHouseBtn.width / 2;
this.wareHouseBtn.name = '仓库';
this.storeBtn = bottomGroup.addChild(Tool.getSprite('btn_商店.png'))
this.storeBtn.x = 750 / 6 * 5 - this.storeBtn.width / 2;
this.storeBtn.name = '商店';
bottomGroup.y = getAdjustBottomHeight(bottomGroup, (1624 - 1382 - 133) / 1624);
// 顶部
let topGroup = this.addChild(new Container());
this.userInfoGroup = topGroup.addChild(new UserInfoGroup({
avatar: 'https://source.unsplash.com/collection/collectionid/100x100',
nickName: '哈哈哈哈',
waterNum: '666'
}));
this.ruleBtn = topGroup.addChild(Tool.getSprite('btn_规则.png'));
this.ruleBtn.position.set(622, 0);
this.ruleBtn.name = '规则';
topGroup.y = getAdjustTopHeight(topGroup, 117 / 1624);
// 广告按钮
this.adBtn = this.addChild(Tool.getSprite('广告.png'));
this.adBtn.position.set(30, (1624 - this.adBtn.height) / 2);
this.adBtn.name = '广告';
}
}
import { Scene } from "../../module/views/Scene"; import { Scene } from "../../module/views/Scene";
import { Tool } from "../Tools"; import { Tool } from "../Tools";
import PlantList from "../parts/Game/PlantList"; import GameLayer from "../parts/Game/GameLayer";
import Container = FYGE.Container; import { UILayer } from "../parts/UI/UILayer";
import { getAdjustBottomHeight, getAdjustTopHeight } from "../const/myLab";
import { UserInfoGroup } from "../parts/UI/UserInfoGroup";
import Sprite = FYGE.Sprite;
import MouseEvent = FYGE.MouseEvent; import MouseEvent = FYGE.MouseEvent;
import OptionPool, { OPTION_TYPE } from "../const/OptionPool";
export class GameScene extends Scene { export class GameScene extends Scene {
get groupNames() { get groupNames() {
return ['gameScene'] return ['gameScene'];
} }
private plantList: PlantList; // 种植列表 // 游戏层
private gameLayer: GameLayer; // 游戏层
// 顶部 // UI层
private userInfoGroup: UserInfoGroup; // 用户信息 private uiLayer: UILayer;
private ruleBtn: Sprite; // 规则按钮
// 底部
private taskBtn: Sprite; // 任务按钮
private wareHouseBtn: Sprite; // 仓库按钮
private storeBtn: Sprite; // 商店按钮
// 广告
private adBtn: Sprite;// 广告
initUi() { initUi() {
this.addChild(Tool.getSprite('game_bg.jpg')); this.addChild(Tool.getSprite('game_bg.jpg'))
.addEventListener(MouseEvent.CLICK, () => {
// 底部 console.log('点击了BG');
let bottomGroup = this.addChild(new Container()); GameLayer.ins.plantList.hidden(); // 隐藏种植栏
this.taskBtn = bottomGroup.addChild(Tool.getSprite('btn_领水滴.png')) GameLayer.ins.deactivateAllLand();
this.taskBtn.x = 750 / 6 - this.taskBtn.width / 2; });
this.taskBtn.name = '任务';
this.wareHouseBtn = bottomGroup.addChild(Tool.getSprite('btn_仓库.png'))
this.wareHouseBtn.x = 750 / 2 - this.wareHouseBtn.width / 2;
this.wareHouseBtn.name = '仓库';
this.storeBtn = bottomGroup.addChild(Tool.getSprite('btn_商店.png'))
this.storeBtn.x = 750 / 6 * 5 - this.storeBtn.width / 2;
this.storeBtn.name = '商店';
bottomGroup.y = getAdjustBottomHeight(bottomGroup, (1624 - 1382 - 133) / 1624);
// 顶部
let topGroup = this.addChild(new Container());
this.userInfoGroup = topGroup.addChild(new UserInfoGroup({
avatar: 'https://source.unsplash.com/collection/collectionid/100x100',
nickName: '哈哈哈哈',
waterNum: '666'
}));
this.ruleBtn = topGroup.addChild(Tool.getSprite('btn_规则.png')); // 游戏层
this.ruleBtn.position.set(622, 0); this.gameLayer = this.addChild(GameLayer.ins);
this.ruleBtn.name = '规则';
topGroup.y = getAdjustTopHeight(topGroup, 117 / 1624); // UI层
this.uiLayer = this.addChild(new UILayer());
this.adBtn = this.addChild(Tool.getSprite('广告.png')); this.addChild(OptionPool.ins.takeOut(OPTION_TYPE.GET));
this.adBtn.position.set(30, (this.height - this.adBtn.height) / 2);
this.adBtn.name = '广告';
// 种植列表
this.plantList = this.addChild(new PlantList());
// this.plantList.visible = false;
} }
start() { start() {
...@@ -74,43 +40,21 @@ export class GameScene extends Scene { ...@@ -74,43 +40,21 @@ export class GameScene extends Scene {
} }
/**
* 按钮的点击事件
* @param e
*/
private touchBtn(e) {
console.log(e.target.name);
switch (e.target) {
case this.taskBtn:
console.log('点击了任务');
break;
case this.wareHouseBtn:
console.log('点击了仓库');
break;
case this.storeBtn:
console.log('点击了商店');
break;
case this.ruleBtn:
console.log('点击了规则');
break;
case this.adBtn:
console.log('点击了广告');
break;
}
}
initEvents() { initEvents() {
super.initEvents(); super.initEvents();
[this.ruleBtn, this.taskBtn, this.wareHouseBtn, this.storeBtn, this.adBtn].forEach((v) => {
v.addEventListener(MouseEvent.CLICK, this.touchBtn, this); this.gameLayer.initEvent();
}); this.uiLayer.initEvents();
} }
removeEvents() { removeEvents() {
super.removeEvents(); super.removeEvents();
[this.ruleBtn, this.taskBtn, this.wareHouseBtn, this.storeBtn, this.adBtn].forEach((v) => {
v.removeEventListener(MouseEvent.CLICK, this.touchBtn, this); this.gameLayer.removeEvent();
}); this.uiLayer.removeEvents();
} }
} }
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