/// <summary>
    /// En el start declaramos un rigidbody que se le asigna a la primitiva que lleva el componente de zombie;
    /// le asignamos un color al azar entre verde, cyan y magenta;
    /// le asignamos una posicion al azar en el mapa;
    /// le asignamos una tag para poder detectarlo mas facilmente
    /// </summary>
    void Start()
    {
        Rigidbody zom;

        zom             = this.gameObject.AddComponent <Rigidbody>();
        zom.useGravity  = false;
        zom.constraints = RigidbodyConstraints.FreezeAll;
        partesCuerpo Comer;

        Comer             = (partesCuerpo)Random.Range(0, 6);
        gustoZombie       = Comer.ToString();
        zombieDatos.gusto = gustoZombie;
        int numAleatorio = Random.Range(0, 3);

        this.gameObject.name = "Zombie";
        this.gameObject.tag  = "Zombie";

        // en esta parte es donde asignamos el color al azar
        if (numAleatorio == 0)
        {
            this.gameObject.GetComponent <Renderer>().material.color = Color.cyan;
            this.gameObject.transform.position = new Vector3(Random.Range(20, -21), 0, Random.Range(20, -21));
        }
        else if (numAleatorio == 1)
        {
            this.gameObject.GetComponent <Renderer>().material.color = Color.green;
            this.gameObject.transform.position = new Vector3(Random.Range(20, -21), 0, Random.Range(20, -21));
        }
        else if (numAleatorio == 2)
        {
            this.gameObject.GetComponent <Renderer>().material.color = Color.magenta;
            this.gameObject.transform.position = new Vector3(Random.Range(20, -21), 0, Random.Range(20, -21));
        }
    }
Example #2
0
 // Use this for initialization
 void Start()
 {
     taskList           = new List <Task>();
     anim               = GetComponent <Animator>();
     paseando           = anim.GetBehaviour <Paseando>();
     hacerCola          = anim.GetBehaviour <HacerCola>();
     sentarse           = anim.GetBehaviour <Sentarse>();
     pedirComida        = anim.GetBehaviour <PedirComida>();
     comer              = anim.GetBehaviour <Comer>();
     pedirCuenta        = anim.GetBehaviour <PedirCuenta>();
     irse               = anim.GetBehaviour <Irse>();
     paseando.client    = this;
     hacerCola.client   = this;
     sentarse.client    = this;
     pedirComida.client = this;
     comer.client       = this;
     pedirCuenta.client = this;
     irse.client        = this;
     world              = FindObjectOfType <World>();
     soundManager       = FindObjectOfType <SoundManager>();
 }
Example #3
0
            /// <summary>
            /// le otorgamso un rigidboy como en las otras dos calses para efectuar la colisiones
            /// y congelamos en todas las posiciones para evitar comportamientos erraticos debido a estas colisiones
            /// se determina de que color sera el zombie de maenra aleatorea
            /// y se posicionea en un lugar random del mundo entre 10 y menos 10 de los ejes "z" y "x"
            /// </summary>
            public void SinCerbro()
            {
                Rigidbody rb;

                comer = (Comer)Random.Range(0, 5);

                int cambio = Random.Range(1, 4);

                if (cambio == 1)
                {
                    Renderer color = this.gameObject.GetComponent <Renderer>();
                    color.material.color = Color.green;
                    this.gameObject.name = "Zombie";
                    rb             = this.gameObject.AddComponent <Rigidbody>();
                    rb.constraints = RigidbodyConstraints.FreezeAll;
                    rb.useGravity  = false;
                }
                if (cambio == 2)
                {
                    Renderer color = this.gameObject.GetComponent <Renderer>();
                    color.material.color = Color.cyan;
                    this.gameObject.name = "Zombie";
                    rb             = this.gameObject.AddComponent <Rigidbody>();
                    rb.constraints = RigidbodyConstraints.FreezeAll;
                    rb.useGravity  = false;
                }
                if (cambio == 3)
                {
                    Renderer color = this.gameObject.GetComponent <Renderer>();
                    color.material.color = Color.magenta;
                    this.gameObject.name = "Zombie";
                    rb             = this.gameObject.AddComponent <Rigidbody>();
                    rb.constraints = RigidbodyConstraints.FreezeAll;
                    rb.useGravity  = false;
                }
                float x = Random.Range(-10, 10);
                float z = Random.Range(-10, 10);

                this.gameObject.transform.position = new Vector3(x, 0, z);
            }
Example #4
0
    // Use this for initialization
    void Start()
    {
        InitCitizenData();

        // Hay que hacer la fsm del agente
        fsm = new FSM(gameObject, this);

        // Crear los estados en que puede estar Bob
        Casa        casa        = new Casa(this);
        Banarse     bath        = new Banarse(this);
        Comer       comer       = new Comer(this);
        LavaPlatos  lavaplatos  = new LavaPlatos(this);
        LavaCarro   lavacarro   = new LavaCarro(this);
        TirarBasura tirarBasura = new TirarBasura(this);
        Comprar     comprar     = new Comprar(this);



        // Agregar eventos a los estados
        //sleep.AddEvent(EventList.events.dinnerReady);

        // Hay que agregarlos a la FSM
        fsm.AddState(StateID.Casa, casa);
        fsm.AddState(StateID.Banarse, bath);
        fsm.AddState(StateID.Comer, comer);
        fsm.AddState(StateID.LavaPlatos, lavaplatos);
        fsm.AddState(StateID.LavaCarro, lavacarro);
        fsm.AddState(StateID.TirarBasura, tirarBasura);
        fsm.AddState(StateID.Comprar, comprar);



        // Indicar cual es el estado inicial
        fsm.ChangeState(StateID.Casa);

        // Activo la fsm
        fsm.Activate();
    }