public GoatSpawnController(LevelComponent levelComponent, LevelSettingsScriptableObject settings)
        {
            _levelComponent = levelComponent;
            _settings       = settings;

            _random       = new System.Random();
            _spawnPoints  = settings.GoatSpownPoints;
            _activeSpawns = new List <SpawnComponent>();
        }
Exemplo n.º 2
0
        public SpawnController(LevelComponent levelComponent, LevelSettingsScriptableObject settings)
        {
            _levelComponent = levelComponent;
            _settings       = settings;

            _ballonHitClip = Resources.Load <AudioClip>("Audio/balloonhit");

            _random       = new System.Random();
            _spawnPoints  = new List <Vector3>();
            _activeSpawns = new List <ActiveSpawn>();
            _factories    = new List <PoolFactory <SpawnComponent> >();

            foreach (var component in settings.SpawnComponents)
            {
                var factory = new PoolFactory <SpawnComponent>(() => GameObject.Instantiate <SpawnComponent>(component));
                _factories.Add(factory);
            }
        }
Exemplo n.º 3
0
 private void ProcessMouse()
 {
     if (EventSystem.current.IsPointerOverGameObject())
     {
         return;
     }
     if (Input.GetMouseButtonUp(0))
     {
         if (Time.time - touchTime <= clickTime)
         {
             _onShoot.Fire();
         }
         _currentPower       = 0;
         _horizontalDelta    = 0;
         _startTouchPosition = Vector2.zero;
         _mousePressed       = false;
         _onTouchProcess.Fire(TouchPhase.Ended, 0);
         return;
     }
     if (Input.GetMouseButtonDown(0) && !_mousePressed)
     {
         _startTouchPosition = Input.mousePosition;
         _mousePressed       = true;
         touchTime           = Time.time;
         _onTouchProcess.Fire(TouchPhase.Began, 0);
     }
     else if (Input.GetMouseButton(0) && _mousePressed)
     {
         settings            = GameContext.LevelController.Current.Settings;
         _currentPower       = _startTouchPosition.y - Input.mousePosition.y;
         _horizontalDelta    = (Input.mousePosition.x - _startTouchPosition.x) / Screen.dpi * settings.ScreenDragCoeff;
         _startTouchPosition = Input.mousePosition;
         _onTouchProcess.Fire(TouchPhase.Moved, _horizontalDelta);
         _onHorizontalChange.Fire(_horizontalDelta);
     }
 }
Exemplo n.º 4
0
 private void ProcessTouches()
 {
     if (EventSystem.current.IsPointerOverGameObject())
     {
         return;
     }
     if (Input.touchCount == 1)
     {
         Touch touch = Input.touches[0];
         if (touch.phase == TouchPhase.Began)
         {
             _onTouchProcess.Fire(TouchPhase.Began, 0);
             _startTouchPosition = touch.position;
             touchTime           = Time.time;
         }
         else if (touch.phase == TouchPhase.Moved)
         {
             settings         = GameContext.LevelController.Current.Settings;
             _currentPower    = _startTouchPosition.y - touch.position.y;
             _horizontalDelta = touch.deltaPosition.x / Screen.dpi * settings.ScreenDragCoeff;
             _onTouchProcess.Fire(TouchPhase.Moved, _horizontalDelta);
             _onHorizontalChange.Fire(_horizontalDelta);
         }
         else if (touch.phase == TouchPhase.Ended)
         {
             if (Time.time - touchTime <= clickTime)
             {
                 _onShoot.Fire();
             }
             _currentPower       = 0;
             _horizontalDelta    = 0;
             _startTouchPosition = Vector2.zero;
             _onTouchProcess.Fire(TouchPhase.Ended, 0);
         }
     }
 }