123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- import { CELL_TYPE, ANITIME, CELL_STATUS, GRID_HEIGHT } from "./ConstValue";
- export default class CellModel {
- constructor() {
- this.type = null;
- this.status = CELL_STATUS.COMMON;
- this.x = 1;
- this.y = 1;
- this.startX = 1;
- this.startY = 1;
- this.cmd = [];
- this.isDeath = false;
- this.objecCount = Math.floor(Math.random() * 1000);
- }
- init(type) {
- this.type = type;
- }
- isEmpty() {
- return this.type == CELL_TYPE.EMPTY;
- }
- setEmpty() {
- this.type = CELL_TYPE.EMPTY;
- }
- setXY(x, y) {
- this.x = x;
- this.y = y;
- }
- setStartXY(x, y) {
- this.startX = x;
- this.startY = y;
- }
- setStatus(status) {
- this.status = status;
- }
- moveToAndBack(pos) {
- var srcPos = cc.v2(this.x, this.y);
- this.cmd.push({
- action: "moveTo",
- keepTime: ANITIME.TOUCH_MOVE,
- playTime: 0,
- pos: pos
- });
- this.cmd.push({
- action: "moveTo",
- keepTime: ANITIME.TOUCH_MOVE,
- playTime: ANITIME.TOUCH_MOVE,
- pos: srcPos
- });
- }
- moveTo(pos, playTime) {
- var srcPos = cc.v2(this.x, this.y);
- this.cmd.push({
- action: "moveTo",
- keepTime: ANITIME.TOUCH_MOVE,
- playTime: playTime,
- pos: pos
- });
- this.x = pos.x;
- this.y = pos.y;
- }
- toDie(playTime) {
- this.cmd.push({
- action: "toDie",
- playTime: playTime,
- keepTime: ANITIME.DIE
- });
- this.isDeath = true;
- }
- toShake(playTime) {
- this.cmd.push({
- action: "toShake",
- playTime: playTime,
- keepTime: ANITIME.DIE_SHAKE
- });
- }
- setVisible(playTime, isVisible) {
- this.cmd.push({
- action: "setVisible",
- playTime: playTime,
- keepTime: 0,
- isVisible: isVisible
- });
- }
- moveToAndDie(pos) {
- }
- isBird() {
- return this.type == CELL_TYPE.G;
- }
- }
|