public float AIClear(PlayerStatePattern pl, DecisionEntery de) { //if desicion entery's special string isnt null then trigger the special. //the attack manager will then handle the rest. if (de.special != null) { AttackManager.Instance.ExecuteAbility(de.special, pl.playerStats); } //create the direction we want to kick the ball. Vector2 kickDirection = Vector2.zero; //check the goal zones. foreach (GoalZone gz in Field.Instance.gz) { //if the goal zone is not our own then create a vector between it an the player. if (gz.team != pl.playerStats.team) { kickDirection = (gz.transform.position - pl.transform.position); } } //normalize the kick direction and remove its Y component. we want to make it cross feild, not anything else. kickDirection.Normalize(); kickDirection = new Vector2(kickDirection.x * pl.playerStats.pass * pl.playerStats.attackStrengthMultiplier * 2, 0); //finally shoot the ball when we are ready! GameManager.Instance.GetComponent <BallKick>().KickBall(kickDirection); pl.dePossessBall(); Debug.Log("clear triggered"); return(waitDelay); }
public IEnumerator CalculateAttack(PlayerStatePattern pl, DecisionEntery de, bool wait) { if (wait) { yield return(new WaitForSeconds(GameManager.Instance.universalAnimationDuration)); } //set up the direction of the attack. Vector2 kickDirection; //base it off of the position of both players then normalize to only get the direction. kickDirection = (de.target.transform.position - pl.transform.position); kickDirection.Normalize(); //take the direction and factor in player attack stats. kickDirection = new Vector2(kickDirection.x * pl.playerStats.attack * pl.playerStats.attackStrengthMultiplier * 4, kickDirection.y * pl.playerStats.attack * pl.playerStats.attackStrengthMultiplier); //calculate the damage the shot should do. float damage = pl.playerStats.attack; //FIRE IN THE HOLE! GameManager.Instance.GetComponent <BallKick>().KickBall(kickDirection); GameManager.Instance.ballReference.GetComponent <BallAttack>().DefaultAttack(damage, GameManager.Instance.defaultAttackDuration, pl.playerStats); pl.dePossessBall(); Debug.Log("Attack Target is: " + de.target); Debug.Log("Attack triggered by " + pl.playerStats.playerName + " towards: " + kickDirection); yield return(null); }
public float AIPass(PlayerStatePattern pl, DecisionEntery de) { //if desicion entery's special string isnt null then trigger the special. //the attack manager will then handle the rest. if (de.special != null) { AttackManager.Instance.ExecuteAbility(de.special, pl.playerStats); } Vector2 kickDirection; kickDirection = (de.target.transform.position - pl.transform.position); kickDirection.Normalize(); kickDirection = new Vector2(kickDirection.x * pl.playerStats.pass * pl.playerStats.attackStrengthMultiplier, kickDirection.y * pl.playerStats.pass * pl.playerStats.attackStrengthMultiplier); GameManager.Instance.GetComponent <BallKick>().KickBall(kickDirection); de.target.SendMessage("IncomingPass"); pl.dePossessBall(); Debug.Log("pass triggered"); return(waitDelay); }