Ejemplo n.º 1
0
    public BodyFeature InstantiateBodyFeature(Person person, GameObject prefabBodyFeature = null)
    {
        if (prefabBodyFeature == null)
        {
            prefabBodyFeature = Game.S.featureBodies[Random.Range(0, Game.S.featureBodies.Count)];
        }

        BodyFeature body = (BodyFeature)InstantiateFeature(person, prefabBodyFeature);

        person.features.SetBody(body, Logic.True);
        return(body);
    }
Ejemplo n.º 2
0
    void Start()
    {
        Debug.Log("Generating Person", person);

        bool stillClashing = false;

        for (int i = 0; i < 6; i++)
        {
            BodyFeature body   = InstantiateBodyFeature(person);
            int         offset = body.headPixelYOffset;

            InstantiateHairFeature(person, null, offset);
            InstantiateHatFeature(person, null, offset);
            InstantiateFaceFeature(person, null, offset);

            person.GenerateAdditionalFeatures(offset);

            if (Game.S.target == null)
            {
                break;
            }
            if (person == Game.S.detective)
            {
                break;
            }
            if (person == Game.S.target)
            {
                break;
            }

            // CLASSSH!
            if (person.uniqueFeatureId == Game.S.target.uniqueFeatureId)
            {
                stillClashing        = true;
                person.features.body = new KeyValuePair <BodyFeature, Logic>();
                person.features.ornaments.Clear();
                foreach (Transform t in person.spriteOrigin.transform)
                {
                    Destroy(t.gameObject);
                }
                Debug.Log("Person." + person.uniqueFeatureId + " matched target, retrying " + i, person);
            }
            else
            {
                stillClashing = false;
                break;
            }
        }
        if (stillClashing)
        {
            Debug.Log("Can't generate non-clashing features, deleting person. ");
            Destroy(person.gameObject);
        }

        bool isNameClashing = false;
        Name nameGen        = new Name();

        for (int i = 0; i < 6; i++)
        {
            person.displayName = nameGen.GenerateRandomName();

            if (Game.S.target == null)
            {
                break;
            }
            if (person == Game.S.detective)
            {
                break;
            }
            if (person == Game.S.target)
            {
                break;
            }

            // CLASSSH!
            if (person.displayName == Game.S.target.displayName)
            {
                isNameClashing = true;
            }
            else
            {
                isNameClashing = false;
                break;
            }
        }
        if (isNameClashing)
        {
            Debug.Log("Can't generate non-clashing name, deleting person. ");
            Destroy(person.gameObject);
        }

        person.PostFeatureStart();
    }
Ejemplo n.º 3
0
 public void SetBody(BodyFeature feature, Logic logic)
 {
     body = new KeyValuePair <BodyFeature, Logic>(feature, logic);
 }