Esempio n. 1
0
    // Handling allocating points when user clicks the button. Does bounds checking to
    // make sure points aren't over/under distributed, and changes sprite as necessary.
    public void OnPointerClick(PointerEventData eventData)
    {
        if (stats[attributeName].IsEnabled() &&
            eventData.pointerPressRaycast.gameObject.CompareTag("ReactorButton"))
        {
            float pointsRemaining = stats.GetMaxPoints() - stats.GetTotalPointsAllocated() - 1;

            if (eventData.button == PointerEventData.InputButton.Left && pointsRemaining > 0)
            {
                stats[attributeName].pointsAllocated += 1;
                allocSound.Play(0);
            }
            else if (eventData.button == PointerEventData.InputButton.Right)
            {
                stats[attributeName].pointsAllocated -= 1;
                deallocSound.Play(0);
            }
        }
    }
Esempio n. 2
0
 void Update()
 {
     points           = (stats.GetMaxPoints() - 1) - stats.GetTotalPointsAllocated();
     barSprite.sprite = sprites[points];
 }