Ejemplo n.º 1
0
 public void Add()
 {
     value += amountInterval;
     if (value > maxLimit)
     {
         value = maxLimit;
     }
     numericEvent?.Invoke(value);
     UpdateText();
 }
Ejemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
        if (_instance)
        {
            Destroy(_instance);
        }

        _instance = this;

        _beginTime = Time.time;
        _trans     = GetComponent <RectTransform> ();

        SaisonChangeMonthChangeEvent.AddListener(m => Debug.Log("Changement de mois = " + GetMonth()));

        SaisonChangeMonthChangeEvent.Invoke(_month);
    }
Ejemplo n.º 3
0
 private void InstantiateAd()
 {
     if (NbOfAdsInStock > 0)
     {
         var ad            = CreateAd();
         var mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
         ad.transform.position = new Vector3(mousePosition.x, mousePosition.y, 0);
         var distance = Vector3.Distance(FindObjectOfType <IAMouseScript>().transform.position, ad.transform.position);
         NbOfAdsInStock--;
         OnAdCountChanged.Invoke(NbOfAdsInStock);
         if (FindObjectOfType <GameManagerScript>().IsTaskManagerObstructed() && FindObjectOfType <IAMouseScript>().MovingToEndOrTask())
         {
             OnSuccessfulAd.Invoke(distance);
         }
     }
 }
Ejemplo n.º 4
0
    /// <summary>
    /// Sets health to the given amount.
    /// </summary>
    /// /// <param name="newHealth">What value to set the health to.</param>
    /// <returns>Returns by how much the health changed.</returns>
    public int SetHealth(int newHealth)
    {
        // Cache previous health.
        int previousHealth = CurrentHealth;

        // Set health to given amount.
        CurrentHealth = newHealth;

        if (CurrentHealth == 0)
        {
            // Check if health hit 0 just now.
            if (previousHealth > 0)
            {
                _healthDepleted = true;
                OnHealthDepleted.Invoke();
            }
        }
        else
        {
            _healthDepleted = false;
        }

        // Calculate actual health difference.
        int deltaHealth = CurrentHealth - previousHealth;

        if (deltaHealth != 0)
        {
            OnHealthChanged.Invoke(deltaHealth);
        }
        return(deltaHealth);
    }
Ejemplo n.º 5
0
 public void Toggle()
 {
     ++curLanguage;
     curLanguage %= languages.Length;
     //Debug.Log($"Toggle to: {languages[curLanguage]}");
     onSetLanguage.Invoke((int)languages[curLanguage]);
 }
Ejemplo n.º 6
0
 public override void OnEvent(PlayerQuit evnt)
 {
     if (OnPlayerQuit != null)
     {
         OnPlayerQuit.Invoke(evnt.PlayerID);
     }
 }
Ejemplo n.º 7
0
    public void Damage(int damage)
    {
        isHealthy = false;

        BleedOffHealth(damage);
        onDamage.Invoke(damage);
    }
Ejemplo n.º 8
0
 private void Awake()
 {
     if (OnLevelChanged != null)
     {
         OnLevelChanged.Invoke(current);
     }
 }
Ejemplo n.º 9
0
        public void OnDrag(PointerEventData eventData)
        {
            // Getting the delta from last frame position
            var position = viewport.transform.InverseTransformPoint(Camera.main.ScreenToWorldPoint(eventData.position));
            var delta    = position - relativePosToPointer;

            relativePosToPointer = position;

            if (horizontal)
            {
                delta.y = 0;
            }
            else
            {
                delta.x = 0;
            }
            delta.z = 0;

            MoveImages(delta);
            RearrangeImages();
            SetFadeAmount();

            var nearestImageIndex = FindNearestImageIndex();

            if (onValueChange != null)
            {
                onValueChange.Invoke(GetItemIndexByImage(images[nearestImageIndex]));
            }
        }
Ejemplo n.º 10
0
 private void Respond(int value)
 {
     if (OnEventRaised != null)
     {
         OnEventRaised.Invoke(value);
     }
 }
Ejemplo n.º 11
0
 public void Draw()
 {
     evaluator = new PathEvaluator(Path, looping);
     pathReady.Invoke(Evaluator);
     pointsCountReady.Invoke(evaluator.Points.Length);
     pointsReady.Invoke(evaluator.Points);
 }
Ejemplo n.º 12
0
        /// <summary>Pick Up Logic. It can be called by the ANimator</summary>
        public void PickUpItem()
        {
            item = FocusedItem;

            if (item)
            {
                item.Picker = gameObject;  //Set on the Item who did the Picking
                item.Pick();               //Tell the Item that it was picked

                OnPicking.Invoke(item.ID); //Invoke the Method
                CanPickUp.Invoke(false);
                OnItem.Invoke(item.gameObject);

                if (Holder)
                {
                    item.transform.parent           = Holder;       //Parent it to the Holder
                    item.transform.localPosition    = PosOffset;    //Offset the Position
                    item.transform.localEulerAngles = RotOffset;    //Offset the Rotation
                }

                // FocusedItem.OnFocused.Invoke(false);
                FocusedItem = null;                             //Remove the Focused Item


                if (m_HidePickArea.Value)
                {
                    PickUpArea.gameObject.SetActive(false);        //Disable the Pick Up Area
                }
                // Debug.Log("PickUpItem");
            }
        }
Ejemplo n.º 13
0
 //TODO: delete and reset points array when removing points
 IEnumerator CheckCollisions()
 {
     while (true)
     {
         for (int i = points.Length - 1; i >= 0; --i)
         {
             var point = points[i] + transform.position;
             if (CheckController(controller, point, config.correctHandGrace))
             {
                 Instantiate(goodParticlePrefab, point, Quaternion.identity);
                 StartCoroutine(DestroyRest(i + 1));
                 ScorePoint.Invoke(1);
                 break;
             }
             if (otherController != null) //our controller is not the head
             {
                 if (CheckController(otherController, point, config.incorrectHandGrace))
                 {
                     StartCoroutine(DestroyRest(i));
                     break;
                 }
             }
         }
         yield return(null);
     }
 }
        void setButton(int index)
        {
            CurrentIndex = index;
            if (ButtonImage != null)
            {
                ButtonImage.color = data[index].ButtonColor;
            }
            if (ButtonLabel != null)
            {
                ButtonLabel.color = data[index].LabelColor;
            }
            if (ButtonLabel != null)
            {
                ButtonLabel.text = data[index].Label;
            }

            if (disabledEvent)
            {
                return;
            }

            if (data[index].OnSwitchOn != null)
            {
                data[index].OnSwitchOn.Invoke(data[index].Label);
            }

            OnSwitch.Invoke(index);
        }
Ejemplo n.º 15
0
    //метод проверяет результат игрока на соответствие заказу
    public void CompleteOrder()
    {
        //оценка сделанной пиццы
        roundScore = 2;
        //если наличие ингридиента в заказе и в пицце совпадает, к счёту добавляется очко, если нет - отнимается
        roundScore = mushroom.activeInHierarchy == currentOrder.mushroom ?  roundScore + 1 : roundScore - 1;
        roundScore = pepperoni.activeInHierarchy == currentOrder.pepperoni ?  roundScore + 1 : roundScore - 1;
        roundScore = pineapple.activeInHierarchy == currentOrder.pineapple ?  roundScore + 1 : roundScore - 1;

        //перевод очков 5-звёздночную систему
        roundScore = Mathf.Clamp(roundScore, 1, 5);
        //вызывает событие, отвечающее за обработку выполненого заказа
        onOrderComplete.Invoke(roundScore);
        Debug.Log(roundScore);
        //добавление пиццы в общий счёт
        Debug.Log(accumulatedScore.Keys.Count + " " + accumulatedScore.Values.Count);
        accumulatedScore[roundScore]++;

        //проверка на то, осталось ли время, чтобы сделать ещё пиццу(осталось ли ещё время)
        if (timeRemaining > 0)
        {
            //создаёт новый заказ
            CreateNewOrder();
        }
        else
        {
            //конец игры
            GameComplete();
        }
    }
    public void Invoke()
    {
        if (field == null)
        {
            field = GetComponent <InputField>();
        }
        if (field == null)
        {
            return;
        }

        string text = field.text;

        onInvokeWithText.Invoke(text);

        if (string.IsNullOrEmpty(text.Trim()))
        {
            text = "0";
        }

        float floatVal;

        if (float.TryParse(text, out floatVal))
        {
            onInvokeWithFloat.Invoke(floatVal);
        }

        int intVal;

        if (int.TryParse(text, out intVal))
        {
            onInvokeWithInt.Invoke(intVal);
        }
    }
Ejemplo n.º 17
0
 public virtual void OnFocusTap(int tapCount)
 {
     if (onFocusTapped != null)
     {
         onFocusTapped.Invoke(tapCount);
     }
 }
Ejemplo n.º 18
0
    private void Start()
    {
        defendersParent = GameObject.Find(DEFENDER_PARENT_NAME) ?? new GameObject(DEFENDER_PARENT_NAME);

        DifficultyController difficultyController = FindObjectOfType <DifficultyController>();
        Difficulty           difficulty           = difficultyController.getDifficulty();

        stars = Mathf.RoundToInt(stars * difficulty.getStartingStarAmountScaling());
        onStarAmountUpdated.Invoke(stars);

        foreach (DefenderIcon defenderIcon in FindObjectsOfType <DefenderIcon>())
        {
            defenderIcon.registerOnDefenderSelected((selectedDefender) => setDefender(selectedDefender));
        }
        onStarGeneration.AddListener((amount) => addStars(amount));
    }
Ejemplo n.º 19
0
    //check if user's order matches current order
    public void CompleteOrder()
    {
        //judge the completed pizza
        roundScore = 2;
        roundScore = mushroom.activeInHierarchy == currentOrder.mushroom ?  roundScore + 1 : roundScore - 1;
        roundScore = pepperoni.activeInHierarchy == currentOrder.pepperoni ?  roundScore + 1 : roundScore - 1;
        roundScore = pineapple.activeInHierarchy == currentOrder.pineapple ?  roundScore + 1 : roundScore - 1;

        //clamp score between 1 and 5 stars
        roundScore = Mathf.Clamp(roundScore, 1, 5);
        onOrderComplete.Invoke(roundScore);
        Debug.Log(roundScore);
        //add this pizza to the total score
        Debug.Log(accumulatedScore.Keys.Count + " " + accumulatedScore.Values.Count);
        accumulatedScore[roundScore]++;

        //can we make another pizza?
        if (timeRemaining > 0)
        {
            CreateNewOrder();
        }
        else
        {
            //Finish the game
            GameComplete();
        }
    }
Ejemplo n.º 20
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.CompareTag("Player"))
     {
         platformClose.Invoke(quadrant);
     }
 }
Ejemplo n.º 21
0
    private void Awake()
    {
        arityEvent.AddRemovableListener(i => arity = i, this);
        button.onClick.AddListener(Cast);
        SkipButton.onClick.AddListener(() =>
        {
            StartCoroutine(Skip());
            effectAudioEvent.Invoke(15); //Forward Skip Sound
        });

        StepBackButton.onClick.AddListener(StepBack);
        SkipBackButton.onClick.AddListener(() =>
        {
            StartCoroutine(SkipBack());
            effectAudioEvent.Invoke(17); //Backward Skip Sound
        });
        StopButton.onClick.AddListener(() =>
        {
            effectAudioEvent.Invoke(0); //Button Press Sound
            UnCast();
            Destroy(variable_symbols_here.GetComponentInChildren <HighlightParen>().gameObject);
            arityEvent.Invoke(arity);

            Destroy(proposal.GetComponentInChildren <LayoutTracker>().gameObject);
            proposal.Initialize(oldterm);
        });
        evalmode.val = false;
    }
Ejemplo n.º 22
0
    public void OnValueChange()
    {
        actualValue = slider.value;
        int sliderPercentageValue = (int)(actualValue * 100 / maxValue);

        sliderPositionChanged.Invoke(sliderPercentageValue);
    }
Ejemplo n.º 23
0
        // the character gets dmg by another
        public void GetHit(Actor attacher)
        {
            // formula for now dmg = st
            float amount = attacher.GetStat("STR");

            HPChange.Invoke((int)amount);
        }
Ejemplo n.º 24
0
 protected override void InvokeEvents()
 {
     Evaluate();
     FloatOutput.Invoke(_outputFloat);
     IntegerOutput.Invoke(_outputInt);
     Debug.Log(_outputFloat);
     Debug.Log(_outputInt);
 }
Ejemplo n.º 25
0
    // Loads a particular level by chapter and level indices
    public void loadLevel(int chapter, int level)
    {
        // WARNING - changes made here might need to be reflected in startLevelRandom() as well.
        songAudioEvent.Invoke(3);         //Puzzle Track
        isLevelRandom = false;

        if (chapter >= chapterList.Chapters.Length || chapter < 0 || level >= chapterList.Chapters[chapter].Levels.Length || level < 0)
        {
            Debug.LogError($"Trying to load chapter {chapter}, level {level}, which does not exist. Defaulting to chapter 0 level 0.");
            loadLevel(0, 0);
            return;
        }
        chapterIndex = chapter;
        levelIndex   = level;
        currentLevel = chapterList.Chapters[chapterIndex].Levels[levelIndex];
        SceneManager.LoadSceneAsync(levelSceneBuildIndex).completed += onLevelLoaded(currentLevel);
    }
Ejemplo n.º 26
0
        /// <summary>Set everyting up when the Animal Script Start</summary>
        public virtual void AwakeMode(MAnimal animal)
        {
            this.Animal = animal;                                   //Cache the Animal
            ModeTagHash = Animator.StringToHash(AnimationTag);      //Convert the Tag on a TagHash

            OnAbilityIndex.Invoke(AbilityIndex);
            Current_CoolDown_Time = -CoolDown;  //First Time IMPORTANT
        }
Ejemplo n.º 27
0
            public void InvokeEvent_WithImplicitValue_ShouldTriggerListenerUnityEventWithImplicitValue()
            {
                // Arrange
                int counter = 0;

                void IncrementCounter(int incrementAmount)
                {
                    counter += incrementAmount;
                }

                // Act
                _listener.UnityEvent.AddListener(IncrementCounter);
                _genericGameEvent.Invoke();

                // Assert
                counter.Should().Be(1);
            }
Ejemplo n.º 28
0
 void OnDayTime()
 {
     currentCycle = Cycle.Day;
     onNewDay.Invoke(cycleCount);
     //      Debug.Log("wakey wakey look out for snakey");
     //         enemyManager.EnemiesEnterStage(cycleCount);
     cycleCount++;
 }
Ejemplo n.º 29
0
    public void ChangeAmountRequired(int cycle)
    {
        switch (cycle)
        {
        case 0:
            onRequiredUpdate.Invoke(10);
            break;

        case 1:
            onRequiredUpdate.Invoke(15);
            break;

        case 2:
            onRequiredUpdate.Invoke(0);
            break;
        }
    }
Ejemplo n.º 30
0
 private void Next()
 {
     if (animated)
     {
         return;
     }
     index++;
     StartCoroutine(Animated(gridTransform, size, speed, () =>
     {
         if (index == maxIndex)
         {
             gridTransform.anchoredPosition = size;
             index = 0;
         }
         IndexChanged.Invoke(index);
     }));
 }