description import { GameData } from "../../../../script/common/base/GameData" ; import { TANK_LAN_ZH } from "./TankBattleLanguageZH" ; import { TANK_LAN_EN } from "./TankBattleLanguageEN" ; import { i18n } from "../../../../script/common/language/LanguageImpl" ; import { MapLevel } from "./TankBattleLevel" ; import { Manager } from "../../../../script/common/manager/Manager" ; import TankBattleNetController from "../controller/TankBattleNetController" ; import TankBattleMap from "../model/TankBattleMap" ; import TankBattleGameView from "../view/TankBattleGameView" ; export namespace TankBettle { export enum Direction { MIN = 0 , UP = MIN , DOWN , LEFT , RIGHT , MAX = RIGHT } description export const MAX_ENEMY = 20 ; description export const MAX_APPEAR_ENEMY = 5 ; description export const MAX_PLAYER_LIVE = 3 ; export enum GAME_STATUS { description UNKNOWN , description SELECTED , description INIT , description GAME , description OVER , description WIN } export enum BLOCK_TYPE { description WALL = 1 , description STONE_WALL , description GRASS , description WATER , description ICE , description HOME = 9 , description ANOTHREHOME = 8 } export enum GROUP { Wall = "Wall" , StoneWall = "StoneWall" , Grass = "Grass" , Water = "Water" , Ice = "Ice" , Home = "Home" , Bullet = "Bullet" , Player = "Player" , description Boundary = "Boundary" , Props = "Props" } export enum EVENT { description SHOW_MAP_LEVEL = "SHOW_MAP_LEVEL" , description CHANGE_STAGE_FINISHED = "CHANGE_STAGE_FINISHED" , description REQ_LEVEL = "REQ_LEVEL" } export function netController ( ) { return Manager . gameController ; } description export enum PLAYER_STATUS { STRONG , PROTECTED } description export const PLAYER_STATUS_EXIST_TIME = 5 ; export enum ZIndex { TANK , BULLET , BLOCK , PROPS } export enum EnemyType { MIN , description NORMAL = MIN , description SPEED , description STRONG , MAX = STRONG } export class TankConfig { description distance = 5 ; description time = 0.1 ; description bulletDistance = 10 ; description bulletTime = 0.1 ; description live = 1 ; description shootInterval = { min : 2 , max : 5 } ; } description export enum EnemyBornPosition { MIN , LEFT = MIN , MIDDLE , RIGHT , MAX = RIGHT } description export enum PropsType { MIN , description LIVE = MIN , description TIME , description STRONG_BULLET , description BOOM_ALL_ENEMY , description STRONG_MY_SELF , description GOD , MAX } description export const PROPS_DISAPPEAR = 10 ; description export const PROPS_CREATE_INTERVAL = { min : 10 , max : 20 } ; class TankBettleGameData extends GameData { addGameTime ( ) { } onLanguageChange ( ) { let lan = TANK_LAN_ZH ; if ( Manager . language . getLanguage ( ) == TANK_LAN_EN . language ) { lan = TANK_LAN_EN ; } i18n [ `${ this . bundle }` ] = { } ; i18n [ `${ this . bundle }` ] = lan . data ; } description public get bulletPrefab ( ) { return this . gamePrefabs . getChildByName ( "bullet" ) ; } public get bundle ( ) { return "tankBattle" ; } description public gameMap : TankBattleMap = null ; description public gamePrefabs : cc . Node = null ; description public get animationPrefab ( ) { return this . gamePrefabs . getChildByName ( "tank_animations" ) ; } description public getPlayerPrefab ( isOne ) { if ( isOne ) { return this . gamePrefabs . getChildByName ( "player_1" ) ; } else { return this . gamePrefabs . getChildByName ( "player_2" ) ; } } description public getEnemyPrefab ( type ) { return this . gamePrefabs . getChildByName ( `tank_${ type }` ) ; } description public getPropsPrefab ( type ) { return this . gamePrefabs . getChildByName ( `item_${ type }` ) ; } public nextLevel ( ) { let level = this . currentLevel + 1 ; if ( level >= MapLevel . length ) { level = 0 ; } this . curLeftEnemy = TankBettle . MAX_ENEMY ; this . currentLevel = level ; return level ; } public prevLevel ( ) { let level = this . currentLevel - 1 ; if ( level < 0 ) { level = MapLevel . length - 1 ; } this . currentLevel = level ; this . curLeftEnemy = TankBettle . MAX_ENEMY ; return level ; } private _isSingle = true ; description public set isSingle ( value ) { this . _isSingle = value ; if ( value ) { this . playerOneLive = MAX_PLAYER_LIVE ; this . playerTwoLive = 0 ; } else { this . playerOneLive = MAX_PLAYER_LIVE ; this . playerTwoLive = MAX_PLAYER_LIVE ; } this . curLeftEnemy = MAX_ENEMY ; } public get isSingle ( ) { return this . _isSingle ; } private _gameStatus : GAME_STATUS = GAME_STATUS . UNKNOWN ; description public set gameStatus ( status ) { cc . log ( `gamestatus : ${ this . _gameStatus } => ${ status }` ) ; this . _gameStatus = status ; } public get gameStatus ( ) { return this . _gameStatus ; } public get gameView ( ) : TankBattleGameView { return Manager . gameView as TankBattleGameView ; } public isNeedReducePlayerLive = true ; public reducePlayerLive ( isOne ) { if ( this . isNeedReducePlayerLive ) { if ( isOne ) { this . playerOneLive -- ; } else { this . playerTwoLive -- ; } } } public addPlayerLive ( isOne ) { if ( isOne ) { this . playerOneLive ++ ; } else { this . playerTwoLive ++ ; } this . gameView . showGameInfo ( ) ; } public clear ( ) { super . clear ( ) ; this . _isSingle = true ; this . currentLevel = 0 ; this . playerOneLive = 0 ; this . playerTwoLive = 0 ; this . curLeftEnemy = 0 ; } getEnemyConfig ( type ) { let config = new TankConfig ( ) ; if ( type == EnemyType . STRONG ) { config . live = 3 ; } else if ( type == EnemyType . SPEED ) { config . distance *= 2 ; } return config ; } get playerConfig ( ) { let config = new TankConfig ( ) ; config . time = 0.05 ; return config ; } description currentLevel = 0 ; description curLeftEnemy = 0 ; description playerOneLive = 0 ; description playerTwoLive = 0 ; } export const gameData = new TankBettleGameData ; }