Ejemplo n.º 1
0
 public override void Start()
 {
     if (ThrowEventOnStart)
     {
         OnValueChangedEvent.Invoke(CurrentValue);
         OnValueChanged?.Invoke(CurrentValue);
     }
 }
Ejemplo n.º 2
0
    private void SetPage(int pageIndex)
    {
        pageIndex = Mathf.Clamp(pageIndex, 0, pageCount - 1);
        scrollRectContainer.anchoredPosition = pagePositions[pageIndex];
        currentPage = pageIndex;

        OnPageChanged.Invoke(pageIndex);
    }
Ejemplo n.º 3
0
    private void HandleClick()
    {
        var value = (int)AudioHook.DataSource;

        value++;
        if (value > 2)
        {
            value = 0;
        }

        OnValueChanged.Invoke(value);
    }
Ejemplo n.º 4
0
        protected virtual void Start()
        {
            statsContainer = GetComponent <StatsContainer>();

            currentHealth = MaxHealth;

            onHealthChange?.Invoke(currentHealth);

            onMaxHealthChange?.Invoke(MaxHealth);

            onHealthPercentageChange?.Invoke(CalculateHealthPercentage());

            onSpawn?.Invoke(this);
        }
Ejemplo n.º 5
0
 private void InformReadyTask(int taskId)
 {
     if (OnTaskReady != null)
     {
         OnTaskReady.Invoke(taskId);
     }
 }
Ejemplo n.º 6
0
    public void CallEvents()
    {
        switch (m_type.ToLower())
        {
        case "int":
        case "integer":
            m_intEvent.Invoke(GetIntValue()); break;

        case "float":
        case "real":
            m_floatEvent.Invoke(GetFloatValue()); break;

        case "string":
        case "text":
            m_stringEvent.Invoke(GetStringValue()); break;

        case "bool":
        case "boolean":
            m_boolEvent.Invoke(GetBoolValue()); break;

        default: break;
        }

        m_optionEvent.Invoke(this);
    }
    void Start()
    {
        Color currentColor = FindCurrentColorThreshold().m_color;

        m_slider.value = m_value == m_unlimited && m_unlimitedValueAllowed ? m_slider.maxValue : m_value;

        if (m_unlimitedValueAllowed)
        {
            m_text.text = m_prefixText + (m_value != m_unlimited ? m_value.ToString() : "Unlimited") + m_suffixText;
        }
        else
        {
            m_text.text = m_prefixText + m_value.ToString() + m_suffixText;
        }

        m_text.color = currentColor;

        m_slider.onValueChanged.AddListener((value) => {
            m_value = (int)value == (int)m_slider.maxValue && m_unlimitedValueAllowed ? m_unlimited : (int)value;

            if (m_unlimitedValueAllowed)
            {
                m_text.text = m_prefixText + (value < m_slider.maxValue ? value.ToString() : "Unlimited") + m_suffixText;
            }
            else
            {
                m_text.text = m_prefixText + m_value.ToString() + m_suffixText;
            }

            m_text.color = FindCurrentColorThreshold().m_color;
            m_valueChangedEvent.Invoke(m_value);
        });
    }
Ejemplo n.º 8
0
        /// <summary>
        /// Modifies the health by the amount given.
        /// </summary>
        /// <param name="amount"></param>
        private void ModifyHealth(int amount)
        {
            if (amount == 0 || CurrentHealth <= 0)
            {
                return;
            }

            CurrentHealth += amount;

            if (CurrentHealth <= 0)
            {
                CurrentHealth = 0;
                OnHealthEmpty.Invoke();
                return;
            }

            if (amount > 0)
            {
                OnHealthGained.Invoke(CurrentHealth);
            }
            else
            {
                OnHealthLost.Invoke(CurrentHealth);
            }
        }
Ejemplo n.º 9
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.tag == playerTag)
     {
         onPlayerEntered.Invoke(nextLevel);
     }
 }
Ejemplo n.º 10
0
    public void CreateOrder()
    {
        timeUntilNextOrder = timeBetweenOrders + Random.Range(-orderRandomness, orderRandomness);

        var latestOrder = new PizzaOrder()
        {
            orderId = pizzaOrderCounter, ingredients = new List <PizzaIngredient.PizzaInredientType>()
            {
                PizzaIngredient.PizzaInredientType.Cheese, PizzaIngredient.PizzaInredientType.Sauce
            }
        };
        var numToppings = Random.Range(0, gameManager.MaxToppingsThisStage() + 1); // max is exclusive

        for (var i = 0; i < numToppings; i++)
        {
            latestOrder.ingredients.Add(RandomTopping());
        }
        allOrders.Add(latestOrder);
        pizzaOrderCounter++;

        if (OnNewOrder != null)
        {
            OnNewOrder.Invoke(latestOrder.orderId);
        }
    }
Ejemplo n.º 11
0
        private void Update()
        {
            // TODO remove magic number
            const float eps = 0.01f;

            // Movements
            _movement.DoMotions(Time.deltaTime);

            // Attraction of one-type balls
            for (var i = 0; i < _balls.Count - 1; i++)
            {
                if (_balls[i].Type != _balls[i + 1].Type)
                {
                    continue;
                }

                var dist = _balls[i].Traveled - _balls[i + 1].Traveled;
                if (dist > _balls[i].Size + eps)
                {
                    var count = GroupCount(i, -1, j => j - 1);
                    var id    = i - count + 1;
                    _movement.AddMotion(id, -_increase * Time.deltaTime, count);
                }
            }

            // Generating chain
            if (PlaceFree(_prototype.Size) && _ballsFactory.Next())
            {
                var ball = _ballsFactory.Instance() as Ball;
                OnCreateBall.Invoke(ball.Type);
                _balls.Add(ball);
            }
        }
Ejemplo n.º 12
0
 public virtual void OnEventRaised(int?i)
 {
     if (Response != null)
     {
         Response.Invoke(i);
     }
 }
Ejemplo n.º 13
0
        /// <summary>
        /// Modifies the health by the amount given.
        /// </summary>
        /// <param name="amount">amount to modify health by</param>
        internal void ModifyHealth(int amount)
        {
            if (amount == 0 || CurrentHealth <= 0)
            {
                return;
            }

            if (CanExceedMaximumHealth)
            {
                CurrentHealth += amount;
            }
            else
            {
                CurrentHealth = Mathf.Clamp(CurrentHealth + amount, 0, MaximumHealth);
            }

            OnHealthPercentChanged?.Invoke(NormalizedCurrentHealth);

            if (CurrentHealth <= 0)
            {
                CurrentHealth = 0;
                OnHealthEmpty.Invoke();
                return;
            }

            if (amount > 0)
            {
                OnHealthGained?.Invoke(CurrentHealth);
            }
            else
            {
                OnHealthLost?.Invoke(CurrentHealth);
            }
        }
Ejemplo n.º 14
0
 void NextPlayer()
 {
     do
     {
         ++currentPlayer;
         if (currentPlayer == numberPlayers)
         {
             currentPlayer = 0;
             ++turn;
             changeOfTurnEvent.Invoke(turn);
             isEndOfGame = IsEndOfGameTurn();
         }
         isEndOfGame = isEndOfGame || CheckSurvivalEndOfGameTurn();
         if (!isEndOfGame)
         {
             players[currentPlayer].ResetUnitMovement();
             players[currentPlayer].ProduceShields();
             changeOfPlayerEvent.Invoke(currentPlayer);
             players[currentPlayer].ProduceShields();
             IsCurrentPlayerAI = isThereAI && currentPlayer == 1;
             if (IsCurrentPlayerAI)
             {
                 aiPlayer.InitialTasks();
             }
         }
         else
         {
             victoryPanel.SetActive(true);
             break;
         }
     } while (players[currentPlayer].IsDead);
 }
Ejemplo n.º 15
0
 public void AddMoney(int newMoney)
 {
     CurrentMoney += newMoney;
     if (OnMoneyChanged != null)
     {
         OnMoneyChanged.Invoke((int)CurrentMoney);
     }
 }
 private void onItemSelected(int itemId, bool selected)
 {
     if (selected)
     {
         selectedItem = itemId;
         onValueChanged.Invoke(itemId);
     }
 }
Ejemplo n.º 17
0
    private void Start()
    {
        foreach (var x in SelectedBackgrounds)
        {
            if (x == null)
            {
                continue;
            }
            x.gameObject.SetActive(false);
        }

        for (int i = 0; i < Tabs.Length; i++)
        {
            var x = Tabs[i];
            if (x != null)
            {
                var t = i - 1; // why do i do this you ask? because shit mono implementation of lambdas that's why
                x.onClick.AddListener(() => Proc(t + 1));
            }
        }

        foreach (var x in TabContent)
        {
            if (x == null)
            {
                continue;
            }
            x.SetActive(false);
        }

        if (TabContent.Length != 0)
        {
            TabContent[0].SetActive(true);
        }

        if (SelectedBackgrounds.Length != 0)
        {
            SelectedBackgrounds[0].gameObject.SetActive(true);
        }

        if (TabChanged != null)
        {
            TabChanged.Invoke(0);
        }
    }
Ejemplo n.º 18
0
    public static void TriggerIntEvent(string eventName, int input)
    {
        UnityIntEvent thisEvent = null;

        if (instance.intEventDictionary.TryGetValue(eventName, out thisEvent))
        {
            thisEvent.Invoke(input);
        }
    }
Ejemplo n.º 19
0
 private IEnumerator MapScore()
 {
     while (mapScore > 1)
     {
         mapScore = mapScore - 10;
         OnMapScoreChangedEvent.Invoke(mapScore);
         yield return(new WaitForSeconds(1));
     }
 }
Ejemplo n.º 20
0
    public void TakeDamage(int damage)
    {
        damage = CalculateDamage(damage);
        Properties.CurrentHealth -= damage;
        OnDamageTaken.Invoke(BattleId);

        if (Properties.CurrentHealth <= 0)
        {
            gameObject.SetActive(false);
            GridSystem.Instance.RemoveCharacterFromNode(Coords, this);
            OnDie.Invoke(BattleId);
        }
    }
Ejemplo n.º 21
0
        public void OnChildToggled(CUIToggle toggle, bool notify = true, bool instant = false, bool force = false)
        {
            if (!allowDeselection && selectedToggles.Contains(toggle) && !force)
            {
                return;
            }

            //If we allow deselection, disable the toggle that was clicked on
            if (allowDeselection && toggle.isSelected)
            {
                toggle.Deselect(instant);
                return;
            }

            if (!allowMultiSelect)
            {
                //Deselect others:
                foreach (CUIToggle other in selectedToggles)
                {
                    if (other == null)
                    {
                        continue;
                    }
                    if (!other.isSelected)
                    {
                        continue;
                    }
                    other.Deselect(instant);
                }

                selectedToggles.Clear();
            }

            //Select the right one:

            toggle.Select(instant);

            selectedToggles.Add(toggle);

            if (notify)
            {
                onSelectedTogglesUpdated.Invoke();
            }

            //selectedIndex = toggle.transform.GetSiblingIndex();
            selectedIndex = toggles.IndexOf(toggle);
            if (notify)
            {
                onIndexSelected.Invoke(selectedIndex);
            }
        }
Ejemplo n.º 22
0
 public void LoadLevel(int index)
 {
     if (index >= maps.Count)
     {
         SceneManager.LoadScene(0);
         return;
     }
     circuit.Setup(maps[index]);
     currentLevel  = index;
     _currentState = 0;
     onLevelChanged.Invoke(index);
     onStateChanged.Invoke(0);
     outputStates = 0;
 }
Ejemplo n.º 23
0
    public void UpdateSlider(float p_value)
    {
        m_value = (int)p_value == (int)m_slider.maxValue && m_unlimitedValueAllowed ? m_unlimited : (int)p_value;

        if (m_unlimitedValueAllowed && m_value == m_unlimited)
        {
            m_text.text = Get("Unlimited" + m_suffixText);
        }
        else
        {
            m_text.text = Game.m_languages.FormatTexts(Get(m_prefixText + "{0}" + m_suffixText), m_value.ToString());
        }

        m_text.color = FindCurrentColorThreshold().m_color;
        m_valueChangedEvent.Invoke(m_value);
    }
Ejemplo n.º 24
0
        private IEnumerator SpawnWaveCoroutine()
        {
            wave++;
            onWaveUpdated?.Invoke(wave);

            var waveConfiguration = wavesSetup.GetWaveConfiguration(wave);

            currentEnemies = waveConfiguration.NumberOfEnemies * waveConfiguration.NumberOfRounds;
            var waitBetweenRounds = new WaitForSeconds(waveConfiguration.NumberOfEnemies * waveConfiguration.SpawnDelay);

            for (int i = 0; i < waveConfiguration.NumberOfRounds; i++)
            {
                var enemy = waveConfiguration.GetEnemy(i);
                GetRandomSpawner().SpawnWave(enemy, waveConfiguration.NumberOfEnemies, waveConfiguration.SpawnDelay);
                yield return(waitBetweenRounds);
            }
        }
Ejemplo n.º 25
0
    public void AddXP(int xp)
    {
        Services.PlayerService.AddXP(xp);

        if (AddXpEvent != null)
        {
            AddXpEvent.Invoke(xp);
        }

        if (Services.PlayerService.CurrentXP >= Services.PlayerService.XPLevelLimit)
        {
            int c = 0;
            do
            {
                Services.PlayerService.AddLevel(1);
                Services.PlayerService.RemoveXP(Services.PlayerService.XPLevelLimit);

                //_pdata.Level++;
                //_pdata.CurrentXP -= _pdata.XPLevelLimit;
                c++;
            } while (Services.PlayerService.CurrentXP >= Services.PlayerService.XPLevelLimit);


            var achiInfo = new ExtendedAchievmentInfo(id: -1,
                                                      name: $"Level {Services.PlayerService.Level}",
                                                      iconSprite: SpriteDB.SpriteRefs["lvlUp"],
                                                      rewardType: RewardType.None,
                                                      rewardValue: 0,
                                                      points: 10 * c);
            achiInfo.CustomText = "Grats!";
            GameEvents.OnGeneratorAchievmentsReceived(-1, new List <ExtendedAchievmentInfo> {
                achiInfo
            });

            //_pdata.AvailableRewards += c;
            Services.RewardsService.AddAvailableRewards(c);


            PortraitDetails.Stars      = Services.PlayerService.Level / 100;
            PortraitDetails.MaxElement = (int)(((Services.PlayerService.Level - (PortraitDetails.Stars * 100)) / 100f) * MaxLevelElements);

            //_pdata.XPLevelLimit = GetXPLimit(_pdata.Level);
            Services.PlayerService.AddXPLevelLimit(GetXPLimit(Services.PlayerService.Level));
        }
    }
Ejemplo n.º 26
0
    public void OrderComplete(Pizza p)
    {
        var ingredients = p.GetToppings();
        var oo          = FindOpenOrder(ingredients);

        if (oo != null)
        {
            oo.isOrderComplete = true;
            if (OnOrderComplete != null)
            {
                OnOrderComplete.Invoke(oo.orderId);
            }
        }
        else
        {
            Debug.LogError("Couldn't find that open order!");
        }
    }
Ejemplo n.º 27
0
    void Start()
    {
        ValueTextPair pair        = FindCurrentPair();
        string        currentText = pair.m_text;

        m_slider.value  = m_value;
        m_text.text     = Game.m_languages.GetLine(currentText);
        m_text.color    = Constants.WHITE;
        m_text.fontSize = pair.m_textSize;

        m_slider.onValueChanged.AddListener((value) => {
            m_valueChangedEvent.Invoke((int)value);
            m_value = (int)value;

            ValueTextPair vtp = FindCurrentPair();
            m_text.text       = Game.m_languages.GetLine(vtp.m_text);
            m_text.fontSize   = vtp.m_textSize;
        });
    }
Ejemplo n.º 28
0
        public void SetCount(int value)
        {
            _init = true;

            if (value != _count)
            {
                _count = value;
                if (_count > maxValue)
                {
                    _count = minValue;
                }
                if (_count < minValue)
                {
                    _count = maxValue;
                }

                onCounterStringChanged.Invoke(_count.ToString());
                onCountChanged.Invoke(_count);
            }
        }
Ejemplo n.º 29
0
    public void SendContent()
    {
        switch (contentType)
        {
        case ParseTarget.Int:
            IntEvent.Invoke(int.Parse(buttonText.text));
            break;

        case ParseTarget.Float:
            FloatEvent.Invoke(float.Parse(buttonText.text));
            break;

        case ParseTarget.String:
            StringEvent.Invoke(buttonText.text);
            break;

        default:
            break;
        }
    }
Ejemplo n.º 30
0
 public void AddCrystalsAmount(int amount)
 {
     crystalsAmount = Mathf.Clamp(crystalsAmount + amount, 0, 9999);
     RefreshCrystalsText();
     OnCrystalAmountChanged?.Invoke(crystalsAmount);
 }