Start working Mug.cs
This commit is contained in:
parent
71d6586baf
commit
70024c7b6a
3 changed files with 37 additions and 10 deletions
|
@ -8,5 +8,5 @@ public interface IGrabable
|
||||||
// int size {get; set;} //Size (1 or 2 hands) of the object
|
// int size {get; set;} //Size (1 or 2 hands) of the object
|
||||||
void use();
|
void use();
|
||||||
void take();
|
void take();
|
||||||
void drop(Transform position); //Drop to position
|
void drop(Vector2 position); //Drop to position
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,11 +12,12 @@ public class Mug : MonoBehaviour, IGrabable
|
||||||
}
|
}
|
||||||
public void take()
|
public void take()
|
||||||
{
|
{
|
||||||
|
gameObject.SetActive(false);
|
||||||
}
|
}
|
||||||
public void drop(Transform position) //Drop to position
|
public void drop(Vector2 position) //Drop to position
|
||||||
{
|
{
|
||||||
|
gameObject.SetActive(true);
|
||||||
|
gameObject.transform.position = position;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
|
|
|
@ -7,7 +7,7 @@ public class Tavernkeeper_controller : MonoBehaviour
|
||||||
public float mvt_speed = 5.0f; //Movement speed
|
public float mvt_speed = 5.0f; //Movement speed
|
||||||
public float action_dist = 1.5f; //Action distance
|
public float action_dist = 1.5f; //Action distance
|
||||||
|
|
||||||
IDictionary<string, GameObject> hand_container;
|
IDictionary<string, GameObject> hand_container; //Objects in hand
|
||||||
|
|
||||||
// Last user inputs
|
// Last user inputs
|
||||||
float horizontal;
|
float horizontal;
|
||||||
|
@ -96,8 +96,15 @@ public class Tavernkeeper_controller : MonoBehaviour
|
||||||
{
|
{
|
||||||
// hit_object.transform.SetParent(transform);
|
// hit_object.transform.SetParent(transform);
|
||||||
// hit_object.transform.localPosition = new Vector2(-0.2f,0.2f);
|
// hit_object.transform.localPosition = new Vector2(-0.2f,0.2f);
|
||||||
hit_object.SetActive(false);
|
|
||||||
hand_container[hand]=hit_object;
|
//Doit traiter différement chaque Grabable ...
|
||||||
|
Mug obj = hit_object.GetComponent<Mug>();
|
||||||
|
// if (obj.size==1 || (obj.size==2 && ));
|
||||||
|
if(obj!=null)
|
||||||
|
{
|
||||||
|
obj.take();
|
||||||
|
hand_container[hand]=hit_object;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Full hand : try give to client
|
//Full hand : try give to client
|
||||||
|
@ -113,9 +120,28 @@ public class Tavernkeeper_controller : MonoBehaviour
|
||||||
{
|
{
|
||||||
// Debug.Log("Hand full with "+ hand_container[hand]);
|
// Debug.Log("Hand full with "+ hand_container[hand]);
|
||||||
// hand_container[hand].transform.SetParent(null);
|
// hand_container[hand].transform.SetParent(null);
|
||||||
hand_container[hand].SetActive(true);
|
|
||||||
hand_container[hand].transform.position = rigidbody2d.position;
|
//Doit traiter différement chaque Grabable ...
|
||||||
hand_container[hand]=null;
|
Mug obj = hand_container[hand].GetComponent<Mug>();
|
||||||
|
if(obj !=null)
|
||||||
|
{
|
||||||
|
obj.drop(rigidbody2d.position);
|
||||||
|
hand_container[hand]=null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Returns set of free hands (keys)
|
||||||
|
// ISet<string> freeHands()
|
||||||
|
// {
|
||||||
|
// HashSet<string> res = new HashSet<string>();
|
||||||
|
// foreach ( KeyValuePair<string, GameObject> kvp in hand_container)
|
||||||
|
// {
|
||||||
|
// if(kvp.Value is null)
|
||||||
|
// {
|
||||||
|
// res.Add(kvp.Key);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return res;
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue