3prt游戏
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

156 lines
6.1 KiB

import { Component } from "cc";
import { Message, Sleep, UILayerIndex, UIManager } from "../../sdk/API";
import { TeenPattieEventType } from "../../tool/TeenPattieEventType";
import { TeenPattieCommData } from "../TeenPattieCommData";
import { TeenPattiePlayerLogic } from "./TeenPattiePlayerLogic";
import { TeenPattieSeeCardsLogic } from "./TeenPattieSeeCardsLogic";
import { GamePanelConst } from "../../GameConst10001";
import { TeenPattieGameStaticSystem } from "../system/TeenPattieGameStaticSystem";
import { Game10001Res } from "../../comm/Game10001Res";
/**pk数据结果 */
export class TeenPattiePkCardsLogic extends Component {
private pkData: any;
private player: TeenPattiePlayerLogic;
/**看牌数据结果 */
seeCards: TeenPattieSeeCardsLogic;
/**符合输家的信息 */
private lostId: TeenPattiePlayerLogic[] = [];
/**符合赢家的信息 */
private winId: TeenPattiePlayerLogic[] = [];
onLoad(): void {
this.seeCards = this.node?.getComponent(TeenPattieSeeCardsLogic);
Message.add(TeenPattieEventType.PkCardEnd, this.showLostStatus, this);
}
onDestroy(): void {
Message.remove(TeenPattieEventType.PkCardEnd, this.showLostStatus, this);
}
/**比牌结果 */
result(value: any, ow: TeenPattiePlayerLogic) {
this.pkData = value;
this.player = ow;
const allCards = TeenPattieCommData.getInstance().allKanPlayerCard;
const allQi = TeenPattieCommData.getInstance().allQipaiData || [];
const lostId = value.loseSeatId;
if (lostId == ow.data?.SeatId) {
ow.clearTimer();
this.lostId.push(ow);
}
const winId = value.winSeatId;
if (winId == ow.data?.SeatId){
this.winId.push(ow);
}
const id = value.loseSeatId;
if (id == ow.data?.SeatId) {
let ind = allQi.indexOf(id);
if (ind < 0) {
TeenPattieCommData.getInstance()._allQipaiData.push(id);
}
}
if (!value || (value.winSeatId == 0) || !value.loseSeatId) return;
const allPlayerData = TeenPattieCommData.getInstance().allPlayerData || [];
for (let i = 0; i < allPlayerData.length; i++) {
if (allPlayerData[i].SeatId == value.winSeatId) {
TeenPattieCommData.getInstance()._playerData = allPlayerData[i];
}
if (allPlayerData[i].SeatId == value.loseSeatId) {
TeenPattieCommData.getInstance()._beiPlayerData = allPlayerData[i];
if(allPlayerData[i].SeatId == ow.playerSeatId){
TeenPattieCommData.getInstance().isGame = false;
}
}
}
//赢家和输家牌的数据
for(let i = 0;i<allCards.length;i++){
if(allCards[i].SeatId == value.winSeatId){
TeenPattieCommData.getInstance()._bipaiPlayerCardData = allCards[i];
}else if(allCards[i].SeatId == value.loseSeatId){
TeenPattieCommData.getInstance()._beiBipaiPlayerCardData = allCards[i];
}
}
//没有玩家自己
// if (value.winSeatId != ow.playerSeatId && value.loseSeatId != ow.playerSeatId) {
// this.noSelfShowLostStatus();
// return;
// }
if (UIManager.getInstance().getCur() == GamePanelConst.Game_Pk_Panel_TeenPattie) return;
// if(ow.data?.SeatId == ow.playerSeatId && (value.winSeatId == ow.playerSeatId || value.loseSeatId == ow.playerSeatId)){
if(ow.data?.SeatId == value.winSeatId){
console.log("****开始比牌*****");
UIManager.getInstance().show(`10001`, GamePanelConst.Game_Pk_Panel_TeenPattie, UILayerIndex.TopLayer, null, false);
}
}
/**其他人比牌时显示输家 */
private async noSelfShowLostStatus(){
await Sleep(2000);
this.showLostStatus();
}
/**比牌结束后显示赢家输家 */
private showLostStatus() {
if (!this.pkData || !this.player) return;
TeenPattieGameStaticSystem.showEffect.hideBiPaiLigature();
const lostId = this.pkData.loseSeatId;
const winId = this.pkData.winSeatId;
for (let l = 0; l < this.lostId.length; l++) {
if (lostId == this.lostId[l].data?.SeatId) {
const player = this.lostId[l];
player.kanpaiLabel.string = Game10001Res.getInstance()?.getString(`game.tip.transport`);
if (player.headImg.isValid) player.headImg.grayscale = true;
if (player.headFrame.isValid) player.headFrame.grayscale = true;
if (player.seeBtn.isValid) player.seeBtn.node.active = false;
if (player.kanpaiLabel.isValid) player.kanpaiLabel.node.active = false;
// if (player.seen.isValid) player.seen.active = false;
if (player.seeBtn.isValid) player.pack.active = true;
}
}
for (let w=0;w<this.winId.length;w++){
if(TeenPattieCommData.getInstance().isForceCard) continue;
if (winId == this.winId[w].data?.SeatId){
const player = this.winId[w];
if (player.pic_winner) player.pic_winner.active = true;
let tid = setTimeout(() => {
clearTimeout(tid);
tid = null;
if (player.pic_winner) player.pic_winner.active = false;
}, 800);
}
}
this.winId = [];
this.lostId = [];
}
/**强制比牌结果 将牌亮出来 */
public ForceCompareResult(ow: TeenPattiePlayerLogic){
TeenPattieCommData.getInstance().isForceCard = true;
if (ow.seeBtn.isValid) ow.seeBtn.node.active = false;
const value = TeenPattieCommData.getInstance().allKanPlayerCard;
const qiPai = TeenPattieCommData.getInstance().allQipaiData;
for(let i=0;i<value.length;i++){
if(value[i].SeatId == ow.data?.SeatId){
const q = qiPai.indexOf(value[i].SeatId)
if(q < 0){
this.seeCards.selfSeeCards(value,ow,true);
}
}
}
}
}