using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;

public class pourtoipublicscript : MonoBehaviour
{
    Transform sprite;
    Material[] sprites;
    Material spriteMat;
    public Material[] perso1;
    public Material[] perso2;
    public Material[] perso3;
    

    // Start is called before the first frame update
    void Awake()
    {
        sprite = transform.GetChild(0);
        spriteMat = sprite.GetComponent<Material>();
        sprites = perso1;
    }


    void Start()
    {   
        int rand = Random.Range(0,3);
        switch (rand)
        {
            case 0:  sprites = perso1; break;
            case 1:  sprites = perso2; break;
            case 2:  sprites = perso3; break;
        }
        EndOvation();
        Invoke("StartJumping", 0.1f*Random.value);
    } 

    void StartJumping()
    {
        transform.DOJump(sprite.position,0.5f+0.1f*Random.value,1,0.45f+0.02f*Random.value,false).SetLoops(-1,LoopType.Restart);
    }

    void GameOver()
    {
        transform.DOKill();
    }

    void StartOvation()
    {
        spriteMat = sprites[1];
    }

    void EndOvation()
    {
        spriteMat = sprites[0];
    }
 
} // FIN DU SCRIPT
