Exemplo n.º 1
0
        private void PopulateFortifications(bool[,] fortificationGrid)
        {
            int numGridElements = NationSize * NationSize;

            for (int column = 0; column < NationSize; column++)
            {
                for (int row = 0; row < NationSize; row++)
                {
                    int product = row * NationSize;
                    if (fortificationGrid[row, column])
                    {
                        Fortification fort = new Fortification(product + column, Fortifications.Count);
                        Fortifications.Add(fort);
                        IsCapturedMap.Add(fort.FortificationId, false); // all forts start off not captured
                        mNumProtectorsMap.Add(fort.FortificationId, 0);
                        mInvasionOrderingsMap.Add(fort.FortificationId, new HashSet <int>());
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void PopulateFortifications(int numFortsToPopulate)
        {
            Debug.Assert(NationSize % 2 == 1);
            Fortification[,] fortGrid = new Fortification[NationSize, NationSize];
            int numGridElements = NationSize * NationSize;

            for (int column = 0; column < NationSize && Fortifications.Count < numFortsToPopulate; column++)
            {
                for (int row = 0; row < NationSize && Fortifications.Count < numFortsToPopulate; row++)
                {
                    int product = row * NationSize;
                    if ((numFortsToPopulate - Fortifications.Count) == (numGridElements - (product + column)) || // have to place the rest of the forts
                        UnityEngine.Random.Range(1f, 1f) >= 0.5f)
                    {
                        Fortification fort = new Fortification(product + column, Fortifications.Count);
                        Fortifications.Add(fort);
                        IsCapturedMap.Add(fort.FortificationId, false); // all forts start off not captured
                        mNumProtectorsMap.Add(fort.FortificationId, 0);
                        mInvasionOrderingsMap.Add(fort.FortificationId, new HashSet <int>());
                    }
                }
            }
        }