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); }
void UpdatePASS() { if (game.Ball.Owner == Controlled /* && game.Ball.inZone == null*/) { int side = 0; if (stickDirection.x > 0.1f) { side = 1; } else if (stickDirection.x < 0.1f) { side = -1; } if (game.refs.managers.camera.TeamLooked == game.northTeam) { side *= -1; } if (Input.GetKeyDown(Inputs.shortPass.keyboard(this.Team)) || XboxController.GetButtonDown(Inputs.shortPass.xbox)) { List <Unit> listToCheck = null; if (side > 0) { listToCheck = Controlled.Team.GetRight(Controlled); } else if (side < 0) { listToCheck = Controlled.Team.GetLeft(Controlled); } if (listToCheck.Count > 0) { foreach (Unit u in listToCheck) { if (u.typeOfPlayer == Unit.TYPEOFPLAYER.OFFENSIVE) { if (Controlled.Team == game.southTeam) { if (u.transform.position.z < Controlled.transform.position.z && u.canCatchTheBall) { //Debug.Log("try to pass to " + u); unitTo = u; passSide = 1; break; } else { unitTo = null; } } else if (Controlled.Team == game.northTeam) { if (u.transform.position.z > Controlled.transform.position.z && u.canCatchTheBall) { //Debug.Log("try to pass to " + u); u.canCatchTheBall = true; unitTo = u; passSide = -1; break; } else { unitTo = null; } } } } } else { unitTo = null; return; } } else if (Input.GetKeyDown(Inputs.longPass.keyboard(this.Team)) || XboxController.GetButtonDown(Inputs.longPass.xbox)) { List <Unit> listToCheck = null; if (side > 0) { listToCheck = Controlled.Team.GetRight(Controlled); } else if (side < 0) { listToCheck = Controlled.Team.GetLeft(Controlled); } if (listToCheck.Count > 0) { foreach (Unit u in listToCheck) { if (u.typeOfPlayer == Unit.TYPEOFPLAYER.DEFENSE) { if (Controlled.Team == game.southTeam) { if (u.transform.position.z < Controlled.transform.position.z && u.canCatchTheBall) { //Debug.Log("try to pass to " + u); unitTo = u; break; } else { unitTo = null; } } else if (Controlled.Team == game.northTeam) { if (u.transform.position.z > Controlled.transform.position.z && u.canCatchTheBall) { //Debug.Log("try to pass to " + u); u.canCatchTheBall = true; unitTo = u; break; } else { unitTo = null; } } } } } else { unitTo = null; return; } } else if ( Input.GetKeyUp(Inputs.shortPass.keyboard(this.Team)) || Input.GetKeyUp(Inputs.longPass.keyboard(this.Team)) || XboxController.GetButtonUp(Inputs.shortPass.xbox) || XboxController.GetButtonUp(Inputs.longPass.xbox)) { UpdatePASS_OnRelease(); } } if (onActionCapture) { timeOnActionCapture += Time.deltaTime; } else { timeOnActionCapture = 0.0f; } }