Ejemplo n.º 1
0
    void Start()
    {
        CharAnimation test = new CharAnimation();

        test.type      = CharAnimation.Type.Loop;
        test.frames    = new CharAnimation.Frame[2];
        test.frames[0] = new CharAnimation.Frame(200, 1000, 0);
        test.frames[1] = new CharAnimation.Frame(100, 3000, 0);

        currAnimation = test;
    }
Ejemplo n.º 2
0
    public void Animate(CharAnimation anim)
    {
        frameTime -= 0.5f;
        if (frameTime <= 0)
        {
            switch (anim)
            {
            case CharAnimation.Walk:
                currentFrame++;
                if (currentFrame > walkingFrames.Length - 1)
                {
                    currentFrame = 0;
                }
                frameTime = 3;
                break;

            case CharAnimation.Slide:
                SR.sprite = slideSprite;
                if (playSounds)
                {
                    audio.clip = skiddingSound;
                    audio.Play();
                    frameTime = 10;
                }
                break;

            case CharAnimation.Jump:
                if (currentFrame < jumpingFrames.Length)
                {
                    currentFrame++;
                }
                if (currentFrame > jumpingFrames.Length - 1)
                {
                    currentFrame = 0;
                }
                if (playSounds)
                {
                    audio.clip = flapSound;
                    audio.Play();
                }
                SR.sprite = jumpingFrames[currentFrame];
                frameTime = 8;
                break;
            }
        }
    }
Ejemplo n.º 3
0
    public void Animate(CharAnimation anim, float acc)
    {
        if (acc < 0)
        {
            acc = acc * -1;
        }
        frameTime -= 0.5f + 3 * acc;
        if (frameTime <= 0)
        {
            switch (anim)
            {
            case CharAnimation.Walk:
                currentFrame++;
                if (currentFrame > walkingFrames.Length - 1)
                {
                    currentFrame = 0;
                }
                if (playSounds)
                {
                    audio.clip = walkingSound;
                    audio.Play();
                }
                SR.sprite = walkingFrames[currentFrame];
                frameTime = 3;
                break;

            case CharAnimation.Slide:
                SR.sprite = slideSprite;
                break;

            case CharAnimation.Jump:
                if (currentFrame < jumpingFrames.Length)
                {
                    currentFrame++;
                }
                if (currentFrame > jumpingFrames.Length - 1)
                {
                    currentFrame = 0;
                }
                SR.sprite = jumpingFrames[currentFrame];
                frameTime = 8;
                break;
            }
        }
    }
Ejemplo n.º 4
0
 // Use this for initialization
 void Start()
 {
     this.loopedAnim = new RunningAnimation( this.gameObject );
     if(this.loopedAnim!=null) this.loopedAnim.Start();
 }
Ejemplo n.º 5
0
 static void Main(string[] args)
 {
     CharAnimation.Get().Play();
 }