コード例 #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
    private void Update()
    {
        perItemTimer += Time.deltaTime;

        bool shouldIterate = indexInDescription <Description.Count && perItemTimer> currentSpawn.TimeAfterPrevious && currBlock < currentSpawn.blocksInRound;

        if (shouldIterate)
        {
            perItemTimer = 0.0f;
            currBlock++;

            bool shouldSpawn = currentSpawn.AllowedColors != EColorFlag.None;
            if (shouldSpawn)
            {
                GameObject wall = Instantiate(WallPrefab, transform.position, Quaternion.identity, null);
                var        comp = wall.GetComponent <Wall>();
                comp.color = EColorRGBHelper.GetRandomFlagFromFlags(currentSpawn.AllowedColors);
                comp.Speed = currentSpawn.blockSpeed;
            }
        }

        else if (currBlock >= currentSpawn.blocksInRound)
        {
            roundAfterTimer += Time.deltaTime;
            if (indexInDescription == 0 && !AudioManager.bgmPlaying && roundAfterTimer > currentSpawn.TimeAfterAround / 2)
            {
                AudioManager.StartBGM();
            }
            if (roundAfterTimer > currentSpawn.TimeAfterAround)
            {
                roundAfterTimer = 0.0f;
                currBlock       = 0;
                prevIndex       = indexInDescription;
                if (indexInDescription < Description.Count - 1)
                {
                    indexInDescription++;
                }
                currentSpawn = Description[indexInDescription];

                if (prevIndex != indexInDescription)
                {
                    AudioManager.PlayVoice(indexInDescription);
                }

                SetUpAllowedColors();
            }
        }
    }
コード例 #4
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);
    }
コード例 #5
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;
    }
コード例 #6
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;
        }
    }