Beispiel #1
0
 public void UpdateProperties()
 {
     if (!self.IsActive || CurrentHealth <= 0f)
     {
         return;
     }
     IsStuck           = (self.IsStationary && state != State.Camping);
     PrimaryEnemy      = AIController.instance.GetEnemyLeader(self);
     PrimaryAlly       = AIController.instance.GetClosestAlly(self);
     IsLastManStanding = (PrimaryAlly == self || PrimaryAlly.vehicle.CurrentHealth <= 0f);
     DistanceToEnemy   = PrimaryEnemy.DistanceTo(self);
     DistanceToTarget  = Mathf.Abs(Position.x - Waypoint.x);
     DistanceToAlly    = PrimaryAlly.DistanceTo(self);
     if (PrimaryEnemy.vehicle != null && PrimaryEnemy.vehicle.circleSawContainer != null && self.vehicle != null && self.vehicle.circleSawContainer != null)
     {
         MeleeContactDistance = PrimaryEnemy.vehicle.circleSawContainer.localPosition.x + Vehicle.circleSawContainer.localPosition.x;
         MeleeContactPoint    = PrimaryEnemy.Position + new Vector2(MeleeContactDistance, 0f) * (float)Backward;
     }
     BehindEnemyLines = ((Forward == Direction.Left) ? (PrimaryEnemy.Position.x > self.Position.x) : (PrimaryEnemy.Position.x < self.Position.x));
     MoveDirection    = ((!Mathf.Approximately(Speed, 0f)) ? ((Mathf.Sign(Speed) < 0f) ? Backward : Forward) : Direction.Stationary);
     if (self.team != 0)
     {
         if (BehindEnemyLines && CollidesWithPlayer)
         {
             CollidesWithPlayer = false;
             TankGame.instance.SetArenaPlayerCollision(self.vehicle, CollidesWithPlayer);
         }
         else if (!PrimaryEnemy.IsPointBehind(Position + ForwardVec * MeleeContactDistance) && !CollidesWithPlayer)
         {
             CollidesWithPlayer = true;
             TankGame.instance.SetArenaPlayerCollision(self.vehicle, CollidesWithPlayer);
         }
     }
 }
Beispiel #2
0
 private void UpdateState()
 {
     if (state != State.Camping && !WaypointSet)
     {
         SetState(State.RequestingNewWaypoint);
     }
     if (state != State.Resolving && state != State.NeedingResolve)
     {
         if ((DistanceToEnemy < MeleeContactDistance * 0.5f && (!PrimaryEnemy.NearBlocker || !self.NearBlocker) && boosterType != BoosterGameplayType.CircleSaw) || (BehindEnemyLines && !PrimaryEnemy.IsPointBehind(Waypoint) && state != State.Camping) || (PrimaryEnemy.IsPointBehind(Waypoint) && !PrimaryEnemy.NearFrontBlocker) || AIController.instance.IsPlayerCamping() || (!BehindEnemyLines && DistanceToEnemy > profile.preferDistance.max && self.IsPointBehind(Waypoint)))
         {
             SetState(State.NeedingResolve);
             return;
         }
         if (CurrentBehaviour == Behaviour.Follower && DistanceToAlly > profile.preferDistance.max)
         {
             SetState(State.RequestingNewWaypoint);
             return;
         }
     }
     if (state == State.Camping)
     {
         if (self.stationaryTimer >= profile.stationaryCheckTime)
         {
             SetState(State.RequestingNewWaypoint);
         }
     }
     else if (CloseToTarget)
     {
         SetState(State.RequestingNewWaypoint);
     }
 }
Beispiel #3
0
    private void UpdateBoosterTriggers()
    {
        if (boosterUsed)
        {
            return;
        }
        if (!IsBoosterFlagSet(BoosterReadyFlag.Time) && totalTimeAwake >= UseBoosterTime)
        {
            SetBoosterReady(BoosterReadyFlag.Time);
        }
        switch (boosterType)
        {
        case BoosterGameplayType.CircleSaw:
        case BoosterGameplayType.ForceField:
            break;

        case BoosterGameplayType.Airstrike:
            SetBoosterReady(BoosterReadyFlag.Location, DistanceToEnemy <= profile.useAirstrikeDistance.max && DistanceToEnemy >= profile.useAirstrikeDistance.min && !PrimaryEnemy.IsPointBehind(Position));
            SetBoosterReady(BoosterReadyFlag.Movement, MoveDirection != Forward);
            break;

        case BoosterGameplayType.RepairKit:
        {
            bool flag = !IsLastManStanding && PrimaryAlly.vehicle.CurrentHealthPercentage < profile.useRepairKitAtHealth && (!self.IsPointBehind(PrimaryAlly.Position) || DistanceToAlly < 5f);
            SetBoosterReady(BoosterReadyFlag.Movement, (MoveDirection != Backward && DistanceToEnemy > 15f) | flag);
            break;
        }

        case BoosterGameplayType.Shockwave:
            SetBoosterReady(BoosterReadyFlag.Location, DistanceToEnemy < 5f);
            break;

        case BoosterGameplayType.Mine:
            if (IsBoosterFlagSet(BoosterReadyFlag.Time))
            {
                if (CurrentBehaviour == Behaviour.Casual && (useBoosterLocation.IsNegativeInfinity() || (useBoosterLocation - Position).sqrMagnitude > 100f))
                {
                    useBoosterLocation = GetClosestPOI(Backward);
                }
                else if (CurrentBehaviour == Behaviour.Aggressive && DistanceToEnemy < 20f && (useBoosterLocation.IsNegativeInfinity() || self.IsPointBehind(useBoosterLocation)))
                {
                    useBoosterLocation = GetClosestPOI(Forward);
                }
                else if (CurrentBehaviour == Behaviour.Defensive && DistanceToEnemy < 30f && (useBoosterLocation.IsNegativeInfinity() || !self.IsPointBehind(useBoosterLocation)))
                {
                    useBoosterLocation = GetClosestPOI(Backward);
                }
                SetBoosterReady(BoosterReadyFlag.Location, Mathf.Abs(useBoosterLocation.x - Position.x) <= UseBoosterRadius);
            }
            break;
        }
    }
Beispiel #4
0
 private void UpdateWaypoint()
 {
     if (state == State.NeedingResolve)
     {
         if (PrimaryEnemy.NearFrontBlocker)
         {
             SetWaypoint(PrimaryEnemy.Position, resolving: true);
         }
         else if (DistanceToEnemy < MeleeContactDistance * 0.5f && (!PrimaryEnemy.NearBlocker || !self.NearBlocker) && boosterType != BoosterGameplayType.CircleSaw)
         {
             SetWaypoint(GetClosestPOI(Backward), resolving: true);
         }
         else if (BehindEnemyLines && PrimaryEnemy.IsPointBehind(Waypoint) && !self.NearBackBlocker)
         {
             SetWaypoint(MeleeContactPoint, resolving: true);
         }
         else if (AIController.instance.IsPlayerCamping())
         {
             SetWaypoint(PrimaryEnemy.Position + BackwardVec * 2f);
         }
         else if (!BehindEnemyLines && DistanceToEnemy > profile.preferDistance.max && self.IsPointBehind(Waypoint))
         {
             SetWaypoint(GetClosestPOI(Forward), resolving: true);
         }
         else if (!IsLastManStanding && DistanceToAlly > profile.preferDistance.max)
         {
             SetWaypoint(PrimaryAlly.Position, resolving: true);
         }
     }
     if (state != 0)
     {
         return;
     }
     if (CurrentBehaviour == Behaviour.Aggressive || CurrentBehaviour == Behaviour.Casual)
     {
         if (PrimaryEnemy.NearBlocker && self.NearBlocker && BulletDef.type != BulletType.Missile)
         {
             Stop();
         }
         else if (boosterType == BoosterGameplayType.CircleSaw)
         {
             if (DistanceToEnemy > MeleeContactDistance - 1f)
             {
                 SetWaypoint(MeleeContactPoint);
             }
             else
             {
                 Stop();
             }
         }
         else if (IsCloseRangeWeapon())
         {
             if (DistanceToEnemy < MeleeContactDistance)
             {
                 SetWaypoint(MeleeContactPoint + BackwardVec * 2f);
             }
             else if (DistanceToEnemy > BulletDef.damageRange)
             {
                 SetWaypoint(MeleeContactPoint + BackwardVec * 2f);
             }
             else if (DistanceToEnemy < BulletDef.damageRange && !CanHitEnemy)
             {
                 SetWaypoint(MeleeContactPoint);
             }
             else
             {
                 Stop();
             }
         }
         else if (BulletDef.type == BulletType.Missile)
         {
             if (DistanceToEnemy > BulletDef.damageRange * 2f)
             {
                 SetWaypoint(GetClosestPOI(Forward, 5f));
             }
             else if (DistanceToEnemy < profile.preferDistance.min)
             {
                 SetWaypoint(GetClosestPOI(Backward));
             }
             else
             {
                 Stop();
             }
         }
         else if (DistanceToEnemy > profile.preferDistance.max && !self.NearBackBlocker)
         {
             SetWaypoint(GetClosestPOI(Forward, 5f));
         }
         else if (!CanHitEnemy)
         {
             SetWaypoint((DistanceToEnemy < profile.preferDistance.min) ? (Position + BackwardVec * 2f) : (Position + ForwardVec * 2f));
         }
         else
         {
             Stop();
         }
     }
     else if (CurrentBehaviour == Behaviour.Defensive)
     {
         if (self.IsPointBehind(MeleeContactPoint))
         {
             SetWaypoint(MeleeContactPoint + BackwardVec * profile.preferDistance.min);
         }
         else if (DistanceToEnemy < profile.preferDistance.min && !self.NearBackBlocker)
         {
             SetWaypoint(GetClosestPOI(Backward, profile.preferDistance.min));
         }
         else if (DistanceToEnemy < profile.preferDistance.min && PrimaryEnemy.NearFrontBlocker)
         {
             SetWaypoint(GetClosestPOI(Forward));
         }
         else if (DistanceToEnemy > profile.preferDistance.max)
         {
             SetWaypoint(GetClosestPOI(Forward));
         }
         else if (!CanHitEnemy)
         {
             if (DistanceToEnemy < profile.preferDistance.min)
             {
                 SetWaypoint(GetClosestPOI(Backward));
             }
             else
             {
                 SetWaypoint(GetClosestPOI(Forward));
             }
         }
         else
         {
             Stop();
         }
     }
     else if (CurrentBehaviour == Behaviour.Leader)
     {
         if (self.IsPointBehind(PrimaryAlly.Position) && DistanceToAlly > profile.preferDistance.min)
         {
             if (DistanceToEnemy > profile.preferDistance.max)
             {
                 Stop();
             }
             else
             {
                 SetWaypoint(GetClosestPOI(Backward));
             }
         }
         else if (PrimaryEnemy.IsPointBehind(Waypoint) || BehindEnemyLines)
         {
             SetWaypoint(PrimaryEnemy.Position + BackwardVec * profile.preferDistance.min);
         }
         else if (DistanceToEnemy < profile.preferDistance.min)
         {
             SetWaypoint(GetClosestPOI(Backward));
         }
         else if (DistanceToEnemy > profile.preferDistance.max)
         {
             SetWaypoint(GetClosestPOI(Backward, 0f - DistanceToEnemy));
         }
         else if (IsCloseRangeWeapon() || boosterType == BoosterGameplayType.CircleSaw)
         {
             if (DistanceToEnemy > BulletDef.damageRange)
             {
                 SetWaypoint(MeleeContactPoint + BackwardVec * profile.preferDistance.min);
             }
             else if (DistanceToEnemy < BulletDef.damageRange && !CanHitEnemy)
             {
                 SetWaypoint(MeleeContactPoint + BackwardVec * profile.preferDistance.min);
             }
             else
             {
                 Stop();
             }
         }
         else if (BulletDef.type == BulletType.Missile)
         {
             if (DistanceToEnemy > BulletDef.damageRange * 2f)
             {
                 SetWaypoint(GetClosestPOI(Forward, 5f));
             }
             else
             {
                 Stop();
             }
         }
         else if (!CanHitEnemy)
         {
             if (self.IsStationary)
             {
                 SetWaypoint(MeleeContactPoint);
             }
             else
             {
                 SetWaypoint(GetClosestPOI(Forward));
             }
         }
         else
         {
             Stop();
         }
     }
     else
     {
         if (CurrentBehaviour != Behaviour.Follower)
         {
             return;
         }
         if (!WaypointSet)
         {
             SetWaypoint(PrimaryAlly.Position);
         }
         if (DistanceToAlly > profile.preferDistance.max)
         {
             SetWaypoint(PrimaryAlly.Position);
             return;
         }
         if (!CanHitEnemy)
         {
             SetWaypoint(GetClosestPOI(Forward));
         }
         if (PrimaryEnemy.IsPointBehind(Waypoint) || BehindEnemyLines)
         {
             SetWaypoint(PrimaryAlly.Position + BackwardVec * profile.preferDistance.min);
         }
         if (!WaypointSet)
         {
             SetWaypoint(GetClosestPOI(Forward));
         }
     }
 }