Пример #1
0
    void Start()
    {
        cuerpo       = this.GetComponentInChildren <CapsuleCollider2D> ();
        cabeza       = this.GetComponentInChildren <CircleCollider2D>();
        thisAnimator = this.GetComponentInChildren <Animator>();
        thisSprite   = this.GetComponentInChildren <SpriteRenderer>();

        sonidosPeon = this.GetComponent <AudioSource>();
        thisRigid   = this.GetComponent <Rigidbody2D>();
        checks      = this.GetComponent <CheckGroundAndWalls>();

        initialScale = this.transform.localScale.x;
        initialOrder = thisSprite.sortingOrder;

        GenerarDireccion();

        speed           = 1f;
        pillado         = false;
        distanciaPillar = 3;

        maximoTiempoAndando = (byte)Random.Range(minAndando, maxAndando);
        actualTiempoAndando = 0;

        proximoTiempoSentado = (byte)Random.Range(minSentado, maxSentado);
        actualTiempoSentado  = 0;
    }
Пример #2
0
    void Start()
    {
        CtrlPlayer = GameObject.FindWithTag("PlayerV2").GetComponent <PlayerControl> ();
        animPlayer = GameObject.Find("Sprite").GetComponent <Animator> ();
        checks     = GetComponent <CheckGroundAndWalls>();

        PlatformTransform = this.transform;

        // Guardamos la posición inicial de la plataforma
        //InitialPlatformPosition = PlatformTransform.position;

        // Inicializamos la posición de referencia para el cálculo de rebote horizontal (ping-pong)
        ReferencePingPongHPosition = PlatformTransform.position.x;

        // Inicializamos la posición de referencia para el cálculo de rebote vertical (ping-pong)
        ReferencePingPongVPosition = PlatformTransform.position.y;
    }
Пример #3
0
    void Awake()
    {
        // COGEMOS COMPONENTES

        if (this.name.ToLower().Contains("player"))
        {
            // Asignamos componente SpriteRenderer del gameobject Sprite.
            thisSprite = this.transform.Find("Sprite").GetComponentInChildren <SpriteRenderer>();
            thisShadow = thisSprite.transform.Find("Sombra").GetComponentInChildren <SpriteRenderer>();


            // Asignamos componente Animator del gameobject Sprite
            thisAnimator = this.transform.GetComponentInChildren <Animator>();

            // Asignamos componente RigidBody2D del gameobject
            thisRigid = this.GetComponent <Rigidbody2D> ();

            sourceofSounds = this.GetComponent <AudioSource>();

            Checks = this.GetComponent <CheckGroundAndWalls>();
        }
    }
Пример #4
0
    //Vector3 ancho;


    void Start()
    {
        // Almacenamos en un array de GameObjects, todos los que están en el tag "Player".
        // Buscamos en el array el transform que no de nulo en rigidbody (Padre de todos los demás).
        // Almacenamos el transform de ese gameobject en 'playertransform'.

        GameObject [] player = GameObject.FindGameObjectsWithTag("Player");
        foreach (GameObject play in player)
        {
            if (play.GetComponent <Rigidbody2D>() != null)
            {
                playerTransform = play.GetComponent <Transform>();
            }
            if (play.GetComponent <Animator>() != null)
            {
                //playerSprite = play.GetComponent <SpriteRenderer>();
            }
            if (play.GetComponent <PlayerControl>() != null)
            {
                ctrlPlayer = play.GetComponent <PlayerControl>();
            }
        }
        Checks = this.GetComponent <CheckGroundAndWalls>();

        // Almacenamos en las variables creadas los Componentes de cada GameObject necesario.
        thisSprite     = GetComponent <SpriteRenderer> ();
        thisRigid      = GetComponent <Rigidbody2D>();
        thisCanvas     = this.transform.Find("Canvas").GetComponent <Canvas>();
        imagesOfCanvas = thisCanvas.GetComponentsInChildren <Image>();


        // Activamos la variable isKinematic de éste RigidBody (No le afecta la física
        // Desactivamos el canvas que muestra el Tip
        thisRigid.isKinematic = true;
        thisCanvas.enabled    = false;
    }