MyZoneItem.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import i18n from "../../i18n/i18n";
  2. import Area, { Zone,History_Role } from "../Area";
  3. const {ccclass, property} = cc._decorator;
  4. @ccclass
  5. export default class MyZoneItem extends cc.Component {
  6. @property(cc.Label)
  7. mZoneName: cc.Label = null;
  8. @property(cc.Label)
  9. mRoleName: cc.Label = null;
  10. @property(cc.Node)
  11. mRoleNode: cc.Node = null;
  12. @property(cc.Node)
  13. mNullNode: cc.Node = null;
  14. public area:Area;
  15. public zone:Zone;
  16. public role:History_Role;
  17. public callback:(item:MyZoneItem)=>void;
  18. onLoad () {
  19. if(this.role != null){
  20. this.zone = this.area.getZoneById(this.role.zoneId);
  21. this.mRoleNode.active = true;
  22. this.mNullNode.active = false;
  23. this.mRoleName.string = this.role.name;
  24. }else{
  25. this.mRoleNode.active = false;
  26. this.mNullNode.active = true;
  27. }
  28. this.mZoneName.string = i18n.t(this.zone.name);
  29. }
  30. public setCallback(callback:(item:MyZoneItem)=>void){
  31. this.callback = callback;
  32. }
  33. public onclick(){
  34. this.callback(this);
  35. }
  36. }