Exemplo n.º 1
0
    public string Interpolate(string source)
    {
        return(Regex.Replace(source, @"#{(\.|)(.+?)}", _ =>
        {
            string entryName = _.Groups[2].Value;
            if (_.Groups[1].Value == ".")
            {
                HasPoints points = transform.Require <HasPoints>();

                if (points.Has(entryName))
                {
                    return "" + (int)points.Get(entryName);
                }
                else
                {
                    return _.Value;
                }
            }
            else
            {
                if (Has(entryName))
                {
                    return Get(entryName);
                }
                else
                {
                    return _.Value;
                }
            }
        }));
    }
Exemplo n.º 2
0
    void Update()
    {
        for (int i = 0; i < (int)(points.Get(type) / pointsPerMarker) && i < markers.Length; i++)
        {
            if (markers[i].gameObject.activeSelf == false)
            {
                if (addEffect != null)
                {
                    Instantiate(addEffect, markers[i].transform.position, Quaternion.identity);
                }
                markers[i].gameObject.SetActive(true);
            }
        }

        for (int i = (int)(points.Get(type) / pointsPerMarker); i < markers.Length; i++)
        {
            if (markers[i].gameObject.activeSelf == true)
            {
                if (loseEffect != null)
                {
                    Instantiate(loseEffect, markers[i].transform.position, Quaternion.identity);
                }
                markers[i].gameObject.SetActive(false);
            }
        }

        foreach (Transform currentMarker in markers)
        {
            if (Mathf.Repeat(Time.time, 0.6f) > 0.3f && points.Get(type) < blinkThreshold)
            {
                foreach (Renderer renderer in currentMarker.GetComponentsInChildren <Renderer>())
                {
                    renderer.enabled = false;
                }
            }
            else
            {
                foreach (Renderer renderer in currentMarker.GetComponentsInChildren <Renderer>())
                {
                    renderer.enabled = true;
                }
            }
        }
    }
    public virtual bool Deal(float amount)
    {
        points.Set(type, points.Get(type) + amount * modifier);

        if (effect != null)
        {
            Instantiate(effect, transform.position, Quaternion.identity);
        }

        return(true);
    }
Exemplo n.º 4
0
    void Update()
    {
        foreach (KeyValuePair <string, PointEventListener> listener in listeners)
        {
            listener.Value.Compare(previousValues[listener.Key], points.Get(listener.Key), points.GetMax(listener.Key));
        }

        foreach (Point point in points.points)
        {
            previousValues[point.type] = point.amount;
        }
    }
    void OnEnable()
    {
        HasPoints points = module.Require <HasPoints>();

        if (points.Has(type) && points.Get(type) >= threshold)
        {
            Spark(yes);
        }
        else
        {
            Spark(no);
        }
    }
Exemplo n.º 6
0
    void Update()
    {
        for (int i = 1; i <= Mathf.RoundToInt(points.Get(type)); i++)
        {
            if (i >= leftBracket.childCount)
            {
                Transform newBar = Instantiate(barPrefab) as Transform;
                newBar.parent        = leftBracket;
                newBar.localPosition = i * distanceBetweenBars;
                newBar.localScale    = Vector3.one;
            }
        }

        for (int i = Mathf.RoundToInt(points.Get(type)); i < leftBracket.childCount; i++)
        {
            Destroy(leftBracket.GetChild(i).gameObject);
        }

        Transform oldParent = rightBracket.parent;

        rightBracket.parent        = leftBracket;
        rightBracket.localPosition = ((int)points.GetMax(type) + 1) * distanceBetweenBars;
        rightBracket.parent        = oldParent;
    }
Exemplo n.º 7
0
    void Update()
    {
        if (points.Get(point) > 0.0f)
        {
            timeout         -= Time.deltaTime;
            renderer.enabled = timeout < 0.5f / blinksPerSecond;

            if (timeout < 0.0f)
            {
                timeout = 1.0f / blinksPerSecond;
            }
        }
        else
        {
            renderer.enabled = true;
        }
    }
Exemplo n.º 8
0
 public void ItShouldHave____(float amount, string type)
 {
     it.Get(type).ShouldBe(amount);
 }
    void Update()
    {
        if (thresholds.Count == 0)
        {
            return;
        }

        float    p = points.Get(pointType);
        int      currentThreshold = 0;
        Material material         = thresholds[0].material;

        for (int i = 0; i < thresholds.Count; i++)
        {
            if (p >= thresholds[i].threshold)
            {
                if (p < thresholds[i].blinkThreshold)
                {
                    if (Mathf.Repeat(Time.time, 0.4f) > 0.2f)
                    {
                        material = thresholds[i - 1].material;
                    }
                    else
                    {
                        material = thresholds[i].material;
                    }
                }
                else
                {
                    material = thresholds[i].material;
                }

                currentThreshold = i;
            }
        }

        if (material != lastMaterial)
        {
            foreach (Renderer renderer in renderers)
            {
                if (alsoSetChildRenderers)
                {
                    foreach (Renderer childRenderer in renderer.GetComponentsInChildren <Renderer>())
                    {
                        childRenderer.material = material;
                    }
                }
                else
                {
                    renderer.material = material;
                }
            }
        }

        if (currentThreshold < lastThreshold)
        {
            if (addEFfect != null)
            {
                Instantiate(addEFfect, transform.position, Quaternion.identity);
            }
        }
        else if (currentThreshold > lastThreshold)
        {
            if (loseEffect != null)
            {
                Instantiate(loseEffect, transform.position, Quaternion.identity);
            }
        }

        lastMaterial  = material;
        lastThreshold = currentThreshold;
    }