| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- var Constants = require('Constants');
- var tiledMapUnit = cc.Class({
- name: "tiledMapUnit",
- properties: () => ({
- //获取id
- getBuildingID: {
- get: function () {
- return this._id;
- }
- },
- //占位的起始点,左下角的tiled
- getIsItOccupyPosition: {
- get: function () {
- return this._isItOccupyPosition;
- }
- },
- // isItOccupyPosition: [cc.Boolean],
- getTiledPosition: {
- get: function () {
- return this._tiledStartPosition;
- }
- },
- //占位的区域,比如是3*3 ,起点往后各占3格
- getOccupyingArea: {
- get: function () {
- return cc.v2(this._row, this._column);
- }
- },
- //对象的siblingIndex
- getSiblingIndex: {
- get: function () {
- return this._getSiblingIndex;
- }
- },
- //对象的ZIndex
- getZIndex: {
- get: function () {
- return this._ZIndex;
- }
- },
- //约定的index 的数组
- getIndexArray: {
- get: function () {
- return this._tiledIndexArray;
- }
- },
- //目标的buildingsInfo脚本
- getBuildingsInfo: {
- get: function () {
- return this._buildingsInfo;
- }
- }
- }),
- //记录对象的id,唯一的
- //只设置一次
- onSetBuildingID(id) {
- this._id = id;
- },
- //设置对象的siblingIndex
- onSetSiblingIndex(_siblingIndex) {
- this._getSiblingIndex = _siblingIndex;
- },
- //根据约定值取出渲染的index
- onGetSblingIndexFromIndex(_stargetIndex) {
- if (!this._tiledIndexArray)
- return false;
- let length = this._tiledIndexArray.length;
- for (let i = 0; i < length; i++) {
- if (targetIndex === this._tiledIndexArray[i])
- return this._getSiblingIndex;
- }
- return false;
- },
- //设置对象的ZIndex
- onSetZIndex(_ZIndex) {
- this._ZIndex = _ZIndex;
- },
- //根据约定值取出渲染的ZIndex
- onGetZIndexFromIndex(_stargetIndex) {
- if (!this._tiledIndexArray)
- return false;
- let length = this._tiledIndexArray.length;
- for (let i = 0; i < length; i++) {
- if (targetIndex === this._tiledIndexArray[i])
- return this._ZIndex;
- }
- return false;
- },
- //记录初始tile位置
- onSetStartTiledPos(tiledPos) {
- this._tiledStartPosition = tiledPos;
- },
- //Init Occupy State
- onSetOccupyState(value) {
- this._isItOccupyPosition = value;
- },
- //左边记为列 右边为行
- onSetOccupyingArea(x, y) {
- this._row = x;
- this._column = y;
- },
- //记录约定数组
- onSetIndexArray(index) {
- this._tiledIndexArray = index;
- },
- //记录目标的buildingsInfo脚本
- onSetBuildingsInfo(buildingsInfo) {
- this._buildingsInfo = buildingsInfo;
- },
- //约定的index是否存在这里
- onIndexExistInThis(targetIndex) {
- if (!this._tiledIndexArray)
- return false;
- let length = this._tiledIndexArray.length;
- for (let i = 0; i < length; i++) {
- if (targetIndex === this._tiledIndexArray[i])
- return true;
- }
- return false;
- }
- });
- module.exports = tiledMapUnit;
|