예제 #1
0
 void Start()
 {
     _worker          = GetComponent <Worker>();
     _factionCom      = GetComponent <FactionCom>();
     _beliefControler = GetComponent <BeliefControler>();
     _needs           = GetComponent <Needs>();
 }
예제 #2
0
    public void AddMember(FactionCom newMember)
    {
        Debug.Assert(Leader.factionBubble.activeSelf);

        _members.Add(newMember);
        Leader.factionBubble.GetComponent <SphereCollider>().radius = MemberMultipler * 5;
    }
예제 #3
0
    void Update()
    {
        _factionCom = GetComponent <FactionCom>();

        if (outline.activeSelf && ((PeopleInfo.Instance.SelectedCard != null && PeopleInfo.Instance.SelectedCard.Name != _name) || PeopleInfo.Instance.SelectedCard == null))
        {
            outline.SetActive(false);
        }
    }
예제 #4
0
    public void RemoveMember(FactionCom memeber, bool fromOnDestory = false)
    {
        _members.Remove(memeber);

        if (Leader != null)
        {
            Leader.factionBubble.GetComponent <SphereCollider>().radius = MemberMultipler * 5;
        }
    }
예제 #5
0
    // Start is called before the first frame update
    void Start()
    {
        _prevousStates = new Stack <State>();
        personList.Add(this);
        ChangeState(State.Wandering);
        _talkingToOtherCD = Random.Range(0, 120);
        _worker           = GetComponent <Worker>();
        _needs            = GetComponent <Needs>();
        _factionCom       = GetComponent <FactionCom>();

        _fightingLine = new Stack <GameObject>();
    }
예제 #6
0
    public FactionCom GetNextTarget(FactionCom member)
    {
        Debug.Assert(_fightingWith.Fighting && Fighting);

        var fightingMembers = _fightingWith.MembersReadyToFight;

        var cloeset = Helper.FindClosest(fightingMembers, member.transform);

        if (cloeset == null)
        {
            _fightingWith._fighting     = false;
            _fightingWith._fightingWith = null;

            _fighting     = false;
            _fightingWith = null;

            return(null);
        }

        return(cloeset);
    }
예제 #7
0
    public void Step()
    {
        Debug.Assert(!_quit);

        switch (_state)
        {
        case State.Following:
            float dist = Vector3.Distance(following.position, agent.transform.position);
            if (dist > 5)
            {
                agent.isStopped = false;
                agent.SetDestination(following.position);
            }

            if (agent.remainingDistance < 2)
            {
                agent.isStopped = true;
            }
            break;

        case State.Fighting:
            if (_fightingTarget == null || !_fightingTarget.normalPersonAI.Working)
            {
                ClearFightingLine();

                if (!FactionCom.Faction.Fighting)
                {
                    StopFightMode();
                    break;
                }

                Debug.Assert(FactionCom.normalPersonAI.Working);
                _fightingTarget = FactionCom.Faction.GetNextTarget(FactionCom);

                if (_fightingTarget == null)
                {
                    StopFightMode();
                    break;
                }

                var newLine = Factory.Instance.GetTalkingLine();

                var lat = newLine.GetComponent <LineAttachTo>();
                lat.targetA = FactionCom.transform;
                lat.targetB = _fightingTarget.transform;

                var lr = newLine.GetComponent <LineRenderer>();
                lr.material.color = Color.black;

                _fightingLine = newLine;

                _changeCD = Random.Range(1f, 4f);
            }

            _changeCD -= Time.deltaTime;

            if (Vector3.Distance(_fightingTarget.transform.position, FactionCom.transform.position) > 1.5f)
            {
                agent.SetDestination(_fightingTarget.transform.position);
            }
            else if (_changeCD < 0)
            {
                if (Random.Range(0, 100) > 80)
                {
                    _fightingTarget.normalPersonAI.DieWhileWorking();

                    ClearFightingLine();

                    _fightingTarget = null;
                }
                else
                {
                    var talkingText = beliefControler.LeftLeaning ? "optimatium caput stercore" : "purgamentum init populist";

                    Helper.CreateTalkingText(Camera, HatColor, FactionCom.transform, talkingText);

                    _changeCD = Random.Range(1f, 4f);
                }
            }

            break;
        }
    }
예제 #8
0
 bool CanFactionFight(FactionCom member)
 {
     return(member.normalPersonAI.Working);
 }
예제 #9
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);
    }