public void Update() { BallController ballControlerScript = BallUtils.FetchBallControllerScript(FieldBall); if (TargetPlayerToTagOut != null && PlayerUtils.HasFielderPosition(this.gameObject)) { Target = TargetPlayerToTagOut.transform.position; } else if (HasSpottedBall && FieldBall.activeInHierarchy && !IsHoldingBall && ballControlerScript.IsTargetedByFielder) { Target = FieldBall.transform.position; } if (Target.HasValue && Target.Value != this.transform.position) { MovePlayer(); this.IsPrepared = true; } else { PlayerStatus playerStatus = PlayerUtils.FetchPlayerStatusScript(this.gameObject); if (playerStatus.IsAllowedToMove) { this.InitiateFielderAction(); } } }
/** * Default constructor. */ public BallHitEvent(string _paddleID_) : base(_Event.BALL_HIT) { ballPosition = BallUtils.GetBallPosition(); leftPosition = GeneralUtils.GetHumanPosition(); rightPosition = GeneralUtils.GetAgentPosition(); paddleSize = GeneralUtils.GetPaddleSize(_paddleID_); }
/** * This function updates the environment to reflect the selected * difficulty level. */ public static void UpdateEnvironmentDifficulty(byte _diff_) { byte currConfig = GeneralUtils.GetCurrentConfig(); //if easy if (_diff_ == Match.EASY) { if (!GeneralUtils.IsRally(currConfig)) { SetPaddleSize(PADDLE_SIZE_LARGE, PADDLE_SIZE_LARGE / PADDLE_SIZE_MEDIUM * PADDLE_WIDTH_MEDIUM); } BallUtils.SetBallSize(BALL_RADIUS_LARGE); m_agentScript.mySkillLevel = AGENT_SKILL_RANDOM; } //if medium else if (_diff_ == Match.MEDIUM) { if (!GeneralUtils.IsRally(currConfig)) { SetPaddleSize(PADDLE_SIZE_MEDIUM, PADDLE_WIDTH_MEDIUM); } BallUtils.SetBallSize(BALL_RADIUS_MEDIUM); m_agentScript.mySkillLevel = AGENT_SKILL_NORMAL; } //if hard else if (_diff_ == Match.HARD) { if (!GeneralUtils.IsRally(currConfig)) { SetPaddleSize(PADDLE_SIZE_SMALL, PADDLE_SIZE_SMALL / PADDLE_SIZE_MEDIUM * PADDLE_WIDTH_MEDIUM); } BallUtils.SetBallSize(BALL_RADIUS_SMALL); m_agentScript.mySkillLevel = AGENT_SKILL_FAST; } }
private void OnTriggerStay2D(Collider2D collision) { if (ColliderUtils.HasBallCollided(collision)) { GameObject player = this.gameObject.transform.parent.parent.parent.gameObject; GameObject ballGameObject = collision.gameObject; BallController ballControlerScript = BallUtils.FetchBallControllerScript(ballGameObject); PlayerStatus currentPlayerStatus = PlayerUtils.FetchPlayerStatusScript(player); GenericPlayerBehaviour genericPlayerBehaviourScript = PlayerUtils.FetchCorrespondingPlayerBehaviourScript(player, currentPlayerStatus); if (ballControlerScript.IsMoving && ballControlerScript.IsHit && !ballControlerScript.IsPitched) { if (PlayerUtils.HasPitcherPosition(player) && !ballControlerScript.IsTargetedByFielder && !ballControlerScript.IsInFoulState) { ballControlerScript.IsTargetedByPitcher = true; ((PitcherBehaviour)genericPlayerBehaviourScript).CalculatePitcherTriggerInterraction(ballGameObject, genericPlayerBehaviourScript, currentPlayerStatus); } if (PlayerUtils.HasFielderPosition(player) && !ballControlerScript.IsTargetedByFielder && !ballControlerScript.IsTargetedByPitcher && !ballControlerScript.IsInFoulState) { GameObject nearestFielder = TeamUtils.GetNearestFielderFromGameObject(ballGameObject); PlayerStatus nearestFielderStatus = PlayerUtils.FetchPlayerStatusScript(nearestFielder); if (nearestFielderStatus.PlayerFieldPosition == currentPlayerStatus.PlayerFieldPosition) { ((FielderBehaviour)genericPlayerBehaviourScript).CalculateFielderTriggerInterraction(genericPlayerBehaviourScript); } } } } }
/** * This function returns the time series tuple for the current frame. * formate:"ts,mID,mDiff,mType,Lx,Ly,Rx,Ry,Bx,By,Lvel,Rvel,Bvel,Plen,H1input,H2input,composInput,Lscore,Rscore\n" * ts: timestamp * mID: match ID * mDiff: match difficulty * mType: match type * Lx,Ly: left paddle x and y position * Rx,Ry: right paddle x and y position * Bx,By: ball x and y position * Lvel: left paddle velocity * Rvel: right paddle velocity * Bvel: ball velocity * Plen: paddle length * H1input: human 1 input * H2input: human 2 input (if not applicable, then value is 9999) * composInput: composite input of both human players (if not applicable, then value is 9999) * Lscore: left paddle score * Rscore: right paddle score * */ public static string GetTimeSeriesTuple() { string t; Vector2 garbage = BallUtils.GetBallVelocity(); //TODO: please figure out why removing this breaks everything t = GeneralUtils.GetTimeStamp() + "," + GeneralUtils.m_dataScript.currMatchNum.ToString() + "," + GeneralUtils.GetCurrentMatch().difficulty.ToString() + "," + GeneralUtils.GetCurrentConfig().ToString() + "," + GeneralUtils.GetHumanPosition().x.ToString() + "," + GeneralUtils.GetHumanPosition().y.ToString() + "," + GeneralUtils.GetAgentPosition().x.ToString() + "," + GeneralUtils.GetAgentPosition().y.ToString() + "," + BallUtils.GetBallPosition().x.ToString() + "," + BallUtils.GetBallPosition().y.ToString() + "," + VelocityUtils.GetVelocity("leftPaddle").ToString() + "," + VelocityUtils.GetVelocity("rightPaddle").ToString() + "," + VelocityUtils.GetVelocity("ball").ToString() + "," + GeneralUtils.GetPaddleSize("Left") + "," + GeneralUtils.GetPaddleSize("Right") + "," + GeneralUtils.GetHumanInput(1).ToString() + "," + GeneralUtils.GetHumanInput(2).ToString() + "," + GeneralUtils.GetHumanInput(3).ToString() + "," + GeneralUtils.GetPlayerScore("Left").ToString() + "," + GeneralUtils.GetPlayerScore("Right").ToString() + "\n"; return(t); }
public override void Start() { base.Start(); IsoRenderer.LastDirection = 4; IsoRenderer.SetDirection(Vector2.zero); IsoRenderer.PreferredDirection = 4; ballControlerScript = BallUtils.FetchBallControllerScript(FieldBall); }
public void CalculatePitcherTriggerInterraction(GameObject ballGameObject, GenericPlayerBehaviour genericPlayerBehaviourScript, PlayerStatus playerStatus) { BallController ballControlerScript = BallUtils.FetchBallControllerScript(ballGameObject); ballControlerScript.IsTargetedByPitcher = true; genericPlayerBehaviourScript.HasSpottedBall = true; playerStatus.IsAllowedToMove = true; genericPlayerBehaviourScript.Target = ballGameObject.transform.position; this.transform.rotation = Quaternion.identity; }
/** * Default constructor. */ public MatchEndEvent() : base(_Event.MATCH_END) { ballPosition = BallUtils.GetBallPosition(); leftPosition = GeneralUtils.GetHumanPosition(); rightPosition = GeneralUtils.GetAgentPosition(); paddleSize = GeneralUtils.GetPaddleSize("Left"); matchDuration = GeneralUtils.TimeSinceMatchBegan(); LeftScore = GeneralUtils.GetPlayerScore("Left"); RightScore = GeneralUtils.GetPlayerScore("Right"); }
public void AimForTheBall(GenericPlayerBehaviour playerBehaviour) { GameObject player = playerBehaviour.gameObject; PlayerStatus playerStatus = PlayerUtils.FetchPlayerStatusScript(player); BallController ballControlerScript = BallUtils.FetchBallControllerScript(BallGameObject); ballControlerScript.IsTargetedByFielder = true; playerBehaviour.HasSpottedBall = true; playerStatus.IsAllowedToMove = true; playerBehaviour.Target = ballGameObject.transform.position; player.transform.rotation = Quaternion.identity; }
void Start() { bmAuto = new BallMovementAutomaton(); agentComm = GameObject.Find("Agent").GetComponent <AgentInput>(); ballLaunced = false; ballCollidedPaddle = false; timeThreshold = 25; //milliseconds timeOfLastCurrPosCapture = DateTime.Now; prevBx = 0F; currBx = 0F; currPos = BallUtils.GetBallPosition(); posSamples = new PositionSamples(currPos); }
private void OnTriggerEnter2D(Collider2D collision) { if (ColliderUtils.HasBallCollided(collision)) { GameObject ball = collision.gameObject; BallController ballControllerScript = BallUtils.FetchBallControllerScript(ball); if (ballControllerScript.IsHit) { ballControllerScript.IsInFoulState = true; } } }
/** * This function calculates the destination of the agent paddle. */ public static Vector2 GetAgentDestination() { Vector2 intersection; Vector2 b = BallUtils.GetBallPosition(); Vector2 v = BallUtils.GetBallVelocity(); float m = (v.x == 0 ? 0 : (v.y / v.x)); float x_dest = 42.47662F; float y_intercept = ((-1F * b.x * v.y) / v.x) + b.y; intersection = new Vector2(x_dest, m * x_dest + y_intercept); return(intersection); }
/** * Static constructor. */ public static void InitGeneralUtils() { BallUtils.InitBallUtilities(); NetUtils.InitNetUtils(); m_mainScript = GameObject.Find("ScriptHub").GetComponent <Main>(); m_agentScript = GameObject.Find("Agent").GetComponent <AgentInput>(); m_humanScript = GameObject.Find("P1").GetComponent <HumanInput>(); m_sessionScript = GameObject.Find("ScriptHub").GetComponent <SessionBehavior>(); m_menuScript = GameObject.Find("ScriptHub").GetComponent <MenuBehavior>(); m_ballScript = GameObject.Find("Ball").GetComponent <BallBehavior>(); m_dataScript = GameObject.Find("ScriptHub").GetComponent <DataManger>(); ROLE_SERVER = 0; ROLE_CLIENT = 1; HUMAN_ID = 0; HUMAN_LEFT = 2; HUMAN_RIGHT = 3; AGENT_ID = 1; AGENT_SKILL_RANDOM = 0; AGENT_SKILL_NORMAL = 1; AGENT_SKILL_FAST = 2; RALLY_ID = 2; UNASSIGNED = 10; INPUT_KEYBOARD = 0; INPUT_MOUSE = 1; INPUT_HYDRA = 2; BALL_RADIUS_LARGE = 2; BALL_RADIUS_MEDIUM = 1; BALL_RADIUS_SMALL = 0.5F; PADDLE_SIZE_LARGE = 9.0757605F; //150% PADDLE_SIZE_MEDIUM = 6.050507F; //100% PADDLE_SIZE_SMALL = 4.53788025F; //75% PADDLE_WIDTH_MEDIUM = 7.41716F; RASyN_IP = "127.0.0.1"; RASyN_PORT_MAP = new Dictionary <string, int> (); PONG_SERVER_ID = "PongServer"; PONG_CLIENT1_ID = "PongClient1"; PONG_CLIENT2_ID = "PongClient2"; ASSIGNED_PONG_CLIENT_ID = "NULL"; RASyN_PORT_MAP.Add(PONG_SERVER_ID, 19000); RASyN_PORT_MAP.Add(PONG_CLIENT1_ID, 19011); RASyN_PORT_MAP.Add(PONG_CLIENT2_ID, 19012); jss = new JsonSerializerSettings(); jss.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; jss.MissingMemberHandling = MissingMemberHandling.Ignore; //jss.PreserveReferencesHandling = PreserveReferencesHandling.Objects; DRAW_TIMEOUT = 1000 * 60; //60 second timeout in milliseconds BallUtils.InitBallUtilities(); NetUtils.InitNetUtils(); rallyCfg = new RallyConfiguration(Application.dataPath + "/Config/RallyConfiguration.json"); }
private void InitiateFielderAction() { BallController ballControlerScript = BallUtils.FetchBallControllerScript(FieldBall); if (FieldBall.activeInHierarchy && !HasSpottedBall) { IsoRenderer.LookAtFieldElementAnimation(FieldBall.transform.position); this.GetAngleToLookAt(); } else if (HasSpottedBall && FieldBall.activeInHierarchy && !IsHoldingBall && ballControlerScript.IsTargetedByFielder) { Target = FieldBall.transform.position; } }
private void OnTriggerExit2D(Collider2D collision) { if (ColliderUtils.HasBallCollided(collision)) { GameObject ball = collision.gameObject; BallController ballControllerScript = BallUtils.FetchBallControllerScript(ball); if (ballControllerScript.IsHit) { Debug.Log("the ball not foul any more"); ballControllerScript.IsInFoulState = false; timeElapsed = 0; } } }
private void Update() { BallController ballControlerScript = BallUtils.FetchBallControllerScript(FieldBall); if (HasSpottedBall && FieldBall.activeInHierarchy && !IsHoldingBall && ballControlerScript.IsTargetedByFielder) { Target = FieldBall.transform.position; } if (Target.HasValue && Target.Value != this.transform.position) { MovePlayer(); this.IsPrepared = true; } }
private void OnTriggerEnter2D(Collider2D collision) { if (this.HasBallCollided(collision)) { BallController ballController = BallUtils.FetchBallControllerScript(collision.transform.gameObject); ballController.Target = null; ballController.IsMoving = false; ballController.IsPassed = false; ballController.IsPitched = false; ballController.IsHit = false; PlayersTurnManager playersTurnManager = GameUtils.FetchPlayersTurnManager(); playersTurnManager.TurnState = TurnStateEnum.BATTER_TURN; PlayersTurnManager.IsCommandPhase = true; } }
private void OnTriggerExit2D(Collider2D collision) { if (ColliderUtils.HasBallCollided(collision)) { GameObject ballGameObject = collision.gameObject; BallController ballControlerScript = BallUtils.FetchBallControllerScript(ballGameObject); if (ballControlerScript.IsMoving && ballControlerScript.IsHit && !ballControlerScript.IsPitched) { GameObject player = this.gameObject.transform.parent.parent.parent.gameObject; if (PlayerUtils.HasPitcherPosition(player)) { ballControlerScript.IsTargetedByPitcher = false; PitcherBehaviour pitcherBehaviour = PlayerUtils.FetchPitcherBehaviourScript(player); pitcherBehaviour.Target = FieldUtils.GetTileCenterPositionInGameWorld(FieldUtils.GetPitcherBaseTilePosition()); pitcherBehaviour.HasSpottedBall = false; } } } }
/** * This function returns the current EnvState object. */ public static EnvState GetEnvState(string extraInfo = "NULL") { int humanScore = m_sessionScript.LeftScore; int agentScore = m_sessionScript.RightScore; Position3D ballOrientation = Position3D.Vector3ToPosition3D(m_ballScript.transform.eulerAngles); Position2D humanPos = Position2D.Vector2ToPosition2D(GeneralUtils.GetHumanPosition()); Position2D agentPos = Position2D.Vector2ToPosition2D(GeneralUtils.GetAgentPosition()); Position2D ballPos = Position2D.Vector2ToPosition2D(BallUtils.GetBallPosition()); float leftPaddleLen = m_humanScript.transform.localScale.y; float rightPaddleLen = m_agentScript.transform.localScale.y; float leftPaddleWidth = m_humanScript.transform.localScale.x; float rightPaddleWidth = m_agentScript.transform.localScale.x; Match currMatch = m_sessionScript.currMatch; int sessionState = m_sessionScript.sessionAuto.CurrState; EnvState envState = new EnvState(humanScore, agentScore, ballOrientation, ballPos, agentPos, humanPos, leftPaddleLen, rightPaddleLen, leftPaddleWidth, rightPaddleWidth, sessionState, currMatch, extraInfo); return(envState); }
private void OnTriggerStay2D(Collider2D collision) { if (ColliderUtils.HasBallCollided(collision) && !GameData.isPaused) { GameObject ball = collision.gameObject; BallController ballControllerScript = BallUtils.FetchBallControllerScript(ball); if (ballControllerScript.IsHit) { timeElapsed += Time.deltaTime; if (timeElapsed >= TIME_TO_WAIT_IN_FOUL_ZONE) { Debug.Log("the ball is foul"); timeElapsed = 0; DialogBoxManager dialogBoxManagerScript = GameUtils.FetchDialogBoxManager(); dialogBoxManagerScript.DisplayDialogAndTextForGivenAmountOfTime(1f, false, "FOUL!!"); PlayersTurnManager playersTurnManager = GameUtils.FetchPlayersTurnManager(); GameObject pitcher = TeamUtils.GetPlayerTeamMember(PlayerFieldPositionEnum.PITCHER, TeamUtils.GetPlayerIdFromPlayerFieldPosition(PlayerFieldPositionEnum.PITCHER)); GameManager gameManager = GameUtils.FetchGameManager(); GameObject currentBatter = gameManager.AttackTeamBatterListClone.First(); BatterBehaviour currentBatterBehaviour = PlayerUtils.FetchBatterBehaviourScript(currentBatter); GameObject bat = currentBatterBehaviour.EquipedBat; currentBatterBehaviour.FoulOutcomeCount += 1; currentBatter.transform.rotation = Quaternion.identity; bat.transform.position = FieldUtils.GetBatCorrectPosition(currentBatter.transform.position); bat.transform.rotation = Quaternion.Euler(0f, 0f, -70f); gameManager.ReinitPitcher(pitcher); gameManager.ReturnBallToPitcher(ballControllerScript.gameObject); gameManager.ReinitRunners(gameManager.AttackTeamRunnerList); ballControllerScript.IsInFoulState = false; playersTurnManager.TurnState = TurnStateEnum.PITCHER_TURN; PlayersTurnManager.IsCommandPhase = true; } } } }
public void OnCollisionExit2D(Collision2D c) { if (GeneralUtils.MatchInProgress() && GeneralUtils.GetProcessRole() == GeneralUtils.ROLE_SERVER) { //increment the ball hit count ballHitCount += 1; //if the ball hit a paddle foreach (ContactPoint2D contactPt2d in c.contacts) { if (contactPt2d.collider.tag == "paddle") { //announce that the ball has hit a paddle EventUtils.LogEvent(_Event.BALL_HIT); //if this is Rally mode, announce a point if (GeneralUtils.IsRally(GeneralUtils.GetCurrentConfig())) { EventUtils.AnnouncePoint(GeneralUtils.RALLY_ID); } //get ball and paddle positions as well as paddle length Vector3 paddlePos; float Pl = 0F; if (contactPt2d.collider.transform.name == "P1") { //announce hit event EventUtils.AnnounceBallHitEvent("Left"); Pl = GeneralUtils.GetPaddleSize("Left"); paddlePos = GeneralUtils.GetHumanPosition(); } else { //announce hit event EventUtils.AnnounceBallHitEvent("Right"); Pl = GeneralUtils.GetPaddleSize("Right"); paddlePos = GeneralUtils.GetAgentPosition(); } Vector3 ballPos = BallUtils.GetBallPosition(); //store y component of paddle pos float Py = paddlePos.y; //get distance between paddle hit and paddle center float d = Math.Abs(Py - ballPos.y); //piecewise function for adding force perturbation based on paddle hit location float scalar = 1F; if (d < (Pl / 10F)) //use slow scalar { scalar = Cs; } else if (d > (3F * Pl / 10F)) //use fast scalar { scalar = Cf; } else //use medium speed scalar { scalar = Cm; } //apply force perturbation myRigidbody2D.velocity = Vector2.zero; myRigidbody2D.angularVelocity = 0; if (contactPt2d.collider.name == "P1") { myRigidbody2D.AddForce(new Vector2(scalar * 10F, scalar * 2.5F * (signs[rand.Next(0, 8)] ? 1F : -1F))); myRigidbody2D.AddTorque(20F); } else { myRigidbody2D.AddForce(new Vector2(scalar * -10F, scalar * 2.5F * (signs[rand.Next(0, 8)] ? 1F : -1F))); myRigidbody2D.AddTorque(-20F); } } else { //tell the agent that the ball hit something agentComm.ballHitSomething = true; } } } }
void Update() { //if this process is the server if (GeneralUtils.GetProcessRole() == GeneralUtils.ROLE_SERVER) { //store ball position changes if (DateTime.Now.Subtract(timeOfLastCurrPosCapture).TotalMilliseconds > 50) { //capture the current time timeOfLastCurrPosCapture = DateTime.Now; } currPos = BallUtils.GetBallPosition(); posSamples.AddSample(currPos); // //draw lines TODO: remove this when done testing // Vector2 p1 = BallUtils.GetBallPosition(); // Vector2 ballVel = BallUtils.GetBallVelocity(); // Vector2 p2 = new Vector2( p1.x+5F*ballVel.x, p1.y+5F*ballVel.y ); // Vector3 draw1 = new Vector3 ( p1.x, p1.y, 0 ); // Vector3 draw2 = new Vector3 ( p2.x, p2.y, 0 ); // Debug.DrawLine ( draw1, draw2, Color.green ); //CURRENT STATE: MATCH HAS NOT YET BEGUN if (bmAuto.CurrState == BallMovementAutomaton.MATCH_NOT_IN_PROGRESS) { //if the match begins if (GeneralUtils.MatchInProgress()) { //enact transition to the next state bmAuto.Transition(BallMovementAutomaton.BALL_NOT_LAUNCHED); } } //CURRENT STATE: BALL HAS NOT YET BEEN LAUNCHED / COLLIDED else if (bmAuto.CurrState == BallMovementAutomaton.BALL_NOT_LAUNCHED) { //if the ball is launched if (ballLaunced) { //reset flags ballLaunced = false; //capture the current time timeBeganObserving = DateTime.Now; //capture the ball's position prevBx = BallUtils.GetBallPosition().x; //enact transition to the next state bmAuto.Transition(BallMovementAutomaton.OBSERVING_TRAJECTORY); } //if the match ends if (!GeneralUtils.MatchInProgress()) { //enact transition to the next state bmAuto.Transition(BallMovementAutomaton.MATCH_NOT_IN_PROGRESS); } } //CURRENT STATE: CURRENTLY OBSERVING THE BALL'S TRAJECTORY else if (bmAuto.CurrState == BallMovementAutomaton.OBSERVING_TRAJECTORY) { //update the position sample object with the current position posSamples.AddSample(currPos); //if the ball has a collision if (ballCollidedPaddle) { //reset flag ballCollidedPaddle = false; //capture the current time timeBeganObserving = DateTime.Now; //capture the ball's position prevBx = BallUtils.GetBallPosition().x; //enact transition to the next state bmAuto.Transition(BallMovementAutomaton.OBSERVING_TRAJECTORY); } //if enough time has elapsed if (DateTime.Now.Subtract(timeBeganObserving).TotalMilliseconds > timeThreshold) { //capture the ball's current position currBx = BallUtils.GetBallPosition().x; //if the ball has moved closer to the right paddle if (currBx > prevBx) { //annouce that the ball is moving towards the right paddle agentComm.ballMovingToRight = true; agentComm.ballMovingToLeft = false; //print ( "======> RIGHT, v = " + GeneralUtils.GetBallVelocity().ToString() ); } //otherwise else { //annouce that the ball is moving towards the left paddle agentComm.ballMovingToRight = false; agentComm.ballMovingToLeft = true; //print ( "======> LEFT, v = " + GeneralUtils.GetBallVelocity().ToString() ); } //enact transition to the next state bmAuto.Transition(BallMovementAutomaton.OBSERVING_TRAJECTORY); //intended self transition } //if the match ends if (!GeneralUtils.MatchInProgress()) { //enact transition to the next state bmAuto.Transition(BallMovementAutomaton.MATCH_NOT_IN_PROGRESS); } } } }
private void OnCollisionEnter2D(Collision2D collision) { PlayerStatus playerStatusScript = PlayerUtils.FetchPlayerStatusScript(this.gameObject); GenericPlayerBehaviour genericPlayerBehaviourScript = PlayerUtils.FetchCorrespondingPlayerBehaviourScript(this.gameObject, playerStatusScript); if (ColliderUtils.HasBallCollided(collision.collider)) { GameObject ballGameObject = collision.collider.gameObject; BallController ballControllerScript = BallUtils.FetchBallControllerScript(ballGameObject); if (PlayerUtils.HasCatcherPosition(this.gameObject) && ballControllerScript.CurrentPasser != this.gameObject) { CatcherBehaviour catcherBehaviour = (CatcherBehaviour)genericPlayerBehaviourScript; if (catcherBehaviour.CatcherMode == ModeConstants.CATCHER_FIELDER_MODE) { PlayerActionsManager.InterceptBall(ballGameObject, ballControllerScript, genericPlayerBehaviourScript); catcherBehaviour.CatcherMode = ModeConstants.CATCHER_NORMAL_MODE; this.gameObject.transform.position = FieldUtils.GetTileCenterPositionInGameWorld(FieldUtils.GetCatcherZonePosition()); catcherBehaviour.IsoRenderer.ReinitializeAnimator(); } PlayersTurnManager playersTurnManager = GameUtils.FetchPlayersTurnManager(); playersTurnManager.TurnState = TurnStateEnum.CATCHER_TURN; PlayersTurnManager.IsCommandPhase = true; } else if (PlayerUtils.HasFielderPosition(this.gameObject) && !ballControllerScript.IsPitched && ballControllerScript.CurrentPasser != this.gameObject) { ((FielderBehaviour)genericPlayerBehaviourScript).CalculateFielderColliderInterraction(ballGameObject, ballControllerScript, genericPlayerBehaviourScript); } else if (PlayerUtils.HasPitcherPosition(this.gameObject) && !ballControllerScript.IsPitched && !ballControllerScript.IsPassed && ballControllerScript.CurrentPasser != this.gameObject) { ((PitcherBehaviour)genericPlayerBehaviourScript).CalculatePitcherColliderInterraction(ballGameObject, ballControllerScript, genericPlayerBehaviourScript); } } else if (ColliderUtils.HasPlayerCollided(collision)) { if (PlayerUtils.HasFielderPosition(this.gameObject) && genericPlayerBehaviourScript.IsHoldingBall && PlayerUtils.HasRunnerPosition(collision.gameObject)) { PlayerStatus runnerToTagOutStatus = PlayerUtils.FetchPlayerStatusScript(collision.transform.gameObject); RunnerBehaviour runnerBehaviourScript = ((RunnerBehaviour)PlayerUtils.FetchCorrespondingPlayerBehaviourScript(collision.transform.gameObject, runnerToTagOutStatus)); if (!runnerBehaviourScript.IsSafe) { ((FielderBehaviour)genericPlayerBehaviourScript).TagOutRunner(collision.transform.gameObject); } else { ((FielderBehaviour)genericPlayerBehaviourScript).ReplanAction(); } } } else { if (PlayerUtils.HasRunnerPosition(this.gameObject)) { if (!ColliderUtils.IsBaseTile(collision.gameObject.name)) { return; } if (genericPlayerBehaviourScript == null) { return; } if (!genericPlayerBehaviourScript.IsPrepared) { return; } RunnerBehaviour runnerBehaviour = ((RunnerBehaviour)genericPlayerBehaviourScript); BaseEnum baseReached = runnerBehaviour.NextBase; if (baseReached == BaseEnum.HOME_BASE && runnerBehaviour.HasPassedThroughThreeFirstBases()) { //win a point automaticaly without issuing commands if arrived at home base after a complete turn runnerBehaviour.CalculateRunnerColliderInterraction(FieldUtils.GetTileEnumFromName(collision.gameObject.name), true); } else if (baseReached == BaseEnum.FIRST_BASE && runnerBehaviour.IsInWalkState) { //Walk done after 4 ball from pitcher runnerBehaviour.CalculateRunnerColliderInterraction(FieldUtils.GetTileEnumFromName(collision.gameObject.name)); PlayersTurnManager playersTurnManager = GameUtils.FetchPlayersTurnManager(); playersTurnManager.TurnState = TurnStateEnum.PITCHER_TURN; PlayersTurnManager.IsCommandPhase = true; } else if (baseReached == BaseEnum.HOME_BASE) { //automaticaly run to next base, no need for command input runnerBehaviour.CalculateRunnerColliderInterraction(FieldUtils.GetTileEnumFromName(collision.gameObject.name)); runnerBehaviour.GoToNextBase(baseReached, true); } else { //Runner next turn runnerBehaviour.CalculateRunnerColliderInterraction(FieldUtils.GetTileEnumFromName(collision.gameObject.name), true); } } } }