2020-12-04 21:49:58 +01:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
//Represents consumable : sprite and informations
|
|
|
|
|
public class Consumable //: MonoBehaviour
|
|
|
|
|
{
|
2021-01-12 16:55:43 +01:00
|
|
|
|
static public HashSet<string> allowed_types = new HashSet<string>(new [] {"beer", "vodka"});
|
2020-12-05 15:22:00 +01:00
|
|
|
|
private string _type; //Type from allowed_types
|
2020-12-04 21:49:58 +01:00
|
|
|
|
private int _value;
|
2020-12-05 15:22:00 +01:00
|
|
|
|
private Sprite _sprite; //Display details
|
2020-12-04 21:49:58 +01:00
|
|
|
|
|
|
|
|
|
//Read-only accessors
|
|
|
|
|
public string Type
|
|
|
|
|
{
|
|
|
|
|
get{ return _type;}
|
|
|
|
|
// set{}
|
|
|
|
|
}
|
|
|
|
|
public int Value
|
|
|
|
|
{
|
|
|
|
|
get{ return _value;}
|
|
|
|
|
// set{}
|
|
|
|
|
}
|
|
|
|
|
public Sprite Sprite
|
|
|
|
|
{
|
|
|
|
|
get{ return _sprite;}
|
|
|
|
|
// set{}
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-05 15:22:00 +01:00
|
|
|
|
//Constructor
|
2020-12-04 21:49:58 +01:00
|
|
|
|
//TODO : Handle sprite = null
|
|
|
|
|
public Consumable(string type, int value, Sprite sprite)
|
|
|
|
|
{
|
2020-12-05 15:22:00 +01:00
|
|
|
|
//Test if type is an allowed type
|
2020-12-04 21:49:58 +01:00
|
|
|
|
if(!allowed_types.Contains(type))
|
|
|
|
|
{
|
2021-01-12 16:55:43 +01:00
|
|
|
|
Debug.LogError("Invalid consumable type :"+type);
|
2020-12-04 21:49:58 +01:00
|
|
|
|
}
|
|
|
|
|
_type=type;
|
|
|
|
|
_value=value;
|
|
|
|
|
_sprite=sprite;
|
|
|
|
|
}
|
|
|
|
|
}
|