示例#1
0
 private void HandleTarget(FactionMember newTarget)
 {
     m_target = (newTarget == null) ? null : newTarget.transform;
     if (m_target != null && m_member.GetAffinity(newTarget) <= dislikeThreshold)
     {
         ChangeState(aggressive ? State.Pursue : State.Evade, newTarget.transform);
     }
     else
     {
         ChangeState(State.Wander, null);
     }
 }
示例#2
0
        private void OnCollisionEnter2D(Collision2D coll)
        {
            var otherMember = coll.collider.GetComponentInChildren <FactionMember>();

            if (otherMember == null || !aggressive)
            {
                return;
            }
            if (m_member.GetAffinity(otherMember) < 0)
            {
                if (m_deedReporter != null)
                {
                    m_deedReporter.ReportDeed("attack", otherMember);
                }
                if (!string.Equals(otherMember.faction.name, "Farmer"))
                {
                    Destroy(otherMember.gameObject);
                    HandleTarget(null);
                    m_inRange.RemoveAll(x => x == null);
                    CheckForNewTarget();
                }
            }
        }