166 lines
6.2 KiB
JavaScript
166 lines
6.2 KiB
JavaScript
"use strict";
|
|
cc._RF.push(module, 'c58deN2u1NGZL8nJwvnu1PR', 'Block');
|
|
// Script/Block.ts
|
|
|
|
"use strict";
|
|
// Learn TypeScript:
|
|
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
|
|
// Learn Attribute:
|
|
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
|
|
// Learn life-cycle callbacks:
|
|
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
|
|
var __extends = (this && this.__extends) || (function () {
|
|
var extendStatics = function (d, b) {
|
|
extendStatics = Object.setPrototypeOf ||
|
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
return extendStatics(d, b);
|
|
};
|
|
return function (d, b) {
|
|
extendStatics(d, b);
|
|
function __() { this.constructor = d; }
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
})();
|
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.PathType = exports.BlockType = void 0;
|
|
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
|
|
var BlockType;
|
|
(function (BlockType) {
|
|
/*普通地块 */
|
|
BlockType[BlockType["Nomal"] = 0] = "Nomal";
|
|
/*起点地块 */
|
|
BlockType[BlockType["Start"] = 1] = "Start";
|
|
/*湿地 */
|
|
BlockType[BlockType["Nunja"] = 2] = "Nunja";
|
|
/*山峰 */
|
|
BlockType[BlockType["Peak"] = 3] = "Peak";
|
|
/*终点地块 */
|
|
BlockType[BlockType["End"] = 4] = "End";
|
|
/*息壤 */
|
|
BlockType[BlockType["Xi_Soil"] = 5] = "Xi_Soil";
|
|
/*加固 */
|
|
BlockType[BlockType["Reinforce"] = 6] = "Reinforce";
|
|
})(BlockType = exports.BlockType || (exports.BlockType = {}));
|
|
var PathType;
|
|
(function (PathType) {
|
|
PathType["err"] = "err";
|
|
PathType["up"] = "up";
|
|
PathType["down"] = "down";
|
|
PathType["left"] = "left";
|
|
PathType["right"] = "right";
|
|
PathType["up_left"] = "up_left";
|
|
PathType["up_right"] = "up_right";
|
|
PathType["down_left"] = "down_left";
|
|
PathType["down_right"] = "down_right";
|
|
PathType["left_up"] = "left_up";
|
|
PathType["left_down"] = "left_down";
|
|
PathType["right_up"] = "right_up";
|
|
PathType["right_down"] = "right_down";
|
|
})(PathType = exports.PathType || (exports.PathType = {}));
|
|
var NewClass = /** @class */ (function (_super) {
|
|
__extends(NewClass, _super);
|
|
function NewClass() {
|
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
}
|
|
NewClass.prototype.onLoad = function () {
|
|
this.finishi = false;
|
|
};
|
|
NewClass.prototype.start = function () {
|
|
};
|
|
NewClass.prototype.initData = function (type) {
|
|
this.block_Type = type;
|
|
if (type == cc.Enum(BlockType).Start) {
|
|
this.node.color = cc.color(245, 70, 70);
|
|
}
|
|
else if (type == cc.Enum(BlockType).End) {
|
|
this.node.color = cc.color(20, 255, 0);
|
|
}
|
|
};
|
|
NewClass.prototype.setPath = function (type) {
|
|
this.path_Type = type;
|
|
};
|
|
//洪峰执行
|
|
NewClass.prototype.runWater = function (data) {
|
|
var target = null;
|
|
var progress = 1;
|
|
var time = data.time;
|
|
var order = data.order + 1;
|
|
target = this.node.getChildByName("vertical");
|
|
console.log(this.path_Type);
|
|
if (this.path_Type == cc.Enum(PathType).up) {
|
|
}
|
|
else if (this.path_Type == cc.Enum(PathType).down) {
|
|
target.angle = 180;
|
|
}
|
|
else if (this.path_Type == cc.Enum(PathType).left) {
|
|
target.angle = 90;
|
|
}
|
|
else if (this.path_Type == cc.Enum(PathType).right) {
|
|
target.angle = 270;
|
|
}
|
|
else {
|
|
target = this.node.getChildByName("turn");
|
|
progress = 0.25;
|
|
if (this.path_Type == cc.Enum(PathType).up_left) {
|
|
target.setPosition(-9, -9);
|
|
}
|
|
else if (this.path_Type == cc.Enum(PathType).up_right) {
|
|
target.scaleX = -1;
|
|
target.setPosition(9, -9);
|
|
}
|
|
else if (this.path_Type == cc.Enum(PathType).down_left) {
|
|
target.angle = 180;
|
|
target.scaleX = -1;
|
|
target.setPosition(-9, 9);
|
|
}
|
|
else if (this.path_Type == cc.Enum(PathType).down_right) {
|
|
target.angle = 180;
|
|
target.scaleX = 1;
|
|
target.setPosition(9, 9);
|
|
}
|
|
else if (this.path_Type == cc.Enum(PathType).left_up) {
|
|
target.angle = -90;
|
|
target.scaleY = -1;
|
|
target.setPosition(9, 9);
|
|
}
|
|
else if (this.path_Type == cc.Enum(PathType).left_down) {
|
|
target.angle = 90;
|
|
target.scaleY = -1;
|
|
target.setPosition(-9, -9);
|
|
}
|
|
else if (this.path_Type == cc.Enum(PathType).right_up) {
|
|
target.angle = -90;
|
|
// target.scaleY = -1;
|
|
target.setPosition(-9, 9);
|
|
}
|
|
else if (this.path_Type == cc.Enum(PathType).right_down) {
|
|
target.angle = -90;
|
|
target.scaleX = -1;
|
|
target.setPosition(-9, -9);
|
|
}
|
|
}
|
|
target.active = true;
|
|
target.getComponent(cc.Sprite).fillRange = 0;
|
|
cc.tween(target.getComponent(cc.Sprite))
|
|
.to(time, { fillRange: progress })
|
|
.call(function () {
|
|
if (data.circulate)
|
|
cc.fx.Notifications.emit(cc.fx.Message.next, order);
|
|
})
|
|
.start();
|
|
};
|
|
NewClass = __decorate([
|
|
ccclass
|
|
], NewClass);
|
|
return NewClass;
|
|
}(cc.Component));
|
|
exports.default = NewClass;
|
|
|
|
cc._RF.pop(); |