Пример #1
0
        public void increasePanicFromPower(int cost, Ability ability)
        {
            if (cost == 0)
            {
                return;
            }

            panicFromPowerUse += cost * map.param.panic_panicPerPower;
            if (panicFromPowerUse > 1)
            {
                panicFromPowerUse = 1;
            }

            List <Person> allPeople = new List <Person>();

            foreach (SocialGroup sg in map.socialGroups)
            {
                if (sg is Society)
                {
                    allPeople.AddRange(((Society)sg).people);
                }
            }
            double sumWeighting = 0;

            foreach (Person p in allPeople)
            {
                double pv = p.getAwarenessMult();
                if (p.title_land == null)
                {
                    continue;
                }
                if (p.awareness >= 1)
                {
                    pv = 0;
                }
                if (p.awareness > 0)
                {
                    pv *= map.param.awarenessInvestigationDetectMult;
                }
                pv           *= pv;
                sumWeighting += pv;
            }
            Person detector = null;
            double roll     = Eleven.random.NextDouble() * sumWeighting;

            foreach (Person p in allPeople)
            {
                double pv = p.getAwarenessMult();
                if (p.title_land == null)
                {
                    continue;
                }
                if (p.awareness >= 1)
                {
                    pv = 0;
                }
                if (p.awareness > 0)
                {
                    pv *= map.param.awarenessInvestigationDetectMult;
                }
                pv   *= pv;
                roll -= pv;
                if (roll <= 0)
                {
                    detector = p;
                    break;
                }
            }

            if (detector != null)
            {
                double gain = cost * map.param.awareness_increasePerCost * map.param.awareness_master_speed;
                gain *= detector.getAwarenessMult();
                detector.awareness += gain;
                if (detector.awareness > 1)
                {
                    detector.awareness = 1;
                }
                map.turnMessages.Add(new MsgEvent(detector.getFullName() + " has noticed a sign of dark power. Gains " + (int)(100 * gain) + " awareness", MsgEvent.LEVEL_RED, false));
            }

            map.worldPanic = this.computeWorldPanic(new List <ReasonMsg>());
        }