Ejemplo n.º 1
0
    public void initalizeAIPriorities(Nation player)
    {
        TopLevel aiTopLevel = player.getAI().GetTopLevel();

        foreach (MyEnum.macroPriorities macro in Enum.GetValues(typeof(MyEnum.macroPriorities)))
        {
            aiTopLevel.setMacroPriority(player, macro, 1);
        }
        for (int i = 0; i < player.getProvinces().Count; i++)
        {
            int pIndex = player.getProvinces()[i];
            assemblyCsharp.Province prov = State.getProvinces()[pIndex];
            if (prov.getResource() == MyEnum.Resources.coal)
            {
                aiTopLevel.alterMacroPriority(player, MyEnum.macroPriorities.buildFactory, 0.15f);
                aiTopLevel.alterMacroPriority(player, MyEnum.macroPriorities.research, 0.15f);
            }
            if (prov.getResource() == MyEnum.Resources.cotton)
            {
                aiTopLevel.alterMacroPriority(player, MyEnum.macroPriorities.colonies, 0.1f);
                aiTopLevel.alterMacroPriority(player, MyEnum.macroPriorities.developProvince, 0.1f);
            }
            if (prov.getResource() == MyEnum.Resources.dyes)
            {
                aiTopLevel.alterMacroPriority(player, MyEnum.macroPriorities.developProvince, 0.1f);
            }
            if (prov.getResource() == MyEnum.Resources.gold)
            {
                aiTopLevel.alterMacroPriority(player, MyEnum.macroPriorities.culture, 0.15f);
                aiTopLevel.alterMacroPriority(player, MyEnum.macroPriorities.spheres, 0.15f);
            }
            if (prov.getResource() == MyEnum.Resources.iron)
            {
                aiTopLevel.alterMacroPriority(player, MyEnum.macroPriorities.buildFactory, 0.15f);
                aiTopLevel.alterMacroPriority(player, MyEnum.macroPriorities.conquest, 0.15f);
            }
            if (prov.getResource() == MyEnum.Resources.oil)
            {
                aiTopLevel.alterMacroPriority(player, MyEnum.macroPriorities.developProvince, 0.1f);
                aiTopLevel.alterMacroPriority(player, MyEnum.macroPriorities.conquest, 0.05f);
            }
            if (prov.getResource() == MyEnum.Resources.rubber)
            {
                aiTopLevel.alterMacroPriority(player, MyEnum.macroPriorities.research, 0.1f);
            }
            if (prov.getResource() == MyEnum.Resources.spice)
            {
                aiTopLevel.alterMacroPriority(player, MyEnum.macroPriorities.culture, 0.1f);
            }
            if (prov.getResource() == MyEnum.Resources.wood)
            {
                aiTopLevel.alterMacroPriority(player, MyEnum.macroPriorities.colonies, 0.1f);
                aiTopLevel.alterMacroPriority(player, MyEnum.macroPriorities.navy, 0.1f);
                aiTopLevel.alterMacroPriority(player, MyEnum.macroPriorities.buildFactory, 0.05f);
            }
        }
    }
Ejemplo n.º 2
0
    private void pickProductionPicture(assemblyCsharp.Province province)
    {
        MyEnum.Resources res = province.getResource();

        if (res == MyEnum.Resources.wheat || res == MyEnum.Resources.fruit || res == MyEnum.Resources.rubber || res == MyEnum.Resources.dyes)
        {
            DevelopmentImage.sprite = Resources.Load("Resource/Icons/plow", typeof(Sprite)) as Sprite;
        }
        if (res == MyEnum.Resources.oil)
        {
            DevelopmentImage.sprite = Resources.Load("Resource/Icons/oil_rig", typeof(Sprite)) as Sprite;
        }
        if (res == MyEnum.Resources.iron || res == MyEnum.Resources.coal || res == MyEnum.Resources.gold)
        {
            DevelopmentImage.sprite = Resources.Load("Resource/Icons/miningTools", typeof(Sprite)) as Sprite;
        }
        if (res == MyEnum.Resources.cotton)
        {
            DevelopmentImage.sprite = Resources.Load("Resource/Icons/cottonGinIcon", typeof(Sprite)) as Sprite;
        }
        if (res == MyEnum.Resources.meat)
        {
            DevelopmentImage.sprite = Resources.Load("Resource/Icons/barbedWire", typeof(Sprite)) as Sprite;
        }
        if (res == MyEnum.Resources.wood)
        {
            DevelopmentImage.sprite = Resources.Load("Resource/Icons/axe", typeof(Sprite)) as Sprite;
        }
    }
Ejemplo n.º 3
0
    public void ThatFillInData(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;
        Debug.Log("You f****r...." + province.getProduction().ToString());
        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;
        string nation = province.getOwner().ToString();

        Debug.Log("Owner: " + nation);
        this.DevelopmentLevel.text = province.getDevelopmentLevel().ToString();
        this.NationName.text       = nation;
        //text.text = "Province produces " + Resource;
        this.Flag.sprite = Resources.Load("Flags/" + province.getOwner().ToString(), typeof(Sprite)) as Sprite;
        pickProductionPicture(province);
        // Text flagText = FlagTip.GetComponentInChildren<Text>();
        // Debug.Log("Flag text: " + flagText.text);
        // flagText.text = Owner;
        //flagTip.GetComponent<Text>().text = nation;
    }
Ejemplo n.º 4
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);
    }
Ejemplo n.º 5
0
    private void distributeStartingResourcesAndGoods(Nation player)
    {
        for (int i = 0; i < player.getProvinces().Count; i++)
        {
            int index = player.getProvinceIndex(i);
            assemblyCsharp.Province prov = State.getProvinces()[index];
            MyEnum.Resources        res  = prov.getResource();
            float amount = prov.getProduction();
            if (res == MyEnum.Resources.gold)
            {
                player.receiveGold(amount * 5);
            }
            else
            {
                player.collectResource(res, amount);
            }
            player.addRuralPOP();
            player.addRuralPOP();
        }

        player.receiveGold(5);

        if (player.getType() == MyEnum.NationType.major)
        {
            player.collectGoods(MyEnum.Goods.steel, 1);
            player.collectGoods(MyEnum.Goods.fabric, 1);
            player.collectGoods(MyEnum.Goods.lumber, 1);
            player.collectGoods(MyEnum.Goods.arms, 2);

            player.collectResource(MyEnum.Resources.wheat, 1);
            player.collectResource(MyEnum.Resources.meat, 0.5f);
            player.collectResource(MyEnum.Resources.fruit, 0.5f);
            player.receiveGold(5);
        }
    }
Ejemplo n.º 6
0
    private static void collectResources(Nation player)
    {
        for (int i = 0; i < player.getProvinces().Count; i++)
        {
            int index = player.getProvinces()[i];
            assemblyCsharp.Province prov = State.getProvinces()[index];
            float            resYield    = prov.getProduction();
            MyEnum.Resources res         = prov.getResource();
            Debug.Log("prov res: " + res);
            if (res != MyEnum.Resources.gold)
            {
                player.collectResource(res, resYield);
            }
            else
            {
                player.receiveGold(resYield * 5);
            }
        }

        for (int i = 0; i < player.getColonies().Count; i++)
        {
            int index = player.getColonies()[i];
            assemblyCsharp.Province prov = State.getProvinces()[index];
            float            resYield    = prov.getProduction();
            MyEnum.Resources res         = prov.getResource();
            player.collectResource(res, resYield);
        }
    }
Ejemplo n.º 7
0
    public void ThatFillInData(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.Produces.text      = "Produces " + Produces.ToString() + " " + 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;
        string nation = province.getOwner().ToString();

        this.NationName.text = nation;
        //text.text = "Province produces " + Resource;
        this.Flag.sprite = Resources.Load("Flags/" + province.getOwner().ToString(), typeof(Sprite)) as Sprite;
        // Text flagText = FlagTip.GetComponentInChildren<Text>();
        // Debug.Log("Flag text: " + flagText.text);
        // flagText.text = Owner;
    }
Ejemplo n.º 8
0
    private void prepareAuctionPanel(AuctionHandler auction)
    {
        increaseBid.enabled = true;
        decreaseBid.enabled = true;
        App             app         = UnityEngine.Object.FindObjectOfType <App>();
        int             playerIndex = app.GetHumanIndex();
        Nation          player      = State.getNations()[playerIndex];
        TextMeshProUGUI title       = AuctionPanelTitleText.GetComponent <TextMeshProUGUI>();
        Nation          item        = State.getNations()[0];

        // Colony Auction
        backGroudImage.sprite = Resources.Load("Sprites/BackGrounds/imperialism_cartoon", typeof(Sprite)) as Sprite;
        title.text            = "Colony Bids";
        pointTypeText.text    = "Colonial Points";
        // PointTypeImage.sprite = Resources.Load("Sprites/GUI/eagle", typeof(Sprite)) as Sprite;

        item = State.getNations()[auction.getIndexOfCurrentItem()];

        // GameObject mapPrefab = Instantiate(Resources.Load<GameObject>("RPG100set/512/Prop/06_letter" + item.getNationName()));
        currentNumberOfBiddingPoints.text = player.GetColonialPoints().ToString();
        if (player.GetColonialPoints() < State.CurrentColonyAuctionBid || player.RecognizingTheseClaims.Contains(item.getIndex()) || player.landForces.Strength < 2)
        {
            increaseBid.interactable = false;
        }
        else
        {
            increaseBid.interactable = true;
        }

        TextMeshProUGUI itemName = ItemNameText.GetComponent <TextMeshProUGUI>();

        itemName.text = item.getNationName();

        GameObject itemFlag = Instantiate(Resources.Load <GameObject>("Flags/Prefabs/" + item.getNationName()));

        itemFlag1.ObjectPrefab = itemFlag.transform;

        // TextMeshProUGUI currentPlayerBid = currentBidAmount.GetComponent<TextMeshProUGUI>();
        currentBidAmount.text = "00";
        int firstProvIndex  = -1;
        int secondProvIndex = -1;

        foreach (int provIndex in item.getProvinces())
        {
            if (firstProvIndex == -1)
            {
                firstProvIndex = provIndex;
            }
            else
            {
                secondProvIndex = provIndex;
            }
        }

        assemblyCsharp.Province firstProvince = State.getProvince(firstProvIndex);
        itemProvinces.Rows[1].Cells[0].GetComponentInChildren <Text>().text = firstProvince.getProvName();
        //  itemProvinces.Rows[1].Cells[1].GetComponentInChildren<Image>().sprite =
        Transform P1Res      = itemProvinces.Rows[1].Cells[1].transform.GetChild(0);
        Image     P1ResImage = P1Res.GetComponent <Image>();

        // Image provOneRes = itemProvinces.Rows[1].Cells[1].GetComponentInChildren<Image>() as Image;
        //resImg.sprite = Resources.Load("Resource/" + imp.getResourceType().ToString(), typeof(Sprite)) as Sprite;
        //  Debug.Log("First Resource is: " + firstProvince.getResource());
        P1ResImage.sprite = Resources.Load("Resource/" + firstProvince.getResource().ToString(), typeof(Sprite)) as Sprite;
        itemProvinces.Rows[1].Cells[2].GetComponentInChildren <Text>().text = firstProvince.getDevelopmentLevel().ToString();
        Toggle provOneRail = itemProvinces.Rows[1].Cells[3].GetComponentInChildren <Toggle>();

        if (firstProvince.getRail())
        {
            provOneRail.isOn = true;
        }
        else
        {
            provOneRail.isOn = false;
        }

        assemblyCsharp.Province secondProvince = State.getProvince(secondProvIndex);
        itemProvinces.Rows[2].Cells[0].GetComponentInChildren <Text>().text = secondProvince.getProvName();
        //  itemProvinces.Rows[1].Cells[1].GetComponentInChildren<Image>().sprite =
        // Image provTwoRes = itemProvinces.Rows[2].Cells[1].GetComponentInChildren<Image>() as Image;
        // Debug.Log("Second Resource is: " + secondProvince.getResource());
        Transform P2Res      = itemProvinces.Rows[2].Cells[1].transform.GetChild(0);
        Image     P2ResImage = P2Res.GetComponent <Image>();

        P2ResImage.sprite = Resources.Load("Resource/" + secondProvince.getResource().ToString(), typeof(Sprite)) as Sprite;
        itemProvinces.Rows[2].Cells[2].GetComponentInChildren <Text>().text = secondProvince.getDevelopmentLevel().ToString();
        Toggle provTwoRail = itemProvinces.Rows[2].Cells[3].GetComponentInChildren <Toggle>();

        if (secondProvince.getRail())
        {
            provTwoRail.isOn = true;
        }
        else
        {
            provTwoRail.isOn = false;
        }
        if (item.IsColonyOf() != -1)
        {
            Nation currentOwner = State.getNations()[item.IsColonyOf()];
            currentOwnerName.text         = currentOwner.getNationName();
            relationWithCurrentOwner.text = player.Relations[currentOwner.getIndex()].ToString();
        }
        else
        {
            currentOwnerName.text = "None";
        }

        if (player.RecognizingTheseClaims.Contains(item.getIndex()))
        {
            isRecognizing.isOn = true;
        }
        else
        {
            isRecognizing.isOn = false;
        }
    }
Ejemplo n.º 9
0
    public void initalizeResourcePriorities(Nation player)
    {
        TopLevel aiTopLevel = player.getAI().GetTopLevel();

        aiTopLevel.setResPriority(player, MyEnum.Resources.wheat, 3);
        aiTopLevel.setResPriority(player, MyEnum.Resources.meat, 2.5f);
        aiTopLevel.setResPriority(player, MyEnum.Resources.fruit, 2.5f);
        aiTopLevel.setResPriority(player, MyEnum.Resources.coal, 1);
        aiTopLevel.setResPriority(player, MyEnum.Resources.cotton, 1.5f);
        aiTopLevel.setResPriority(player, MyEnum.Resources.dyes, 2.5f);
        aiTopLevel.setResPriority(player, MyEnum.Resources.gold, 3f);
        aiTopLevel.setResPriority(player, MyEnum.Resources.iron, 2.25f);
        aiTopLevel.setResPriority(player, MyEnum.Resources.oil, 0.25f);
        aiTopLevel.setResPriority(player, MyEnum.Resources.rubber, 0.25f);
        aiTopLevel.setResPriority(player, MyEnum.Resources.spice, 2.75f);
        aiTopLevel.setResPriority(player, MyEnum.Resources.wood, 1.5f);

        for (int i = 0; i < player.getProvinces().Count; i++)
        {
            int pIndex = player.getProvinces()[i];
            assemblyCsharp.Province prov = State.getProvinces()[pIndex];
            if (prov.getResource() == MyEnum.Resources.wheat)
            {
                aiTopLevel.alterResPriority(player, MyEnum.Resources.wheat, -0.2f);
            }
            if (prov.getResource() == MyEnum.Resources.meat)
            {
                aiTopLevel.alterResPriority(player, MyEnum.Resources.meat, -0.15f);
            }
            if (prov.getResource() == MyEnum.Resources.fruit)
            {
                aiTopLevel.alterResPriority(player, MyEnum.Resources.fruit, -0.15f);
            }
            if (prov.getResource() == MyEnum.Resources.coal)
            {
                aiTopLevel.alterResPriority(player, MyEnum.Resources.iron, 0.15f);
                aiTopLevel.alterResPriority(player, MyEnum.Resources.coal, -0.05f);
            }
            if (prov.getResource() == MyEnum.Resources.cotton)
            {
                aiTopLevel.alterResPriority(player, MyEnum.Resources.dyes, 0.16f);
                aiTopLevel.alterResPriority(player, MyEnum.Resources.cotton, -0.075f);
                aiTopLevel.alterResPriority(player, MyEnum.Resources.wood, 0.075f);
            }

            if (prov.getResource() == MyEnum.Resources.dyes)
            {
                aiTopLevel.alterResPriority(player, MyEnum.Resources.cotton, 0.2f);
            }
            if (prov.getResource() == MyEnum.Resources.gold)
            {
                aiTopLevel.alterResPriority(player, MyEnum.Resources.gold, -0.15f);
            }
            if (prov.getResource() == MyEnum.Resources.iron)
            {
                aiTopLevel.alterResPriority(player, MyEnum.Resources.coal, 0.1f);
                aiTopLevel.alterResPriority(player, MyEnum.Resources.iron, -0.075f);
            }
            if (prov.getResource() == MyEnum.Resources.oil)
            {
                aiTopLevel.alterResPriority(player, MyEnum.Resources.oil, -0.075f);
            }
            if (prov.getResource() == MyEnum.Resources.rubber)
            {
                aiTopLevel.alterResPriority(player, MyEnum.Resources.rubber, -0.075f);
            }
            if (prov.getResource() == MyEnum.Resources.spice)
            {
                aiTopLevel.alterResPriority(player, MyEnum.Resources.gold, -0.075f);
            }
            if (prov.getResource() == MyEnum.Resources.wood)
            {
                aiTopLevel.alterResPriority(player, MyEnum.Resources.wood, -0.1f);
                aiTopLevel.alterResPriority(player, MyEnum.Resources.cotton, 0.075f);
            }
        }
    }
Ejemplo n.º 10
0
    //just for AI
    public void initalizeFactoryPriorities(Nation player)
    {
        TopLevel aiTopLevel = player.getAI().GetTopLevel();

        foreach (MyEnum.Goods good in Enum.GetValues(typeof(MyEnum.Goods)))
        {
            aiTopLevel.setFactPriority(player, good, 1);
        }

        for (int i = 0; i < player.getProvinces().Count; i++)
        {
            int pIndex = player.getProvinces()[i];
            assemblyCsharp.Province prov = State.getProvinces()[pIndex];

            if (prov.getResource() == MyEnum.Resources.coal)
            {
                aiTopLevel.alterFactPriority(player, MyEnum.Goods.steel, 0.25f);
                aiTopLevel.alterFactPriority(player, MyEnum.Goods.parts, 0.15f);
                aiTopLevel.alterFactPriority(player, MyEnum.Goods.arms, 0.15f);
                aiTopLevel.alterFactPriority(player, MyEnum.Goods.chemicals, 0.2f);
            }
            if (prov.getResource() == MyEnum.Resources.cotton)
            {
                aiTopLevel.alterFactPriority(player, MyEnum.Goods.fabric, 0.25f);
                aiTopLevel.alterFactPriority(player, MyEnum.Goods.clothing, 0.2f);
                aiTopLevel.alterFactPriority(player, MyEnum.Goods.furniture, 0.1f);
            }

            if (prov.getResource() == MyEnum.Resources.dyes)
            {
                aiTopLevel.alterFactPriority(player, MyEnum.Goods.fabric, 0.25f);
                aiTopLevel.alterFactPriority(player, MyEnum.Goods.clothing, 0.2f);
            }

            if (prov.getResource() == MyEnum.Resources.iron)
            {
                aiTopLevel.alterFactPriority(player, MyEnum.Goods.steel, 0.25f);
                aiTopLevel.alterFactPriority(player, MyEnum.Goods.parts, 0.2f);
                aiTopLevel.alterFactPriority(player, MyEnum.Goods.arms, 0.2f);
                aiTopLevel.alterFactPriority(player, MyEnum.Goods.gear, 0.075f);
                aiTopLevel.alterFactPriority(player, MyEnum.Goods.auto, 0.075f);
                aiTopLevel.alterFactPriority(player, MyEnum.Goods.tank, 0.12f);
            }

            if (prov.getResource() == MyEnum.Resources.oil)
            {
                aiTopLevel.alterFactPriority(player, MyEnum.Goods.auto, 0.15f);
                aiTopLevel.alterFactPriority(player, MyEnum.Goods.fighter, 0.1f);
                aiTopLevel.alterFactPriority(player, MyEnum.Goods.tank, 0.1f);
            }
            if (prov.getResource() == MyEnum.Resources.rubber)
            {
                aiTopLevel.alterFactPriority(player, MyEnum.Goods.gear, 0.25f);
                aiTopLevel.alterFactPriority(player, MyEnum.Goods.telephone, 0.2f);
                aiTopLevel.alterFactPriority(player, MyEnum.Goods.auto, 0.12f);
                aiTopLevel.alterFactPriority(player, MyEnum.Goods.fighter, 0.075f);
                aiTopLevel.alterFactPriority(player, MyEnum.Goods.tank, 0.075f);
            }

            if (prov.getResource() == MyEnum.Resources.wood)
            {
                aiTopLevel.alterFactPriority(player, MyEnum.Goods.lumber, 0.25f);
                aiTopLevel.alterFactPriority(player, MyEnum.Goods.paper, 0.25f);
                aiTopLevel.alterFactPriority(player, MyEnum.Goods.furniture, 0.15f);
                aiTopLevel.alterFactPriority(player, MyEnum.Goods.telephone, 0.075f);
                aiTopLevel.alterFactPriority(player, MyEnum.Goods.fighter, 0.075f);
            }
        }
    }