2020-12-03 18:52:34 +01:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
2020-12-05 15:22:00 +01:00
|
|
|
|
//Define the behavior of a mug (movable container of Consumable)
|
2020-12-04 13:12:01 +01:00
|
|
|
|
[RequireComponent(typeof(Collider2D))]
|
2020-12-03 18:52:34 +01:00
|
|
|
|
public class Mug : MonoBehaviour, IGrabable
|
|
|
|
|
{
|
|
|
|
|
public int size = 1; //Size (1 or 2 hands) of the object
|
2020-12-07 15:42:25 +01:00
|
|
|
|
public bool dirty = false;
|
2020-12-07 16:04:11 +01:00
|
|
|
|
public Consumable content{get; protected set;} = null; //new Consumable("beer",1,null);
|
2020-12-03 18:52:34 +01:00
|
|
|
|
|
|
|
|
|
public void use()
|
|
|
|
|
{
|
2020-12-04 13:12:01 +01:00
|
|
|
|
//Do nothing
|
2020-12-03 18:52:34 +01:00
|
|
|
|
}
|
2020-12-04 13:12:01 +01:00
|
|
|
|
public void take() //Object taken
|
2020-12-03 18:52:34 +01:00
|
|
|
|
{
|
2020-12-04 11:15:18 +01:00
|
|
|
|
gameObject.SetActive(false);
|
2020-12-03 18:52:34 +01:00
|
|
|
|
}
|
2020-12-04 11:15:18 +01:00
|
|
|
|
public void drop(Vector2 position) //Drop to position
|
2020-12-03 18:52:34 +01:00
|
|
|
|
{
|
2020-12-04 11:15:18 +01:00
|
|
|
|
gameObject.SetActive(true);
|
|
|
|
|
gameObject.transform.position = position;
|
2020-12-03 18:52:34 +01:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-05 15:22:00 +01:00
|
|
|
|
public void fill(Consumable new_content) //Fill Mug w/ new Consumable
|
2020-12-04 13:12:01 +01:00
|
|
|
|
{
|
2020-12-04 21:49:58 +01:00
|
|
|
|
if(content is null)
|
|
|
|
|
{
|
|
|
|
|
content = new_content;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Debug.Log(gameObject.name+" cannot be filled (already full) with "+new_content.Type);
|
|
|
|
|
}
|
2020-12-04 13:12:01 +01:00
|
|
|
|
}
|
2020-12-05 15:22:00 +01:00
|
|
|
|
public void consume() //Empty Mug of its Consumable
|
2020-12-04 13:12:01 +01:00
|
|
|
|
{
|
2020-12-04 21:49:58 +01:00
|
|
|
|
content=null;
|
2020-12-07 15:42:25 +01:00
|
|
|
|
dirty = true; //Used and dirty
|
2020-12-04 13:12:01 +01:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-03 18:52:34 +01:00
|
|
|
|
// Start is called before the first frame update
|
|
|
|
|
void Start()
|
|
|
|
|
{
|
2020-12-07 17:22:30 +01:00
|
|
|
|
if(gameObject.layer != LayerMask.NameToLayer("Interactions"))
|
|
|
|
|
Debug.LogWarning(gameObject.name+" layer should be set to 'Interactions' to work properly");
|
|
|
|
|
if(gameObject.tag != "Mug")
|
|
|
|
|
Debug.LogWarning(gameObject.name+" tag should be set to 'Mug' to work properly");
|
2020-12-03 18:52:34 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update is called once per frame
|
|
|
|
|
void Update()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|