Example #1
0
        public static Event1 CreateEvent(EventType type, int battleTurn, string text, params object[] args)
        {
            var ev = new Event1()
            {
                EventType = (int)type, BattleTurn = battleTurn, Text = string.Format(text, args), Time = DateTime.UtcNow
            };

            return(ev);
        }
        public Event1 AddEvent(EventType type, string message, params object[] args)
        {
            var e = new Event1()
            {
                EventType = (int)type, Text = string.Format(message, args), BattleTurn = GetConfig().CombatTurn, Time = DateTime.UtcNow
            };

            Events.InsertOnSubmit(e);
            return(e);
        }
Example #3
0
 public void ApplyPopulationTick(int turn)
 {
     foreach (var body in CelestialObjects)
     {
         var growth = body.CelestialObjectStructures.Sum(x => (int?)x.StructureType.MakesPeople * x.Count);
         if ((growth ?? 0) > 0)
         {
             if (body.Population + growth > body.MaxPopulation)
             {
                 var ev = Event1.CreateEvent(EventType.Player, turn, "Population cannot grow anymore on {0}, transport it to other planet!", body.Name);
                 ev.Connect(this);
                 ev.Connect(body);
             }
             body.Population = Math.Min(body.Population + growth ?? 0, body.MaxPopulation);
         }
     }
 }
Example #4
0
        public void ApplyResourceTurn(int turn)
        {
            MetalIncome        = 0;
            FoodIncome         = 0;
            QuantiumIncome     = 0;
            DarkMatterIncome   = 0;
            ResearchIncome     = 0;
            PopulationCapacity = 0;


            var curPeople = 0;

            foreach (var o in CelestialObjects)
            {
                curPeople = o.Population;
            }

            foreach (var t in PopulationTransports)
            {
                curPeople += t.Count;
            }

            FoodIncome -= curPeople;

            foreach (var o in CelestialObjects)
            {
                MetalIncome        += o.MetalIncome * o.Efficiency;
                FoodIncome         += o.FoodIncome * o.Efficiency;
                QuantiumIncome     += o.QuantiumIncome * o.Efficiency;
                DarkMatterIncome   += o.DarkMatterIncome * o.Efficiency;
                ResearchIncome     += o.ResearchIncome * o.Efficiency;
                PopulationCapacity += o.MaxPopulation;
                o.BuildpowerUsed    = 0;             // reset bp to 0
            }

            Metal          += MetalIncome;
            Food           += FoodIncome;
            Quantium       += QuantiumIncome;
            DarkMatter     += DarkMatterIncome;
            ResearchPoints += ResearchIncome;

            if (Food < 0)
            {
                var toKill = 1 + (int)-Food;

                curPeople -= toKill;
                if (curPeople < 0)
                {
                    curPeople = 0;
                }

                Food = 0;
                foreach (var o in CelestialObjects.OrderByDescending(x => x.Population))
                {
                    if (o.Population > 0)
                    {
                        var killed = Math.Min(o.Population, toKill);
                        o.Population -= killed;
                        o.UpdateIncomeInfo();
                        var ev = Event1.CreateEvent(EventType.Player, turn, "{0}m people have died on planet {1} from starvation", killed, o.Name);
                        ev.Connect(this);
                        ev.Connect(o);

                        toKill -= killed;
                    }
                    if (toKill <= 0)
                    {
                        break;
                    }
                }
            }

            Population = curPeople;
        }
		public Event1 AddEvent(EventType type, string message, params object[] args)
		{
			var e = new Event1() { EventType = (int)type, Text = string.Format(message, args), BattleTurn = GetConfig().CombatTurn, Time = DateTime.UtcNow };
			Events.InsertOnSubmit(e);
			return e;
		}
 partial void DeleteEvent1(Event1 instance);
 partial void UpdateEvent1(Event1 instance);
 partial void InsertEvent1(Event1 instance);
		public static Event1 CreateEvent(EventType type, int battleTurn, string text, params object[] args)
		{
			var ev = new Event1() { EventType = (int)type, BattleTurn = battleTurn, Text = string.Format(text, args), Time = DateTime.UtcNow };
			return ev;
		}