Пример #1
0
    public void ThisFillInData(assemblyCsharp.Province province)
    {
        this.Name.text = province.getProvName();
        string resource          = province.getResource().ToString();
        Sprite newResourceSprite = Resources.Load("Resource/" + resource, typeof(Sprite)) as Sprite;

        this.Resource.sprite         = newResourceSprite;
        this.Resource.preserveAspect = true;

        this.Produces.text      = "Produces " + province.getProduction().ToString("0.0") + " " + resource + " /turn";
        this.RailroadLevel.text = province.getInfrastructure().ToString();
        this.FortLevel.text     = province.getFortLevel().ToString();
        this.Culture.text       = "Culture: " + province.culture;
        // this.resourceText.text = "Province produces " + resource;
        // Text text = ResourceTip.GetComponentInChildren<Text>();
        // text.text =  "Province produces " + Resource;
        pickProductionPicture(province);

        State.setCurrentlySelectedProvince(province.getIndex());
        App    app         = UnityEngine.Object.FindObjectOfType <App>();
        int    playerIndex = app.GetHumanIndex();
        Nation player      = State.getNations()[playerIndex];

        updateSelfProvinceButtons(player, province);
    }
Пример #2
0
    private void initalizeArmies(Nation player)
    {
        player.GetMilitaryForm().setMaxMorale(1);
        Army firstArmy = new Army(player.getIndex());

        // Debug.Log("Nation Type: " + player.getType() + "________________________");
        if (player.getType() == MyEnum.NationType.major)
        {
            //    Debug.Log("Any Major Nations Here?");
            firstArmy.addUnit(MyEnum.ArmyUnits.infantry);
            firstArmy.addUnit(MyEnum.ArmyUnits.infantry);
            firstArmy.addUnit(MyEnum.ArmyUnits.cavalry);

            Fleet firstFleet = new Fleet(player.getIndex());
            firstFleet.addUnit(MyEnum.NavyUnits.frigates, 1);
            player.addFleet(firstFleet);
            //Still need to place fleet
        }
        else
        {
            firstArmy.addUnit(MyEnum.ArmyUnits.infantry);
        }
        player.addArmy(firstArmy);
        PlaceArmy armyPlacer = new PlaceArmy();
        string    capName    = player.capital;

        Debug.Log(player.getNationName());
        Debug.Log(capName);
        assemblyCsharp.Province prov = State.GetProvinceByName(capName);
        int capIndex = prov.getIndex();

        armyPlacer.placeArmyOnMap(capIndex, player, firstArmy.GetIndex());
        player.setMilitaryScore();
        Debug.Log("Military Score: " + player.getMilitaryScore().ToString());
    }
Пример #3
0
 private static void placeNewLandUnits(Nation player)
 {
     foreach (MyEnum.ArmyUnits unitType in Enum.GetValues(typeof(MyEnum.ArmyUnits)))
     {
         string capitalString            = player.capital;
         assemblyCsharp.Province capital = State.GetProvinceByName(capitalString);
         for (int i = 0; i < player.getArmyProducing(unitType); i++)
         {
             Army newArmy = new Army(player.getIndex());
             newArmy.addUnit(unitType);
             newArmy.setLocation(capital.getIndex());
             capital.addFriendlyArmy(newArmy.GetIndex());
             player.addArmy(newArmy);
             armyPlacer.placeArmyOnMap(capital.getIndex(), player, newArmy.GetIndex());
         }
     }
 }
Пример #4
0
    public void drawRailroadOnMap(assemblyCsharp.Province prov, Nation player)
    {
        WorldMapStrategyKit.Province mapProvince = map.provinces[prov.getIndex()];
        Vector2 provCenter = mapProvince.center;

        for (int i = 0; i < prov.Neighbours.Count; i++)
        {
            if (PlayerCalculator.getAllProvinces(player).Contains(prov.Neighbours[i]))
            {
                // draw rail segment from prv to neighbourProv
                assemblyCsharp.Province neighbourProvince = State.getProvinces()[prov.Neighbours[i]];
                if (neighbourProvince.railroad && !neighbourProvince.Linked.Contains(prov.getIndex()) &&
                    !prov.Linked.Contains(neighbourProvince.getIndex()))
                {
                    WorldMapStrategyKit.Province mapNeighbourProvince = map.provinces[prov.Neighbours[i]];
                    Vector2    neighbourCenter = mapNeighbourProvince.center;
                    Cell       startCell       = map.GetCell(provCenter);
                    Cell       endCell         = map.GetCell(neighbourCenter);
                    List <int> cellIndices     = map.FindRoute(startCell, endCell, TERRAIN_CAPABILITY.OnlyGround);
                    if (cellIndices == null)
                    {
                        return;
                    }
                    int positionsCount = cellIndices.Count;
                    Debug.Log("Number of positions: " + positionsCount);

                    Vector2[] positions = new Vector2[positionsCount];
                    for (int k = 0; k < positionsCount; k++)
                    {
                        positions[k] = map.cells[cellIndices[k]].center;
                    }

                    // Build a railroad along the map coordinates
                    LineMarkerAnimator lma         = map.AddLine(positions, Color.white, 0.0f, 0.15f);
                    Texture2D          railwayMatt = Resources.Load("Sprites/GUI/railRoad", typeof(Texture2D)) as Texture2D;

                    lma.lineMaterial.mainTexture      = railwayMatt;
                    lma.lineMaterial.mainTextureScale = new Vector2(16f, 2f);
                    neighbourProvince.Linked.Add(prov.getIndex());
                    prov.Linked.Add(neighbourProvince.getIndex());
                }
            }
        }
    }
Пример #5
0
    private void pickNewFleetPosition(Nation player)
    {
        WMSK map = WMSK.instance;

        Debug.Log(player.getNationName());
        string capitalString = player.capital;

        assemblyCsharp.Province capital = State.GetProvinceByName(capitalString);
        int            capitalIndex     = capital.getIndex();
        List <Vector2> capitalCoast     = map.GetProvinceCoastalPoints(capitalIndex);
        int            coastSize        = capitalCoast.Count;
        int            middle           = (int)coastSize / 2;
        //   Debug.Log("Middle: " + middle);
        Vector2 navalChoice = capitalCoast[middle];

        player.setNewNavyPosition(navalChoice);
    }
Пример #6
0
    private static void placeNewSeaUnits(Nation player)
    {
        WMSK map = WMSK.instance;

        foreach (MyEnum.NavyUnits unitType in Enum.GetValues(typeof(MyEnum.ArmyUnits)))
        {
            string capitalString            = player.capital;
            assemblyCsharp.Province capital = State.GetProvinceByName(capitalString);
            for (int i = 0; i < player.getNavyProducing(unitType); i++)
            {
                Fleet newFleet = new Fleet(player.getIndex());
                newFleet.addUnit(unitType, 1);
                // map.GetProvinceCoastalPoints
                newFleet.setLocation(capital.getIndex());
                player.addFleet(newFleet);

                //maybe add mount object for port and have new fleets appear there by default
            }
        }
    }