Beispiel #1
0
        private void Accept(object sender, EventArgs args)
        {
            _selectedCity = _cities[_citySelect.ActiveItem + _index];

            _index = 0;
            var currBldgs = _selectedCity.Buildings;

            _buildings = Reflect.GetBuildings().Where(b => currBldgs.All(x => x.Id != b.Id) && !(b is Palace)).ToArray();

            CloseMenus();
        }
Beispiel #2
0
        public void City5With1EntAndTemple()
        {
            var  unit  = Game.Instance.GetUnits().First(x => x.Owner == playa.Civilization.Id);
            City acity = Game.Instance.AddCity(playa, 1, unit.X, unit.Y);

            acity.Size = 5;
            acity.ResetResourceTiles(); // setting city size doesn't allocate all resources

            MakeOneEntertainer(acity);
            acity.AddBuilding(Reflect.GetBuildings().First(b => b is Temple));

            using (var foo = acity.Residents.GetEnumerator())
            {
                foo.MoveNext();
                var citizenTypes = foo.Current;
                // initial state
                Assert.Equal(0, citizenTypes.happy);
                Assert.Equal(2, citizenTypes.content);
                Assert.Equal(2, citizenTypes.unhappy);
                Assert.Equal(1, citizenTypes.elvis);

                foo.MoveNext();
                citizenTypes = foo.Current;
                // luxury
                Assert.Equal(1, citizenTypes.happy);
                Assert.Equal(1, citizenTypes.content);
                Assert.Equal(2, citizenTypes.unhappy);
                Assert.Equal(1, citizenTypes.elvis);

                foo.MoveNext();
                citizenTypes = foo.Current;
                // temple
                Assert.Equal(1, citizenTypes.happy);
                Assert.Equal(2, citizenTypes.content);
                Assert.Equal(1, citizenTypes.unhappy);
                Assert.Equal(1, citizenTypes.elvis);
            }
        }
Beispiel #3
0
        public Picture DrawPage(byte pageNumber)
        {
            Picture output = new Picture(320, 200);

            int yy;

            switch (pageNumber)
            {
            case 1:
                string[] text = new string[0];
                text = Resources.Instance.GetCivilopediaText("BLURB0/" + Name.ToUpper());

                yy = 76;
                foreach (string line in text)
                {
                    Console.WriteLine(line);
                    output.DrawText(line, 6, 1, 12, yy);
                    yy += 9;
                }

                break;

            case 2:
                yy = 84;
                if (pageNumber == 2)
                {
                    if (RequiredTechs.Length > 0)
                    {
                        StringBuilder requiredTech = new StringBuilder();
                        foreach (IAdvance tech in RequiredTechs)
                        {
                            if (requiredTech.Length > 0)
                            {
                                requiredTech.Append(" and ");
                            }
                            requiredTech.Append(tech.Name);
                        }
                        output.DrawText(string.Format("Requires {0}", requiredTech), 6, 1, 32, yy); yy += 8;
                    }
                    yy += 16;
                    output.DrawText("Allows:", 6, 1, 32, yy); yy += 8;
                    foreach (IAdvance tech in Common.Advances.Where(a => a.Requires(Id)))
                    {
                        string allows = tech.Name;
                        foreach (IAdvance at in tech.RequiredTechs.Where(a => a.Id != Id))
                        {
                            allows += string.Format(" (with {0})", at.Name);
                        }
                        output.DrawText(allows, 6, 9, 40, yy); yy += 8;
                    }
                    yy += 4;
                    foreach (IUnit unit in Reflect.GetUnits().Where(u => u.RequiredTech != null && u.RequiredTech.Id == Id))
                    {
                        output.AddLayer(unit.GetUnit(Game.PlayerNumber(Human)), 40, yy - 5);
                        output.DrawText(string.Format("{0} unit", unit.Name), 6, 12, 60, yy); yy += 12;
                    }
                    foreach (IBuilding building in Reflect.GetBuildings().Where(b => b.RequiredTech != null && b.RequiredTech.Id == Id))
                    {
                        if (building.SmallIcon != null)
                        {
                            output.AddLayer(building.SmallIcon, 39, yy - 2);
                        }
                        output.DrawText(string.Format("{0} improvement", building.Name), 6, 2, 60, yy); yy += 12;
                    }
                    foreach (IWonder wonder in Reflect.GetWonders().Where(w => w.RequiredTech != null && w.RequiredTech.Id == Id))
                    {
                        if (wonder.SmallIcon != null)
                        {
                            output.AddLayer(wonder.SmallIcon, 39, yy - 2);
                        }
                        output.DrawText(string.Format("{0} Wonder", wonder.Name), 6, 2, 60, yy); yy += 12;
                    }
                }
                break;

            default:
                Console.WriteLine("Invalid page number: {0}", pageNumber);
                break;
            }

            return(output);
        }