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; } }
// 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(); } } } }