Beispiel #1
0
    public void Bop(Vector2 posSub, BopType bopType, Player otherPlayer = null)
    {
        if (invincible) return; // Can't get bopped if recently been bopped

        // Bop up, up and away
        if (bopType == BopType.KICKED) {
            bopForce.x = Mathf.Sign(posSub.x);
            rbody.velocity = bopForce;
        }
        // Enable stun particles
        if (bopType != BopType.INKED) {
            Go.killAllTweensWithTarget(stunHalo);
            stunHalo.gameObject.SetActive(true);
            stunHalo.localScale *= 0.7f;

            Go.to(stunHalo, 1.5f, haloConfig);
        }
        // Audiovisual update
        if (bopType == BopType.INKED) {
            // Ink splat
            head.EnableInkSplat();
            isInked = true;
            face.SetFace(Face.FaceType.Surprised);
            _audio.PlayClipOnce("inkhit", 1f * AudioManager.sfxVol, Random.Range(0.4f, 0.7f));
        } else if (bopType == BopType.NOPED) {
            face.SetFace(Face.FaceType.Surprised);
            _audio.PlayClipOnce("kick", 1.5f * AudioManager.sfxVol, 0.5f);
        } else {
            face.SetFace(Face.FaceType.Bopped);
            _audio.PlayClipOnce("kick", 1.5f * AudioManager.sfxVol, 1f);
        }

        invincible = true;
        canControl = false;

        Go.killAllTweensWithTarget(_collider);
        _collider.offset = new Vector2(0, 0.5f);
        _collider.size = new Vector2(1f, 1f);

        // Present-release
        if (hasGift) {
            hasGift = false;
            GameManager.gift.SetFree(posSub, otherPlayer);
        }

        // Time to recover depends on what hit you - ink shooter or other player
        WaitForSeconds wfs = wfs_unBopDelay;
        if (bopType == BopType.INKED) wfs = wfs_unBopInkDelay;
        if (bopType == BopType.NOPED) wfs = wfs_unBopNopeDelay;
        StartCoroutine(ThenUnbop(wfs));
    }