public override void OnStart() { Ball = Agent.getBall().GetComponent <Ball>(); isLeft = Agent.WhichTeam(); Agent = GetComponent <SoccerAgent>(); originPos = Agent.transform.position; }
public override void OnStart() { //Get the agent, ball and team component agent = GetComponent <SoccerAgent>(); Ball = agent.getBall().GetComponent <Ball>(); isLeft = agent.WhichTeam(); }
public override void OnStart() { mAgent = GetComponent <SoccerAgent>(); isLeft = mAgent.WhichTeam(); ballLoaction = mAgent.getBallPosition(); ball = mAgent.getBall().GetComponent <Ball>(); }
private void OnDrawGizmos() { agent = GetComponent <SoccerAgent>(); ball = GameObject.FindGameObjectWithTag("ball"); isLeft = agent.WhichTeam(); Gizmos.color = Color.red; if (Condition.CanGoalKeeper(ball.transform.position, isLeft)) { Gizmos.color = Color.green; } Gizmos.DrawLine(transform.position, ball.transform.position); // Gizmos.DrawWireSphere(transform.position, maxRadius); /* * team.Sort((a, b) => { * return Vector3.Distance(a.transform.position, ball.transform.position).CompareTo(Vector3.Distance(b.transform.position, ball.transform.position)); * }); * * Debug.Log(team[0]); * * Gizmos.color = Color.red; * if (team[0].transform.position == agent.transform.position) { * Gizmos.color = Color.green; * } * * Gizmos.DrawLine(transform.position, ball.transform.position); * * }*/ }
public override TaskStatus OnUpdate() { //Get football position; ballLocation = Agent.getBallPosition(); //Get agent position; agentLocation = Agent.transform.position; //To get into this node the agent must have seen the ball if (Condition.CanKickDefence(agentLocation, ballLocation)) { //if close to the ball if (Condition.CanKickBall(agentLocation, ballLocation)) { //face to the ball ; Agent.transform.LookAt(ballLocation); //Depending on the direction of opponent's goal, give the ball a force; bool isLeft = Agent.WhichTeam(); if (isLeft) { Ball.AddForceBig(ballLocation, Define.RightDoorPosition); } else { Ball.AddForceBig(ballLocation, Define.LeftDoorPosition); } //Return successful; return(TaskStatus.Success); } else { if (Condition.CanDefenceGroup(Agent.WhichTeam(), Agent.transform.position, ballLocation)) { var target = DefenceStrategy.Instance.GetDefenceGroupLocation(Agent, ballLocation, isLeft); Agent.setDestination(target); return(TaskStatus.Running); } else { //agent can defence the ball, but the distance is not enought to kick the ball, so move towards the ball; Agent.setDestination(ballLocation); } return(TaskStatus.Running); } } // return Failure when can't defence the ball; return(TaskStatus.Failure); }
public override void OnStart() { Agent = GetComponent <SoccerAgent>(); Ball = Agent.getBall().GetComponent <Ball>(); isLeft = Agent.WhichTeam(); }
public override void OnStart() { //Get agent Scripts Agent = GetComponent <SoccerAgent>(); isLeft = Agent.WhichTeam(); }
void Start() { agent = GetComponent <SoccerAgent>(); Ball = agent.getBall().GetComponent <Ball>(); isLeft = agent.WhichTeam(); }