Ejemplo n.º 1
0
    public GameObject generateMonsterAtPosition(Vector3 pos, bool shouldWalk = true)
    {
        List <GameObject> goList = new List <GameObject> ();
        GameObject        o      = root.generateMonster(pos, 0, null, monsterMat, new Color(Random.Range(.5f, .8f), Random.Range(.5f, .8f), Random.Range(.5f, .8f)), goList);
        Creature          cr     = o.AddComponent <Creature> ();

        cr.nodeSetup(goList, monster.GetInstructions());
        cr.setShouldWalk(true);
        FitnessFunction fn = o.AddComponent <FitnessFunction>();

        fn.AssignMonster(monster);
        if (eye != null)
        {
            float      eyeSmall = .3f;
            float      eyeLarge = .5f;
            float      eyeSize  = Random.Range(eyeSmall, eyeLarge);
            float      eyeDiff  = Random.Range(eyeSize / 2, .5f - eyeSize / 2);
            GameObject e1       = GameObject.Instantiate(eye);
            e1.transform.SetParent(o.transform);
            e1.transform.localScale    = new Vector3(eyeSize, eyeSize, eyeSize / 2);
            e1.transform.localPosition = new Vector3(-eyeDiff, 0, -.5f);
            GameObject e2 = GameObject.Instantiate(eye);
            e2.transform.SetParent(o.transform);
            e2.transform.localScale    = new Vector3(eyeSize, eyeSize, eyeSize / 2);
            e2.transform.localPosition = new Vector3(eyeDiff, 0, -.5f);
        }
        return(o);
    }