Beispiel #1
0
 public void SetOnArmy(Army army)
 {
     Army        = army;
     army.Active = false;
     MapMetrics.UpdateAgentVision(army.curPosition, army.curPosition, army.VisionRadius, -1);
     army.gameObject.SetActive(false);
 }
Beispiel #2
0
 public void CellChange(Vector2Int oldCell, Vector2Int newCell)
 {
     FindLand(newCell);
     if (curOwner == Player.curPlayer)
     {
         MapMetrics.UpdateAgentVision(oldCell, newCell, VisionRadius);
         MapMetrics.UpdateSplatMap();
         Army.FoggedArmy();
     }
 }
Beispiel #3
0
    public void WhitePeace(State annexator, State target)
    {
        foreach (var reg in annexator.regions)
        {
            if (reg.ocptby == target)
            {
                reg.ocptby = null;
            }
        }
        foreach (var army in annexator.army)
        {
            if (army.navAgent.target?.curOwner == target)
            {
                army.navAgent.target = null;
            }
        }
        foreach (var reg in target.regions)
        {
            if (reg.ocptby == annexator)
            {
                reg.ocptby = null;
            }
        }

        foreach (var army in target.army)
        {
            if (army.navAgent.target?.curOwner == annexator)
            {
                army.navAgent.target = null;
            }
        }

        foreach (var reg in regions)
        {
            reg.UpdateSplateState(curPlayer);
        }
        foreach (var agent in curPlayer.army)
        {
            MapMetrics.UpdateAgentVision(agent.curPosition, agent.curPosition, agent.VisionRadius, 1);
        }
        foreach (var agent in curPlayer.ships)
        {
            MapMetrics.UpdateAgentVision(agent.curPosition, agent.curPosition, agent.VisionRadius, 1);
        }
        if (target.stateAI.autoArmyCommander.IsOn)
        {
            target.stateAI.autoArmyCommander.RecalculateRegions();
        }
        if (annexator.stateAI.autoArmyCommander.IsOn)
        {
            annexator.stateAI.autoArmyCommander.RecalculateRegions();
        }
        MapMetrics.UpdateOccupedMap();
        MapMetrics.UpdateSplatMap();
    }
Beispiel #4
0
    public static void SetState(State state)
    {
        if (state != null)
        {
            MenuManager.SetState(state);
        }

        curPlayer = state;
        foreach (var r in curPlayer.regions)
        {
            if (r.data.portLevel != 0)
            {
                Ship.CreateShip(r);
            }
        }
        foreach (Region r in regions)
        {
            r.UpdateSplateState(curPlayer);
            r.UpdateBorder();
        }
        for (int i = 0; i < states.Count; i++)
        {
            states[i].SetNameStatus(!CameraController.showstate);
            states[i].stateAI.autoBuilder.IsOn         = (state != states[i]);
            states[i].stateAI.autoReasercher.IsOn      = (state != states[i]);
            states[i].stateAI.autoTrader.IsOn          = (state != states[i]);
            states[i].stateAI.autoRegimentBuilder.IsOn = (state != states[i]);
            states[i].stateAI.autoArmyCommander.IsOn   = (state != states[i]);
            states[i].stateAI.autoPersonControl.IsOn   = (state != states[i]);
            states[i].stateAI.autoDiplomacy.IsOn       = (state != states[i]);
        }
        foreach (var army in Army.AllArmy)
        {
            army.GetComponent <ArmyAI>().enabled = army.owner != state;
        }
        foreach (var army in state.army)
        {
            MapMetrics.UpdateAgentVision(army.curPosition, army.curPosition, army.VisionRadius, 1);
        }
        foreach (var ship in state.ships)
        {
            MapMetrics.UpdateAgentVision(ship.curPosition, ship.curPosition, ship.VisionRadius, 1);
        }
        CameraController.SetTarget(curPlayer.Capital.pos);
        StateStatistic.ShowStates();
        Army.FoggedArmy();
        MapMetrics.UpdateSplatMap();
        MenuManager.HiddenProvinceMenu();
        GameTimer.UpdateListenerQueue();
    }
Beispiel #5
0
    private void ShipInitialization(Region region)
    {
        Vector2 v = region.Port.CornerPosition;

        SetPosition(v);
        curOwner = region.owner;

        navAgent         = gameObject.AddComponent <NavAgent>();
        navAgent.pos     = v;
        navAgent.curCell = new Vector2Int((int)v.x, (int)v.y);
        FindLand(navAgent.curCell);
        navAgent.SetToMovable(this);
        Select(false);
        if (Player.curPlayer == curOwner)
        {
            MapMetrics.UpdateAgentVision(navAgent.curCell, navAgent.curCell, VisionRadius, 1);
        }
    }
Beispiel #6
0
 public bool CanDesant(Vector3 point)
 {
     if (!NearestLand.HasValue || Army == null)
     {
         return(false);
     }
     Army.navAgent.curCell = NearestLand.Value;
     Army.navAgent.pos     = NearestLand.Value;
     if (Army.TryMoveTo(point))
     {
         Army.Active = true;
         Army.gameObject.SetActive(true);
         MapMetrics.UpdateAgentVision(Army.curPosition, Army.curPosition, Army.VisionRadius, 1);
         Army = null;
         return(true);
     }
     return(false);
 }