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

public class Item : MonoBehaviour {

    public enum ItemName {
        COCONUT,
        WOOD,
        LEAVES,
        SAND,
        SHELL,
        ROCKS
    }

    public ItemName itemName;

    public Sprite[] sprites;
    SpriteRenderer renderer;

    private void Awake() {
        renderer = GetComponentInChildren<SpriteRenderer>();
    }

    void Start() {
        switch (itemName) {
            case (ItemName.COCONUT):
                renderer.sprite = sprites[0];
                break;
            case (ItemName.WOOD):
                GetComponent<Rigidbody>().freezeRotation = true;
                renderer.sprite = sprites[1];
                break;
            case (ItemName.LEAVES):
                GetComponent<Rigidbody>().freezeRotation = true;
                renderer.sprite = sprites[2];
                break;
            case (ItemName.SAND):
                //GetComponent<Rigidbody>().isKinematic = true;
                GetComponent<Rigidbody>().freezeRotation = true;
                transform.rotation = Quaternion.identity;
                renderer.sprite = sprites[3];
                break;
            case (ItemName.SHELL):
                renderer.sprite = sprites[4];
                break;
            case (ItemName.ROCKS):
                GetComponent<Rigidbody>().freezeRotation = true;
                renderer.sprite = sprites[5];
                break;
        }
    }

    // Update is called once per frame
    void Update() {
        
    }
}
