Example #1
0
    private float GetSmashResult(out bool used)
    {
        float smash = 0;

        used = false;

        InputSettings inputs = game.settings.Inputs;

        XboxInputs.Controller southCtrl = game.southTeam.Player.XboxController;
        XboxInputs.Controller northCtrl = game.northTeam.Player.XboxController;

        bool smashSouth = southCtrl.GetButtonDown(inputs.smashButton.xbox) || Input.GetKeyDown(inputs.smashButton.keyboard(game.southTeam));
        bool smashNorth = northCtrl.GetButtonDown(inputs.smashButton.xbox) || Input.GetKeyDown(inputs.smashButton.keyboard(game.northTeam));

        bool superSouth = southCtrl.GetButtonDown(inputs.superButton.xbox) || Input.GetKeyDown(inputs.superButton.keyboard(game.southTeam));
        bool superNorth = northCtrl.GetButtonDown(inputs.superButton.xbox) || Input.GetKeyDown(inputs.superButton.keyboard(game.northTeam));

        if (smashSouth)
        {
            smash            += this.settings.SmashValue;
            this.SuperLoading = Mathf.Min(1, this.SuperLoading + this.settings.FeedSuperPerSmash);
            this.ScrumBloc.FeedBackSmash(game.southTeam);
        }

        if (smashNorth)
        {
            smash            -= this.settings.SmashValue;
            this.SuperLoading = Mathf.Min(1, this.SuperLoading + this.settings.FeedSuperPerSmash);
            this.ScrumBloc.FeedBackSmash(game.northTeam);
        }

        if (this.SuperLoading == 1)
        {
            int super = 0;

            if (superSouth)
            {
                super += 1;
                used   = true;
            }

            if (superNorth)
            {
                super -= 1;
                used   = true;
            }

            if (used)
            {
                this.InvincibleTime = settings.InvincibleCooldown;
                this.SuperLoading   = 0;
                smash += super * this.settings.SuperMultiplicator * this.settings.SmashValue;

                var audio = this.game.refs.CameraAudio["SuperScrum"];
                audio.volume = 1;
                audio.PlayOneShot(game.refs.sounds.SuperScrum);

                audio        = this.game.refs.CameraAudio["SuperScrumSuccess"];
                audio.volume = 1;
                audio.PlayOneShot(game.refs.sounds.SuperScrumSuccess);

                if (super != 0)
                {
                    Team t = game.southTeam;
                    if (super != 1)
                    {
                        t = game.northTeam;
                    }

                    game.refs.gameObjects.ScrumBloc.PushFor(t);
                }
            }
        }
        else
        {
            if (InvincibleTime > 0)
            {
                InvincibleTime -= Time.deltaTime;
            }
            else
            {
                bool fail = false;

                if (superSouth)
                {
                    this.MalusSouth = Time.time;
                    smash          -= this.settings.SmashValue * this.settings.MalusValue;
                    southCtrl.SetLeftVibration(0.8f, 0.4f);
                    fail = true;
                }

                if (superNorth)
                {
                    this.MalusNorth = Time.time;
                    smash          += this.settings.SmashValue * this.settings.MalusValue;
                    northCtrl.SetLeftVibration(0.8f, 0.4f);
                    fail = true;
                }

                if (fail)
                {
                    var audio = this.game.refs.CameraAudio["SuperScrum"];
                    audio.volume = 1;
                    audio.PlayOneShot(game.refs.sounds.SuperScrum);

                    audio        = this.game.refs.CameraAudio["SuperScrumFail"];
                    audio.volume = 1;
                    audio.PlayOneShot(game.refs.sounds.SuperScrumFail);
                }
            }
        }

        return(smash);
    }