コード例 #1
0
    public IEnumerator SetBoost(float time)
    {
        GameObject newBar = Instantiate(powerBar);

        newBar.transform.parent = gameObject.transform;
        PowerBar newBarScript = newBar.GetComponent <PowerBar>();

        newBarScript.SetPosition();

        newBarScript.ChangeActive(true);
        newBarScript.SetColor(colorManager.GetColor("orange"));

        float time_left = time;

        while (time_left > 0)
        {
            m_currentSpeed_y = p_speed_y * (1 + p_boostPercentage / 100);
            m_currentSpeed_x = p_speed_x * (1 + p_boostPercentage / 100);
            time_left       -= Time.deltaTime;
            newBarScript.SetFill(time_left / time);
            yield return(null);
        }
        m_currentSpeed_y = p_speed_y;
        m_currentSpeed_x = p_speed_x;
        newBarScript.DestroyBar();
    }
コード例 #2
0
    public IEnumerator Invincibility(float time)
    {
        invincible = true;
        GameObject newBar       = Instantiate(powerBar);
        PowerBar   newBarScript = newBar.GetComponent <PowerBar>();

        newBar.transform.parent = gameObject.transform;
        newBarScript.SetPosition();

        invincibilityStar.SetActive(true);
        newBarScript.SetColor(colorManager.GetColor("purple"));

        float time_left      = time;
        float blink_start    = time / 5;
        float blink_interval = .5f;
        float blink_timer    = 0;
        bool  on             = true;

        while (time_left > 0)
        {
            invincible = true;
            if (time_left <= blink_start)
            {
                if (blink_timer <= 0)
                {
                    if (on)
                    {
                        invincibilityStar.SetActive(false);
                        on          = false;
                        blink_timer = blink_interval;
                    }
                    else
                    {
                        invincibilityStar.SetActive(true);
                        on          = true;
                        blink_timer = blink_interval;
                    }
                }
                blink_timer -= Time.deltaTime;
            }
            time_left -= Time.deltaTime;
            newBarScript.SetFill(time_left / time);
            yield return(null);
        }
        invincible = false;
        invincibilityStar.SetActive(false);
        newBarScript.DestroyBar();
    }
コード例 #3
0
    public IEnumerator Overdrive(float time)
    {
        GameObject newBar       = Instantiate(powerBar);
        PowerBar   newBarScript = newBar.GetComponent <PowerBar>();

        newBar.transform.parent = gameObject.transform;
        newBarScript.SetPosition();

        m_overdrive = true;
        newBarScript.ChangeActive(true);
        newBarScript.SetColor(colorManager.GetColor("green"));
        colorManager.Cancel();
        float time_left = time;
        float shotCD    = 0;
        //Get Rainbow Scoop
        GameObject rainbowScoop = colorManager.GetRainbowScoop();

        while (time_left > 0)
        {
            m_overdrive = true;
            time_left  -= Time.deltaTime;
            newBarScript.SetFill(time_left / time);
            if (shotCD <= 0)
            {
                Shoot(rainbowScoop);
                shotCD = p_overdriveShotInterval;
            }
            else
            {
                shotCD -= Time.deltaTime;
            }

            yield return(null);
        }
        m_overdrive = false;
        newBarScript.DestroyBar();
    }