コード例 #1
0
ファイル: AIKiril.cs プロジェクト: Woewal/ElectiveDevelopment
 public override void UpdateBallPass(RobotControls controls)
 {
     if (_canPassBall)
     {
         controls.passBall(_PassBallVector);
         _canPassBall = false;
     }
 }
コード例 #2
0
 public override void UpdateBallPass(RobotControls controls)
 {
     if (controls.myself.currentHealth < 40 && Vector3.Distance(controls.myself.currentPosition, controls.updateBall) < 1.5f)
     {
         controls.passBall(_closestTeammate.currentPosition);
     }
     else
     {
         return;
     }
 }
コード例 #3
0
    public override void UpdateBallPass(RobotControls controls)
    {
        if (!_hasBall)
        {
            return;
        }

        if (controls.myself.currentHealth < 30)
        {
            controls.passBall(_closestTeammate.currentPosition);
        }
    }
コード例 #4
0
    public override void UpdateMovement(RobotControls controls)
    {
        #region Ball carrier exists

        if (GetBallCarrier(controls) != null)
        {
            #region I am ball carrier

            if (GetBallCarrier(controls).Value.team == controls.myself.team &&
                GetBallCarrier(controls).Value.id == controls.myself.id)
            {
                #region Powerup Exists

                powerupsVisible  = controls.updatePickup.Count > 0;
                powerupsRecalled = RecallPowerPositions(controls) != Vector3.zero;
                alliesVisible    = GetSeenRobotTarget(controls, controls.myself.currentPosition, true, true) != null;
                opponentsVisible = GetSeenRobotTarget(controls, controls.myself.currentPosition, false, true) != null;
                lowOnHealth      = controls.myself.currentHealth > curHealthThreshold;

                if ((powerupsVisible || powerupsRecalled) && (!lowOnHealth || !alliesVisible) && opponentsVisible)
                {
                    //Move towards closest powerup
                    GetClosestPowerup(controls, controls.myself.currentPosition);
                    immobilised = false;
                    //Shoot closest opponent
                    TragectoryPrediction(controls, GetSeenRobotTarget(controls, controls.myself.currentPosition, false, true));
                    if (controls.reload == 0)
                    {
                    }
                }

                #endregion

                #region Evade closest opponent

                powerupsVisible  = controls.updatePickup.Count > 0;
                powerupsRecalled = RecallPowerPositions(controls) != Vector3.zero;
                alliesVisible    = GetSeenRobotTarget(controls, controls.myself.currentPosition, true, true) != null;
                opponentsVisible = GetSeenRobotTarget(controls, controls.myself.currentPosition, false, true) != null;
                lowOnHealth      = controls.myself.currentHealth > curHealthThreshold;

                if ((!powerupsVisible && !powerupsRecalled) && (!lowOnHealth || !alliesVisible) && opponentsVisible)
                {
                    //Move away from closest opponent
                    controls.goTo(
                        GetSeenRobotTarget(controls, controls.myself.currentPosition, false, true).Value.currentPosition -
                        controls.myself.currentPosition);
                    immobilised = false;
                    //Shoot closest opponent
                    TragectoryPrediction(controls, GetSeenRobotTarget(controls, controls.myself.currentPosition, false, true));
                }

                #endregion

                #region Pass the ball

                powerupsVisible  = controls.updatePickup.Count > 0;
                powerupsRecalled = RecallPowerPositions(controls) != Vector3.zero;
                alliesVisible    = GetSeenRobotTarget(controls, controls.myself.currentPosition, true, true) != null;
                opponentsVisible = GetSeenRobotTarget(controls, controls.myself.currentPosition, false, true) != null;
                lowOnHealth      = controls.myself.currentHealth > curHealthThreshold;

                if ((lowOnHealth && alliesVisible) && opponentsVisible)
                {
                    //Pass the ball to furthest ally
                    controls.passBall(
                        GetSeenRobotTarget(controls, controls.myself.currentPosition, true, false).Value.currentPosition);
                }

                #endregion

                #region Coast clear

                powerupsVisible  = controls.updatePickup.Count > 0;
                powerupsRecalled = RecallPowerPositions(controls) != Vector3.zero;
                alliesVisible    = GetSeenRobotTarget(controls, controls.myself.currentPosition, true, true) != null;
                opponentsVisible = GetSeenRobotTarget(controls, controls.myself.currentPosition, false, true) != null;
                lowOnHealth      = controls.myself.currentHealth > curHealthThreshold;

                if (!opponentsVisible)
                {
                    if (immobilised)
                    {
                        //Stop moving
                        controls.goTo(controls.myself.currentPosition);
                        immobilised = true;
                    }
                }

                #endregion
            }

            #endregion

            #region Ally ball

            else if (GetBallCarrier(controls).Value.team == controls.myself.team)
            {
                //Move towards ball
                controls.goTo(controls.updateBall);
                immobilised = false;
                //Shoot at closest opponent to ball carrier if any
                if (GetSeenRobotTarget(controls, GetBallCarrier(controls).Value.currentPosition, false, true) != null)
                {
                    TragectoryPrediction(controls,
                                         GetSeenRobotTarget(controls,
                                                            GetBallCarrier(controls).Value.currentPosition, false, true));
                }
            }

            #endregion

            #region Opponent ball

            else if (GetBallCarrier(controls).Value.team != controls.myself.team)
            {
                //Move towards ball
                controls.goTo(controls.updateBall);
                immobilised = false;
                //Shoot at ball carrier
                TragectoryPrediction(controls,
                                     GetBallCarrier(controls));
            }

            #endregion
        }

        #endregion

        #region Anybody's ball

        else if (GetBallCarrier(controls) == null)
        {
            //Move towards ball
            controls.goTo(controls.updateBall);
            immobilised = false;
            //Shoot at closest opponent if any
            if (GetSeenRobotTarget(controls, controls.myself.currentPosition, false, true) != null)
            {
                TragectoryPrediction(controls,
                                     GetSeenRobotTarget(controls, controls.myself.currentPosition, false, true));
            }
        }

        #endregion
    }