예제 #1
0
    public void HandleInput(RodAction action)
    {
        switch (action)
        {
        case RodAction.Cast:
            OneShotManager.PlayOneShot(castOneShot);
            animator.SetTrigger("CastStart");
            break;

        case RodAction.SmallBite:
            animator.SetTrigger("SmallBite");
            break;

        case RodAction.BigBite:
            bigBiteLoopSource.Play();
            animator.SetTrigger("BigBite");
            break;

        case RodAction.Reel:
            bigBiteLoopSource.Stop();
            OneShotManager.PlayOneShot(reelOneShot);
            animator.SetTrigger("ReelStart");
            break;

        case RodAction.Idle:
            break;
        }
    }
예제 #2
0
        /// <summary>
        /// Choose player to respond on current rod and action to perform
        /// </summary>
        /// <param name="rod">Current rod</param>
        /// <param name="bfc">Ball Future Coordinates</param>
        /// <param name="respondingPlayer">Responding Player index (1 based) on current rod [out]</param>
        /// <returns>Rod Action to be performed</returns>
        protected RodAction DefineActionAndRespondingPlayer(IRod rod, BallCoordinates bfc, out int respondingPlayer)
        {
            if (rod == null)
            {
                throw new ArgumentException(String.Format(
                                                "[{0}] Unable to define action and responding player while rod argument is NULL!",
                                                MethodBase.GetCurrentMethod().Name));
            }

            if (bfc == null || !bfc.IsDefined)
            {
                throw new ArgumentException(String.Format(
                                                "[{0}] Unable to define action and responding player while ball coordinates are NULL or UNDEFINED!",
                                                MethodBase.GetCurrentMethod().Name));
            }

            RodAction action = null;

            respondingPlayer = -1;
            switch (_helper.IsBallInSector(bfc.X, rod.RodXCoordinate, rod.DynamicSector))
            {
            //Ball is in Current Rod Sector
            case eXPositionSectorRelative.IN_SECTOR:
                action           = SubTree.Decide(rod, bfc);
                respondingPlayer = SubTree.RespondingPlayer;
                break;

            /* OLD :
             *  //The Big Sub Tree
             *  action = EnterDecisionTreeBallInSector(rod, bfc, out respondingPlayer);
             */

            //Ball is ahead of Current Rod Sector
            case eXPositionSectorRelative.AHEAD_SECTOR:
                //Ball Vector Direction is TO Current Rod and we have intersection point
                if (_helper.IsBallVectorToRod(bfc.Vector) &&
                    rod.Intersection.IsDefined)
                {
                    action = new RodAction(rod.RodType, eRotationalMove.DEFENCE, eLinearMove.VECTOR_BASED);

                    //Define responding player index
                    BallYPositionToPlayerYCoordinate(bfc.Y, rod);
                    respondingPlayer = this.RespondingPlayer;
                }
                else
                {
                    //Ball Vector Direction is FROM Current Rod
                    action = new RodAction(rod.RodType, eRotationalMove.DEFENCE, eLinearMove.BEST_EFFORT);
                }
                break;

            //Ball is behind Current Rod Sector
            case eXPositionSectorRelative.BEHIND_SECTOR:
                action = new RodAction(rod.RodType, eRotationalMove.RISE, eLinearMove.BEST_EFFORT);
                break;
            }
            return(action);
        }
예제 #3
0
        /// <summary>
        /// Main Decision Flow Method
        /// </summary>
        /// <param name="rod">Rod to use for decision</param>
        /// <param name="bfc">Ball Future coordinates</param>
        /// <returns>Rod Action to perform</returns>
        public override RodAction Decide(IRod rod, BallCoordinates bfc)
        {
            //Player to respond  (index base is 0)
            int respondingPlayer = -1;

            //Chose responding player on rod and define action to perform
            RodAction action = DefineActionAndRespondingPlayer(rod, bfc, out respondingPlayer);

            //Define actual desired rod coordinate to move to
            int startStopperDesiredY = CalculateNewRodCoordinate(rod, respondingPlayer, bfc, action.Linear);

            action.DcCoordinate = rod.NearestPossibleDcPosition(startStopperDesiredY);

            //Set last decided rod and player coordinates
            rod.State.DcPosition    = action.DcCoordinate;
            rod.State.ServoPosition = action.Rotation;
            return(action);
        }
예제 #4
0
        /// <summary>
        /// Decide on action to be taken for each rod
        /// </summary>
        /// <param name="currentCoordinates">Current ball coordinates and vector</param>
        /// <returns>List of actions per each rod</returns>
        public List <RodAction> Decide(BallCoordinates currentCoordinates)
        {
            if (!IsInitialized)
            {
                Initialize();
            }

            if (currentCoordinates == null)
            {
                throw new ArgumentException(String.Format("[{0}] Coordinates received from vector calculation unit are null",
                                                          MethodBase.GetCurrentMethod().Name));
            }

            //Convert pts and pts/sec to mm and mm/sec
            currentCoordinates = _surveyor.PtsToMm(currentCoordinates);

            //Calculate Actual Possible Action Time
            DateTime timeOfAction = DateTime.Now + SystemDelays;

            //Calculate ball future coordinates
            BallCoordinates bfc = _predictor.FindBallFutureCoordinates(currentCoordinates, timeOfAction);

            List <RodAction> actions = new List <RodAction>();

            foreach (IRod rod in _controlledRods)
            {
                //Calculate dynamic sectors
                rod.CalculateDynamicSector(currentCoordinates);

                //Draw dynamic sector, better to use on one rod at a time because together is chaos on the screen
                Marks.DrawSector(rod.RodType, rod.DynamicSector);

                //Calculate intersection point
                rod.CalculateSectorIntersection(bfc);
                //Decide on action
                RodAction action = _decisionTree.Decide(rod, bfc);
                actions.Add(action);
                //if (rod.RodType == eRod.GoalKeeper) Log.Common.Debug(action.Linear + ": " + action.DcCoordinate);
            }
            return(actions);
        }
예제 #5
0
        /// <summary>
        /// Main Decision Flow Method desides on action and sets property of responding player
        /// </summary>
        /// <param name="rod">Rod to use for decision</param>
        /// <param name="bfc">Ball Future coordinates</param>
        /// <returns>Rod Action to perform</returns>
        public override RodAction Decide(IRod rod, BallCoordinates bfc)
        {
            //Get relative Y position and set Responding Player
            eYPositionPlayerRelative relativeY = BallYPositionToPlayerYCoordinate(bfc.Y, rod);

            //Get relative X position
            eXPositionRodRelative relativeX = BallXPositionToRodXPosition(bfc.X, rod);

            RodAction action = new RodAction(rod.RodType);

            /*
             * For Alpha this is good enough to make a kick.
             * For Beta need to define the actual sub tree.
             */
            if (relativeX.Equals(eXPositionRodRelative.FRONT))
            {
                action = new RodAction(rod.RodType, eRotationalMove.KICK, eLinearMove.VECTOR_BASED);
            }
            if (relativeX.Equals(eXPositionRodRelative.BACK))
            {
                action = new RodAction(rod.RodType, eRotationalMove.RISE, eLinearMove.VECTOR_BASED);
            }
            if (relativeX.Equals(eXPositionRodRelative.CENTER))
            {
                action = new RodAction(rod.RodType, eRotationalMove.KICK, eLinearMove.BALL_Y);
            }

            //Define actual desired rod coordinate to move to
            int startStopperDesiredY = CalculateNewRodCoordinate(rod, RespondingPlayer, bfc, action.Linear);

            action.DcCoordinate = rod.NearestPossibleDcPosition(startStopperDesiredY);

            //Set last decided rod and player coordinates
            rod.State.DcPosition    = action.DcCoordinate;
            rod.State.ServoPosition = action.Rotation;

            return(action);
        }
예제 #6
0
        public RodAction Decide(Rod rod, BallCoordinates bfc)
        {
            RodAction action = null;

            //calculate sector start and end coordinates
            sectorStart = rod.RodXCoordinate - rod.DynamicSector / 2;
            sectorEnd   = rod.RodXCoordinate + rod.DynamicSector / 2;

            switch (IsBallInSector(bfc.X))
            {
            //Ball is in Current Rod Sector
            case eBallRelativePos.IN_SECTOR:
                //The Big Tree


                break;

            //Ball is ahead of Current Rod Sector
            case eBallRelativePos.AHEAD_SECTOR:
                if (IsBallVectorToRod(bfc.Vector))
                {
                    //Ball Vector Direction is TO Current Rod
                    action = new RodAction(rod.RodType, eRotationalMove.DEFENCE, eLinearMove.VECTOR_BASED);
                }
                else
                {
                    //Ball Vector Direction is FROM Current Rod
                    action = new RodAction(rod.RodType, eRotationalMove.DEFENCE, eLinearMove.BEST_EFFORT);
                }
                break;

            //Ball is behind Current Rod Sector
            case eBallRelativePos.BEHIND_SECTOR:
                action = new RodAction(rod.RodType, eRotationalMove.RISE, eLinearMove.BEST_EFFORT);
                break;
            }

            //Define actual desired rod location to move to
            switch (action.Linear)
            {
            case eLinearMove.BALL_Y:

                break;

            case eLinearMove.BEST_EFFORT:

                break;

            case eLinearMove.LEFT_BALL_DIAMETER:

                break;

            case eLinearMove.RIGHT_BALL_DIAMETER:

                break;

            case eLinearMove.VECTOR_BASED:

                break;

            default:

                break;
            }

            return(action);
        }