Пример #1
0
        public override void Draw()
        {
            GUILayout.Space(10);

            using (new GUILayout.HorizontalScope())
            {
                GUILayout.Label("Faction Id");

                var factionId       = (int)_unitFactory.FactionId;
                var factionIdString = GUILayout.TextField(_unitFactory.FactionId.ToString());

                if (int.TryParse(factionIdString, out factionId))
                {
                    _unitFactory.FactionId = (byte)factionId;
                }
            }

            foreach (var each in _unitFactory.UnitInfos)
            {
                if (GUILayout.Button("Create " + each.Name))
                {
                    _unitFactory.CreateUnit(each);
                }
            }

            GUILayout.Space(10);
            foreach (var each in _unitFactory.BuildingInfos)
            {
                if (GUILayout.Button("Create " + each.Name))
                {
                    _unitFactory.CreateBuilding(each);
                }
            }
        }
 public void PopulateWorld(BaseWorld world, int count)
 {
     for (var i = 0; i < count; ++i)
     {
         var unit            = _unitFactory.CreateUnit(_worldData.TreeInfo, true);
         var randomDirection = Random.onUnitSphere.Set(y: 0).normalized;
         var randomPosition  = randomDirection * 10 + randomDirection * Random.Range(5, 10);
         unit.SetPosition(randomPosition);
         unit.SetFactionId(2); // Neutral, otherwise trees will be hostile to enemies
     }
 }
Пример #3
0
 private void HireCitizen()
 {
     if (_world.Popularity <= 0 && _world.Population > _world.MinPopulation)
     {
         RemoveCitizen();
     }
     else if (CanHire())
     {
         _unitFactory.CreateUnit(_worldData.UnitInfos.First(x => x.Name == "Peasant"));
     }
 }
Пример #4
0
 public void HireUnit(UnitInfo unitInfo)
 {
     _unitFactory.CreateUnit(unitInfo, World.HireCitizen());
 }