Exemplo n.º 1
0
    void Start()
    {
        this.MaxHealth             = 100f;
        this.CharacteristicsCanvas = characteristics;


        // Initializing the possible states for the creature
        this.seBalader    = this.gameObject.AddComponent <SeBalader>();
        this.chasser      = this.gameObject.AddComponent <Chasser>();
        this.seReproduire = this.gameObject.AddComponent <SeReproduire>();
        this.dead         = this.gameObject.AddComponent <Dead>();

        // Defining the initial state of the creature
        this.CurrentState = seBalader;

        // Initializing different parameters of the creature
        this.Hunger           = Random.Range(Game.minHunger, 100);
        this.ReproductiveNeed = Random.Range(Game.minReproductionNeed, 100);
        this.Speed            = Random.Range(1, 10);
        this.CurrentHealth    = Random.Range(MaxHealth / 2, MaxHealth);
        this.mCreatureType    = CreatureType.CARNIVORE;

        // Initializing the initial rotation of the creature
        this.gameObject.transform.Rotate(this.gameObject.transform.up * Random.Range(0, 360));

        // Sex
        int rand = Random.Range(1, 2);

        this.GetComponent <CarnivoreBrain>().mSex = rand == 1 ? Creature.Sex.FEMALE : Creature.Sex.MALE;

        // Body type
        Random.seed = System.DateTime.Now.Millisecond;
        rand        = Random.Range(1, System.Enum.GetNames(typeof(Body.BodyType)).Length);
        this.GetComponent <CarnivoreBrain>().mBody.mBodyType = (Body.BodyType)rand;

        Random.seed = System.DateTime.Now.Millisecond;
        // Head active
        rand = Random.Range(1, System.Enum.GetNames(typeof(Head.Active)).Length);
        this.GetComponent <CarnivoreBrain>().mHead.mActive = (Head.Active)rand;

        Random.seed = System.DateTime.Now.Millisecond;
        // Head passive
        rand = Random.Range(1, System.Enum.GetNames(typeof(Head.Passive)).Length);
        this.GetComponent <CarnivoreBrain>().mHead.mPassive = (Head.Passive)rand;

        Random.seed = System.DateTime.Now.Millisecond;
        // Front limb active
        rand = Random.Range(1, System.Enum.GetNames(typeof(Limb.Active)).Length);
        this.GetComponent <CarnivoreBrain>().FrontLimb.mActive = (Limb.Active)rand;

        Random.seed = System.DateTime.Now.Millisecond;
        // Front limb passive
        rand = Random.Range(1, System.Enum.GetNames(typeof(Limb.Passive)).Length);
        this.GetComponent <CarnivoreBrain>().FrontLimb.mPassive = (Limb.Passive)rand;

        Random.seed = System.DateTime.Now.Millisecond;
        // Back limb active
        rand = Random.Range(1, System.Enum.GetNames(typeof(Limb.Active)).Length);
        this.GetComponent <CarnivoreBrain>().BackLimb.mActive = (Limb.Active)rand;

        Random.seed = System.DateTime.Now.Millisecond;
        // Back limb passive
        rand = Random.Range(1, System.Enum.GetNames(typeof(Limb.Passive)).Length);
        this.BackLimb.mPassive = (Limb.Passive)rand;
    }
Exemplo n.º 2
0
    private void Start()
    {
        this.MaxHealth             = 100f;
        this.CharacteristicsCanvas = characteristics;

        // Initializing the possible states for the creature
        this.seReproduire = this.gameObject.AddComponent <SeReproduire>();
        seReproduire.name = "Se Reproduire";
        this.seBalader    = this.gameObject.AddComponent <SeBalader>();
        seBalader.name    = "Se Balader";
        this.seNourir     = this.gameObject.AddComponent <SeNourir>();
        seNourir.name     = "Se Nourir";
        this.fuir         = this.gameObject.AddComponent <Fuir>();
        fuir.name         = "Fuir";
        this.dead         = this.gameObject.AddComponent <Dead>();
        dead.name         = "Dead";

        // Initializing different parameters of the creature

        this.Hunger           = Random.Range(Game.minHunger, 100);
        this.ReproductiveNeed = Random.Range(Game.minReproductionNeed, 100);
        this.Speed            = Random.Range(1, 10);
        this.CurrentHealth    = Random.Range(MaxHealth / 2, MaxHealth);
        this.mCreatureType    = CreatureType.HERBIVORE;

        // Sex
        int rand = Random.Range(1, 2);

        Debug.Log("sex = " + rand);
        this.gameObject.GetComponent <HerbivoreBrain>().mSex = rand == 1 ? Creature.Sex.FEMALE : Creature.Sex.MALE;

        // Body type

        rand = Random.Range(1, System.Enum.GetNames(typeof(Body.BodyType)).Length);
        Debug.Log("body type = " + rand);
        this.gameObject.GetComponent <HerbivoreBrain>().mBody.mBodyType = (Body.BodyType)rand;

        // Head active
        rand = Random.Range(1, System.Enum.GetNames(typeof(Head.Active)).Length);
        Debug.Log("head active = " + rand);
        this.gameObject.GetComponent <HerbivoreBrain>().mHead.mActive = (Head.Active)rand;

        // Head passive
        rand = Random.Range(1, System.Enum.GetNames(typeof(Head.Passive)).Length);
        Debug.Log("head passive = " + rand);
        this.gameObject.GetComponent <HerbivoreBrain>().mHead.mPassive = (Head.Passive)rand;

        // Front limb active
        rand = Random.Range(1, System.Enum.GetNames(typeof(Limb.Active)).Length);
        this.gameObject.GetComponent <HerbivoreBrain>().FrontLimb.mActive = (Limb.Active)rand;

        // Front limb passive
        rand = Random.Range(1, System.Enum.GetNames(typeof(Limb.Passive)).Length);
        this.gameObject.GetComponent <HerbivoreBrain>().FrontLimb.mPassive = (Limb.Passive)rand;

        // Back limb active
        rand = Random.Range(1, System.Enum.GetNames(typeof(Limb.Active)).Length);
        this.gameObject.GetComponent <HerbivoreBrain>().BackLimb.mActive = (Limb.Active)rand;

        // Back limb passive
        rand = Random.Range(1, System.Enum.GetNames(typeof(Limb.Passive)).Length);
        this.gameObject.GetComponent <HerbivoreBrain>().BackLimb.mPassive = (Limb.Passive)rand;

        // Initializing the initial rotation of the creature
        this.gameObject.transform.Rotate(this.gameObject.transform.up * Random.Range(0, 360));

        // Defining the initial state of the creature
        this.CurrentState = seBalader;

        //Debug.Log("Hunger au debut:" + this.Hunger);
    }