// Update is called once per frame void Update() { Stamina.Update(); if (Input.GetKeyDown(KeyCode.A)) { Stamina.AddCurrentValue(100); } else if (Input.GetKeyDown(KeyCode.S)) { Stamina.SubCurrentValue(100); } else if (Input.GetKeyDown(KeyCode.Space)) { Stamina.TriggerCooldown(); } }
private void Handle_FollowBallState() { //Indo atraz da bola se estiver perto bool isBallNear = Player.IsBallMostNear(); bool teamHasBall = Player.IsBallfromMyTeam(); if (isBallNear == false || teamHasBall == true || Player.IsMyBall() || Player.IsSelected()) { Stop(); aiState = SoccerAIState.nothing; return; } Vector3 ballPosition = BallController.GetPosition(); ballPosition.y = Player.transform.position.y; //Rasteira ou acao secundaria PlayerController enemyforward; SkillVar skill = Player.GetSkill_BasicActionTwo(); if (Player.IsHitForwad(0.5f, out enemyforward, Player.GetCampTeam().Enemy())) { if (skill.IsReady) { motionType = LocomotionType.normal; if (Locomotion.TriggerPass()) { skill.TriggerCooldown(); } } } Vector2 move = Locomotion.GetDirectionAI(); Direction = move.x; Speed = move.y; Agent.SetDestination(ballPosition); }
//Ativamos a canvas e o icone de injuried para que seja apresentado visualmente o cooldown private void OnTripingStar() { canvas.gameObject.SetActive(true); injuried.panel.gameObject.SetActive(true); injuried.TriggerCooldown(); }
void Update() { if (player == null) { return; } //Seleciona outro jogador manual mais proximo se eu estiver muito longe da bola if (player.GetCampTeam().GetSelectionMode() == GameOptionMode.automatric && player.GetCampTeam().HasPlayerOk() && !player.Locomotion.inHoldTug && !player.Locomotion.isJoint && playerToPass == null) { timeToSelect += Time.deltaTime; if (timeToSelect > 1.5f) { if (player.Distance(BallController.GetPosition()) > 3.5f || player.isOk == false) //Procurando jogador mais proximo { PlayerController nearBall = GameManager.instance.GetPlayerNearBall(player.GetCampTeam()); if (nearBall != player) { speed = 0; dir = 0; nearBall.SelectME(); timeToSelect = 0.0f; return; } } } } //Loockat na bola se estiver em strafe if (locomotion.inStrafe) { locomotion.ResetSpeedMultiples(); Vector3 ballposition = BallController.GetPosition(); ballposition.y = transform.position.y; transform.LookAt(ballposition); } //Gerenciamento de stamina if (locomotion.inSoccer) { SkillVar stamina = player.GetSkill_Stamina(); stamina.mode = SkillVarMode.autoSubtract; if (stamina.IsMin || player.isOk == false) { player.GetSkill_Stamina().mode = SkillVarMode.autoRegen; locomotion.ResetSpeedMultiples(); player.SetMotionNormal(); } } //Para ações manuais se estiver tropeçando if (player.Locomotion.inStumble)//Tropeçando { locomotion.ResetSpeedMultiples(); speed = 0; dir = 0; return; } //Solicita avoid dos aliados a frente if (player.IsMyBall()) { PlayerController allyBtw = null; if (player.IsHitForwad(5.5f, out allyBtw, player.GetCampTeam())) { if (allyBtw.IsLookAt(player)) { Vector3 origim = allyBtw.transform.position + (-allyBtw.transform.forward * 4.5f); Vector3 freePos = locomotion.GetRandomNavCircle(origim, 4.5f); allyBtw.GetComponent <AIController>().GoToPosition(freePos, BallController.instance.transform); } } } //Se houver um jogador selecionado para o passe de bola vou esperar ficar distante que o jogador efetue alguma ação difernte de se mover //para remover a seleção do jogador a passar a bola if (playerToPass != null) { if (playerToPass.Distance(player) > 11.5f) { playerToPass = null; GameManager.instance.ResetIndicator(); } } Vector2 move = locomotion.GetDirectionAxis1(); dir = move.x; speed = move.y; //Fill kick power amount if (ControllerInput.GetButtonDown(player.GetInputType(), player.GetInputs().Input_Kick)) { //Fill kick power or fill action2 power SkillVar skillKick = player.GetSkill_BasicKick(); if (player.IsMyBall()) { skillKick.SetToggle(); if (skillKick.IsReady) { skillKick.mode = SkillVarMode.autoRegen; } } playerToPass = null; GameManager.instance.ResetIndicator(); } //Kick ball if (ControllerInput.GetButtonUp(player.GetInputType(), player.GetInputs().Input_Kick)) { //Fill kick power if is myBall SkillVar skillKick = player.GetSkill_BasicKick(); locomotion.ResetHoldTugAnimator(); if (player.IsMyBall() && skillKick.isToggle) { if (skillKick.IsReady) { if (locomotion.TriggerKick()) { skillKick.TriggerCooldown(); } } } skillKick.mode = SkillVarMode.nothing; skillKick.SetCurrentValue(0); skillKick.ResetTogle(); playerToPass = null; GameManager.instance.ResetIndicator(); } //Soccer Motion if (ControllerInput.GetButton(player.GetInputType(), player.GetInputs().Input_Stamina)) { SkillVar Stamina = player.GetSkill_Stamina(); if (Stamina.IsCritical == false && player.isOk) { // playerToPass = null; // GameManager.instance.ResetIndicator(); player.SetMotionSoccer(); player.Locomotion.SetSpeedMultiplies(1.2f); } } if (ControllerInput.GetButtonUp(player.GetInputType(), player.GetInputs().Input_Stamina)) { // playerToPass = null; // GameManager.instance.ResetIndicator(); player.Locomotion.ResetSpeedMultiples(); player.SetMotionNormal(); player.GetSkill_Stamina().mode = SkillVarMode.autoRegen; } //Strafe Motion if (ControllerInput.GetButtonDown(player.GetInputType(), player.GetInputs().Input_Strafe)) { // playerToPass = null; // GameManager.instance.ResetIndicator(); player.SetMotionStrafe(); player.Locomotion.SetSpeedMultiplies(1.2f); } if (ControllerInput.GetButtonUp(player.GetInputType(), player.GetInputs().Input_Strafe)) { // playerToPass = null; // GameManager.instance.ResetIndicator(); player.Locomotion.ResetSpeedMultiples(); player.SetMotionNormal(); } //Seleção para passe de bola if (ControllerInput.GetButton(player.GetInputType(), player.GetInputs().Input_Pass)) { if (player.IsMyBall() == true && locomotion.inNormal) { Vector3 mdirection = transform.forward; List <PlayerController> players = player.GetPlayersNear(10.5f); if (players.Count > 0) { PlayerController target = players.MinAngle(player, mdirection); playerToPass = target; GameManager.instance.IndicatePlayer(playerToPass); } } } //Rasteira if (ControllerInput.GetButtonDown(player.GetInputType(), player.GetInputs().Input_Pass)) { if (player.IsMyBall() == false && locomotion.inNormal) { SkillVar skilltrack = player.GetSkill_BasicActionTwo(); if (skilltrack.IsReady) { if (locomotion.TriggerActionTwo()) { skilltrack.TriggerCooldown(); } } } } //Passe de bola if (ControllerInput.GetButtonUp(player.GetInputType(), player.GetInputs().Input_Pass)) { //playerToPass = null; //GameManager.instance.ResetIndicator(); SkillVar skillPass = player.GetSkill_BasicPass(); if (skillPass.IsReady && player.IsMyBall()) { if (locomotion.inNormal) { if (locomotion.TriggerPass()) { skillPass.TriggerCooldown(); } else { playerToPass = null; GameManager.instance.ResetIndicator(); } } } else { playerToPass = null; GameManager.instance.ResetIndicator(); } } //JUMP if (ControllerInput.GetButtonDown(player.GetInputType(), player.GetInputs().Input_Jump)) { locomotion.jump = true; } if (ControllerInput.GetButtonUp(player.GetInputType(), player.GetInputs().Input_Jump)) { locomotion.jump = false; } }
private void Handle_FollowBallState() { //Corre atraz da bola se ela estiver a uma distancia aceitavel ou procura um jogador mais proximo //enquanto continua indo atraz da bola. //Ação finalizada se: Jogador deixar de estar selecionado ou pegar a bola if (Player.IsMyBall() || !Player.IsSelected()) { Stop(); aiState = SoccerAIState.nothing; return; } Vector3 goTotarget = BallController.GetPosition(); BallController ball = BallController.instance; float balldistance = ball.transform.Distance(Player.transform); //Ativa movimento soccer se tiver stamina e estiver muito longe da bola if (balldistance > 5.0f && Player.isOk) { if (Player.GetSkill_Stamina().IsCritical == false) { motionType = LocomotionType.soccer; } else if (Player.GetSkill_Stamina().IsMin) { motionType = LocomotionType.normal; } } else { motionType = LocomotionType.normal; } SkillVar skillTug = Player.GetSkill_BasicActionOne(); SkillVar skillTrak = Player.GetSkill_BasicActionTwo(); //Ação Rasteira if (skillTrak.IsReady && Player.Locomotion.isJoint == false) { //Rasteira ou acao secundaria de poce de bola PlayerController enemyforward; if (Player.IsHitForwad(0.2f, out enemyforward, Player.GetCampTeam().Enemy())) { motionType = LocomotionType.normal; if (Locomotion.TriggerActionTwo()) { skillTrak.TriggerCooldown(); } } } //Ação TugOfWar if (!skillTrak.IsReady && skillTug.IsReady && Player.Locomotion.isJoint == false) { PlayerController enemy = Player.GetEnemyNear(); if (enemy != null) { if (enemy.Distance(Player) <= 1.5f && enemy.IsMyBall()) { Player.Locomotion.SetHoldTugAnimator(); } else { Player.Locomotion.ResetHoldTugAnimator(); } } } else if (Player.Locomotion.isJoint) { Player.Locomotion.ResetHoldTugAnimator(); goTotarget = Player.GetEnemyGoalPosition().position; if (skillTug.IsMax || Locomotion.JoitedPlayer.IsMyBall() == false) { skillTug.TriggerCooldown(); skillTug.SetCurrentValue(0); Player.GetTugOfWar().RemoveJoint(); } } //Verifica a distancia da bola, se estiver muito longe procuro outor jogador mais proximo para selecionar if (Player.GetCampTeam().GetSelectionMode() == GameOptionMode.automatric && Player.GetCampTeam().HasPlayerOk() && !Player.Locomotion.isJoint) { timeToSelect += Time.deltaTime; if (timeToSelect > 1.5f) { if (balldistance > 3.5f || Player.isOk == false) //Procurando jogador mais proximo { PlayerController nearBall = GameManager.instance.GetPlayerNearBall(Player.GetCampTeam()); if (nearBall != Player) { nearBall.SelectME(); timeToSelect = 0.0f; } } } } //Corre atraz do trajeto Agent.SetDestination(goTotarget); Vector2 move = Locomotion.GetDirectionAI(); Speed = move.y; Direction = move.x; }
// Update is called once per frame void Update() { SmootIKWeight(); PlayerController mnPlayer; mnPlayer = player.GetPlayerNear(); //Estica maos para o jogaodr mais proximo HandleHandsTo(mnPlayer); if (jointPlayer) { if (!player.isOk || player.Locomotion.inStumble || player.Locomotion.inTrack || player.IsMyBall() || !jointPlayer.isOk || !player.GetSkill_BasicActionOne().IsReady ) { RemoveJoint(); } } else if (player.Locomotion.inHoldTug) { if (mnPlayer != null && !player.Locomotion.inAir && player.isOk && !mnPlayer.IsMyTeaM(player)) { float dist = mnPlayer.Distance(player); if (dist <= tugWarDistance && dist > 0.5f && mnPlayer.isOk && !mnPlayer.Locomotion.inAir) { //JOINT player.Locomotion.JointTo(mnPlayer); jointPlayer = mnPlayer; jointPlayer.GetAnimatorEvents().OnChangeDirStart += EnemyOnChangeDir; } } } //CONTROLE MANUAL if (!player.IsIA) { if (player.IsMyBall() || player.isOk == false) { if (player.Locomotion.inHoldTug) { player.Locomotion.ResetHoldTugAnimator(); } player.GetSkill_BasicActionOne().mode = SkillVarMode.autoSubtract; return; } if (ControllerInput.GetButton(player.GetInputType(), player.GetInputs().Input_Kick) && player.isOk) { SkillVar skilltug = player.GetSkill_BasicActionOne(); skilltug.SetToggle(); if (skilltug.IsMax) { skilltug.TriggerCooldown(); } if (skilltug.IsReady) { skilltug.mode = SkillVarMode.autoRegen; if (jointPlayer == null) { player.Locomotion.SetHoldTugAnimator(); } else { player.Locomotion.ResetHoldTugAnimator(); } } else { skilltug.SetCurrentValue(0); skilltug.mode = SkillVarMode.nothing; player.Locomotion.ResetHoldTugAnimator(); } } if (ControllerInput.GetButtonUp(player.GetInputType(), player.GetInputs().Input_Kick)) { SkillVar skilltug = player.GetSkill_BasicActionOne(); if (skilltug.isToggle == false) { return; } skilltug.mode = SkillVarMode.autoSubtract; player.Locomotion.ResetHoldTugAnimator(); skilltug.ResetTogle(); if (skilltug.IsReady) { RemoveJoint(); } } } }