first commit
This commit is contained in:
22
assets/scripts/union/UnionApplyItemLogic.ts
Normal file
22
assets/scripts/union/UnionApplyItemLogic.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { _decorator, Component, Label } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
import UnionCommand from "./UnionCommand";
|
||||
import { Apply } from "./UnionProxy";
|
||||
|
||||
@ccclass('UnionApplyItemLogic')
|
||||
export default class UnionApplyItemLogic extends Component {
|
||||
@property(Label)
|
||||
nameLabel: Label | null = null;
|
||||
protected _applyData:Apply = null;
|
||||
protected onLoad():void{
|
||||
|
||||
}
|
||||
protected updateItem(data:Apply):void{
|
||||
this._applyData = data;
|
||||
this.nameLabel.string = this._applyData.nick_name;
|
||||
}
|
||||
protected verify(event:any,decide:number = 0):void{
|
||||
UnionCommand.getInstance().unionVerify(this._applyData.id,Number(decide));
|
||||
}
|
||||
}
|
||||
|
||||
11
assets/scripts/union/UnionApplyItemLogic.ts.meta
Normal file
11
assets/scripts/union/UnionApplyItemLogic.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "721efa5d-56b8-4009-b25d-a205083f6b4d",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
45
assets/scripts/union/UnionApplyLogic.ts
Normal file
45
assets/scripts/union/UnionApplyLogic.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
// // 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
|
||||
|
||||
import { _decorator, Component, ScrollView } from 'cc';
|
||||
const {ccclass, property} = _decorator;
|
||||
|
||||
import UnionCommand from "./UnionCommand";
|
||||
import { Union } from "./UnionProxy";
|
||||
import { MapCityData } from "../map/MapCityProxy";
|
||||
import MapCommand from "../map/MapCommand";
|
||||
import { EventMgr } from '../utils/EventMgr';
|
||||
|
||||
@ccclass('UnionApplyLogic')
|
||||
export default class UnionApplyLogic extends Component {
|
||||
@property(ScrollView)
|
||||
applyView:ScrollView | null = null;
|
||||
protected onLoad():void{
|
||||
EventMgr.on("update_union_apply",this.updateApply,this);
|
||||
EventMgr.on("verify_union_success",this.getApply,this);
|
||||
}
|
||||
|
||||
protected onDestroy():void{
|
||||
EventMgr.targetOff(this);
|
||||
}
|
||||
protected updateApply(data:any[]){
|
||||
var comp = this.applyView.node.getComponent("ListLogic");
|
||||
comp.setData(data?data:[]);
|
||||
}
|
||||
protected getApply():void{
|
||||
let city:MapCityData = MapCommand.getInstance().cityProxy.getMyMainCity();
|
||||
let unionData:Union = UnionCommand.getInstance().proxy.getUnion(city.unionId);
|
||||
if(unionData.isMajor(city.rid)){
|
||||
UnionCommand.getInstance().unionApplyList(unionData.id);
|
||||
}
|
||||
}
|
||||
protected onEnable():void{
|
||||
console.log("getApply");
|
||||
this.getApply()
|
||||
}
|
||||
}
|
||||
|
||||
11
assets/scripts/union/UnionApplyLogic.ts.meta
Normal file
11
assets/scripts/union/UnionApplyLogic.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "45642013-2187-4c84-ac94-b5e038ab69d1",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
345
assets/scripts/union/UnionCommand.ts
Normal file
345
assets/scripts/union/UnionCommand.ts
Normal file
@@ -0,0 +1,345 @@
|
||||
import { _decorator } from 'cc';
|
||||
import { NetManager } from "../network/socket/NetManager";
|
||||
import UnionProxy, { Union } from "./UnionProxy";
|
||||
import { ServerConfig } from "../config/ServerConfig";
|
||||
import { MapCityData } from "../map/MapCityProxy";
|
||||
import MapCommand from "../map/MapCommand";
|
||||
import { EventMgr } from '../utils/EventMgr';
|
||||
|
||||
export default class UnionCommand {
|
||||
//单例
|
||||
protected static _instance: UnionCommand;
|
||||
public static getInstance(): UnionCommand {
|
||||
if (this._instance == null) {
|
||||
this._instance = new UnionCommand();
|
||||
}
|
||||
return this._instance;
|
||||
}
|
||||
|
||||
|
||||
//数据model
|
||||
protected _proxy: UnionProxy = new UnionProxy();
|
||||
|
||||
public static destory(): boolean {
|
||||
if (this._instance) {
|
||||
this._instance.onDestory();
|
||||
this._instance = null;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//数据model
|
||||
|
||||
constructor() {
|
||||
EventMgr.on(ServerConfig.union_create, this.onUnionCreate, this);
|
||||
EventMgr.on(ServerConfig.union_join, this.onUnionJoin, this);
|
||||
EventMgr.on(ServerConfig.union_list, this.onUnionList, this);
|
||||
EventMgr.on(ServerConfig.union_member, this.onUnionMember, this);
|
||||
EventMgr.on(ServerConfig.union_dismiss, this.onUnionDisMiss, this);
|
||||
EventMgr.on(ServerConfig.union_applyList, this.onUnionApply, this);
|
||||
EventMgr.on(ServerConfig.union_verify, this.onUnionVerify, this);
|
||||
EventMgr.on(ServerConfig.union_exit, this.onUnionDisMiss, this);
|
||||
EventMgr.on(ServerConfig.union_kick, this.onUnionKick, this);
|
||||
EventMgr.on(ServerConfig.union_appoint, this.onUnionAppoint, this);
|
||||
EventMgr.on(ServerConfig.union_abdicate, this.onUnionAbdicate, this);
|
||||
EventMgr.on(ServerConfig.union_modNotice, this.onUnionNotice, this)
|
||||
EventMgr.on(ServerConfig.union_info, this.onUnionInfo, this);
|
||||
EventMgr.on(ServerConfig.union_log, this.onUnionLog, this);
|
||||
EventMgr.on(ServerConfig.union_apply_push, this.onUnionApplyPush, this);
|
||||
}
|
||||
|
||||
public onDestory(): void {
|
||||
EventMgr.targetOff(this);
|
||||
}
|
||||
|
||||
public clearData(): void {
|
||||
this._proxy.clearData();
|
||||
}
|
||||
|
||||
public get proxy(): UnionProxy {
|
||||
return this._proxy;
|
||||
}
|
||||
|
||||
|
||||
protected onUnionCreate(data: any, otherData: any): void {
|
||||
console.log("onUnionCreate", data);
|
||||
if (data.code == 0) {
|
||||
EventMgr.emit("create_union_success");
|
||||
this.unionList();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected onUnionJoin(data: any, otherData: any): void {
|
||||
console.log("onUnionJoin", data);
|
||||
if (data.code == 0) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected onUnionList(data: any, otherData: any): void {
|
||||
console.log("onUnionList", data);
|
||||
if (data.code == 0) {
|
||||
this._proxy.updateUnionList(data.msg.list);
|
||||
EventMgr.emit("update_union_list",data.msg.list);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected onUnionMember(data: any, otherData: any): void {
|
||||
console.log("onUnionMember", data);
|
||||
if (data.code == 0) {
|
||||
this._proxy.updateMemberList(data.msg.id,data.msg.Members);
|
||||
EventMgr.emit("update_union_member",data.msg.Members);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected onUnionDisMiss(data: any, otherData: any): void {
|
||||
console.log("onUnionDisMiss", data);
|
||||
if (data.code == 0) {
|
||||
this.unionList();
|
||||
EventMgr.emit("dismiss_union_success");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected onUnionApply(data: any, otherData: any): void {
|
||||
console.log("onUnionApply", data);
|
||||
if (data.code == 0) {
|
||||
this._proxy.updateApplyList(data.msg.id, data.msg.applys);
|
||||
EventMgr.emit("update_union_apply", data.msg.applys);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected onUnionVerify(data: any, otherData: any): void {
|
||||
console.log("onUnionVerify", data);
|
||||
if (data.code == 0) {
|
||||
EventMgr.emit("kick_union_success");
|
||||
EventMgr.emit("verify_union_success");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected onUnionKick(data: any, otherData: any): void {
|
||||
console.log("onUnionKick", data);
|
||||
if (data.code == 0) {
|
||||
EventMgr.emit("kick_union_success");
|
||||
}
|
||||
}
|
||||
|
||||
protected onUnionAppoint(data: any, otherData: any): void {
|
||||
console.log("onUnionAppoint", data);
|
||||
if (data.code == 0) {
|
||||
EventMgr.emit("union_appoint", data.msg);
|
||||
}
|
||||
}
|
||||
|
||||
protected onUnionAbdicate(data: any, otherData: any): void {
|
||||
console.log("onUnionAbdicate", data);
|
||||
if (data.code == 0) {
|
||||
EventMgr.emit("union_abdicate", data.msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected onUnionNotice(data: any, otherData: any): void {
|
||||
console.log("onUnionNotice", data);
|
||||
if(data.code == 0){
|
||||
this._proxy.updateNotice(data.msg.id, data.msg.text)
|
||||
EventMgr.emit("union_notice", data.msg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected onUnionInfo(data: any, otherData: any): void {
|
||||
console.log("onUnionInfo", data);
|
||||
if(data.code == 0){
|
||||
let l = []
|
||||
l.push(data.msg.info)
|
||||
this._proxy.updateUnionList(l);
|
||||
|
||||
EventMgr.emit("union_info", data.msg);
|
||||
}
|
||||
}
|
||||
|
||||
protected onUnionLog(data: any, otherData: any): void {
|
||||
console.log("onUnionLog", data);
|
||||
if(data.code == 0){
|
||||
EventMgr.emit("union_log", data.msg.logs);
|
||||
}
|
||||
}
|
||||
|
||||
protected onUnionApplyPush(data: any, otherData: any): void {
|
||||
console.log("onUnionApplyPush", data);
|
||||
let city:MapCityData = MapCommand.getInstance().cityProxy.getMyMainCity();
|
||||
let unionData:Union = UnionCommand.getInstance().proxy.getUnion(city.unionId);
|
||||
if (unionData && unionData.isMajor(city.rid)){
|
||||
this._proxy.updateApply(city.unionId, data.msg);
|
||||
EventMgr.emit("update_union_apply", data.msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public unionCreate(name:string):void{
|
||||
let sendData: any = {
|
||||
name: ServerConfig.union_create,
|
||||
msg: {
|
||||
name: name,
|
||||
}
|
||||
};
|
||||
NetManager.getInstance().send(sendData);
|
||||
}
|
||||
|
||||
|
||||
public unionJoin(id:number = 0):void{
|
||||
let sendData: any = {
|
||||
name: ServerConfig.union_join,
|
||||
msg: {
|
||||
id: id,
|
||||
}
|
||||
};
|
||||
NetManager.getInstance().send(sendData);
|
||||
}
|
||||
|
||||
|
||||
public unionList():void{
|
||||
let sendData: any = {
|
||||
name: ServerConfig.union_list,
|
||||
msg: {
|
||||
}
|
||||
};
|
||||
NetManager.getInstance().send(sendData);
|
||||
}
|
||||
|
||||
public unionInfo(id:number = 0):void{
|
||||
let sendData: any = {
|
||||
name: ServerConfig.union_info,
|
||||
msg: {
|
||||
id:id
|
||||
}
|
||||
};
|
||||
NetManager.getInstance().send(sendData);
|
||||
}
|
||||
|
||||
|
||||
public unionMember(id:number = 0):void{
|
||||
let sendData: any = {
|
||||
name: ServerConfig.union_member,
|
||||
msg: {
|
||||
id: id,
|
||||
}
|
||||
};
|
||||
NetManager.getInstance().send(sendData);
|
||||
}
|
||||
|
||||
|
||||
public unionApplyList(id:number = 0):void{
|
||||
let sendData: any = {
|
||||
name: ServerConfig.union_applyList,
|
||||
msg: {
|
||||
id: id,
|
||||
}
|
||||
};
|
||||
NetManager.getInstance().send(sendData);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public unionDismiss():void{
|
||||
let sendData: any = {
|
||||
name: ServerConfig.union_dismiss,
|
||||
msg: {
|
||||
}
|
||||
};
|
||||
NetManager.getInstance().send(sendData);
|
||||
}
|
||||
|
||||
|
||||
public unionVerify(id:number = 0,decide:number = 0):void{
|
||||
let sendData: any = {
|
||||
name: ServerConfig.union_verify,
|
||||
msg: {
|
||||
id:id,
|
||||
decide:decide
|
||||
}
|
||||
};
|
||||
NetManager.getInstance().send(sendData);
|
||||
}
|
||||
|
||||
|
||||
public unionExit():void{
|
||||
let sendData: any = {
|
||||
name: ServerConfig.union_exit,
|
||||
msg: {
|
||||
}
|
||||
};
|
||||
NetManager.getInstance().send(sendData);
|
||||
}
|
||||
|
||||
|
||||
public unionKick(rid:number = 0):void{
|
||||
let sendData: any = {
|
||||
name: ServerConfig.union_kick,
|
||||
msg: {
|
||||
rid:rid,
|
||||
}
|
||||
};
|
||||
console.log("unionKick");
|
||||
NetManager.getInstance().send(sendData);
|
||||
}
|
||||
|
||||
public unionAppoint(rid:number = 0, title=1):void{
|
||||
let sendData: any = {
|
||||
name: ServerConfig.union_appoint,
|
||||
msg: {
|
||||
rid:rid,
|
||||
title:title
|
||||
}
|
||||
};
|
||||
NetManager.getInstance().send(sendData);
|
||||
}
|
||||
|
||||
public unionAbdicate(rid:number = 0):void{
|
||||
let sendData: any = {
|
||||
name: ServerConfig.union_abdicate,
|
||||
msg: {
|
||||
rid:rid
|
||||
}
|
||||
};
|
||||
NetManager.getInstance().send(sendData);
|
||||
}
|
||||
|
||||
public modNotice(text:string):void{
|
||||
let sendData: any = {
|
||||
name: ServerConfig.union_modNotice,
|
||||
msg: {
|
||||
text:text,
|
||||
}
|
||||
};
|
||||
NetManager.getInstance().send(sendData);
|
||||
}
|
||||
|
||||
public appoint(rid:number = 0):void{
|
||||
let sendData: any = {
|
||||
name: ServerConfig.union_kick,
|
||||
msg: {
|
||||
rid:rid,
|
||||
}
|
||||
};
|
||||
NetManager.getInstance().send(sendData);
|
||||
}
|
||||
|
||||
public unionLog():void{
|
||||
let sendData: any = {
|
||||
name: ServerConfig.union_log,
|
||||
msg: {
|
||||
}
|
||||
};
|
||||
NetManager.getInstance().send(sendData);
|
||||
}
|
||||
}
|
||||
11
assets/scripts/union/UnionCommand.ts.meta
Normal file
11
assets/scripts/union/UnionCommand.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "66f67a83-25f5-4cf3-b1a6-8e67cf9327bd",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
43
assets/scripts/union/UnionCreateLogic.ts
Normal file
43
assets/scripts/union/UnionCreateLogic.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
// // 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
|
||||
|
||||
import { _decorator, Component, EditBox } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
import UnionCommand from "./UnionCommand";
|
||||
import { EventMgr } from '../utils/EventMgr';
|
||||
|
||||
@ccclass('UnionCreateLogic')
|
||||
export default class UnionCreateLogic extends Component {
|
||||
@property(EditBox)
|
||||
editName: EditBox | null = null;
|
||||
protected onLoad():void{
|
||||
EventMgr.on("create_union_success",this.onClickClose,this)
|
||||
this.editName.string = this.getRandomName();
|
||||
}
|
||||
protected onCreate() {
|
||||
UnionCommand.getInstance().unionCreate(this.editName.string);
|
||||
}
|
||||
protected onRandomName():void{
|
||||
this.editName.string = this.getRandomName();
|
||||
}
|
||||
protected getRandomName():string{
|
||||
let name = ""
|
||||
var firstname:string[] = ["李","西门","沈","张","上官","司徒","欧阳","轩辕","咳咳","妈妈"];
|
||||
var nameq:string[] = ["彪","巨昆","锐","翠花","小小","撒撒","熊大","宝强"];
|
||||
var xingxing = firstname[Math.floor(Math.random() * (firstname.length))];
|
||||
var mingming = nameq[Math.floor(Math.random() * (nameq.length))];
|
||||
name = xingxing + mingming;
|
||||
return name
|
||||
}
|
||||
protected onDestroy():void{
|
||||
EventMgr.targetOff(this);
|
||||
}
|
||||
protected onClickClose(): void {
|
||||
this.node.active = false;
|
||||
}
|
||||
}
|
||||
11
assets/scripts/union/UnionCreateLogic.ts.meta
Normal file
11
assets/scripts/union/UnionCreateLogic.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "1e553d70-14d7-4c56-baa7-580078d7139e",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
36
assets/scripts/union/UnionItemLogic.ts
Normal file
36
assets/scripts/union/UnionItemLogic.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { _decorator, Component, Label, Node } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
import UnionCommand from "./UnionCommand";
|
||||
import { Union } from "./UnionProxy";
|
||||
import { EventMgr } from '../utils/EventMgr';
|
||||
|
||||
@ccclass('UnionItemLogic')
|
||||
export default class UnionItemLogic extends Component {
|
||||
@property(Label)
|
||||
nameLabel: Label | null = null;
|
||||
@property(Node)
|
||||
joinButtonNode: Node | null = null;
|
||||
protected _unionData:Union = null;
|
||||
protected onLoad():void{
|
||||
this.joinButtonNode.active = false;
|
||||
}
|
||||
protected updateItem(data:Union):void{
|
||||
this._unionData = data;
|
||||
this.nameLabel.string = this._unionData.name;
|
||||
this.joinButtonNode.active = this.isCanJoin();
|
||||
|
||||
|
||||
}
|
||||
protected isCanJoin():boolean{
|
||||
return !UnionCommand.getInstance().proxy.isMeInUnion();
|
||||
}
|
||||
protected join():void{
|
||||
UnionCommand.getInstance().unionJoin(this._unionData.id)
|
||||
}
|
||||
protected click():void{
|
||||
var isCanjoin:boolean = this.isCanJoin();
|
||||
if(!isCanjoin){
|
||||
EventMgr.emit("open_my_union",this._unionData)
|
||||
}
|
||||
}
|
||||
}
|
||||
11
assets/scripts/union/UnionItemLogic.ts.meta
Normal file
11
assets/scripts/union/UnionItemLogic.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "886edb26-db1b-4e10-b033-661f003a5c44",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
33
assets/scripts/union/UnionLobbyLogic.ts
Normal file
33
assets/scripts/union/UnionLobbyLogic.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { _decorator, Component, ScrollView } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
import UnionCommand from "./UnionCommand";
|
||||
import { Union } from "./UnionProxy";
|
||||
import { EventMgr } from '../utils/EventMgr';
|
||||
|
||||
@ccclass('UnionLobbyLogic')
|
||||
export default class UnionLobbyLogic extends Component {
|
||||
@property(ScrollView)
|
||||
scrollView:ScrollView | null = null;
|
||||
private _isFrist:boolean = false;
|
||||
protected onLoad():void{
|
||||
EventMgr.on("update_union_list",this.updateUnion,this);
|
||||
}
|
||||
|
||||
protected onDestroy():void{
|
||||
EventMgr.targetOff(this);
|
||||
}
|
||||
protected updateUnion(data:any[]){
|
||||
var comp = this.scrollView.node.getComponent("ListLogic");
|
||||
var list:Union[] = UnionCommand.getInstance().proxy.getUnionList();
|
||||
comp.setData(list);
|
||||
}
|
||||
protected onEnable():void{
|
||||
this._isFrist = true;
|
||||
UnionCommand.getInstance().unionList();
|
||||
}
|
||||
protected onDisable():void{
|
||||
this._isFrist = false;
|
||||
}
|
||||
}
|
||||
|
||||
11
assets/scripts/union/UnionLobbyLogic.ts.meta
Normal file
11
assets/scripts/union/UnionLobbyLogic.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "cfa84fa7-ec4d-45d2-8631-b142da79c32b",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
26
assets/scripts/union/UnionLogItemLogic.ts
Normal file
26
assets/scripts/union/UnionLogItemLogic.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
// // 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
|
||||
|
||||
import { _decorator, Component, Label } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
import DateUtil from "../utils/DateUtil";
|
||||
@ccclass('UnionLogItemLogic')
|
||||
export default class UnionApplyItemLogic extends Component {
|
||||
@property(Label)
|
||||
desLabel: Label | null = null;
|
||||
@property(Label)
|
||||
timeLabel: Label | null = null;
|
||||
protected onLoad():void{
|
||||
|
||||
}
|
||||
protected updateItem(data:any):void{
|
||||
this.desLabel.string = data.des;
|
||||
this.timeLabel.string = DateUtil.converTimeStr(data.ctime, "YYYY-MM-DD hh:mm:ss");
|
||||
}
|
||||
}
|
||||
|
||||
11
assets/scripts/union/UnionLogItemLogic.ts.meta
Normal file
11
assets/scripts/union/UnionLogItemLogic.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "3fe1bfa7-f44b-4b03-8b10-36bb9edd0606",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
45
assets/scripts/union/UnionLogLogic.ts
Normal file
45
assets/scripts/union/UnionLogLogic.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
// // 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
|
||||
|
||||
import { _decorator, Component, ScrollView } from 'cc';
|
||||
const {ccclass, property} = _decorator;
|
||||
|
||||
import UnionCommand from "./UnionCommand";
|
||||
import { Union } from "./UnionProxy";
|
||||
import { MapCityData } from "../map/MapCityProxy";
|
||||
import MapCommand from "../map/MapCommand";
|
||||
import { EventMgr } from '../utils/EventMgr';
|
||||
|
||||
@ccclass('UnionLogLogic')
|
||||
export default class UnionLogLogic extends Component {
|
||||
@property(ScrollView)
|
||||
logView:ScrollView | null = null;
|
||||
protected onLoad():void{
|
||||
EventMgr.on("union_log",this.updateLog,this);
|
||||
}
|
||||
|
||||
protected onDestroy():void{
|
||||
EventMgr.targetOff(this);
|
||||
}
|
||||
protected updateLog(data:any[]){
|
||||
|
||||
var comp = this.logView.node.getComponent("ListLogic");
|
||||
comp.setData(data?data:[]);
|
||||
}
|
||||
protected getLog():void{
|
||||
let city:MapCityData = MapCommand.getInstance().cityProxy.getMyMainCity();
|
||||
let unionData:Union = UnionCommand.getInstance().proxy.getUnion(city.unionId);
|
||||
if(unionData.isMajor(city.rid)){
|
||||
UnionCommand.getInstance().unionLog();
|
||||
}
|
||||
}
|
||||
protected onEnable():void{
|
||||
console.log("getLog");
|
||||
this.getLog()
|
||||
}
|
||||
}
|
||||
|
||||
11
assets/scripts/union/UnionLogLogic.ts.meta
Normal file
11
assets/scripts/union/UnionLogLogic.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "3041baac-4838-4b4a-87f9-db8d99d92435",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
94
assets/scripts/union/UnionLogic.ts
Normal file
94
assets/scripts/union/UnionLogic.ts
Normal file
@@ -0,0 +1,94 @@
|
||||
// // 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
|
||||
|
||||
import { _decorator, Component, Node, Label } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
import { MapCityData } from "../map/MapCityProxy";
|
||||
import MapCommand from "../map/MapCommand";
|
||||
import { EventMgr } from '../utils/EventMgr';
|
||||
|
||||
@ccclass('UnionLogic')
|
||||
export default class UnionLogic extends Component {
|
||||
@property(Node)
|
||||
createNode:Node | null = null;
|
||||
@property(Node)
|
||||
mainNode:Node | null = null;
|
||||
@property(Node)
|
||||
lobbyNode:Node | null = null;
|
||||
@property(Node)
|
||||
memberNode:Node | null = null;
|
||||
@property(Node)
|
||||
applyNode:Node | null = null;
|
||||
|
||||
@property(Node)
|
||||
logNode:Node | null = null;
|
||||
@property(Label)
|
||||
nameLab:Label | null = null;
|
||||
protected onLoad():void{
|
||||
this.visibleView();
|
||||
EventMgr.on("open_my_union",this.openMyUnion,this);
|
||||
EventMgr.on("dismiss_union_success",this.exit,this);
|
||||
EventMgr.on("close_union",this.onClickClose,this);
|
||||
EventMgr.on("create_union_success",this.openMyUnion,this);
|
||||
}
|
||||
protected onDestroy():void{
|
||||
EventMgr.targetOff(this);
|
||||
}
|
||||
protected onClickClose(): void {
|
||||
console.log("onClickClose");
|
||||
this.node.active = false;
|
||||
}
|
||||
protected onClickMember(): void {
|
||||
this.memberNode.active = true;
|
||||
this.mainNode.active = false;
|
||||
}
|
||||
protected onClickApply(): void {
|
||||
this.mainNode.active = false;
|
||||
this.applyNode.active = true;
|
||||
}
|
||||
protected onClickLog(): void {
|
||||
this.mainNode.active = false;
|
||||
this.logNode.active = true;
|
||||
}
|
||||
protected openCreate():void{
|
||||
this.createNode.active = true;
|
||||
}
|
||||
protected visibleView():void{
|
||||
this.memberNode.active =
|
||||
this.createNode.active =
|
||||
this.lobbyNode.active =
|
||||
this.applyNode.active =
|
||||
this.memberNode.active =
|
||||
this.logNode.active = false;
|
||||
}
|
||||
protected openMyUnion():void{
|
||||
this.visibleView();
|
||||
this.mainNode.active = true
|
||||
}
|
||||
protected onEnable():void{
|
||||
|
||||
let city:MapCityData = MapCommand.getInstance().cityProxy.getMyMainCity();
|
||||
if(city.unionId > 0){
|
||||
this.openMyUnion();
|
||||
}else{
|
||||
this.mainNode.active = false;
|
||||
this.lobbyNode.active = true;
|
||||
}
|
||||
}
|
||||
protected onDisable():void{
|
||||
this.visibleView();
|
||||
}
|
||||
protected back():void{
|
||||
this.openMyUnion();
|
||||
}
|
||||
protected exit():void{
|
||||
this.visibleView();
|
||||
this.lobbyNode.active = true
|
||||
}
|
||||
}
|
||||
|
||||
11
assets/scripts/union/UnionLogic.ts.meta
Normal file
11
assets/scripts/union/UnionLogic.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "5486e42e-f4ad-4b05-a893-74fb1ec46f4f",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
88
assets/scripts/union/UnionMainLogic.ts
Normal file
88
assets/scripts/union/UnionMainLogic.ts
Normal file
@@ -0,0 +1,88 @@
|
||||
import { _decorator, Component, Label, Node, EditBox, Button } from 'cc';
|
||||
const {ccclass, property} = _decorator;
|
||||
|
||||
import UnionCommand from "./UnionCommand";
|
||||
import { Union } from "./UnionProxy";
|
||||
import { MapCityData } from "../map/MapCityProxy";
|
||||
import MapCommand from "../map/MapCommand";
|
||||
import { EventMgr } from '../utils/EventMgr';
|
||||
|
||||
@ccclass('UnionMainLogic')
|
||||
export default class UnionMainLogic extends Component {
|
||||
@property(Label)
|
||||
nameLab: Label | null = null;
|
||||
@property(Label)
|
||||
mengZhuLab: Label | null = null;
|
||||
@property(Label)
|
||||
noticeLab: Label | null = null;
|
||||
@property(Node)
|
||||
editNode: Node | null = null;
|
||||
@property(EditBox)
|
||||
editBox: EditBox | null = null;
|
||||
@property(Button)
|
||||
modifyBtn: Button | null = null;
|
||||
@property(Button)
|
||||
applyBtn: Button | null = null;
|
||||
@property(Node)
|
||||
applyRedDot: Node | null = null;
|
||||
|
||||
onLoad () {
|
||||
EventMgr.on("union_notice",this.onUnionNotice,this);
|
||||
EventMgr.on("union_info",this.onInfo, this);
|
||||
EventMgr.on("update_union_apply", this.onUnionApply, this);
|
||||
}
|
||||
|
||||
protected onDestroy():void{
|
||||
EventMgr.targetOff(this);
|
||||
}
|
||||
onEnable() {
|
||||
let city:MapCityData = MapCommand.getInstance().cityProxy.getMyMainCity();
|
||||
UnionCommand.getInstance().unionInfo(city.unionId);
|
||||
this.updateRedDot()
|
||||
}
|
||||
updateRedDot(){
|
||||
let city:MapCityData = MapCommand.getInstance().cityProxy.getMyMainCity();
|
||||
let cnt = UnionCommand.getInstance().proxy.getApplyCnt(city.unionId);
|
||||
this.applyRedDot.active = cnt > 0;
|
||||
}
|
||||
onInfo(){
|
||||
let city:MapCityData = MapCommand.getInstance().cityProxy.getMyMainCity();
|
||||
let unionData:Union = UnionCommand.getInstance().proxy.getUnion(city.unionId);
|
||||
this.nameLab.string = "联盟:" + unionData.name;
|
||||
if (unionData.notice == ""){
|
||||
this.noticeLab.string = "暂无公告";
|
||||
}else{
|
||||
this.noticeLab.string = unionData.notice;
|
||||
}
|
||||
this.mengZhuLab.string = "盟主:" + unionData.getChairman().name
|
||||
this.editNode.active = false;
|
||||
|
||||
let ok = unionData.isMajor(city.rid);
|
||||
this.modifyBtn.node.active = ok;
|
||||
this.applyBtn.node.active = ok;
|
||||
}
|
||||
onUnionNotice(data){
|
||||
this.noticeLab.string = data.text;
|
||||
}
|
||||
onUnionApply(){
|
||||
this.updateRedDot();
|
||||
}
|
||||
onEditSubmit(){
|
||||
this.noticeLab.node.active = true;
|
||||
this.editNode.active = false;
|
||||
this.modifyBtn.node.active = true;
|
||||
|
||||
var str = this.editBox.string
|
||||
UnionCommand.getInstance().modNotice(str);
|
||||
}
|
||||
onModify(){
|
||||
this.noticeLab.node.active = false;
|
||||
this.editNode.active = true;
|
||||
this.modifyBtn.node.active = false;
|
||||
}
|
||||
onCancel(){
|
||||
this.noticeLab.node.active = true;
|
||||
this.editNode.active = false;
|
||||
this.modifyBtn.node.active = true;
|
||||
}
|
||||
}
|
||||
11
assets/scripts/union/UnionMainLogic.ts.meta
Normal file
11
assets/scripts/union/UnionMainLogic.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "2982e156-c21c-4c8b-a02d-71fec7e7d9ec",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
62
assets/scripts/union/UnionMemItemLogic.ts
Normal file
62
assets/scripts/union/UnionMemItemLogic.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
// // 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
|
||||
|
||||
import { _decorator, Component, Label } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
|
||||
import UnionCommand from "./UnionCommand";
|
||||
import { Member } from "./UnionProxy";
|
||||
import { EventMgr } from '../utils/EventMgr';
|
||||
|
||||
@ccclass('UnionMemItemLogic')
|
||||
export default class UnionMemItemLogic extends Component {
|
||||
|
||||
@property(Label)
|
||||
nameLabel: Label = null;
|
||||
|
||||
@property(Label)
|
||||
titleLabel: Label = null;
|
||||
|
||||
@property(Label)
|
||||
posLabel: Label = null;
|
||||
|
||||
protected _menberData:Member = null;
|
||||
|
||||
protected onLoad():void{
|
||||
}
|
||||
|
||||
protected updateItem(data:Member):void{
|
||||
this._menberData = data;
|
||||
this.titleLabel.string = "(" + this._menberData.titleDes + ")";
|
||||
this.nameLabel.string = this._menberData.name;
|
||||
this.posLabel.string = "坐标:(" + this._menberData.x + "," + this._menberData.y+")";
|
||||
}
|
||||
|
||||
protected click():void{
|
||||
EventMgr.emit("clickUnionMemberItem", this._menberData);
|
||||
}
|
||||
|
||||
protected kick():void{
|
||||
UnionCommand.getInstance().unionKick(this._menberData.rid);
|
||||
}
|
||||
|
||||
|
||||
protected appoint():void{
|
||||
UnionCommand.getInstance().unionKick(this._menberData.rid);
|
||||
}
|
||||
|
||||
protected abdicate():void{
|
||||
UnionCommand.getInstance().unionKick(this._menberData.rid);
|
||||
}
|
||||
|
||||
protected jump():void{
|
||||
EventMgr.emit("close_union");
|
||||
EventMgr.emit("scroll_to_map", this._menberData.x, this._menberData.y);
|
||||
}
|
||||
|
||||
}
|
||||
11
assets/scripts/union/UnionMemItemLogic.ts.meta
Normal file
11
assets/scripts/union/UnionMemItemLogic.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "b9d19f6b-1842-4a78-9864-7da2e1288027",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
98
assets/scripts/union/UnionMemberItemOpLogic.ts
Normal file
98
assets/scripts/union/UnionMemberItemOpLogic.ts
Normal file
@@ -0,0 +1,98 @@
|
||||
import { _decorator, Component, Button, Node } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
import { MapCityData } from "../map/MapCityProxy";
|
||||
import MapCommand from "../map/MapCommand";
|
||||
import UnionCommand from "./UnionCommand";
|
||||
import { Member, Union } from "./UnionProxy";
|
||||
|
||||
@ccclass('UnionMemberItemOpLogic')
|
||||
export default class UnionMemberItemOpLogic extends Component {
|
||||
|
||||
|
||||
@property(Button)
|
||||
kickButton: Button = null;
|
||||
|
||||
@property(Button)
|
||||
abdicateButton: Button = null;
|
||||
|
||||
@property(Button)
|
||||
appointButton: Button = null;
|
||||
|
||||
|
||||
@property(Button)
|
||||
unAppointButton: Button = null;
|
||||
|
||||
|
||||
protected _menberData:Member = null;
|
||||
|
||||
protected onLoad():void{
|
||||
this.node.on(Node.EventType.TOUCH_END, this.click, this);
|
||||
}
|
||||
|
||||
protected onDestroy():void{
|
||||
this.node.off(Node.EventType.TOUCH_END, this.click, this);
|
||||
}
|
||||
|
||||
protected click():void{
|
||||
this.node.active = false;
|
||||
}
|
||||
|
||||
public setData(data):void{
|
||||
this._menberData = data;
|
||||
let city:MapCityData = MapCommand.getInstance().cityProxy.getMyMainCity();
|
||||
let unionData:Union = UnionCommand.getInstance().proxy.getUnion(city.unionId);
|
||||
if (unionData){
|
||||
if(this._menberData.rid == city.rid){
|
||||
this.node.active = false;
|
||||
}else{
|
||||
if(unionData.getChairman().rid == city.rid){
|
||||
console.log("unionData:", unionData, unionData.getViceChairman(), this._menberData);
|
||||
|
||||
this.unAppointButton.node.active = unionData.getViceChairman().rid == this._menberData.rid;
|
||||
this.kickButton.node.active = unionData.isMajor(city.rid);
|
||||
this.abdicateButton.node.active = unionData.getChairman().rid == city.rid;
|
||||
this.appointButton.node.active = unionData.getChairman().rid == city.rid && unionData.getViceChairman().rid != this._menberData.rid;
|
||||
}else if(unionData.getViceChairman().rid == city.rid){
|
||||
if(unionData.getChairman().rid == this._menberData.rid){
|
||||
this.node.active = false;
|
||||
}else{
|
||||
this.unAppointButton.node.active = false;
|
||||
this.kickButton.node.active = true;
|
||||
this.abdicateButton.node.active = unionData.getViceChairman().rid != this._menberData.rid;
|
||||
this.appointButton.node.active = false;
|
||||
this.node.active = true;
|
||||
}
|
||||
}else{
|
||||
this.node.active = false;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
this.node.active = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected kick():void{
|
||||
UnionCommand.getInstance().unionKick(this._menberData.rid);
|
||||
this.node.active = false;
|
||||
}
|
||||
|
||||
|
||||
protected appoint():void{
|
||||
UnionCommand.getInstance().unionAppoint(this._menberData.rid, 1);
|
||||
this.node.active = false;
|
||||
}
|
||||
|
||||
protected unAppoint():void{
|
||||
UnionCommand.getInstance().unionAppoint(this._menberData.rid, 2);
|
||||
this.node.active = false;
|
||||
}
|
||||
|
||||
protected abdicate():void{
|
||||
UnionCommand.getInstance().unionAbdicate(this._menberData.rid);
|
||||
this.node.active = false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
11
assets/scripts/union/UnionMemberItemOpLogic.ts.meta
Normal file
11
assets/scripts/union/UnionMemberItemOpLogic.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "5c2166f4-f998-4549-8561-cdb80d6eb51f",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
104
assets/scripts/union/UnionMemberLogic.ts
Normal file
104
assets/scripts/union/UnionMemberLogic.ts
Normal file
@@ -0,0 +1,104 @@
|
||||
import { _decorator, Component, ScrollView, Node, instantiate } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
import UnionCommand from "./UnionCommand";
|
||||
import { Member, Union } from "./UnionProxy";
|
||||
import { MapCityData } from "../map/MapCityProxy";
|
||||
import MapCommand from "../map/MapCommand";
|
||||
import UnionMemberItemOpLogic from "./UnionMemberItemOpLogic";
|
||||
import { EventMgr } from '../utils/EventMgr';
|
||||
|
||||
@ccclass('UnionMemberLogic')
|
||||
export default class UnionMemberLogic extends Component {
|
||||
|
||||
@property(ScrollView)
|
||||
memberView:ScrollView = null;
|
||||
|
||||
@property(Node)
|
||||
disMissButton: Node = null;
|
||||
|
||||
@property(Node)
|
||||
exitButton: Node = null;
|
||||
|
||||
@property(Node)
|
||||
opNode: Node = null;
|
||||
|
||||
protected _op: Node = null;
|
||||
|
||||
protected onLoad():void{
|
||||
|
||||
EventMgr.on("update_union_member",this.updateMember,this);
|
||||
EventMgr.on("kick_union_success",this.getMember,this);
|
||||
EventMgr.on("union_appoint",this.getMember,this);
|
||||
EventMgr.on("union_abdicate",this.getMember,this);
|
||||
EventMgr.on("clickUnionMemberItem",this.onClickItem,this);
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected onDestroy():void{
|
||||
EventMgr.targetOff(this);
|
||||
}
|
||||
|
||||
protected click():void{
|
||||
if(this._op != null){
|
||||
this._op.active = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected onClickItem(menberData):void{
|
||||
if (this._op == null){
|
||||
var node = instantiate(this.opNode);
|
||||
node.parent = this.node;
|
||||
this._op = node;
|
||||
}
|
||||
this._op.active = true;
|
||||
this._op.getComponent(UnionMemberItemOpLogic).setData(menberData);
|
||||
}
|
||||
|
||||
protected updateMember(data:any[]){
|
||||
|
||||
let city:MapCityData = MapCommand.getInstance().cityProxy.getMyMainCity();
|
||||
let unionData:Union = UnionCommand.getInstance().proxy.getUnion(city.unionId);
|
||||
|
||||
var comp = this.memberView.node.getComponent("ListLogic");
|
||||
var list:Member[] = UnionCommand.getInstance().proxy.getMemberList(unionData.id).concat();
|
||||
|
||||
comp.setData(list);
|
||||
|
||||
this.updateBtn();
|
||||
}
|
||||
|
||||
protected updateBtn(){
|
||||
let city:MapCityData = MapCommand.getInstance().cityProxy.getMyMainCity();
|
||||
let unionData:Union = UnionCommand.getInstance().proxy.getUnion(city.unionId);
|
||||
if(unionData.getChairman().rid == city.rid){
|
||||
this.exitButton.active = false;
|
||||
this.disMissButton.active = true;
|
||||
}else{
|
||||
this.exitButton.active = true;
|
||||
this.disMissButton.active = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected getMember():void{
|
||||
let city:MapCityData = MapCommand.getInstance().cityProxy.getMyMainCity();
|
||||
let unionData:Union = UnionCommand.getInstance().proxy.getUnion(city.unionId);
|
||||
UnionCommand.getInstance().unionMember(unionData.id);
|
||||
}
|
||||
|
||||
protected onEnable():void{
|
||||
this.updateBtn();
|
||||
this.getMember();
|
||||
}
|
||||
|
||||
protected dismiss():void{
|
||||
UnionCommand.getInstance().unionDismiss();
|
||||
}
|
||||
|
||||
protected exit():void{
|
||||
UnionCommand.getInstance().unionExit();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
11
assets/scripts/union/UnionMemberLogic.ts.meta
Normal file
11
assets/scripts/union/UnionMemberLogic.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "405903f7-bcdf-405b-9e92-43537cc15bb7",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
207
assets/scripts/union/UnionProxy.ts
Normal file
207
assets/scripts/union/UnionProxy.ts
Normal file
@@ -0,0 +1,207 @@
|
||||
import { _decorator } from 'cc';
|
||||
import LoginCommand from "../login/LoginCommand";
|
||||
import { Role } from "../login/LoginProxy";
|
||||
import { MapCityData } from "../map/MapCityProxy";
|
||||
import MapCommand from "../map/MapCommand";
|
||||
|
||||
export class Apply {
|
||||
id: number = 0;
|
||||
rid: number = 0;
|
||||
nick_name: string = "";
|
||||
}
|
||||
|
||||
|
||||
export class Member {
|
||||
rid: number = 0;
|
||||
name: string = "";
|
||||
title: number = 0;
|
||||
public get titleDes() : string {
|
||||
if(this.title == 0){
|
||||
return "盟主";
|
||||
}
|
||||
|
||||
if(this.title == 1){
|
||||
return "副盟主";
|
||||
}
|
||||
|
||||
return "普通成员"
|
||||
}
|
||||
x:number = 0;
|
||||
y:number = 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
export class Union {
|
||||
id:number = 0;
|
||||
name: string = "";
|
||||
cnt: number = 0;
|
||||
notice: string = "";
|
||||
major:Member[] = [];
|
||||
|
||||
|
||||
public getChairman():Member{
|
||||
var major:Member[] = this.major.concat();
|
||||
for(var i = 0;i < major.length;i++){
|
||||
if(major[i].title == 0){
|
||||
return major[i];
|
||||
}
|
||||
}
|
||||
return new Member()
|
||||
}
|
||||
|
||||
public getViceChairman():Member{
|
||||
var major:Member[] = this.major.concat();
|
||||
for(var i = 0;i < major.length;i++){
|
||||
if(major[i].title == 1){
|
||||
return major[i];
|
||||
}
|
||||
}
|
||||
return new Member()
|
||||
}
|
||||
|
||||
public isMajor(rid:number):boolean{
|
||||
var major:Member[] = this.major.concat();
|
||||
for(var i = 0;i < major.length;i++){
|
||||
if(major[i].rid == rid){
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export default class UnionProxy {
|
||||
|
||||
private _unionMap:Map<number,Union> = new Map<number,Union>();
|
||||
private _menberMap:Map<number,Member[]> = new Map<number,Member[]>();
|
||||
private _applyMap:Map<number,Apply[]> = new Map<number,Apply[]>();
|
||||
|
||||
public clearData(): void {
|
||||
this._unionMap.clear();
|
||||
this._menberMap.clear();
|
||||
}
|
||||
|
||||
public updateUnionList(data:any[]):void{
|
||||
this._unionMap.clear();
|
||||
for(var i = 0; i < data.length ;i++){
|
||||
var obj = this.createUnion(data[i]);
|
||||
this._unionMap.set(obj.id,obj);
|
||||
}
|
||||
}
|
||||
|
||||
protected createUnion(data:any):Union{
|
||||
var obj = new Union();
|
||||
obj.id = data.id;
|
||||
obj.name = data.name;
|
||||
obj.cnt = data.cnt;
|
||||
obj.notice = data.notice;
|
||||
obj.major = data.major.concat();
|
||||
return obj
|
||||
}
|
||||
|
||||
protected createMember(data:any):Member{
|
||||
var obj = new Member();
|
||||
obj.rid = data.rid;
|
||||
obj.name = data.name;
|
||||
obj.title = data.title;
|
||||
obj.x = data.x;
|
||||
obj.y = data.y;
|
||||
return obj
|
||||
}
|
||||
|
||||
|
||||
public getUnionList():Union[]{
|
||||
return Array.from(this._unionMap.values());
|
||||
}
|
||||
|
||||
|
||||
public updateMemberList(id:number,data:any[]):void{
|
||||
var member:Member[] = [];
|
||||
var union = this._unionMap.get(id);
|
||||
if(union != null){
|
||||
union.major = []
|
||||
}
|
||||
for(var i = 0; i < data.length ;i++){
|
||||
var obj = this.createMember(data[i]);
|
||||
member.push(obj);
|
||||
|
||||
if(obj.title == 0 || obj.title == 1){
|
||||
union.major.push(obj)
|
||||
}
|
||||
}
|
||||
this._menberMap.set(id,member);
|
||||
}
|
||||
|
||||
public updateNotice(unionid:number,text:string):void{
|
||||
let union:Union = this._unionMap.get(unionid);
|
||||
if(union){
|
||||
union.notice = text
|
||||
}
|
||||
}
|
||||
|
||||
public updateApplyList(id:number,data:any[]):void{
|
||||
var apply:Apply[] = [];
|
||||
for(var i = 0; i < data.length ;i++){
|
||||
var obj = data[i]
|
||||
apply.push(obj);
|
||||
}
|
||||
this._applyMap.set(id,apply);
|
||||
}
|
||||
|
||||
public updateApply(id:number,data:any):void{
|
||||
var apply = this._applyMap.get(id);
|
||||
if (apply != null) {
|
||||
apply.push(data)
|
||||
this._applyMap.set(id, apply)
|
||||
}else{
|
||||
var t = []
|
||||
t.push(data)
|
||||
this.updateApplyList(id, t)
|
||||
}
|
||||
}
|
||||
|
||||
public isChairman(unionid:number,rid:number):boolean{
|
||||
let union:Union = this._unionMap.get(unionid);
|
||||
if(!union){
|
||||
return false;
|
||||
}
|
||||
|
||||
var major:Member[] = union.major.concat();
|
||||
for(var i = 0;i < major.length;i++){
|
||||
if(major[i].rid == rid && major[i].title == 0){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public isMeInUnion():boolean{
|
||||
let city:MapCityData = MapCommand.getInstance().cityProxy.getMyMainCity();
|
||||
return city.unionId > 0?true:false;
|
||||
}
|
||||
|
||||
public isMeChairman(unionid:number):boolean{
|
||||
var roleData:Role = LoginCommand.getInstance().proxy.getRoleData();
|
||||
return this.isChairman(unionid,roleData.rid);
|
||||
}
|
||||
|
||||
public getMemberList(id:number):Member[]{
|
||||
return this._menberMap.get(id);
|
||||
}
|
||||
|
||||
public getUnion(id:number = 0):Union{
|
||||
return this._unionMap.get(id);
|
||||
}
|
||||
|
||||
public getApplyCnt(id:number = 0):number{
|
||||
let t = this._applyMap.get(id);
|
||||
if (t == null){
|
||||
return 0
|
||||
}
|
||||
console.log("getApplyCnt:", t)
|
||||
return t.length
|
||||
}
|
||||
}
|
||||
11
assets/scripts/union/UnionProxy.ts.meta
Normal file
11
assets/scripts/union/UnionProxy.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "70e678d4-36c4-4011-9c66-41108fa711e6",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user