public void OnClickMenu()
    {
        if (_DialougeController == null)
        {
            return;
        }
        _logicController.SwitchToGameMenuState();
        _DialougeController.gameObject.SetActive(true);
        var config = new ConfirmDialougeWidgetController.Config
        {
            Text      = Consts.RETURN_TO_MENU_TEXT,
            OnConfirm = () =>
            {
                _DialougeController.gameObject.SetActive(true);
                if (!_logicController.DidPlayerWin())
                {
                    GameDataManager.SaveCommands(ServiceManager.Get <CommandManager>().GetCommands(), ServiceManager.Get <CubesManager>().GetCurrentCubeSize());
                }
                GameEventsManager.BroadcastMessage(GameEventConstants.ON_RETURN_TO_MENU);
            },
            OnClose = () =>
            {
                _logicController.SwitchToPlayState();
            }
        };

        _DialougeController.Init(config);
    }
Beispiel #2
0
 private void OnCollected()
 {
     if (GameEventsManager.OnCollectableTaken != null)
     {
         GameEventsManager.OnCollectableTaken();
     }
 }
Beispiel #3
0
 public Controller(SaperView.View view, Board board, GameEventsManager gameEventsManager)
 {
     this.view              = view;
     this.board             = board;
     this.gameEventsManager = gameEventsManager;
     view.Init(this);
 }
Beispiel #4
0
 // Use this for initialization
 void Start()
 {
     gsm = this.gameObject;
     gameEventsManager = FindObjectOfType <GameEventsManager>();
     controllerDroit   = gameEventsManager.controllerDroit;
     controllerGauche  = gameEventsManager.controllerGauche;
 }
 private void Update()
 {
     if (Input.GetButtonDown("Jump"))
     {
         GameEventsManager.TriggerGameStart();
     }
 }
    private void Update()
    {
        if (!_enabled)
        {
            return;
        }

        if (_fullReloading)
        {
            Reload();
            return;
        }

        if (Input.GetKeyDown(KeyCode.Space))
        {
            _isActive = !_isActive;

            if (GameEventsManager.OnBoostActivated != null)
            {
                GameEventsManager.OnBoostActivated(_isActive);
            }
        }

        // Consuming if it is active
        if (_isActive)
        {
            Consume();
        }
        else
        {
            Reload();
        }
    }
    private void Consume()
    {
        _currentAmount -= _consumingTimeStep * Time.deltaTime;

        if (_currentAmount <= 0)
        {
            _currentAmount = 0;

            // Deactivates automatically until full reloading
            _isActive = false;

            // Starts full reloading
            _fullReloading = true;

            // Informs that boost speed was deactivated
            if (GameEventsManager.OnBoostActivated != null)
            {
                GameEventsManager.OnBoostActivated(false);
            }
        }

        if (GameEventsManager.OnBoostAmountChanged != null)
        {
            GameEventsManager.OnBoostAmountChanged(_currentAmount / _maxAmount);
        }
    }
    private void Empty()
    {
        _collider.enabled = false;
        _playerCharging   = false;
        _fuelComponent    = null;

        if (GameEventsManager.OnFuelStopCharging != null)
        {
            GameEventsManager.OnFuelStopCharging();
        }
    }
Beispiel #9
0
        public void SubscriberIsAdded()
        {
            var manager = new GameEventsManager();
            int testVal = 0;

            Action <TestEvent> listener = evt => testVal = evt.value;

            manager.Subscribe(listener);
            manager.Invoke(new TestEvent(10));

            Assert.IsTrue(testVal == 10);
        }
Beispiel #10
0
    public override void Init()
    {
        Settings               = GameSettings.Instance;
        Data                   = new GameData();
        _gameEventsManager     = new GameEventsManager();
        _gameBehavioursManager = new GameBehavioursManager(this);

        PlayerFactory.Instance.CreatePlayer();
        UIFactory.Instance.CreateMainMenu();
        QuestionBoardFactory.Instance.CreateQuestionBoard();
        OpenCloseCircleFactory.Instance.CreateOpenCloseCircle();
        MarkersFactory.Instance.CreateDistanceMarker();
        MarkersFactory.Instance.CreateCorrectAnswersMarker();
    }
Beispiel #11
0
        public void MultipleSubscribersAreAdded()
        {
            var manager = new GameEventsManager();
            int testVal = 0;

            Action <TestEvent> l1 = evt => testVal += evt.value;
            Action <TestEvent> l2 = evt => testVal += evt.value;

            manager.Subscribe(l1);
            manager.Subscribe(l2);
            manager.Invoke(new TestEvent(10));

            Assert.IsTrue(testVal == 20);
        }
    private void OnTriggerEnter(Collider other)
    {
        _fuelComponent = other.GetComponent <FuelConsumptionComponent>();

        if (_fuelComponent != null)
        {
            _playerCharging = true;

            if (GameEventsManager.OnFuelStartCharging != null)
            {
                GameEventsManager.OnFuelStartCharging();
            }
        }
    }
Beispiel #13
0
    private void CollectableWasTaken()
    {
        _amountCollected++;

        UpdateLabel();

        // TODO: move this logic to a Game Manager
        if (_amountCollected == _collectables.Length)
        {
            if (GameEventsManager.OnAllCollectablesWereTaken != null)
            {
                GameEventsManager.OnAllCollectablesWereTaken();
            }
        }
    }
    private void OnTriggerExit(Collider other)
    {
        _fuelComponent = other.GetComponent <FuelConsumptionComponent>();

        if (_fuelComponent != null)
        {
            _fuelComponent = null;

            _playerCharging = false;

            if (GameEventsManager.OnFuelStopCharging != null)
            {
                GameEventsManager.OnFuelStopCharging();
            }
        }
    }
Beispiel #15
0
 private IEnumerator PlayState()
 {
     _gameTime = 0.0f;
     while (true)
     {
         _startTime = Time.time;
         _gameTime += Time.deltaTime;
         if (CheckIfCubeIsSolved())
         {
             GameState = GameState.Win;
             GameEventsManager.BroadcastMessage(GameEventConstants.ON_GAME_WON);
             StartCoroutine(WinState());
             yield break;
         }
         yield return(null);
     }
 }
    private void Consume()
    {
        _currentAmount -= _consumingTimeStep * Time.deltaTime;

        if (GameEventsManager.OnFuelAmountChanged != null)
        {
            GameEventsManager.OnFuelAmountChanged(_currentAmount / _maxAmount);
        }

        if (_currentAmount <= 0)
        {
            if (GameEventsManager.OnFuelEmpty != null)
            {
                GameEventsManager.OnFuelEmpty();
            }
        }
    }
    public bool Charge(float amount)
    {
        if (_currentAmount >= _maxAmount)
        {
            return(false);
        }

        //_currentAmount = Mathf.Clamp(_currentAmount + _chargingTimeStep * Time.deltaTime, 0, _maxAmount);
        _currentAmount = Mathf.Clamp(_currentAmount + amount, 0, _maxAmount);

        if (GameEventsManager.OnFuelAmountChanged != null)
        {
            GameEventsManager.OnFuelAmountChanged(_currentAmount / _maxAmount);
        }

        return(_currentAmount < _maxAmount);
    }
    private void Setup(float consumingStep, float maxAmount)
    {
        _consumingTimeStep = consumingStep;
        _maxAmount         = maxAmount;

        _currentAmount = _maxAmount;

        _isConsuming = false;

        _isCharging = false;

        if (GameEventsManager.OnFuelAmountChanged != null)
        {
            GameEventsManager.OnFuelAmountChanged(_currentAmount / _maxAmount);
        }

        _enabled = true;
    }
Beispiel #19
0
        public void ActivateShark(GameEventsManager events)
        {
            Events          = events;
            StalkerModeMove = true;
            NormalMove      = true;
            DeathMove       = false;
            var position = CalculateInitialPosition();

            Mesh.Transform             = TGCMatrix.Scaling(Constants.Scale) * TGCMatrix.Translation(position);
            Body.WorldTransform        = Mesh.Transform.ToBulletMatrix();
            director                   = Constants.DirectorZ;
            TotalRotation              = TGCMatrix.Identity;
            EventTimeCounter           = Constants.EVENT_TIME;
            DeathTimeCounter           = Constants.DEATH_TIME;
            ChangeDirectionTimeCounter = Constants.CHANGE_DIRECTION_TIME;
            AcumulatedXRotation        = 0;
            AcumulatedYRotation        = 0;
            AcumulatedZRotation        = 0;
        }
    private IEnumerator Shuffle(int size)
    {
        _canControl = false;
        var max   = size <= 4 ? Consts.MAX_SHUFFLES_SMALL : Consts.MAX_SHULLES_LARGE;
        var total = Random.Range(size * 2, max);
        int count = 0;

        while (count < total)
        {
            ShuffleCube();
            count++;
            while (!_commandManager.AcceptInput())
            {
                yield return(null);
            }
        }
        GameEventsManager.BroadcastMessage(GameEventConstants.ON_SHUFFLE_COMPLETE);
        _canControl = true;
        StartCoroutine(CheckMouseInput());
    }
    private void Reload()
    {
        if (_currentAmount >= _maxAmount)
        {
            return;
        }

        _currentAmount += _consumingTimeStep * Time.deltaTime;

        if (_currentAmount >= _maxAmount)
        {
            _currentAmount = _maxAmount;
            _fullReloading = false;
        }

        if (GameEventsManager.OnBoostAmountChanged != null)
        {
            GameEventsManager.OnBoostAmountChanged(_currentAmount / _maxAmount);
        }
    }
    private void Update()
    {
        if (!_playerCharging)
        {
            return;
        }

        if (_currentCharge <= 0)
        {
            return;
        }

        if (_fuelComponent == null)
        {
            return;
        }

        float amount = _chargingTimeStep * Time.deltaTime;

        _currentCharge -= amount;

        bool canContinueCharging = _fuelComponent.Charge(amount);

        // If fuel is full then stop charging
        if (!canContinueCharging)
        {
            _playerCharging = false;

            if (GameEventsManager.OnFuelStopCharging != null)
            {
                GameEventsManager.OnFuelStopCharging();
            }
        }

        // Checks if charge station has charge
        if (_currentCharge <= 0)
        {
            Empty();
        }
    }
Beispiel #23
0
    public void ShowWinMessage()
    {
        _DialougeController.gameObject.SetActive(true);
        var config = new ConfirmDialougeWidgetController.Config
        {
            Text      = string.Format(Consts.PLAYER_WON_TEXT, _TimerWidget.GetTime()),
            OnConfirm = () =>
            {
                _DialougeController.gameObject.SetActive(true);
                var cubeSize = ServiceManager.Get <CubesManager>().GetCurrentCubeSize();
                if (GameDataManager.CheckIfSaveDataExists(cubeSize))
                {
                    GameDataManager.DeleteCurrentSave(cubeSize);
                }
                GameEventsManager.BroadcastMessage(GameEventConstants.ON_RETURN_TO_MENU);
            },
            OnClose = () =>
            {
            }
        };

        _DialougeController.Init(config);
    }
Beispiel #24
0
    void Start()
    {
        GameManager.Instance.GameEventsManagerP = gameObject;

        //sert à s'inscrire sur la liste des Event subscribed scripts
        GameManager.Instance.SubscribeScriptToGameEventUpdates(this);

        gameEventsManager = FindObjectOfType <GameEventsManager>();

        nPC01AudioSource  = nPC01.GetComponentInChildren <AudioSource>();
        nPC02AudioSource  = nPC02.GetComponent <AudioSource>();
        nPC03AudioSource  = nPC03.GetComponentInChildren <AudioSource>();
        nPC04AudioSource  = nPC04.GetComponentInChildren <AudioSource>();
        playerAudioSource = player.GetComponentInChildren <AudioSource>();

        for (int i = 0; i < 18; i++)
        {
            hasBeenPlayed[i] = false;
        }
        for (int i = 0; i < 11; i++)
        {
            hasBeenPlayedTuto[i] = false;
        }
    }
    private void Setup(float reloadingStep, float consumingStep, float maxAmount)
    {
        _fullReloading = true;

        _reloadingTimeStep = reloadingStep;
        _consumingTimeStep = consumingStep;
        _maxAmount         = maxAmount;

        _currentAmount = 0;

        _isActive = false;

        if (GameEventsManager.OnBoostAmountChanged != null)
        {
            GameEventsManager.OnBoostAmountChanged(_currentAmount / _maxAmount);
        }

        if (GameEventsManager.OnBoostActivated != null)
        {
            GameEventsManager.OnBoostActivated(false);
        }

        _enabled = true;
    }
Beispiel #26
0
    void Update()
    {
        // Jump button is being pressed
        if (Input.GetButtonDown("Jump"))
        {
            if (touchingPlatform)
            {
                rb.AddForce(jumpVelocity, ForceMode.VelocityChange);
                touchingPlatform = false;
            }
            else if (boosts > 0)
            {
                rb.AddForce(boostVelocity, ForceMode.VelocityChange);
                boosts -= 1;
                //GUIManager.SetBoosts(boosts);
            }
        }

        // Right button is being pressed
        else if (Input.GetButton("Right") && rb.velocity.x < maxVelocity)
        {
            if (rb.velocity.x < 0)
            {
                Vector3 increaseSpeed = new Vector3(3f, 0f, 0f);
                rb.velocity = rb.velocity + increaseSpeed;
            }
            else
            {
                Vector3 increaseSpeed = new Vector3(1f, 0f, 0f);
                rb.velocity = rb.velocity + increaseSpeed;
            }
        }

        // Left button is being pressed
        else if (Input.GetButton("Left") && rb.velocity.x > -maxVelocity)
        {
            if (rb.velocity.x > 0)
            {
                Vector3 increaseSpeed = new Vector3(3f, 0f, 0f);
                rb.velocity = rb.velocity - increaseSpeed;
            }
            else
            {
                Vector3 increaseSpeed = new Vector3(1f, 0f, 0f);
                rb.velocity = rb.velocity - increaseSpeed;
            }
        }

        // No input is being pressed
        else
        {
            if (rb.velocity.x > 0)
            {
                if (rb.velocity.x < 1)
                {
                    rb.velocity = Vector3.zero;
                }
                else if (touchingPlatform && touchingPlatform)
                {
                    Vector3 decreaseSpeed = new Vector3(1f, 0f, 0f);
                    rb.velocity = rb.velocity - decreaseSpeed;
                }
                else
                {
                    Vector3 decreaseSpeed = new Vector3(.5f, 0f, 0f);
                    rb.velocity = rb.velocity - decreaseSpeed;
                }
            }
            else if (rb.velocity.x < 0)
            {
                if (rb.velocity.x > -1 && touchingPlatform)
                {
                    rb.velocity = Vector3.zero;
                }
                else if (touchingPlatform)
                {
                    Vector3 decreaseSpeed = new Vector3(1f, 0f, 0f);
                    rb.velocity = rb.velocity + decreaseSpeed;
                }
                else
                {
                    Vector3 decreaseSpeed = new Vector3(0.5f, 0f, 0f);
                    rb.velocity = rb.velocity + decreaseSpeed;
                }
            }
            else if (touchingPlatform)
            {
                rb.velocity = Vector3.zero;
            }
        }
        distanceTraveled = transform.localPosition.x;
        //GUIManager.SetDistance(distanceTraveled);

        if (transform.localPosition.y < gameOverY)
        {
            GameEventsManager.TriggerGameOver();
        }
    }
Beispiel #27
0
        private void HandleClick(GameEventsManager sender, MouseClickEventArgs args)
        {
            // Create ray of current mouse position on set camera and test for hit
            RaycastHit hit;
            bool       didHit = this.GetRayHit(Input.mousePosition, out hit);

            if (didHit)
            {
                // Get hit object and check if it's selectable
                var selectedObject = GetComponentFromAbove <SelectableGameObject>(hit.collider.gameObject);
                if (selectedObject != null)
                {
                    if (this.Debug.SelectionMade)
                    {
                        UnityEngine.Debug.Log(
                            String.Format("Mouse down Select on {0}", hit.collider.gameObject.name),
                            hit.collider.gameObject);
                    }

                    // Mark object as selected and add it to list if successfully selected
                    var wasSelected = selectedObject.Selected(this);
                    if (wasSelected)
                    {
                        this.selectedObjects.Add(selectedObject);
                    }
                    else if (this.Debug.SelectionMade)
                    {
                        UnityEngine.Debug.Log(
                            String.Format("Mouse down Refused to select {0}", hit.collider.gameObject.name),
                            hit.collider.gameObject);
                    }
                }
                else
                {
                    if (this.Debug.SelectionMade)
                    {
                        UnityEngine.Debug.Log(
                            String.Format("Mouse down Invalid selection on {0}", hit.collider.gameObject.name),
                            hit.collider.gameObject);
                    }
                }
            }
            else
            {
                // Try to deselect all selected objects
                for (int index = 0; index < this.selectedObjects.Count; index++)
                {
                    if (this.selectedObjects.ElementAt(index).Deselected(this))
                    {
                        this.selectedObjects.RemoveAt(index);
                        index--;
                    }
                }

                if (this.Debug.SelectionClear)
                {
                    UnityEngine.Debug.Log(
                        String.Format("Mouse down Selection cleared {0} left", this.selectedObjects.Count));
                }
            }
        }
Beispiel #28
0
 public virtual void Awake()
 {
     this.gameEventsManager = this.GetComponent <GameEventsManager>();
 }
Beispiel #29
0
 private void EngineKeyOnOnKey(GameEventsManager sender, GameEventsManager.WatchedKey source)
 {
     this.ApplyEngineForce();
 }
Beispiel #30
0
 private void FrontDownOnOnKey(GameEventsManager sender, GameEventsManager.WatchedKey source)
 {
     this.FrontThrustersVertical(false);
 }