using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Prop : MonoBehaviour
{
    public int idx;
    public float rotateSpeed;

    public MeshRenderer mesh;
    private int playerLayer;

    private void Start()
    {
        playerLayer = LayerMask.NameToLayer("Player");
        mesh = GetComponent<MeshRenderer>();
        idx = Random.Range(0, 3);
        Material mat = new Material( Resources.Load<Material>("Materials/Prop" + idx));
        mesh.material = mat;
    }

    private void Update()
    {
        transform.Rotate(Vector3.up, rotateSpeed * Time.deltaTime);
    }

    private void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.layer == playerLayer)
        {
            Player player = collision.gameObject.GetComponent<Player>();
            switch (idx)
            {
                case 0:
                    player.BigBullet();
                    break;
                case 1: 
                    player.GoldenFoot();
                    break;
                case 2:
                    player.LastJump();
                    break;
                default:
                    break;
            }
            Destroy(gameObject);
        }
    }
}
