1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- import dungeonLogic from "./dungeonLogic";
- import LevelLogic from "./levelLogic";
- import gameData from "./utrl/gameData";
- import { ATTACK_MODE, EVENT_TYPE } from "./utrl/gameEnum";
- import gameEventManager from "./utrl/gameEventManager";
- const { ccclass, property } = cc._decorator;
- /**游戏主逻辑 */
- @ccclass
- export default class GameLogic extends cc.Component {
- @property(cc.Node)
- /**摄像机节点 */
- camera: cc.Node = null;
- @property(cc.Prefab)
- /**玩家预制体 */
- player_pre: cc.Prefab = null;
- @property(cc.Prefab)
- /**僵尸预制体 */
- zombie_pre: cc.Prefab = null;
- /**子弹预制体 */
- @property(cc.Prefab)
- bullet_pre: cc.Prefab = null;
- /**迷你地图节点 */
- @property(cc.Node)
- mini_map: cc.Node = null;
- /**当前关卡逻辑 */
- private level_logic: LevelLogic = null;
- /**当前副本逻辑 */
- private dungeon_logic: dungeonLogic = null;
- onLoad() {
- let pm = cc.director.getPhysicsManager();
- pm.enabled = true;
- }
- /**初始化 */
- init(level: cc.Node,isNew = false) {
- this.level_logic = level.getComponent(LevelLogic);
- this.level_logic.setMiniMap(this.mini_map);
- this.level_logic.init(this.camera, this.player_pre, this.zombie_pre, this.bullet_pre,isNew);
- }
- //副本初始化
- dungeonInit(dungeon: cc.Node) {
- this.dungeon_logic = dungeon.getComponent(dungeonLogic);
- this.dungeon_logic.init(this.camera, this.player_pre, this.zombie_pre, this.bullet_pre);
- }
- /**切换攻击模式 */
- switchAttackMode() {
- if (gameData.cur_attack_mode == ATTACK_MODE.close) {
- gameData.cur_attack_mode = ATTACK_MODE.remote;
- }
- else {
- gameData.cur_attack_mode = ATTACK_MODE.close;
- }
- gameEventManager.emit(EVENT_TYPE.attack_mode);
- }
- }
|