コード例 #1
0
ファイル: Wall.cs プロジェクト: Calypso391/Portfolio-Code
    private void Update()
    {
        //var newPosition = (Vector2)transform.position + Direction * Speed * Time.deltaTime;
        //rb.MovePosition(newPosition);
        transform.position += Time.deltaTime * Vector3.left * Speed;


        // helps me quickly visualize every color is working by cycling through them
        // DEBUG ONLY
        if (DebugCycleThroughColors)
        {
            timer += Time.deltaTime;
            if (timer > 1.0f)
            {
                timer = 0.0f;
                int nextColor = ((int)color) << 1;
                if (nextColor > 0x800)   // wrap
                {
                    nextColor = 0x1;
                }
                color = (EColorFlag)nextColor;

                Color rgb = EColorRGBHelper.FromSingleFlagToRGB(color);

                var spriteRenderers = GetComponentsInChildren <SpriteRenderer>();
                foreach (var sprite in spriteRenderers)
                {
                    sprite.color = rgb;
                }
            }
        }
    }
コード例 #2
0
ファイル: Wall.cs プロジェクト: Calypso391/Portfolio-Code
    private void Start()
    {
        rb = GetComponent <Rigidbody2D>();

        Color rgb = EColorRGBHelper.FromSingleFlagToRGB(color);

        var spriteRenderers = GetComponentsInChildren <SpriteRenderer>();

        foreach (var sprite in spriteRenderers)
        {
            sprite.color = rgb;
        }
    }
コード例 #3
0
    public void ShuffleBindings(int totalAllowed)
    { //Goes through and rebinds 0-11, None is left at element 12
        for (int i = 11; i > 0; i--)
        {
            int        ran  = Random.Range(0, i);
            EColorFlag temp = colors[i];
            colors[i]   = colors[ran];
            colors[ran] = temp;
        }

        StartCoroutine(RevealKeys(totalAllowed));

        if (prevSelected > -1 && prevSelected < 9)
        {
            buttons[prevSelected].gameObject.transform.GetChild(0).GetComponent <Text>().color = Color.black;
        }

        playerColor = EColorFlag.None;
        playerRenderer.material.SetColor("_Color", EColorRGBHelper.FromSingleFlagToRGB(playerColor));
        miniPlayer.color = EColorRGBHelper.FromSingleFlagToRGB(playerColor);
    }
コード例 #4
0
    private IEnumerator ButtonFade(KeyCode key, int button)
    {
        float   buttonEffectTimer = 0.0f;
        Vector3 buttonScale       = buttons[button].transform.localScale;

        Color startColor = EColorRGBHelper.FromSingleFlagToRGB(colors[button]);

        while (buttonEffectTimer < buttonEffectTimerMax)
        {
            if (Input.GetKeyDown(key) && buttonEffectTimer > .1f)
            {
                yield break;
            }
            buttonEffectTimer += Time.deltaTime;
            Color tempColor = Color.Lerp(startColor, Color.gray, buttonEffectTimer / buttonEffectTimerMax);
            buttons[button].image.color = tempColor;

            yield return(null);
        }

        buttons[button].transform.localScale = buttonScale;
    }
コード例 #5
0
    public void SetNewColor(KeyCode key, int button)
    {
        AudioSource.PlayClipAtPoint(colorChangeSounds[Random.Range(0, colorChangeSounds.Count - 1)], new Vector3(0.0f, 0.0f - 10.0f));
        EColorFlag tempColor = colors[bindings[key]];

        playerRenderer.material.SetColor("_Color", EColorRGBHelper.FromSingleFlagToRGB(tempColor));
        miniPlayer.color            = EColorRGBHelper.FromSingleFlagToRGB(tempColor);
        playerColor                 = tempColor;
        cooldown                    = cooldownMax;
        buttons[button].image.color = EColorRGBHelper.FromSingleFlagToRGB(tempColor);

        StartCoroutine(ButtonFade(key, button));

        if (prevSelected != button)
        {
            if (prevSelected > -1 && prevSelected < 9)
            {
                buttons[prevSelected].gameObject.transform.GetChild(0).GetComponent <Text>().color = Color.black;
            }
            buttons[button].gameObject.transform.GetChild(0).GetComponent <Text>().color = Color.white;
            prevSelected = button;
        }
    }