1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- import { _decorator, Component, Node, SkeletalAnimationComponent, AnimationComponent, Vec3, director, find, instantiate } from 'cc';
- import { WeaponBase } from './weapons/WeaponBase';
- import { GameModel } from '../../models/GameModel';
- import { EventDispatcher } from '../../../engines/events/EventDispatcher';
- const { ccclass, property } = _decorator;
- export class GameController extends EventDispatcher{
- public weapon:WeaponBase;
- constructor()
- {
- super();
- }
- /**
- * 初始化
- * @param leftHand
- * @param rightHand
- */
- Init(leftHand:AnimationComponent,rightHand:AnimationComponent):void{
- this.weapon=new WeaponBase(leftHand,rightHand);
- this.StartGame();
- }
- /**
- * 开始游戏
- */
- StartGame():void{
- //直接重置子弹数量
- this.weapon.bulletCount=GameModel.single.currentWeaponConfig.clip;
- }
- TryFire(fireKey:number):void{
- if(fireKey==0){
- this.weapon.StopFire();
- }else{
- this.weapon.StartFire(fireKey);
- }
-
- }
- Update(dt:number):void{
- this.weapon.Update(dt);
- }
- private static instance:GameController;
- public static get single(){
- if(this.instance==null){
- this.instance=new GameController();
- }
- return this.instance;
- }
- }
|