| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- import { JCEntity } from "./JCEngine";
- import Fruit from "./Fruit";
- import WebView from "./WebView";
- const {ccclass, property} = cc._decorator;
- @ccclass
- export default class Player extends JCEntity {
- onLoad(){
- window.player = this;
- window.appGame.initGame();
- }
- matchSuccess(playerInfo:any, modeInfo:ModeInfo){
- window.gc.modeInfo = modeInfo;
- if(playerInfo.index == 0){
- window.myPlayerInfo.index = 1;
- }else{
- window.myPlayerInfo.index = 0;
- }
- window.otherPlayerInfo = {
- index: playerInfo.index,
- nickName: undefined,
- gender: undefined,
- avatar: null
- }
-
- if (playerInfo.nickName == "none" && playerInfo.gender == 0 && playerInfo.avatarUrl == "none") {
- window.appGame.getAiInfo();
- } else {
- this.matchSuccessHandle(playerInfo);
- }
- }
- matchSuccessHandle(playerInfo:any) {
- window.otherPlayerInfo.nickName = playerInfo.nickName;
- window.otherPlayerInfo.gender = playerInfo.gender;
- WebView.loadSpriteFrame(playerInfo.avatarUrl, (spriteFrame: cc.SpriteFrame) => {
- window.otherPlayerInfo.avatar = spriteFrame;
- window.matchPanel.renderOtherInfo(
- window.otherPlayerInfo.nickName,
- window.otherPlayerInfo.gender,
- window.otherPlayerInfo.avatar
- );
- });
- }
- updateBirdPosition(x:number,y:number){
- window.gm.birds[window.otherPlayerInfo.index].node.setPosition(x,y);
- }
- flyUp(x:number,y:number,hitPower:number){
- window.gm.birds[window.otherPlayerInfo.index].node.setPosition(x,y);
- window.gm.birds[window.otherPlayerInfo.index].flyUp(hitPower);
- }
- quicken(strength:number){
- window.gm.birds[window.otherPlayerInfo.index].quicken(strength);
- }
- gameOver(index:number){
- window.gm.gameOver(index);
- }
- updateTime(time:number){
- window.topBar.updateTime(time);
- }
- eatFruit(fruitIndex){
- let args = window.gc.fruitNodes[fruitIndex].getComponent(Fruit).eat();
- if(window.fruitGroove.fruitCount<3){
- window.fruitGroove.addFruit.apply(window.fruitGroove,args);
- }
- }
- fruitEaten(fruitIndex){
- try {
- window.gc.fruitNodes[fruitIndex].getComponent(Fruit).eat();
- } catch {}
- }
- setAI() {
- window.gm.birds[window.otherPlayerInfo.index].setAI();
- }
- }
|