public void EmulateBeliefStep(BeliefControler other, int n)
    {
        for (int i = 0; i < n; i++)
        {
            var key = Util.RandomElement(other._beliefs).Key;

            if (!_beliefs.ContainsKey(key))
            {
                var newBelief = new GenBelief(key, 0, 0);
                // DO NOT COMIBNE
                newBelief.Value = other._beliefs[key].Value * Util.RandomFloat(0.3f, 0.5f);
                _beliefs.Add(newBelief.Name, newBelief);
            }

            var diff = System.Math.Abs(other._beliefs[key].Value - _beliefs[key].Value);

            float increment = 0f;

            increment = diff * Util.RandomFloat(0.5f, 1f);

            if (other._beliefs[key].Value < _beliefs[key].Value)
            {
                increment = -increment;
            }

            _beliefs[key].Value += increment;
        }
    }
Exemple #2
0
 void Start()
 {
     _worker          = GetComponent <Worker>();
     _factionCom      = GetComponent <FactionCom>();
     _beliefControler = GetComponent <BeliefControler>();
     _needs           = GetComponent <Needs>();
 }
    public void PopluateValue(string name, Faction faction, Worker worker, BeliefControler beliefControler, Needs needs)
    {
        Color32  factionColor;
        string   factionName;
        string   jobTitle;
        float    leaning;
        float    maxLeaning;
        DiedNeed foodNeed;
        DiedNeed socialNeed;
        DiedNeed sleepingNeed;

        factionColor = faction == null ? DefualtColor : faction.FactionColor;
        factionName  = faction == null ? "N/A" : faction.Name;
        jobTitle     = worker.Job == null ? "N/A" : worker.Job.JobTitle;
        leaning      = beliefControler.TotalLeaning;
        maxLeaning   = (beliefControler.BeliefCount) * BeliefControler.MAX_RIGHT;
        foodNeed     = new DiedNeed(needs.FoodNeed);
        socialNeed   = new DiedNeed(needs.SocialNeed);
        sleepingNeed = new DiedNeed(needs.SleepingNeed);

        _cardInfo = new CardInfo()
        {
            FactionColor = factionColor,
            FactionName  = factionName,
            Job          = jobTitle,
            Leaning      = leaning,
            MaxLeaning   = maxLeaning,
            Name         = name,
            FoodNeed     = foodNeed,
            SleepingNeed = sleepingNeed,
            SocialNeed   = socialNeed
        };
    }
Exemple #4
0
    public void RegstierMax(BeliefControler beliefControler, GameObject crown)
    {
        if (!_factionLst.ContainsKey(beliefControler))
        {
            var factionCom = beliefControler.GetComponent <FactionCom>();

            var newFact = new Faction(beliefControler.TotalLeaning)
            {
                Leader = factionCom,
                Name   = beliefControler.GetComponent <CardInfoCom>().PersonName + " Party"
            };

            crown.SetActive(true);

            crown.GetComponentsInChildren <Renderer>().ToList().ForEach(i => i.material.color = newFact.FactionColor);

            newFact.Leader.factionBubble.SetActive(true);

            newFact.Leader.Faction = newFact;

            Debug.LogFormat("Frame:{0} {1} LEADER OF FACTION ", Time.frameCount, beliefControler.gameObject.name);

            _factionLst.Add(beliefControler, newFact);
        }
    }
Exemple #5
0
    public GameObject FindClosetToFollow(FollowerJob newJob, BeliefControler beliefControler, FactionCom factionCom)
    {
        var applcableFactions = _factionLst.Values.Where(i => i.Leader.beliefControler.LeftLeaning == beliefControler.LeftLeaning && i.Leader.normalPersonAI.HasJob);

        if (applcableFactions.Count() == 0)
        {
            return(null);
        }

        SortedList <float, Faction> canadiets = new SortedList <float, Faction>();

        Faction tMin = null;

        foreach (var go in applcableFactions)
        {
            float diff = Mathf.Abs(go.Leaning - beliefControler.TotalLeaning);

            canadiets.Add(diff, go);
        }

        int n = (int)System.Math.Max(canadiets.Count * 0.3f, 1);

        while (canadiets.Count > n)
        {
            canadiets.RemoveAt(canadiets.IndexOfValue(canadiets.Last().Value));
        }

        tMin = Helper.FindClosest(canadiets.Values.Select(i => i.Leader), factionCom.normalPersonAI.Home.door).Faction;

        factionCom.Faction = tMin;
        tMin.AddMember(factionCom);
        return(tMin.Leader.beliefControler.gameObject);
    }
Exemple #6
0
    public void UnregsterMax(BeliefControler beliefControler)
    {
        Debug.Assert(_factionLst.ContainsKey(beliefControler));

        _factionLst[beliefControler].Destroy();

        _factionLst.Remove(beliefControler);
    }
    public void TalkTo(BeliefControler other, string subject)
    {
        var speakers = new List <BeliefControler>()
        {
            this, other
        }.OrderByDescending(i => Util.RandomFloat(0, i.convincingVal)).ToArray();

        var otherValue = speakers[1]._beliefs[subject].Value;

        otherValue *= speakers[1].convincingVal / MAX_CONVINCING;

        speakers[0]._beliefs[subject].Value += otherValue;

        speakers[0].ReactToBeliefChange();
    }
    public string CommonBelief(BeliefControler other)
    {
        var beliefIntersect = _beliefs.Keys.Intersect(other._beliefs.Keys);

        if (beliefIntersect.Count() <= 0)
        {
            return(null);
        }

        beliefIntersect = beliefIntersect.OrderByDescending(i => System.Math.Max(_beliefs[i].Value, other._beliefs[i].Value)).ToList();

        var subject = beliefIntersect.First();

        return(subject);
    }
Exemple #9
0
    public BeliefControler FindClosestSocialInteraction(BeliefControler beliefControler, float maxDist = 20f)
    {
        var target = Helper.FindClosest(_lookingForSocialInteraction, beliefControler.transform);

        if (target == null || Vector3.Distance(target.transform.position, beliefControler.transform.position) > maxDist)
        {
            _lookingForSocialInteraction.Add(beliefControler);
            target = null;
        }
        else
        {
            _lookingForSocialInteraction.Remove(target);
        }

        return(target);
    }
    public void ReceiveSpeechBelief(BeliefControler other, Faction otherFaction)
    {
        if (!_beliefs.ContainsKey(other._speechBelief))
        {
            _beliefs.Add(other._speechBelief, new GenBelief(other._speechBelief, _personalLeaning, _modifer));
        }

        var otherValue = other.SpeechBelief.Value;

        otherValue *= other.convincingVal / MAX_CONVINCING;
        otherValue *= otherFaction.MemberMultipler;
        otherValue *= _stubones;

        _beliefs[other._speechBelief].Value += otherValue;

        ReactToBeliefChange();
    }
Exemple #11
0
 public void RegsiterPerson(BeliefControler beliefControler)
 {
     _allBeliefControlers.Add(beliefControler);
 }
Exemple #12
0
 public void RemoveSocialSeeker(BeliefControler beliefControler)
 {
     _lookingForSocialInteraction.Remove(beliefControler);
 }
Exemple #13
0
 public void UnregsterPerson(BeliefControler beliefControler)
 {
     _allBeliefControlers.Remove(beliefControler);
 }