Commit d840db21 authored by haiyoucuv's avatar haiyoucuv

1

parent f2ca6358
......@@ -2,27 +2,10 @@
<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/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" />
</list>
<option name="SHOW_DIALOG" value="false" />
......@@ -112,7 +95,7 @@
<updated>1590749938444</updated>
<workItem from="1590749939792" duration="84000" />
<workItem from="1590976087296" duration="15316000" />
<workItem from="1590996860067" duration="2879000" />
<workItem from="1590996860067" duration="7029000" />
</task>
<servers />
</component>
......@@ -120,22 +103,22 @@
<option name="version" value="2" />
</component>
<component name="WindowStateProjectService">
<state width="255" height="907" key="GridCell.Tab.0.bottom" timestamp="1590998229565">
<state width="255" height="907" key="GridCell.Tab.0.bottom" timestamp="1591000059062">
<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">
<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">
<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">
<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">
<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">
<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">
<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 width="255" height="907" key="GridCell.Tab.0.right/35.23.1645.1027/1680.-199.1920.1177@35.23.1645.1027" timestamp="1591000059062" />
<state x="614" y="245" key="RollbackChangesDialog" timestamp="1590993046653">
<screen x="35" y="23" width="1645" height="1027" />
</state>
......@@ -144,9 +127,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="1590998043497">
<state x="522" y="250" width="670" height="676" key="search.everywhere.popup" timestamp="1591001551518">
<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" />
<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" />
</component>
</project>
\ No newline at end of file
......@@ -38,13 +38,6 @@ export default class GameLayer extends Container {
}
// 取消所有土地的选中状态
public deactivateAllLand() {
this.landList.forEach((v) => {
v.deactivate();
});
}
public initEvent() {
}
......
import Container = FYGE.Container;
import { RES } from "../../../module/RES";
import Sprite = FYGE.Sprite;
import DisplayObject = FYGE.DisplayObject;
import MouseEvent = FYGE.MouseEvent;
import { RES } from "../../../module/RES";
import GameLayer from "./GameLayer";
import OptionPool, { OPTION_TYPE } from "../../const/OptionPool";
import Option from "./Option";
export enum LAND_STATE {
DEFAULT = 'default',
......@@ -13,18 +15,22 @@ export enum LAND_STATE {
export class Land extends Container {
public static activeLand: Land = null;
// 田_初始.png 田_种植.png 田_选择.png
// 三个田的选择状态对应的texture
// 三个田的选择状态对应的 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;
private state: LAND_STATE;
private option: Option;
// id
private _id;
private _id: number;
public set id(id: number) {
this._id = id;
}
......@@ -56,7 +62,6 @@ export class Land extends Container {
this.addEventListener(MouseEvent.CLICK, () => {
console.log(`点到了土地: ${this.id}`);
GameLayer.ins.plantList.show(this.id); // 显示种植列表
GameLayer.ins.deactivateAllLand();
this.activate(); // 变成选中状态
});
......@@ -65,11 +70,24 @@ export class Land extends Container {
}
public changeState(state) {
if (state == this.state) return;
if (state === this.state) return;
this.state = state;
this.landSprite.texture = this[`land_${this.state}_texture`];
switch (this.state) {
case LAND_STATE.CHOOSE:
this.addOption(OPTION_TYPE.PLANT);
break;
case LAND_STATE.PLANT:
break;
default:
case LAND_STATE.DEFAULT:
break;
}
}
/**
......@@ -78,9 +96,9 @@ export class Land extends Container {
public activate() {
// 如果是已经是选中状态或种植状态则啥都干
if (LAND_STATE.CHOOSE === this.state || LAND_STATE.PLANT === this.state) return;
Land.activeLand && Land.activeLand.deactivate();
this.changeState(LAND_STATE.CHOOSE);
Land.activeLand = this;
}
/**
......@@ -90,7 +108,37 @@ export class Land extends Container {
// 如果是已经是默认状态或种植状态则啥都干
if (LAND_STATE.DEFAULT === this.state || LAND_STATE.PLANT === this.state) return;
Land.activeLand = null;
this.changeState(LAND_STATE.DEFAULT);
if (this.option) {
this.removeChild(this.option);
OptionPool.ins.takeIn(this.option);
this.option = null;
}
}
/**
* 为自己添加一个Option
* @param {OPTION_TYPE} type Option的类型
*/
private addOption(type: OPTION_TYPE) {
this.removeOption();
this.option = this.addChild(OptionPool.ins.takeOut(type));
this.option.x = 160;
this.option.y = -50;
this.option.play();
}
/**
* 移除自己的当前Option
*/
private removeOption() {
if (this.option) {
this.removeChild(this.option);
OptionPool.ins.takeIn(this.option);
this.option = null;
}
}
}
......@@ -25,12 +25,12 @@ export default class Option extends Sprite {
this.stop(); // 先stop
Tween.get(this)
.set({scaleX: 0, scaleY: 0})
.to({scaleX: 1, scaleY: 1}, 200, Ease.quadInOut)
.to({scaleX: 1, scaleY: 1}, 400, Ease.backOut)
.call(() => {
const _y = this.y;
Tween.get(this, {loop: true})
.to({y: _y - 10}, 200, Ease.quadInOut)
.to({y: _y}, 200, Ease.quadInOut);
.to({y: _y - 6}, 1000, Ease.quadInOut)
.to({y: _y}, 1000, Ease.quadInOut);
});
}
......
......@@ -4,6 +4,7 @@ import GameLayer from "../parts/Game/GameLayer";
import { UILayer } from "../parts/UI/UILayer";
import MouseEvent = FYGE.MouseEvent;
import OptionPool, { OPTION_TYPE } from "../const/OptionPool";
import { Land } from "../parts/Game/Land";
export class GameScene extends Scene {
......@@ -22,7 +23,7 @@ export class GameScene extends Scene {
.addEventListener(MouseEvent.CLICK, () => {
console.log('点击了BG');
GameLayer.ins.plantList.hidden(); // 隐藏种植栏
GameLayer.ins.deactivateAllLand();
Land.activeLand && Land.activeLand.deactivate();
});
// 游戏层
......@@ -31,8 +32,6 @@ export class GameScene extends Scene {
// UI层
this.uiLayer = this.addChild(new UILayer());
this.addChild(OptionPool.ins.takeOut(OPTION_TYPE.GET));
}
start() {
......@@ -53,7 +52,6 @@ export class GameScene extends Scene {
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