Exemplo n.º 1
0
    private void IncreaseIP()
    {
        App    app    = UnityEngine.Object.FindObjectOfType <App>();
        Nation player = State.getNations()[app.GetHumanIndex()];

        PlayerPayer.payForIP(player);
        Debug.Log("Increasing AP");
        if (player.getNumberResource(MyEnum.Resources.spice) < 1 || player.getAP() < 1 ||
            player.getNumberGood(MyEnum.Goods.furniture) < 1)
        {
            encourageCapitalists.interactable = false;
        }
        MyEnum.Era era = State.era;
        if (era == MyEnum.Era.Middle && player.getNumberGood(MyEnum.Goods.paper) < 1)
        {
            encourageCapitalists.interactable = false;
        }
        if (era == MyEnum.Era.Late && (player.getNumberGood(MyEnum.Goods.telephone) < 1 ||
                                       player.getNumberGood(MyEnum.Goods.auto) < 1))
        {
            encourageCapitalists.interactable = false;
        }
        PlayerReceiver.receiveIP(player);
        currentIP.text = player.getIP().ToString();
        capLevel.text  = player.getInvestmentLevel().ToString();
        AP.text        = player.getAP().ToString();
    }
Exemplo n.º 2
0
    private void RecruitColonists()
    {
        App    app    = UnityEngine.Object.FindObjectOfType <App>();
        Nation player = State.getNations()[app.GetHumanIndex()];

        PlayerPayer.payForColonialists(player);

        if (player.getNumberGood(MyEnum.Goods.clothing) < 1 || player.getAP() < 1 ||
            player.getNumberGood(MyEnum.Goods.furniture) < 1)
        {
            recruitColonists.interactable = false;
        }
        MyEnum.Era era = State.era;
        if (era != MyEnum.Era.Early && player.getNumberGood(MyEnum.Goods.paper) < 1)
        {
            recruitColonists.interactable = false;
        }
        if (era == MyEnum.Era.Late && player.getNumberResource(MyEnum.Resources.spice) < 1)
        {
            recruitColonists.interactable = false;
        }
        currentColonialPoints.text = player.ColonialPoints.ToString();
        string numCol = player.getColonies().Count.ToString();

        currentNumberColonies.text = numCol;
        colonialLevel.text         = player.getColonialLevel().ToString();
        AP.text = player.getAP().ToString();
    }
Exemplo n.º 3
0
    private void getTacticCards()
    {
        Debug.Log("press tactic cards");
        App    app    = UnityEngine.Object.FindObjectOfType <App>();
        Nation player = State.getNations()[app.GetHumanIndex()];

        //....................

        PlayerPayer.payTacticCards(player);
        PlayerReceiver.collectTacticCards(player);

        drawTacticCards.interactable = true;

        MyEnum.Era era = State.era;
        if (player.getNumberGood(MyEnum.Goods.arms) < 1 || player.getAP() < 1 ||
            player.getNumberResource(MyEnum.Resources.spice) < 1)
        {
            drawTacticCards.interactable = false;
        }
        if (era != MyEnum.Era.Early)
        {
            if (player.getNumberGood(MyEnum.Goods.furniture) < 1)
            {
                drawTacticCards.interactable = false;
            }
        }
        if (era == MyEnum.Era.Late && player.getNumberGood(MyEnum.Goods.auto) < 1)
        {
            drawTacticCards.interactable = false;
        }
        showTacticsHandPanel();
        AP.text = player.getAP().ToString();
    }
Exemplo n.º 4
0
    public void UpgradeFactory()
    {
        App    app  = UnityEngine.Object.FindObjectOfType <App>();
        string type = GetComponentInChildren <Text>().text;
        //    MyEnum.Goods goodType = (MyEnum.Goods)System.Enum.Parse(typeof(MyEnum.Goods), type);
        Nation player = State.getNations()[app.GetHumanIndex()];

        PlayerPayer.payForFactory(player, good);
        player.industry.setFactoryLevel(good, player.industry.getFactoryLevel(good) + 1);
        int factoryLevel = player.industry.getFactoryLevel(good);

        if (factoryLevel == 1)
        {
            productionLevelImage.sprite = Resources.Load("Sprites/factorySmall",
                                                         typeof(Sprite)) as Sprite;
        }
        if (factoryLevel == 2)
        {
            productionLevelImage.sprite = Resources.Load("Sprites/FactoryBig") as Sprite;
        }
        PlayerReceiver.increaseFactoryLevel(player, good);
        float ableToProduce = player.industry.determineCanProduce(good, player);

        canProduce.text     = "Able to Produce: " + ableToProduce.ToString();
        slider.maxValue     = (float)Math.Floor(ableToProduce);
        APValue.text        = player.getAP().ToString();
        button.interactable = false;
    }
Exemplo n.º 5
0
    /* private void buildNavy()
     * {
     *   App app = UnityEngine.Object.FindObjectOfType<App>();
     *   int playerIndex = app.GetHumanIndex();
     *   Nation player = State.getNations()[playerIndex];
     *   if (player.GetTechnologies().Contains("oil_powered_ships"))
     *   {
     *       PlayerPayer.PayDreadnought(player);
     *       player.seaForces.dreadnought.addUnit();
     *   }
     *
     *   else if (player.GetTechnologies().Contains("ironclad"))
     *   {
     *       PlayerPayer.PayIronClad(player);
     *       player.seaForces.ironclad.addUnit();
     *   }
     *   else
     *   {
     *       PlayerPayer.PayFrigate(player);
     *       player.seaForces.frigate.addUnit();
     *   }
     *   uiUpdater.updateUI();
     *
     * } */

    private void getCultureCards()
    {
        selfProvince.SetActive(false);
        otherProvince.SetActive(false);
        progressPanel.SetActive(false);
        coordinator.progressFlag = false;

        App    app    = UnityEngine.Object.FindObjectOfType <App>();
        Nation player = State.getNations()[app.GetHumanIndex()];

        PlayerPayer.payForDevelopmentAction(player, 1);

        MyEnum.cultCard newCard = PlayerReceiver.collectCultureCard(player);

        uiUpdater.updateUI();

        Stack <CultureCard>   remainingCultCards = State.getCultureDeck();
        HashSet <CultureCard> cultDeckSet        = new HashSet <CultureCard>(remainingCultCards);

        List <MyEnum.cultCard> playerCultHand = new List <MyEnum.cultCard>(player.getCultureCards());
        HashSet <CultureCard>  playerCultSet  = new HashSet <CultureCard>(remainingCultCards);

        foreach (MyEnum.cultCard cardName in playerCultHand)
        {
            CultureCard card = State.getCultureCardByName(cardName);
            playerCultSet.Add(card);
        }

        updateCultureCardBook(newCard);
        showCultureHandPanel();
    }
Exemplo n.º 6
0
    public void researchTech()
    {
        string techName = hiddenTechName.text;

        Debug.Log(techName);
        Technology tech   = State.GetTechnologies()[techName];
        App        app    = UnityEngine.Object.FindObjectOfType <App>();
        Nation     player = State.getNations()[app.GetHumanIndex()];

        PlayerPayer.PayForTechnology(player, techName);
        PlayerReceiver.addNewTech(player, tech);
        PlayerReceiver.registerTechChanges(tech, player);
        tech.SetDiscovered(true);
        tech.SetDiscoveredBy(player.getIndex());
        research.interactable = false;
        researchPoints.text   = player.Research.ToString();
        numberPattents.text   = player.getNumberPattents().ToString();
        GameObject buttonOfResearchedTech = GetChildWithName.getChildWithName(techTreeConnector, tech.GetTechName());
        Image      image = buttonOfResearchedTech.GetComponent <Image>();

        image.sprite = Resources.Load("AlchemistUITools/SteamContent/Sprites/Buttons/QuadroBtnBg", typeof(Sprite)) as Sprite;

        RectTransform imageTransform = image.rectTransform;

        imageTransform.ForceUpdateRectTransforms();
        uI_updater.updateUI();
    }
Exemplo n.º 7
0
    public void Recruit()
    {
        Debug.Log("Is Pressed!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
        App    app    = UnityEngine.Object.FindObjectOfType <App>();
        Nation player = State.getNations()[app.GetHumanIndex()];

        if (type == 1)
        {
            PlayerPayer.PayFrigate(player);
            recruitingText.text = player.getNavyProducing(MyEnum.NavyUnits.frigates).ToString();
            recruitingText.text = player.getArmyProducing(MyEnum.ArmyUnits.infantry).ToString();
        }
        if (type == 2)
        {
            PlayerPayer.PayIronClad(player);
            recruitingText.text = player.getNavyProducing(MyEnum.NavyUnits.ironclad).ToString();
        }
        if (type == 3)
        {
            PlayerPayer.PayDreadnought(player);
            recruitingText.text = player.getNavyProducing(MyEnum.NavyUnits.dreadnought).ToString();

            freePOP.text = player.getUrbanPOP().ToString();
            AP.text      = player.getAP().ToString();
            UpdateRecruitButtons(player);
        }
    }
Exemplo n.º 8
0
    public void adjustDevelopmentPriorityInLightOfPotential(Nation player)
    {
        if (player.getIP() < 1 && State.era == MyEnum.Era.Early)
        {
            if (PlayerCalculator.canMakeDevelopmentAction(player))
            {
                PlayerPayer.payForDevelopmentAction(player, 1);
                player.addIP(2);
            }
            else
            {
                this.progressPriorities[MyEnum.progressPriorities.investment]++;
            }
        }

        if (player.getIP() < 2 && State.era != MyEnum.Era.Early)
        {
            if (PlayerCalculator.canMakeDevelopmentAction(player))
            {
                PlayerPayer.payForDevelopmentAction(player, 1);
                player.addIP(2);
            }
            else
            {
                this.progressPriorities[MyEnum.progressPriorities.investment]++;
            }
        }
    }
Exemplo n.º 9
0
    public void addDP()
    {
        App    app    = UnityEngine.Object.FindObjectOfType <App>();
        Nation player = State.getNations()[app.GetHumanIndex()];

        PlayerPayer.payForDP(player);
        uiUpdater.updateUI();
    }
Exemplo n.º 10
0
    private void ExpandWarehouse()
    {
        App    app         = UnityEngine.Object.FindObjectOfType <App>();
        int    playerIndex = app.GetHumanIndex();
        Nation player      = State.getNations()[playerIndex];

        PlayerPayer.payWarehouseExpansion(player);
        uiUpdater.updateUI();
    }
Exemplo n.º 11
0
    /* private void IncreasePOP()
     * {
     *   App app = UnityEngine.Object.FindObjectOfType<App>();
     *   Nation player = State.getNations()[app.GetHumanIndex()];
     *   PlayerPayer.payForMorePOP(player);
     *   uiUpdater.updateUI();
     * } */

    private void IncreaseIP()
    {
        App    app    = UnityEngine.Object.FindObjectOfType <App>();
        Nation player = State.getNations()[app.GetHumanIndex()];

        PlayerPayer.payForDevelopmentAction(player, 1);
        Debug.Log("Increasing AP");
        PlayerReceiver.receiveIP(player);
        uiUpdater.updateUI();
    }
Exemplo n.º 12
0
    /* private void openMilitaryTab()
     * {
     *   App app = UnityEngine.Object.FindObjectOfType<App>();
     *   Nation player = State.getNations()[app.GetHumanIndex()];
     *   armyTab.SetActive(true);
     *   if(PlayerCalculator.canExpandArmy(player) == false)
     *   {
     *       expandArmyButton.interactable = false;
     *   }
     *   else
     *   {
     *       expandArmyButton.interactable = true;
     *   }
     *
     *   Text size = armyTable.Rows[0].Cells[1].GetComponentInChildren<Text>();
     *   size.text = player.landForces.Strength.ToString();
     *   Text attack = armyTable.Rows[1].Cells[1].GetComponentInChildren<Text>();
     *   attack.text = player.landForces.Attack.ToString();
     *   Text defense = armyTable.Rows[2].Cells[1].GetComponentInChildren<Text>();
     *   defense.text = player.landForces.Defense.ToString();
     *   Text morale = armyTable.Rows[3].Cells[1].GetComponentInChildren<Text>();
     *   morale.text = player.landForces.Morale.ToString();
     *   Text shock = armyTable.Rows[4].Cells[1].GetComponentInChildren<Text>();
     *   shock.text = player.landForces.Shock.ToString();
     *   Text maneuver = armyTable.Rows[5].Cells[1].GetComponentInChildren<Text>();
     *   maneuver.text = player.landForces.Maneuver.ToString();
     *   Text recon = armyTable.Rows[6].Cells[1].GetComponentInChildren<Text>();
     *   recon.text = player.landForces.Recon.ToString();
     *   Text prediction = armyTable.Rows[7].Cells[1].GetComponentInChildren<Text>();
     *   prediction.text = player.landForces.Prediction.ToString();
     * } */

    private void fightCorruption()
    {
        App    app    = UnityEngine.Object.FindObjectOfType <App>();
        Nation player = State.getNations()[app.GetHumanIndex()];

        PlayerPayer.payForDevelopmentAction(player, 1);
        // PlayerReceiver.reduceCorruption(player);
        player.decreaseCorruption();
        uiUpdater.updateUI();
    }
Exemplo n.º 13
0
    private void addResearchPoints()
    {
        App    app    = UnityEngine.Object.FindObjectOfType <App>();
        Nation player = State.getNations()[app.GetHumanIndex()];

        PlayerPayer.PayForResearch(player);
        PlayerReceiver.CollectResearchPoints(player);
        currentResearchPoints.text = player.Research.ToString();
        numberPattents.text        = player.getNumberPattents().ToString();
        Debug.Log("fff");
    }
Exemplo n.º 14
0
    private void addResearchPoints()
    {
        Debug.Log("Doing Research");

        App    app    = UnityEngine.Object.FindObjectOfType <App>();
        Nation player = State.getNations()[app.GetHumanIndex()];

        PlayerPayer.payForDevelopmentAction(player, 1);
        PlayerReceiver.CollectResearchPoints(player);
        uiUpdater.updateUI();
    }
Exemplo n.º 15
0
    public void RecruitBattleship()
    {
        App    app    = UnityEngine.Object.FindObjectOfType <App>();
        Nation player = State.getNations()[app.GetHumanIndex()];

        PlayerPayer.PayDreadnought(player);
        recruitingBattleshipsText.text = player.getNavyProducing(MyEnum.NavyUnits.dreadnought).ToString();
        AP.text = player.getAP().ToString();
        UpdateNavalRectuitButtons(player);
        upgradeShipyardButton.interactable = false;
    }
Exemplo n.º 16
0
    private void UpgradeDevelopment()
    {
        App    app       = UnityEngine.Object.FindObjectOfType <App>();
        Nation player    = State.getNations()[app.GetHumanIndex()];
        int    provIndex = State.getCurrentlySelectedProvince();

        assemblyCsharp.Province prov = State.getProvinces()[provIndex];
        PlayerPayer.payDevelopment(player, prov);
        this.DevelopmentLevel.text = prov.getDevelopmentLevel().ToString();
        AP.text = player.getAP().ToString();
        updateSelfProvinceButtons(player, prov);
    }
Exemplo n.º 17
0
    public void RecruitFrigate()
    {
        Debug.Log("Build Frigate!");
        App    app    = UnityEngine.Object.FindObjectOfType <App>();
        Nation player = State.getNations()[app.GetHumanIndex()];

        PlayerPayer.PayFrigate(player);
        recruitingFrigatesText.text = player.getNavyProducing(MyEnum.NavyUnits.frigates).ToString();
        UpdateNavyTable();
        upgradeShipyardButton.interactable = false;
        ui_updater.updateUI();
    }
Exemplo n.º 18
0
    private void getCultureCards()
    {
        App    app    = UnityEngine.Object.FindObjectOfType <App>();
        Nation player = State.getNations()[app.GetHumanIndex()];

        PlayerPayer.payForCultureCard(player);
        MyEnum.cultCard newCard = PlayerReceiver.collectCultureCard(player);


        MyEnum.Era era = State.era;
        if (player.getNumberGood(MyEnum.Goods.paper) < 1 || player.getAP() < 1)
        {
            drawCultureCards.interactable = false;
        }
        if (era != MyEnum.Era.Late && player.getNumberResource(MyEnum.Resources.spice) < 1)
        {
            drawCultureCards.interactable = false;
        }
        if (era != MyEnum.Era.Early)
        {
            if (player.getNumberGood(MyEnum.Goods.clothing) < 1)
            {
                drawCultureCards.interactable = false;
            }
        }
        if (era == MyEnum.Era.Late && player.getNumberGood(MyEnum.Goods.telephone) < 1)
        {
            drawCultureCards.interactable = false;
        }
        Stack <CultureCard>   remainingCultCards = State.getCultureDeck();
        HashSet <CultureCard> cultDeckSet        = new HashSet <CultureCard>(remainingCultCards);

        List <MyEnum.cultCard> playerCultHand = new List <MyEnum.cultCard>(player.getCultureCards());
        HashSet <CultureCard>  playerCultSet  = new HashSet <CultureCard>(remainingCultCards);

        foreach (MyEnum.cultCard cardName in playerCultHand)
        {
            CultureCard card = State.getCultureCardByName(cardName);
            playerCultSet.Add(card);
        }


        if (cultDeckSet.IsSubsetOf(playerCultSet))
        {
            drawCultureCards.interactable = false;
        }
        AP.text = player.getAP().ToString();
        // numberCultureCards.text = player.getCultureCards().Count.ToString();
        cultureLevel.text = player.getCulureLevel().ToString();
        updateCultureCardBook(newCard);
        showCultureHandPanel();
    }
Exemplo n.º 19
0
    private void UpgradeFort()
    {
        App    app       = UnityEngine.Object.FindObjectOfType <App>();
        Nation player    = State.getNations()[app.GetHumanIndex()];
        int    provIndex = State.getCurrentlySelectedProvince();

        Debug.Log("Currently selected province: " + State.getProvinces()[provIndex].getProvName());
        assemblyCsharp.Province prov = State.getProvinces()[provIndex];
        PlayerPayer.payFortUpgrade(player, prov);
        FortLevel.text = prov.getFortLevel().ToString();
        AP.text        = player.getAP().ToString();
        updateSelfProvinceButtons(player, prov);
    }
    private void upgradeShipyard()
    {
        App    app    = UnityEngine.Object.FindObjectOfType <App>();
        Nation player = State.getNations()[app.GetHumanIndex()];

        PlayerPayer.payShipyYardUpgrade(player);

        AP.text = player.getAP().ToString();
        TextMeshPro _shipyardLevel = shipyardLevelText.GetComponent <TextMeshPro>();

        _shipyardLevel.SetText("Shipyard Level: " + player.GetShipyardLevel().ToString());
        upgradeShipyardButton.interactable = false;
    }
Exemplo n.º 21
0
    private void DecreaseCorruption()
    {
        App    app    = UnityEngine.Object.FindObjectOfType <App>();
        Nation player = State.getNations()[app.GetHumanIndex()];

        PlayerPayer.payToReduceCorruption(player);
        currentCorruption.text = player.GetCorruption().ToString();
        if (player.getNumberResource(MyEnum.Resources.spice) < 1 || player.getAP() < 1 ||
            player.getNumberGood(MyEnum.Goods.paper) < 1)
        {
            decreaseCorruption.interactable = false;
        }
        AP.text = player.getAP().ToString();
    }
Exemplo n.º 22
0
    private void expandWarehouse()
    {
        App    app    = UnityEngine.Object.FindObjectOfType <App>();
        Nation player = State.getNations()[app.GetHumanIndex()];

        PlayerPayer.payWarehouseExpansion(player);
        storageCapacity.text = player.GetCurrentWarehouseCapacity().ToString();
        if (player.getNumberGood(MyEnum.Goods.lumber) < 1 || player.getAP() < 1)
        {
            expand.interactable = false;
        }
        storageCapacity.text = player.numberOfResourcesAndGoods().ToString() + "/" +
                               player.GetCurrentWarehouseCapacity().ToString();
    }
Exemplo n.º 23
0
    private void IncreasePOP()
    {
        App    app    = UnityEngine.Object.FindObjectOfType <App>();
        Nation player = State.getNations()[app.GetHumanIndex()];

        PlayerPayer.payForMorePOP(player);
        if (player.getNumberResource(MyEnum.Resources.wheat) < 1 || player.getAP() < 1 ||
            player.getNumberGood(MyEnum.Goods.clothing) < 1 ||
            (player.getPOPIncreasedThisTurn() > 1 && player.getNumberGood(MyEnum.Goods.chemicals) < 1))
        {
            increasePOP.interactable = false;
        }
        AP.text = player.getAP().ToString();

        freePOP.text = player.getUrbanPOP().ToString();
    }
Exemplo n.º 24
0
    private void upgradeFactory()
    {
        {
            Debug.Log("Upgrade Factory");
            Debug.Log("Good Type: " + goodType.text);
            App app = UnityEngine.Object.FindObjectOfType <App>();
            //string type = GetComponentInChildren<Text>().text;
            //    MyEnum.Goods goodType = (MyEnum.Goods)System.Enum.Parse(typeof(MyEnum.Goods), type);
            factoryType = (MyEnum.Goods)System.Enum.Parse(typeof(MyEnum.Goods), goodType.text);

            Nation player = State.getNations()[app.GetHumanIndex()];
            PlayerPayer.payForFactory(player, factoryType);
            player.industry.setFactoryLevel(factoryType, player.industry.getFactoryLevel(factoryType) + 1);
            int factoryLevel = player.industry.getFactoryLevel(factoryType);
            if (factoryLevel == 1)
            {
                factoryLevelImage.sprite = Resources.Load("Sprites/factorySmall", typeof(Sprite)) as Sprite;
            }
            if (factoryLevel == 2)
            {
                factoryLevelImage.sprite = Resources.Load("Sprites/factoryMedium", typeof(Sprite)) as Sprite;
            }
            if (factoryLevel == 3)
            {
                factoryLevelImage.sprite = Resources.Load("Sprites/FactoryBig", typeof(Sprite)) as Sprite;
            }
            factoryLevelText.text = "Factory Level: " + factoryLevel;

            // float ableToProduce = player.industry.determineCanProduce(factoryType, player);
            canProduce.text        = "0";
            factorySlider.maxValue = 0;
            AP.text = player.getAP().ToString();
            upgrade.interactable      = false;
            produceGoods.interactable = false;
            int index = getBuildingIndex();


            Transform buildingStubb = buildingModel.transform.GetChild(index);
            Debug.Log("Name of object: " + buildingStubb.name);
            GameObject building = buildingStubb.GetChild(1).gameObject;
            building.SetActive(true);
            // Debug.Log("Name of object: " + cube.name);
        }
    }
Exemplo n.º 25
0
    private void ProduceGoods()
    {
        MyEnum.Goods factoryType = (MyEnum.Goods)System.Enum.Parse(typeof(MyEnum.Goods), goodType.text);

        App    app    = UnityEngine.Object.FindObjectOfType <App>();
        Nation player = State.getNations()[app.GetHumanIndex()];
        int    amount = (int)factorySlider.value;

        PlayerPayer.payForFactoryProduction(player, factoryType, amount);
        player.industry.setGoodProducing(factoryType, amount);

        AP.text           = player.getAP().ToString();
        amountToMake.text = player.industry.getGoodProducing(factoryType).ToString();
        float ableToProduce = player.industry.determineCanProduce(factoryType, player);

        factorySlider.interactable        = false;
        produceGoods.interactable         = false;
        produceGoods.transform.localScale = new Vector3(0, 0, 0);
        cancel.transform.localScale       = new Vector3(1, 1, 1);
        cancel.interactable = true;
    }
Exemplo n.º 26
0
    public void Recruit()
    {
        Debug.Log("Is Pressed");
        App    app    = UnityEngine.Object.FindObjectOfType <App>();
        Nation player = State.getNations()[app.GetHumanIndex()];

        if (type == 1)
        {
            PlayerPayer.PayInfantry(player);
            recruitingText.text = player.getArmyProducing(MyEnum.ArmyUnits.infantry).ToString();
        }
        if (type == 2)
        {
            PlayerPayer.PayCavalry(player);
            recruitingText.text = player.getArmyProducing(MyEnum.ArmyUnits.cavalry).ToString();
        }
        if (type == 3)
        {
            PlayerPayer.PayArtillery(player);
            recruitingText.text = player.getArmyProducing(MyEnum.ArmyUnits.artillery).ToString();
        }
        if (type == 4)
        {
            PlayerPayer.PayFighter(player);
            recruitingText.text = player.getArmyProducing(MyEnum.ArmyUnits.fighter).ToString();
        }
        if (type == 5)
        {
            PlayerPayer.PayTank(player);
            recruitingText.text = player.getArmyProducing(MyEnum.ArmyUnits.tank).ToString();
        }

        freePOP.text = player.getRuralPOP().ToString();
        AP.text      = player.getAP().ToString();
        UpdateRectuitButtons(player);
    }
Exemplo n.º 27
0
    public void processOptionB()
    {
        eventDecisionTwoPanel.SetActive(false);
        closeToolTips();
        App    app         = UnityEngine.Object.FindObjectOfType <App>();
        int    playerIndex = app.GetHumanIndex();
        Nation player      = State.getNations()[playerIndex];
        Nation otherMajor  = State.getNation(currentEvent.OtherMajor);

        Province disputedProvince = State.getProvince(currentEvent.Province);
        Nation   otherNation      = State.getNation(currentEvent.OtherMajor);

        if (currentEvent.OtherMinor > -1)
        {
            otherNation = State.getNation(currentEvent.OtherMinor);
        }
        if (currentEvent.EventType == MyEnum.eventType.riotResponce)
        {
            nextEventTurn(player);
        }
        else if (currentEvent.EventType == MyEnum.eventType.referendumDemanded)
        {
            // Accept....
            if (eventLogic.referendum(player, otherNation, currentEvent.OtherMinor, disputedProvince))
            {
                // Province Leaves!
                DecisionEvent newEvent = new DecisionEvent();
                eventLogic.initializeProvinceLeaveEvent(newEvent, currentEvent);
                currentEvent = newEvent;
                showDecisionPanel(player);
            }
            else
            {
                DecisionEvent newEvent = new DecisionEvent();
                eventLogic.initializeProvinceStaysEvent(newEvent, currentEvent);
                currentEvent = newEvent;
                showDecisionPanel(player);
            }
        }


        else if (currentEvent.EventType == MyEnum.eventType.AI_Attacks)
        {
            otherMajor = State.getNation(currentEvent.OtherMajor);
            war        = new War(otherMajor, player, disputedProvince.getIndex(), currentEvent.OtherMinor);
            if (war.AmphibiousAttack)
            {
                DecisionEvent newEvent = new DecisionEvent();
                eventLogic.initializeDecideIfUseNavyDefend(newEvent, currentEvent);
                currentEvent = newEvent;
                showDecisionPanel(player);
            }
            prepareWarPanel(player, otherMajor, war);
        }

        else if (currentEvent.EventType == MyEnum.eventType.notificationOfCrackdown)
        {
            DecisionEvent newEvent = new DecisionEvent();
            eventLogic.initializeAskIfBoycott_AI_Event(newEvent, currentEvent);
            currentEvent = newEvent;
            showDecisionPanel(player);
        }

        else if (currentEvent.EventType == MyEnum.eventType.AI_RejectsReferendum)
        {
            // Don't declare war but maybe boycott
            DecisionEvent newEvent = new DecisionEvent();
        }

        else if (currentEvent.EventType == MyEnum.eventType.askIfBoycott)
        {
            PlayerPayer.loseFace(player);
        }

        else if (currentEvent.EventType == MyEnum.eventType.end)
        {
            nextEventTurn(player);
        }

        else if (currentEvent.EventType == MyEnum.eventType.AI_AcceptsReferendum)
        {
            DecisionEvent newEvent = new DecisionEvent();
            if (eventLogic.referendum(otherMajor, player, currentEvent.OtherMinor, disputedProvince))
            {
                eventLogic.initalizeAI_ReferendumVotesYes(newEvent, currentEvent);
                currentEvent = newEvent;
                showDecisionPanel(player);
            }
            else
            {
                eventLogic.initalizeAI_ReferendumVotesNo(newEvent, currentEvent);
                currentEvent = newEvent;
                showDecisionPanel(player);
            }
        }

        nextEventTurn(player);
    }
Exemplo n.º 28
0
    public void respondToProvinceRiots(Nation nation, Province prov)
    {
        Debug.Log("Respond to Province Riots");
        int           numberOfDisruptedProvinces = PlayerCalculator.getNumberOfDisrputedProvinces(nation);
        bool          sameCulture           = true;
        int           nationWithSameCulture = nation.getIndex();
        EventRegister eventLogic            = State.eventRegister;

        App    app        = UnityEngine.Object.FindObjectOfType <App>();
        int    humanIndex = app.GetHumanIndex();
        Nation human      = State.getNations()[humanIndex];

        if (!nation.culture.Equals(prov.getCulture()))
        {
            sameCulture           = false;
            nationWithSameCulture = Utilities.findNationWithThisCulture(prov.getCulture());
        }

        if (prov.isColony)
        {
            if (nation.GetColonialPoints() > 0)
            {
                //crack down on riots
                nation.SpendColonialPoints(1);
            }
            else
            {
                prov.setRioting(true);
            }
        }
        else if (!prov.isColony)
        {
            if (sameCulture)
            {
                if (nation.InfulencePoints > 0)
                {
                    standardProvinceResponse(nation, prov, -1, -1);
                }
                else
                {
                    prov.setRioting(true);
                }
            }
            // Now consider cases where the prov is not a colony and does not share the same culture as its owner

            else if (!prov.isColony && !sameCulture)
            {
                if (nation.InfulencePoints > 0)
                {
                    Debug.Log("Not colony and not same culture");
                    //Consider who might get angry with the crackdown
                    int    otherNationIndex = Utilities.findNationWithThisCulture(prov.getCulture());
                    Nation otherNation      = State.getNation(otherNationIndex);
                    Debug.Log("Other Nation is: " + otherNation.getName());
                    int    minorNationIndex = -1;
                    Nation minorNation      = new Nation();
                    if (otherNation.getType() == MyEnum.NationType.minor)
                    {
                        minorNationIndex = otherNation.getIndex();
                        minorNation      = otherNation;
                        otherNationIndex = PlayerCalculator.getMostFavouredMajorNation(otherNation);
                        // The other nation is the guardian, not the owner of the nation
                        otherNation = State.getNation(otherNationIndex);
                    }
                    int otherStrength = 0;
                    int selfStrength  = PlayerCalculator.CalculateArmyScore(nation);
                    // Will anger another great power
                    int relations = nation.Relations[otherNationIndex];
                    //This value is just for tests
                    if (relations < 85)
                    {
                        Debug.Log("here");
                        standardProvinceResponse(nation, prov, otherNationIndex, minorNationIndex);
                    }
                    else
                    {
                        if (State.mapUtilities.shareLandBorder(nation, otherNation))
                        {
                            otherStrength = PlayerCalculator.CalculateArmyScore(otherNation);
                        }
                        else
                        {
                            otherStrength = PlayerCalculator.CalculateNavalProjection(otherNation);
                        }

                        if (otherStrength * 1.15 < selfStrength)
                        {
                            //Not too afraid
                            standardProvinceResponse(nation, prov, otherNationIndex, minorNationIndex);
                            if (demandReferendum(otherNation, nation, prov))
                            {
                                if (acceptRefDemand(nation, otherNation, prov))
                                {
                                    referendum(nation, otherNation, prov);
                                }
                                else
                                {
                                    //nation refuses to hold a referendum
                                    if (warOverRejection(otherNation, nation, prov))
                                    {
                                        War war = new War(otherNation, nation, prov.getIndex(), minorNationIndex);
                                        war.warBetweenAI(otherNation, nation);
                                    }
                                    else if (boycottOverRefDemandRejection(otherNation))
                                    {
                                        otherNation.addBoycott(nation.getIndex());
                                        //....................
                                    }
                                    else
                                    {
                                        // Backdown
                                        PlayerPayer.loseFace(otherNation);
                                    }
                                }
                            }
                        }

                        if (otherStrength * 1.3 < selfStrength)
                        {
                            // Prefer not to provicate other nation, but might do so if situation calls for it

                            int roll = Random.Range(1, 100);
                            if (roll < 50)
                            {
                                nation.InfulencePoints--;
                                prov.adjustDiscontentment(1);
                                if (otherNation.getIndex() == humanIndex)
                                {
                                    DecisionEvent newEvent = new DecisionEvent();
                                    if (minorNationIndex == -1)
                                    {
                                        eventLogic.initalizeInformedOfCrackdownEvent(newEvent, human, nation, prov);
                                    }
                                    else
                                    {
                                        eventLogic.initalizeInformedOfCrackdownEvent(newEvent, human, nation, prov, minorNationIndex);
                                    }
                                    eventLogic.DecisionEvents.Enqueue(newEvent);
                                }
                                else if (demandReferendum(otherNation, nation, prov))
                                {
                                    if (acceptRefDemand(nation, otherNation, prov))
                                    {
                                        referendum(nation, otherNation, prov);
                                    }
                                    else
                                    {
                                        if (warOverRejection(otherNation, nation, prov))
                                        {
                                            War war = new War(otherNation, nation, prov.getIndex(), minorNationIndex);
                                            war.warBetweenAI(otherNation, nation);
                                        }
                                    }
                                }
                                else
                                {
                                    prov.setRioting(true);
                                }
                            }

                            else
                            {
                                prov.setRioting(true);
                            }
                        }
                        else
                        {
                            // Don't want to f**k with these guys
                            prov.setRioting(true);
                        }
                    }
                }
                else
                {
                    Debug.Log("No Influence Points");
                    prov.setRioting(true);
                    // Just for now
                    nation.InfulencePoints++;
                }
            }
        }
    }
Exemplo n.º 29
0
    public void endWar(War war, Nation attacker, Nation defender)
    {
        Debug.Log("End war");
        warPanel.SetActive(false);
        App           app         = UnityEngine.Object.FindObjectOfType <App>();
        int           playerIndex = app.GetHumanIndex();
        Nation        human       = State.getNations()[playerIndex];
        Province      prov        = State.getProvince(0);
        EventRegister eventLogic  = State.eventRegister;
        DecisionEvent newEvent    = new DecisionEvent();

        if (war.ProvIndex != -1)
        {
            prov = State.getProvince(war.ProvIndex);
        }

        if (war.AttackerForces == 0 || war.AttackerMorale == 0)
        {
            Debug.Log("Attack fails");
            // Attack fails and defender wins
            attacker.decreasePrestige(2);
            defender.increasePrestige(2);
            attacker.landForces.Morale -= 10;
            defender.landForces.Morale += 10;
            int payment = (int)(attacker.getGold() / 3);
            PlayerPayer.payAnotherPlayer(attacker, defender, payment);

            if (war.AttackerIndex == human.getIndex())
            {
                eventLogic.initializeFailedInvasionEvent(newEvent, currentEvent, war);
            }
            else
            {
                eventLogic.initializeSucessfulDefenseEvent(newEvent, currentEvent, war);
            }
            currentEvent = newEvent;
            showDecisionPanel(human);
        }

        else if (war.DefenderMorale == 0 || war.DefenderForces == 0)
        {
            // Attack succeeds
            Debug.Log("Attack succeeds");
            attacker.increasePrestige(2);
            defender.decreasePrestige(2);
            attacker.landForces.Morale += 10;
            defender.landForces.Morale -= 10;
            if (war.ProvIndex > -1)
            {
                prov.changeProvinceControl(defender, attacker);
                MapChange        newMapChange = new MapChange(defender.getIndex(), attacker.getIndex(), prov.getIndex());
                List <MapChange> mapChanges   = State.MapChanges;
                mapChanges.Add(newMapChange);
            }
            else
            {
                int payment = (int)(defender.getGold() / 3);
                PlayerPayer.payAnotherPlayer(defender, attacker, payment);
            }

            if (war.AttackerIndex == human.getIndex())
            {
                eventLogic.initializeSucessfulInvasionEvent(newEvent, currentEvent, war);
                currentEvent = newEvent;
                showDecisionPanel(human);
            }
            else
            {
                eventLogic.initializeFailedDefenseEvent(newEvent, currentEvent, war);
                currentEvent = newEvent;
                showDecisionPanel(human);
            }
        }
    }