public virtual void InitReference(IServiceContainer serviceContainer, IManagerContainer mgrContainer)
 {
     _serviceContainer = serviceContainer;
     //通用Service
     _ecsFacadeService     = serviceContainer.GetService <IECSFacadeService>();
     _randomService        = serviceContainer.GetService <IRandomService>();
     _timeMachineService   = serviceContainer.GetService <ITimeMachineService>();
     _constStateService    = serviceContainer.GetService <IConstStateService>();
     _inputService         = serviceContainer.GetService <IInputService>();
     _viewService          = serviceContainer.GetService <IViewService>();
     _audioService         = serviceContainer.GetService <IAudioService>();
     _map2DService         = serviceContainer.GetService <IMap2DService>();
     _resService           = serviceContainer.GetService <IResService>();
     _effectService        = serviceContainer.GetService <IEffectService>();
     _eventRegisterService = serviceContainer.GetService <IEventRegisterService>();
 }
 public virtual void InitReference(IServiceContainer serviceContainer, IManagerContainer mgrContainer = null)
 {
     this._serviceContainer     = serviceContainer;
     this._ecsFactoryService    = serviceContainer.GetService <IECSFactoryService>();
     this._randomService        = serviceContainer.GetService <IRandomService>();
     this._timeMachineService   = serviceContainer.GetService <ITimeMachineService>();
     this._globalStateService   = serviceContainer.GetService <IGlobalStateService>();
     this._inputService         = serviceContainer.GetService <IInputService>();
     this._viewService          = serviceContainer.GetService <IViewService>();
     this._audioService         = serviceContainer.GetService <IAudioService>();
     this._map2DService         = serviceContainer.GetService <IMap2DService>();
     this._resService           = serviceContainer.GetService <IResService>();
     this._effectService        = serviceContainer.GetService <IEffectService>();
     this._eventRegisterService = serviceContainer.GetService <IEventRegisterService>();
     this._idService            = serviceContainer.GetService <IIdService>();
     this._debugService         = serviceContainer.GetService <IDebugService>();
 }
Beispiel #3
0
 protected override void OnInit(BaseContext context, IServiceContainer services)
 {
     _context = (Context)context;
     //BuildInServices
     _randomService        = services.GetService <IRandomService>();
     _timeMachineService   = services.GetService <ITimeMachineService>();
     _globalStateService   = services.GetService <IGlobalStateService>();
     _viewService          = services.GetService <IViewService>();
     _audioService         = services.GetService <IAudioService>();
     _inputService         = services.GetService <IInputService>();
     _map2DService         = services.GetService <IMap2DService>();
     _resService           = services.GetService <IResService>();
     _effectService        = services.GetService <IEffectService>();
     _eventRegisterService = services.GetService <IEventRegisterService>();
     _idService            = services.GetService <IIdService>();
     _debugService         = services.GetService <IDebugService>();
     //GameServices
     _gameStateService  = services.GetService <IGameStateService>();
     _gameConfigService = services.GetService <IGameConfigService>();
     _gameEventService  = services.GetService <IGameEventService>();
 }
        public static void CheckBulletWithMap(LVector2Int iPos, GameEntity entity, IGameAudioService audioService, IMap2DService map2DService)
        {
            var unit   = entity.unit;
            var bullet = entity.bullet;
            var id     = map2DService.Pos2TileId(iPos, false);

            if (id != 0 && unit.health > 0)
            {
                //collide bullet with world
                if (id == TilemapUtil.TileID_Brick)
                {
                    if (unit.camp == ECampType.Player)
                    {
                        audioService.PlayClipHitBrick();
                    }

                    map2DService.ReplaceTile(iPos, id, 0);
                    unit.health--;
                }
                else if (id == TilemapUtil.TileID_Iron)
                {
                    if (!bullet.canDestoryIron)
                    {
                        if (unit.camp == ECampType.Player)
                        {
                            audioService.PlayClipHitIron();
                        }

                        unit.health = 0;
                    }
                    else
                    {
                        if (unit.camp == ECampType.Player)
                        {
                            audioService.PlayClipDestroyIron();
                        }

                        unit.health = LMath.Max(unit.health - 2, 0);
                        map2DService.ReplaceTile(iPos, id, 0);
                    }
                }
                else if (id == TilemapUtil.TileID_Grass)
                {
                    if (bullet.canDestoryGrass)
                    {
                        if (unit.camp == ECampType.Player)
                        {
                            audioService.PlayClipDestroyGrass();
                        }

                        unit.health -= 0;
                        map2DService.ReplaceTile(iPos, id, 0);
                    }
                }
                else if (id == TilemapUtil.TileID_Wall)
                {
                    unit.health = 0;
                }
            }
        }