Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        PulseCounter += Time.deltaTime;

        if (PulseCounter >= TargetTime)
        {
            PulseCounter = 0.0f;
            CachedSonarManager.BeginNewSonarPulse(transform.position, NextRange / GlobalStaticVars.GlobalSonarSpeed, NextRange);
            ResetTargetTime();
        }
    }
Exemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        // Set up our vars to make it more accessible
        float ClickInput = Input.GetAxisRaw("Fire1");

        ClickState CurrentClickState = ClickState.NoClick;

        if (ClickInput > 0 && !bLastFrameClickWasDown)
        {
            CurrentClickState = ClickState.FirstFrameDown;
        }
        else if (ClickInput < 1 && bLastFrameClickWasDown)
        {
            CurrentClickState = ClickState.FirstFrameUp;
        }
        else if (ClickInput > 0 && bLastFrameClickWasDown)
        {
            CurrentClickState = ClickState.ClickHeld;
        }
        else if (ClickInput < 1 && !bLastFrameClickWasDown)
        {
            CurrentClickState = ClickState.NoClick;
        }

        // Handle the actual event now
        switch (CurrentClickState)
        {
        case ClickState.FirstFrameUp:
        {
            bIsChargingSonar = false;

            if (CurrentChargeTime > 0.0f)
            {
                if (CurrentChargeTime < MinChargeTime)
                {
                    CurrentChargeTime = MinChargeTime;
                }

                float ChargePercent = CurrentChargeTime / MaxChargeTime;
                float SonarDistance = ChargePercent * MaxSonarDistance;
                float SonarTime     = SonarDistance / GlobalStaticVars.GlobalSonarSpeed;
                CachedSonarManager.BeginNewSonarPulse(transform.position + (Vector3.down * transform.localScale.y), SonarTime, SonarDistance);

                CurrentChargeTime = 0.0f;

                this.GetComponent <AudioSource>().PlayOneShot(ClickSound, ChargePercent);
            }
            break;
        }

        case ClickState.FirstFrameDown:
        {
            bIsChargingSonar = true;
            break;
        }

        case ClickState.ClickHeld:
        {
            CurrentChargeTime += Time.deltaTime;

            if (CurrentChargeTime > MaxChargeTime)
            {
                CurrentChargeTime = MaxChargeTime;
            }
            break;
        }

        default:
        {
            break;
        }
        }

        // Set up our vars for next frame's input
        bLastFrameClickWasDown = ClickInput > 0;
    }