123456789101112131415161718192021222324252627282930313233343536373839404142 |
- import ViewObject from "../main/ViewObject";
- import Area, { Zone } from "./Area";
- import ZoneItem from "./item/ZoneItem";
- /**
- * 所有分区
- */
- const {ccclass, property} = cc._decorator;
- @ccclass
- export default class AllArea extends ViewObject {
- public area:Area;
- @property(cc.Node)
- mContent: cc.Node = null;
- @property(cc.Prefab)
- mZoneItem: cc.Prefab = null;
- onLoad () {
- let zones = this.area.zones;
- for (let i = 0; i < zones.length; i++) {
- const element = zones[i];
- this.addItem(element);
- }
- }
- public addItem(zone:Zone){
- let node = cc.instantiate(this.mZoneItem);
- let item = node.getComponent(ZoneItem);
- item.zone = zone;
- node.parent = this.mContent;
- item.setCallback((m:ZoneItem)=>{
- this.area.setOptZone(m.zone);
- this.__distroyAll();
- });
- }
- }
|