コード例 #1
0
    public bool Flap(ControlDir dir)
    {
        if (dc.stunned || !readInput)
        {
            return(false);
        }
        int idir = dir == ControlDir.LEFT ? -1 : 1;

        // Physics
        Vector2 flap = flapVelocity;

        flap.x       *= idir;
        rb2d.velocity = flap;

        // Art Effects
        Turn(idir);
        anim.SetBool("Flap", true);
        AudioSource.PlayClipAtPoint(flapSound, Camera.main.transform.position, flapVolume);

        if (OnFlap != null)
        {
            OnFlap.Invoke();
        }

        chargeTimer = 0;

        return(true);
    }
コード例 #2
0
    private void Flap()
    {
        Transform closest = ClosestDragon();

        if (closest == null)
        {
            flapController.Flap(RandomDir());
            return;
        }

        Vector3 dp    = transform.position - closest.position;
        bool    close = Mathf.Abs(dp.x) < flapMinTowards;
        bool    above = dp.y > 0;
        bool    right = dp.x > 0;

        if (above && close)
        {
            // Fall into a slam!
            return;
        }
        else if (!above && close)
        {
            // Flap away
            flapDir = right ? ControlDir.RIGHT : ControlDir.LEFT;
            flapController.Flap(flapDir);
        }
        else
        {
            // Far away, above or below doesn't matter
            flapDir = right ? ControlDir.LEFT : ControlDir.RIGHT;
            flapController.Flap(flapDir);
        }
    }
コード例 #3
0
    public bool Release(ControlDir dir)
    {
        if (dc.stunned || !readInput)
        {
            return(false);
        }
        int idir = dir == ControlDir.LEFT ? -1 : 1;

        if (charged)
        {
            ShootProjectile(idir);
            Charged = false;
        }
        anim.SetBool("Flap", false);
        chargeTimer = -1;
        return(true);
    }