protected void Move(Vector3 position) { Agent.SetDestination(position); //Move para o destino Vector2 move = Locomotion.GetDirectionAI(); Speed = move.y; Direction = move.x; }
private void Handle_GoToDefaultState() { //Vou para a minha posição de marcação origem //Marcação de dfesa caso meu time nao tenha a bola, marcação de ataque caso tenha. //Vou finalizar quando: //> Eu estiver com a bola //> Eu chegar ao destino //> Time estiver com bola //> Eu estiver perto da bola if (Player.IsSelected() || BallController.HasOwner() == false) { Stop(); aiState = SoccerAIState.nothing; return; } bool isBallNear = Player.IsBallNear(); if (isBallNear == true && BallController.IsFromTeam(Player) == false) { Speed = 0; aiState = SoccerAIState.nothing; return; } Transform defPos = Player.GetMarcationPosition(CampPlaceType.defense); Transform attkPos = Player.GetMarcationPosition(CampPlaceType.attack); bool myTeamHasBall = Player.IsBallfromMyTeam(); Vector2 move = Locomotion.GetDirectionAI(); Speed = move.y; Direction = move.x; Vector3 destination = myTeamHasBall ? attkPos.position : defPos.position; Agent.SetDestination(destination); //Eu cheguei ao destino if (Locomotion.IsAgentDone) { Stop(); aiState = SoccerAIState.nothing; return; } }
private void Handle_HelpTugState() { PlayerController playerToHelp = Player.GetCampTeam().GetSelectedPlayer(); if (playerToHelp == null) { aiState = SoccerAIState.nothing; return; } if (playerToHelp.Locomotion.isJoint == false || Player.IsBallMostNearUnselectedWithSkillTwo() == false) { aiState = SoccerAIState.nothing; return; } Vector2 move = Locomotion.GetDirectionAI(); Direction = move.x; Speed = move.y; //Seta destino bola ou jogador agarrado PlayerController joitedPlayer = playerToHelp.Locomotion.JoitedPlayer; if (joitedPlayer.IsMyBall() == false) { Agent.SetDestination(joitedPlayer.transform.position); } else { Agent.SetDestination(BallController.GetPosition()); } //Rasteira quando estiver peto if (joitedPlayer.Distance(Player) <= 1.5f) { if (Player.GetSkill_BasicActionTwo().IsReady) { motionType = LocomotionType.normal; if (Player.Locomotion.TriggerActionTwo()) { Player.GetSkill_BasicActionTwo().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); }
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; }
public virtual bool UpdateHandleStates() { if (Locomotion == null) { return(false); } Locomotion.motionType = motionType; if (Locomotion.inStumble) //Tropeçando { Agent.destination = Player.transform.position; Speed = 0; Direction = 0; return(false); } if (motionType == LocomotionType.soccer) { Player.GetSkill_Stamina().mode = SkillVarMode.autoSubtract; } else { Player.GetSkill_Stamina().mode = SkillVarMode.autoRegen; } if (Locomotion.isJoint) { Player.GetSkill_BasicActionOne().mode = SkillVarMode.autoRegen; } else { Player.GetSkill_BasicActionOne().mode = SkillVarMode.autoSubtract; } if (isForcedGoTo) { if (Player.IsMyBall()) { Stop(); isForcedGoTo = false; return(true); } Vector2 move = Locomotion.GetDirectionAI(); Speed = move.y; Direction = move.x; //Lookat Vector3 loockposition = forceLoockat.position; loockposition.y = Player.transform.position.y; Player.transform.LookAt(loockposition); //Move AI Agent.destination = forceGoTo; if (Locomotion.IsAgentDone) { Stop(); isForcedGoTo = false; } return(false); } return(true); }