예제 #1
0
    public void TurnEnd(TurnInfo selectedPlayer)     //This function accumulates all the SIM generated by each system to give an empire SIM value
    {
        selectedPlayer.researchCostModifier = 0;

        MasterScript.diplomacyScript.DiplomaticStateEffects();

        CalculateExpansionModifier(selectedPlayer);

        for (int i = 0; i < MasterScript.systemListConstructor.mapSize; ++i)
        {
            if (MasterScript.systemListConstructor.systemList[i].systemOwnedBy != selectedPlayer.playerRace)
            {
                continue;
            }

            SystemSIMData     systemSIMData     = MasterScript.systemListConstructor.systemList[i].systemObject.GetComponent <SystemSIMData>();
            ImprovementsBasic improvementsBasic = MasterScript.systemListConstructor.systemList[i].systemObject.GetComponent <ImprovementsBasic>();
            SystemDefence     systemDefence     = MasterScript.systemListConstructor.systemList[i].systemObject.GetComponent <SystemDefence>();

            systemDefence.CalculateSystemDefence();

            improvementsBasic.ActiveTechnologies(i, selectedPlayer);
            systemSIMData.SystemSIMCounter(selectedPlayer);
            MasterScript.systemFunctions.CheckUnlockedTier(improvementsBasic, i);

            selectedPlayer.knowledge += systemSIMData.totalSystemKnowledge;
            selectedPlayer.power     += systemSIMData.totalSystemPower;

            if (selectedPlayer.playerRace == "Selkies")
            {
                MasterScript.racialTraitScript.amber += systemSIMData.totalSystemAmber;
            }

            selectedPlayer.researchCostModifier += improvementsBasic.researchCost;
        }

        for (int j = 0; j < selectedPlayer.playerOwnedHeroes.Count; ++j)
        {
            HeroScriptParent heroScript = selectedPlayer.playerOwnedHeroes[j].GetComponent <HeroScriptParent>();
            heroScript.HeroEndTurnFunctions(selectedPlayer);
        }

        MasterScript.racialTraitScript.RacialBonus(selectedPlayer);

        MasterScript.turnInfoScript.SortSystemPower();

        if (selectedPlayer.wealth > 10000.0f)
        {
            selectedPlayer.wealth = 10000.0f;
        }

        selectedPlayer.planetsColonisedThisTurn = 0;

        selectedPlayer.systemsColonisedThisTurn = 0;
    }
예제 #2
0
    private void DestroySystem(int system)
    {
        SystemDefence systemDefence = MasterScript.systemListConstructor.systemList [system].systemObject.GetComponent <SystemDefence> ();

        MasterScript.systemListConstructor.systemList [system].systemDefence = 0;
        MasterScript.systemListConstructor.systemList [system].systemOwnedBy = null;

        MasterScript.systemListConstructor.systemList [system].systemObject.renderer.material = MasterScript.turnInfoScript.emptyMaterial;

        systemDefence = MasterScript.systemListConstructor.systemList [system].systemObject.GetComponent <SystemDefence> ();
        systemDefence.underInvasion = false;
    }
예제 #3
0
    private void TN4I4()
    {
        SystemDefence systemDefence = MasterScript.systemListConstructor.systemList[improvements.system].systemObject.GetComponent <SystemDefence>();

        if (systemDefence.underInvasion == true)
        {
            improvements.powerPercentBonus     += 1.0f;
            improvements.knowledgePercentBonus += 1.0f;
        }

        if (checkValue == false)
        {
            if (systemDefence.underInvasion == true)
            {
                improvements.listOfImprovements[58].improvementMessage = "+100% Resource Yield from Invasion";
            }
        }
    }
예제 #4
0
    void Update()
    {
        if (MasterScript.heroGUI.currentHero != null)                                            //If a hero is selected
        {
            heroScript    = MasterScript.heroGUI.currentHero.GetComponent <HeroScriptParent> (); //Get references to hero scripts
            systemDefence = heroScript.heroLocation.GetComponent <SystemDefence> ();             //And the defence script of that system

            if (systemDefence.underInvasion == true && openInvasionMenu == true)                 //If system is under invasion and the invasion menu is open
            {
                UpdateOpenMenuItems();
            }
        }

        if (openInvasionMenu == false)
        {
            UpdateClosedMenuItems();
            management.allTokens.Clear();
        }
    }
예제 #5
0
    void Start()
    {
        systemDefence     = gameObject.GetComponent <SystemDefence> ();
        improvementsBasic = gameObject.GetComponent <ImprovementsBasic>();

        thisSystem = MasterScript.RefreshCurrentSystem(gameObject);

        for (int i = 0; i < MasterScript.systemListConstructor.systemList[thisSystem].systemSize; ++i)
        {
            PlanetUIInfo planetInfo = new PlanetUIInfo();

            planetInfo.generalInfo     = null;
            planetInfo.knowledgeOutput = null;
            planetInfo.powerOutput     = null;
            planetInfo.population      = null;

            allPlanetsInfo.Add(planetInfo);
        }

        embargoedBy = null;
        promotedBy  = null;
    }
예제 #6
0
    public void OpenPlanetInvasionScreen()
    {
        NGUITools.SetActive(invasionScreen, true);

        heroScript = MasterScript.heroGUI.currentHero.GetComponent <HeroScriptParent> ();

        system = MasterScript.RefreshCurrentSystem(heroScript.heroLocation);

        int loadSystem = loadInvasion.CheckForExistingInvasion(system);

        if (loadSystem != -1)
        {
            loadInvasion.ReloadInvasionScreen(loadSystem);
            createdTokens = true;
        }

        systemDefence = MasterScript.systemListConstructor.systemList [system].systemObject.GetComponent <SystemDefence> ();

        systemDefence.underInvasion = true;

        LayoutPlanets(system);
    }
예제 #7
0
    public float CheckThroughPlanets(TurnInfo thisPlayer)
    {
        highestSIM = 0;

        for (int i = 0; i < MasterScript.systemListConstructor.mapSize; ++i)
        {
            if (MasterScript.systemListConstructor.systemList[i].systemOwnedBy == thisPlayer.playerRace)
            {
                systemDefence = MasterScript.systemListConstructor.systemList [i].systemObject.GetComponent <SystemDefence> ();

                if (systemDefence.underInvasion == true)
                {
                    continue;
                }

                for (int j = 0; j < MasterScript.systemListConstructor.systemList[i].systemSize; ++j)
                {
                    if (MasterScript.systemListConstructor.systemList[i].planetsInSystem[j].planetColonised == true || MasterScript.systemListConstructor.systemList[i].planetsInSystem[j].planetImprovementLevel == 3)
                    {
                        continue;
                    }

                    tempSIM = (MasterScript.systemListConstructor.systemList[i].planetsInSystem[j].planetKnowledge + MasterScript.systemListConstructor.systemList[i].planetsInSystem[j].planetPower)
                              * (MasterScript.systemListConstructor.systemList[i].planetsInSystem[j].currentImprovementSlots * 1.5f);

                    if (tempSIM > highestSIM)
                    {
                        highestSIM = tempSIM;

                        tempPlanet = j;

                        tempSystem = i;
                    }
                }
            }
        }

        return(highestSIM);
    }
예제 #8
0
    public void UpdateInvasions()
    {
        for (int i = 0; i < currentInvasions.Count; ++i)
        {
            SystemDefence systemDefence = currentInvasions[i].system.GetComponent <SystemDefence>();
            int           system        = MasterScript.RefreshCurrentSystem(currentInvasions[i].system);

            if (MasterScript.invasionGUI.invasionScreen.activeInHierarchy == true && MasterScript.invasionGUI.system == system)
            {
                management.CacheInvasionInfo();
            }

            for (int j = 0; j < MasterScript.systemListConstructor.systemList[system].systemSize; ++j)
            {
                float assaultDamage   = CalculateTotalTokenValue(currentInvasions[i].tokenAllocation[j].assaultTokenAllocation, "Assault");
                float auxiliaryDamage = CalculateTotalTokenValue(currentInvasions[i].tokenAllocation[j].auxiliaryTokenAllocation, "Auxiliary") - MasterScript.systemListConstructor.systemList[system].planetsInSystem[j].planetCurrentDefence / 10f;

                if (auxiliaryDamage < 0)
                {
                    auxiliaryDamage = 0;
                }

                systemDefence.TakeDamage(assaultDamage / 2, auxiliaryDamage / 2, j);

                if (MasterScript.systemListConstructor.systemList [system].planetsInSystem [j].planetPopulation <= 0)
                {
                    MasterScript.systemListConstructor.systemList [system].planetsInSystem [j].planetColonised       = false;
                    MasterScript.systemListConstructor.systemList [system].planetsInSystem [j].expansionPenaltyTimer = 0f;
                    MasterScript.systemListConstructor.systemList [system].planetsInSystem [j].improvementsBuilt.Clear();
                    MasterScript.systemListConstructor.systemList [system].planetsInSystem [j].planetImprovementLevel = 0;
                    MasterScript.systemListConstructor.systemList [system].planetsInSystem [j].planetPopulation       = 0;
                }
            }

            CheckSystemStatus(system, currentInvasions[i].player);
        }
    }
예제 #9
0
    private void OwnSystem(int system)
    {
        MasterScript.systemListConstructor.systemList [system].systemOwnedBy = hero.heroOwnedBy;

        switch (hero.heroOwnedBy)
        {
        case "Humans":
            MasterScript.voronoiGenerator.voronoiCells[system].renderer.sharedMaterial = MasterScript.turnInfoScript.humansMaterial;
            break;

        case "Selkies":
            MasterScript.voronoiGenerator.voronoiCells[system].renderer.sharedMaterial = MasterScript.turnInfoScript.selkiesMaterial;
            break;

        case "Nereides":
            MasterScript.voronoiGenerator.voronoiCells[system].renderer.sharedMaterial = MasterScript.turnInfoScript.nereidesMaterial;
            break;

        default:
            MasterScript.voronoiGenerator.voronoiCells[system].renderer.sharedMaterial = MasterScript.turnInfoScript.emptyMaterial;
            break;
        }

        MasterScript.voronoiGenerator.voronoiCells[system].renderer.material.shader = Shader.Find("Transparent/Diffuse");

        SystemDefence systemDefence = MasterScript.systemListConstructor.systemList [system].systemObject.GetComponent <SystemDefence> ();

        systemDefence.underInvasion = false;

        for (int i = 0; i < MasterScript.systemListConstructor.systemList [system].systemSize; ++i)
        {
            for (int j = 0; j < MasterScript.systemListConstructor.systemList [system].planetsInSystem[i].improvementsBuilt.Count; ++j)
            {
                MasterScript.systemListConstructor.systemList [system].planetsInSystem[i].improvementsBuilt.Clear();
            }
        }
    }
예제 #10
0
    public void RefreshHeroLocation()
    {
        if (finalPath[currentVertex] != target)                                    //If current system does not equal the destination system
        {
            currentPosition = gameObject.transform.position;                       //Current hero position is updated

            targetPosition = HeroPositionAroundStar(finalPath[currentVertex + 1]); //Target position is set

            if (TestForProximity(currentPosition, targetPosition) == true)         //If current hero position is equal to the next system on route
            {
                SystemDefence systemDefence = finalPath[currentVertex].GetComponent <SystemDefence>();

                systemDefence.underInvasion   = false;
                systemDefence.regenerateTimer = 3;
                heroScript.isInvading         = false;
                MasterScript.systemListConstructor.systemList[currentVertex].enemyHero = null;

                ++currentVertex;                                    //Update current system

                heroScript.heroLocation = finalPath[currentVertex]; //Set herolocation to current system

                targetPosition = Vector3.zero;
            }

            else
            {
                gameObject.transform.position = Vector3.MoveTowards(currentPosition, targetPosition, (10 * heroScript.movementSpeed) * Time.deltaTime);
            }
        }

        if (TestForProximity(currentPosition, HeroPositionAroundStar(target)) == true)
        {
            heroScript.heroLocation = target;
            allowMovement           = false;
            target = null;
        }
    }
예제 #11
0
    public void ImprovePlanet(int planetPosition, int system, TurnInfo thisPlayer)
    {
        systemSIMData = MasterScript.systemListConstructor.systemList [system].systemObject.GetComponent <SystemSIMData> ();

        systemDefence = MasterScript.systemListConstructor.systemList [system].systemObject.GetComponent <SystemDefence> ();

        systemSIMData.improvementNumber = MasterScript.systemListConstructor.systemList[system].planetsInSystem[planetPosition].planetImprovementLevel;

        MasterScript.systemFunctions.CheckImprovement(system, planetPosition);

        if (systemSIMData.canImprove == true && systemDefence.underInvasion == false)
        {
            float powerImprovementCost = MasterScript.systemFunctions.PowerCost(systemSIMData.improvementNumber, system, planetPosition);

            if (thisPlayer.power >= powerImprovementCost && thisPlayer.wealth >= systemSIMData.improvementCost)
            {
                ++MasterScript.systemListConstructor.systemList[system].planetsInSystem[planetPosition].planetImprovementLevel;

                thisPlayer.power -= powerImprovementCost;

                thisPlayer.wealth -= systemSIMData.improvementCost;
            }
        }
    }
예제 #12
0
    public void CacheInvasionInfo()                                   //Used to cache the invasion info
    {
        SystemInvasionInfo cachedInvasion = new SystemInvasionInfo(); //Create a new invasion object

        int invasionLoc = -1;                                         //Set a counter
        int system      = MasterScript.RefreshCurrentSystem(MasterScript.heroGUI.currentHero.GetComponent <HeroScriptParent> ().heroLocation);

        for (int i = 0; i < MasterScript.systemInvasion.currentInvasions.Count; ++i)                                                          //For all current cached invasions
        {
            if (MasterScript.systemInvasion.currentInvasions[i].system == MasterScript.systemListConstructor.systemList[system].systemObject) //If this system already has an invasion underway
            {
                invasionLoc = i;                                                                                                              //Set the counter
            }
        }

        cachedInvasion.system = MasterScript.systemListConstructor.systemList[system].systemObject;         //Set the system to equal this system
        cachedInvasion.player = MasterScript.heroGUI.currentHero.GetComponent <HeroScriptParent> ().heroOwnedBy;

        for (int i = 0; i < MasterScript.systemListConstructor.systemList[system].systemSize; ++i) //For all planets in the system
        {
            PlanetInvasionInfo cachedPlanet = new PlanetInvasionInfo();                            //Create object for planet

            for (int j = 0; j < allTokens.Count; ++j)                                              //else //It must be a token
            {
                TokenUI tokenScript = allTokens[j].GetComponent <TokenUI>();                       //So get a reference to it's script

                TokenInfo temp = new TokenInfo();

                temp.originalPosition = tokenScript.originalPosition;
                temp.currentPosition  = allTokens[j].transform.position;
                temp.heroOwner        = tokenScript.hero;
                temp.originalParent   = tokenScript.originalParent;
                temp.originalHero     = tokenScript.originalHero;
                temp.tokenPositions   = tokenScript.tokenPositions;
                temp.currentParent    = allTokens[j].transform.parent.gameObject;
                temp.name             = tokenScript.name;

                switch (temp.name)                //Switch based on name of container
                {
                case "Defence Token":
                    cachedPlanet.defenceTokenAllocation.Add(temp);                      //If it's a defence token cache the token's hero into the planet list
                    break;

                case "Assault Token":
                    cachedPlanet.assaultTokenAllocation.Add(temp);                      //Same for assault token
                    break;

                case "Auxiliary Token":
                    cachedPlanet.auxiliaryTokenAllocation.Add(temp);                      //And for auxiliary token
                    break;

                default:
                    break;
                }
            }

            cachedInvasion.tokenAllocation.Add(cachedPlanet);
        }

        if (invasionLoc == -1)                                                //If this invasion is not already cached
        {
            MasterScript.systemInvasion.currentInvasions.Add(cachedInvasion); //Cache it
            SystemDefence systemDefence = MasterScript.systemListConstructor.systemList[system].systemObject.GetComponent <SystemDefence>();
            systemDefence.underInvasion = true;
        }
        else                                                                            //If it is
        {
            MasterScript.systemInvasion.currentInvasions[invasionLoc] = cachedInvasion; //Replace it with the updated one
        }
    }
예제 #13
0
    public void HeroDecisionStart(TurnInfo thisPlayer)
    {
        player = thisPlayer;

        for (int i = 0; i < MasterScript.diplomacyScript.relationsList.Count; ++i)
        {
            if (MasterScript.diplomacyScript.relationsList[i].playerOne.playerRace == player.playerRace || MasterScript.diplomacyScript.relationsList[i].playerTwo.playerRace == player.playerRace)
            {
                string enemyRace = null;

                if (MasterScript.diplomacyScript.relationsList[i].playerTwo.playerRace == player.playerRace)
                {
                    enemyRace = MasterScript.diplomacyScript.relationsList[i].playerOne.playerRace;
                }
                if (MasterScript.diplomacyScript.relationsList[i].playerOne.playerRace == player.playerRace)
                {
                    enemyRace = MasterScript.diplomacyScript.relationsList[i].playerTwo.playerRace;
                }

                if (MasterScript.diplomacyScript.relationsList[i].diplomaticState == "War")
                {
                    float protectSystemValue = 0f, invadeSystemValue = 0f;
                    int   systemToProtect = -1, systemToInvade = -1;

                    for (int j = 0; j < MasterScript.systemListConstructor.systemList.Count; ++j)
                    {
                        systemDefence = MasterScript.systemListConstructor.systemList[j].systemObject.GetComponent <SystemDefence>();
                        systemSIMData = MasterScript.systemListConstructor.systemList[j].systemObject.GetComponent <SystemSIMData>();

                        if (MasterScript.systemListConstructor.systemList[j].systemOwnedBy == player.playerRace && systemDefence.underInvasion == true && systemSIMData.totalSystemSIM > protectSystemValue)
                        {
                            protectSystemValue = systemSIMData.totalSystemSIM;
                            systemToProtect    = j;
                        }

                        if (MasterScript.systemListConstructor.systemList[j].systemOwnedBy == enemyRace && systemDefence.underInvasion != true)
                        {
                            float tempSIM     = systemSIMData.totalSystemSIM;
                            float tempDefence = systemDefence.maxSystemDefence;

                            float simToDefRatio = tempSIM / tempDefence;

                            if (simToDefRatio > invadeSystemValue)
                            {
                                invadeSystemValue = simToDefRatio;
                                systemToInvade    = j;
                            }
                        }
                    }

                    if (systemToProtect != -1 && systemToInvade == -1)
                    {
                        SetDestinationSystem(systemToProtect, "Protect");
                    }
                    if (systemToProtect == -1 && systemToInvade != -1)
                    {
                        SetDestinationSystem(systemToInvade, "Invade");
                    }
                    if (systemToProtect != -1 && systemToInvade != -1)
                    {
                        systemSIMData = MasterScript.systemListConstructor.systemList[systemToProtect].systemObject.GetComponent <SystemSIMData>();
                        systemDefence = MasterScript.systemListConstructor.systemList[systemToProtect].systemObject.GetComponent <SystemDefence>();

                        float tempSIM       = systemSIMData.totalSystemSIM;
                        float tempDefence   = systemDefence.maxSystemDefence;
                        float simToDefRatio = tempSIM / tempDefence;

                        if (simToDefRatio >= invadeSystemValue)
                        {
                            SetDestinationSystem(systemToProtect, "Protect");
                        }
                        else
                        {
                            SetDestinationSystem(systemToInvade, "Invade");
                        }
                    }
                }
            }
        }
    }