Example #1
0
 private void Client_TurnBegin_CheckKaijuStatus()
 {
     if (this.Kaiju != null)
     {
         if (this.Kaiju.IsStunned())
         {
             if (this.Kaiju.NextTurnToRecoverFromStun > 0 && (this.gameService.Game as global::Game).Turn == this.Kaiju.NextTurnToRecoverFromStun)
             {
                 this.Kaiju.ChangeToWildState();
             }
         }
         else if (this.Kaiju.IsWild() && this.Kaiju.OnArmyMode())
         {
             global::PlayerController server = this.KaijuEmpire.PlayerControllers.Server;
             if (server != null)
             {
                 Region validKaijuRegion = KaijuCouncil.GetValidKaijuRegion();
                 if (validKaijuRegion == null)
                 {
                     Diagnostics.LogWarning("Unable to find suitable region");
                     return;
                 }
                 WorldPosition validKaijuPosition = KaijuCouncil.GetValidKaijuPosition(validKaijuRegion, false);
                 if (validKaijuPosition == WorldPosition.Zero)
                 {
                     Diagnostics.LogWarning("Unable to find suitable position in target region");
                     return;
                 }
                 OrderRelocateKaiju order = new OrderRelocateKaiju(this.Kaiju.GUID, validKaijuPosition);
                 server.PostOrder(order);
             }
         }
     }
 }
    private WorldPosition GetBestDefensiveKaijuPosition(Region targetRegion)
    {
        Region[] neighbourRegionsWithCityOfEmpire = this.worldPositionningService.GetNeighbourRegionsWithCityOfEmpire(targetRegion, this.MajorEmpire, false);
        if (neighbourRegionsWithCityOfEmpire.Length == 0)
        {
            return(KaijuCouncil.GetValidKaijuPosition(targetRegion, false));
        }
        List <WorldPosition> list = (from position in targetRegion.WorldPositions
                                     where KaijuCouncil.IsPositionValidForSettleKaiju(position, null)
                                     select position).ToList <WorldPosition>();

        if (list.Count == 0)
        {
            return(WorldPosition.Invalid);
        }
        int num   = -1;
        int index = -1;

        for (int i = 0; i < list.Count; i++)
        {
            int num2 = 0;
            foreach (Region region in neighbourRegionsWithCityOfEmpire)
            {
                int distance = this.worldPositionningService.GetDistance(list[i], region.City.WorldPosition);
                num2 += ((distance > 5) ? Mathf.Max(15 - distance, 0) : ((15 - distance) * 3));
            }
            if (num2 > num)
            {
                num   = num2;
                index = i;
            }
        }
        return(list[index]);
    }
Example #3
0
    public void TryRelocateKaijuOrResetETA()
    {
        global::PlayerController server = this.KaijuEmpire.PlayerControllers.Server;
        Region validKaijuRegion         = KaijuCouncil.GetValidKaijuRegion();

        if (validKaijuRegion == null)
        {
            if (this.Kaiju != null)
            {
                this.ResetRelocationETA();
            }
            Diagnostics.LogWarning("Unable to find suitable region. Reset Kaiju ETA!");
            return;
        }
        WorldPosition validKaijuPosition = KaijuCouncil.GetValidKaijuPosition(validKaijuRegion, false);

        if (validKaijuPosition == WorldPosition.Zero)
        {
            if (this.Kaiju != null)
            {
                this.ResetRelocationETA();
            }
            Diagnostics.LogWarning("Unable to find suitable position in target region. Reset Kaiju ETA.");
            return;
        }
        if (server != null && this.Kaiju != null && this.Kaiju.OnGarrisonMode() && this.Kaiju.IsWild())
        {
            IPlayerControllerRepositoryService service = this.gameService.Game.Services.GetService <IPlayerControllerRepositoryService>();
            OrderRelocateKaiju order = new OrderRelocateKaiju(this.Kaiju.GUID, validKaijuPosition);
            server.PostOrder(order);
        }
    }