Пример #1
0
    internal void Load()
    {
        animacion = new AnimPose[animacionsConSS.Length + animacionesSinSS.Length];
        for (int j = 0; j < animacionsConSS.Length; j++)
        {
            animacion[j] = new AnimPose(nPoses, animacionsConSS[j].nFrames);
            animacion[j].animationType = animacionsConSS[j].animationType;
        }
        for (int j = animacionsConSS.Length; j < animacionsConSS.Length + animacionesSinSS.Length; j++)
        {
            animacion[j] = animacionesSinSS[j - animacionsConSS.Length];
        }

        for (int k = 0; k < animacionsConSS.Length; k++)
        {
            Sprite[] sprites = Resources.LoadAll <Sprite>(animacionsConSS[k].SpriteSheet.name);
            for (int i = 0; i < animacionsConSS[k].nFrames; i++)
            {
                for (int j = 0; j < nPoses; j++)
                {
                    animacion[k].poses[j].frames[i] = sprites[(i * 4) + j];
                }
            }
        }
    }
Пример #2
0
    internal override void SelectPose()
    {
        //Posicionamiento iMagen
        Vector3 dirToDross = Vector3.Normalize(Master.originalDross.transform.position - Posicionador.transform.position);
        float   angle      = AngleBetweenVector2(Posicionador.transform.forward, dirToDross);
        byte    index      = 0;

        if (angle < 0f)
        {
            angle += 360;
        }

        if (angle <= 45)
        {
            index = 0; // frontal
        }
        else if (angle <= 135)
        {
            index = 1; // izquierda
            GetComponent <SpriteRenderer>().flipX = false;
        }
        else if (angle <= 225)
        {
            index = 2; //atras
        }
        else if (angle <= 315)
        {
            index = 1; // Derecha
            GetComponent <SpriteRenderer>().flipX = true;
        }
        else if (angle > 315)
        {
            index = 0;
        }
        AnimPose actualAnimacion = animacion[curAnimacion];
        Pose     actualPose      = actualAnimacion.poses[index];
        Sprite   spriteActual    = actualPose.frames[frameActual];

        GetComponent <SpriteRenderer>().sprite = spriteActual;
    }