示例#1
0
    // Should be used as the default behaviour.
    public static void PositionAndShoot(GameObject player, GameObject ball, GameObject goal)
    {
        /* First a position of the goal is found, then player is rotated to face the ball.
         * Next distance from the player to the point from which he would be able to shoot is found.
         * Then the player is moved closer to it or uses a sword to shot at the goal. */
        AIMovementBehaviour.LookAt(player, ball);

        Vector2 goalDirection = AIDirectionBehaviour.FindPositionOf(ball, goal, 0.9f);                            // The point where player should position itself

        if (AICalculate.CalculateLengthBetween(player, ball.transform.position.x, ball.transform.position.y) < 2) // If player is close to the ball
        {
            if (AICalculate.CalculateLengthBetween(player, goalDirection.x, goalDirection.y) > 0.3)
            {
                PositionInFrontOf(player, ball, goal);
            }
            else
            {
                AIBasicBehaviour.UseSword(player);
            }
        }
        else
        {
            AIMovementBehaviour.MoveForward(player);
        }
    }
示例#2
0
 public new void RunTwoPosition()
 {
     /* OGoal | Player | Ball | AI | AIGoal
      */
     if (AICheckBehaviour.FarFromBall(player, ball))
     {
         AIBasicBehaviour.Sprint(player, 1);
         if (aIController.lineOfSight.CheckIfBallSpotted())
         {
             AIMovementBehaviour.LookAt(player, ball);
             AIBasicBehaviour.UseGun(player);
             AIMovementBehaviour.MoveTowards(player, ball);
         }
         else
         {
             AIGlobalBehaviour.PositionAndShoot(player, ball, goal);
         }
     }
     else
     {
         if (AICheckBehaviour.CheckIfBallApproaching(player, ball))
         {
             AIBasicBehaviour.UseShield(player);
         }
         AIGlobalBehaviour.PositionAndShoot(player, ball, goal);
     }
 }
示例#3
0
    public static void ShootInTheMiddle(GameObject player, GameObject ball, GameObject goal)
    {
        /* Same as ShootAtGoal method but this time the player kicks the towards the middle of
         * the football pitch.
         */
        Vector2 goalDirection = AIDirectionBehaviour.FindPositionOf(ball, goal, 0.9f);

        AIMovementBehaviour.LookAt(player, ball);
        if (AICalculate.CalculateLengthBetween(player, ball.transform.position.x, ball.transform.position.y) < 2) // If player is close to the ball
        {
            if (AICalculate.CalculateLengthBetween(player, goalDirection.x, goalDirection.y) > 0.3)
            {
                PositionInFrontOf(player, ball, goal);
            }
            else
            {
                AIMovementBehaviour.LookAt(player, player.transform.position.x, player.GetComponent <PlayerController>().globalSettings.stateBoundary);
                AIBasicBehaviour.UseSword(player);
            }
        }
        else
        {
            AIMovementBehaviour.MoveForward(player);
        }
    }
示例#4
0
 public new void RunOnePosition()
 {
     /* OGoal | AI | Ball | Player | AIGoal
      */
     if (AICheckBehaviour.FarFromBall(player, ball))
     {
         if (AICheckBehaviour.CheckOpponentsHealth(opponent))
         {
             AIMovementBehaviour.LookAt(player, opponent);
             AIBasicBehaviour.UseGun(player);
         }
         else if (AICheckBehaviour.CheckIfCloseToPickup(GetActivePickups(), player))
         {
             AIMovementBehaviour.LookAt(player, AICheckBehaviour.GetClosestPickup(GetActivePickups(), GetActiveCount(), player));
             AIMovementBehaviour.MoveForward(player);
         }
         else
         {
             AIGlobalBehaviour.PositionAndShoot(player, ball, aIController.lineOfSight.GetAvailablePoint());
         }
     }
     else
     {
         AIGlobalBehaviour.PositionAndShoot(player, ball, aIController.lineOfSight.GetAvailablePoint());
     }
 }
 public new void RunTwoPosition()
 {
     /* OGoal | Player | Ball | AI | AIGoal
      */
     if (AICheckBehaviour.FarFromBall(player, ball))
     {
         if (AICheckBehaviour.CheckIfCloseToOpponent(player, opponent))
         {
             AIMovementBehaviour.LookAt(player, opponent);
             AIBasicBehaviour.UseSword(player);
             AIMovementBehaviour.MoveTowards(player, ball);
         }
         else if (AICheckBehaviour.CheckOpponentsHealth(opponent))
         {
             AIMovementBehaviour.LookAt(player, opponent);
             AIBasicBehaviour.UseGun(player);
             AIMovementBehaviour.MoveTowards(player, ball);
         }
         else
         {
             AIMovementBehaviour.LookAt(player, ball);
             AIBasicBehaviour.UseGun(player);
             AIMovementBehaviour.MoveTowards(player, ball);
         }
     }
     else
     {
         if (AICheckBehaviour.CheckIfBallApproaching(player, ball))
         {
             AIBasicBehaviour.UseShield(player);
         }
         AIGlobalBehaviour.PositionAndShoot(player, ball, goal);
     }
 }
示例#6
0
    private void changeMovmentType(AIMovementType mType)
    {
        moveType = mType;

        switch (moveType)
        {
        case AIMovementType.Still:
            destroyCurrentMoveBehavior(null);
            break;

        case AIMovementType.Strafe:
            destroyCurrentMoveBehavior(typeof(Strafe));
            if (currentMoveBehavior == null)                      // add component if not already there
            {
                currentMoveBehavior = transform.GetOrAddComponent <Strafe>();
            }
            break;

        case AIMovementType.Rush:
            break;

        case AIMovementType.GoTo:
            break;

        default:
            break;
        }
    }
 public new void RunOnePosition()
 {
     /* OGoal | AI | Ball | Player | AIGoal
      */
     if (AICheckBehaviour.FarFromBall(player, ball))
     {
         AIBasicBehaviour.Sprint(player, 1);
         if (AICheckBehaviour.CheckIfCloseToPickup(GetActivePickups(), player))
         {
             AIMovementBehaviour.LookAt(player, AICheckBehaviour.GetClosestPickup(GetActivePickups(), GetActiveCount(), player));
             AIMovementBehaviour.MoveForward(player);
         }
         else
         {
             AIMovementBehaviour.LookAt(player, opponent);
             AIBasicBehaviour.UseGun(player);
             AIMovementBehaviour.MoveTowards(player, ball);
         }
     }
     else
     {
         AIBasicBehaviour.Sprint(player, 1);
         AIGlobalBehaviour.PositionAndShoot(player, ball, goal);
     }
 }
    public new void RunThreePosition()
    {
        /* OGoal | Player, AI | Ball | AIGoal
         */

        if (AICheckBehaviour.FarFromBall(player, ball))
        {
            AIBasicBehaviour.Sprint(player, 1);
            if (AICheckBehaviour.CheckIfCloseToOpponent(player, opponent))
            {
                AIMovementBehaviour.LookAt(player, opponent);
                AIBasicBehaviour.UseSword(player);
                AIMovementBehaviour.MoveTowards(player, ball);
            }
            else if (AICheckBehaviour.CheckOpponentsHealth(opponent))
            {
                AIMovementBehaviour.LookAt(player, opponent);
                AIBasicBehaviour.UseGun(player);
                AIMovementBehaviour.MoveTowards(player, ball);
            }
            else
            {
                AIGlobalBehaviour.PositionAndShoot(player, ball, goal);
            }
        }
        else
        {
            AIBasicBehaviour.Sprint(player, 1);
            // Move towards the ball as fast as possible.
            AIGlobalBehaviour.PositionAndShoot(player, ball, goal);
        }
    }
示例#9
0
    public static void PositionInFrontOf(GameObject player, GameObject ball, GameObject goal)
    {
        /* This method position the player in front of the given object.
         * It is mainly used to position the player in front of the ball in such a way that the ball is
         * between the player and the goal.
         */

        Vector2 coordinates = AICalculate.FindPointBetween(player, ball, goal);

        /* Now we know what is the position of the point that the player will move towards.
         * Next we need to move the player towards that point.
         * MoveTowards does not require the player character to look in the
         * certain direction so looking and moving can be done separately.
         */
        AIMovementBehaviour.MoveTowards(player, coordinates.x, coordinates.y);
    }
示例#10
0
 public new void RunZeroPosition()
 {
     /* OGoal | Ball | Player, AI | AIGoal
      */
     if (AICheckBehaviour.FarFromBall(player, ball))
     {
         AIBasicBehaviour.Sprint(player, 1);
         AIMovementBehaviour.LookAt(player, ball);
         AIBasicBehaviour.UseGun(player);
         AIGlobalBehaviour.PositionAndShoot(player, ball, goal);
     }
     else
     {
         if (AICheckBehaviour.CheckIfBallApproaching(player, ball))
         {
             AIBasicBehaviour.UseShield(player);
         }
         AIGlobalBehaviour.PositionAndShoot(player, ball, goal);
     }
 }
示例#11
0
 public new void RunZeroPosition()
 {
     /* OGoal | Ball | Player, AI | AIGoal
      */
     if (AICheckBehaviour.FarFromBall(player, ball))
     {
         if (aIController.lineOfSight.CheckIfBallSpotted())
         {
             AIMovementBehaviour.LookAt(player, ball);
             AIBasicBehaviour.UseGun(player);
         }
     }
     if (aIController.lineOfSight.CheckIfWallSpotted())
     {
         AIGlobalBehaviour.ShootInTheMiddle(player, ball, goal);
     }
     else
     {
         AIGlobalBehaviour.PositionAndShoot(player, ball, aIController.lineOfSight.GetAvailablePoint());
     }
 }
    public new void RunZeroPosition()
    {
        /* OGoal | Ball | Player, AI | AIGoal
         */


        if (AICheckBehaviour.FarFromBall(player, ball))
        { // If far from ball
            if (aIController.lineOfSight.CheckIfWallSpotted())
            {
                AIGlobalBehaviour.ShootInTheMiddle(player, ball, goal);
            }
            else
            {
                AIGlobalBehaviour.PositionAndShoot(player, ball, aIController.lineOfSight.GetAvailablePoint());
            }
        }
        else
        {
            // If close to a pickup - move towards it

            if (aIController.lineOfSight.CheckIfBallSpotted())
            {
                AIMovementBehaviour.LookAt(player, ball);
                AIBasicBehaviour.UseGun(player);
                AIMovementBehaviour.MoveTowards(player, ball);
            }
            else if (AICheckBehaviour.CheckIfCloseToPickup(GetActivePickups(), player))
            {
                AIMovementBehaviour.LookAt(player, AICheckBehaviour.GetClosestPickup(GetActivePickups(), GetActiveCount(), player));
                AIMovementBehaviour.MoveForward(player);
            }
            else
            {
                AIGlobalBehaviour.PositionAndShoot(player, ball, aIController.lineOfSight.GetAvailablePoint());
            }
        }
    }
    public new void RunThreePosition()
    {
        /* OGoal | Player, AI | Ball | AIGoal
         */

        if (AICheckBehaviour.FarFromBall(player, ball))
        {
            if (AICheckBehaviour.CheckIfCloseToOpponent(player, opponent))
            {
                AIMovementBehaviour.LookAt(player, opponent);
                AIBasicBehaviour.UseSword(player);
            }
            AIBasicBehaviour.Sprint(player, 1);
            AIMovementBehaviour.LookAt(player, opponent);
            AIBasicBehaviour.UseGun(player);
            AIGlobalBehaviour.PositionAndShoot(player, ball, goal);
        }
        else
        {
            AIBasicBehaviour.Sprint(player, 1);
            AIGlobalBehaviour.PositionAndShoot(player, ball, goal);
        }
    }
示例#14
0
        override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
        {
            AIBehaviour     = animator.GetComponent <AIMovementBehaviour>();
            MobileBehaviour = animator.GetComponent <BaseMobileBehaviour>();
            MobileHealth    = animator.GetComponent <HealthBehaviour>();
            var playerObj = GameObject.FindGameObjectWithTag("Player");

            if (playerObj != null)
            {
                PlayerBehaviour = playerObj.GetComponent <PlayerBehaviour>();
                DeltaVector     = MobileBehaviour.transform.position - PlayerBehaviour.transform.position;
            }
            if (MobileBehaviour.WeaponBehaviour != null)
            {
                animator.SetBool("IsRanged", MobileBehaviour.WeaponBehaviour.IsRanged);
                animator.SetFloat("AttackDistance", MobileBehaviour.WeaponBehaviour.AttackDistance);
            }

            animator.SetFloat("Health", MobileHealth.Health);
            animator.SetFloat("ChaseDistance", MobileBehaviour.ChaseDistance);
            animator.SetFloat("FleeBelowHealth", MobileBehaviour.FleeBelowHealth);
            animator.SetFloat("FleeDistance", MobileBehaviour.FleeDistance);
        }
示例#15
0
 public MobileMovementInput(AIMovementBehaviour mobileAI)
 {
     MobileAI = mobileAI;
 }
 public static void UseSword(GameObject player)
 {
     AIMovementBehaviour.MoveBackward(player);
     GetController(player).UseSword();
 }
 public HumanMovementInput(AIMovementBehaviour aiBehaviour) : base(aiBehaviour)
 {
 }