Modif utilisation générique des IGrabable quand action sans hit
This commit is contained in:
parent
825de9e1b1
commit
ed07f1332e
2 changed files with 11 additions and 13 deletions
|
@ -14,7 +14,12 @@ public class Mug : MonoBehaviour, IGrabable
|
||||||
//TODO: Gérer objets tavernier (drop) et autres
|
//TODO: Gérer objets tavernier (drop) et autres
|
||||||
public bool use(GameObject userObject)
|
public bool use(GameObject userObject)
|
||||||
{
|
{
|
||||||
//Do nothing
|
if(userObject.tag=="Player")
|
||||||
|
{
|
||||||
|
// Debug.Log(gameObject.name+" dropped by "+userObject.name);
|
||||||
|
drop(userObject.transform.position);
|
||||||
|
return true; //Object taken (on the floor)
|
||||||
|
}
|
||||||
return false; //Return wether the object is taken from tavernkeeper
|
return false; //Return wether the object is taken from tavernkeeper
|
||||||
}
|
}
|
||||||
public void take() //Object taken
|
public void take() //Object taken
|
||||||
|
|
|
@ -168,20 +168,13 @@ public class Tavernkeeper_controller : MonoBehaviour
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (hand_container[hand] != null) //Hand full and no hits
|
else if (hand_container[hand] != null) //Hand full and no hits : use object
|
||||||
{
|
{
|
||||||
if (hand_container[hand].tag == "Grabable") //Drop obj carried on player position
|
IGrabable obj = hand_container[hand].GetComponent<IGrabable>();
|
||||||
|
if(obj !=null)
|
||||||
{
|
{
|
||||||
IGrabable obj = hand_container[hand].GetComponent<IGrabable>();
|
if(obj.use(gameObject)) //Use object in hand
|
||||||
if(obj !=null)
|
hand_container[hand]=null; //True = object dropped
|
||||||
{
|
|
||||||
obj.drop(rigidbody2d.position);
|
|
||||||
hand_container[hand]=null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Debug.Log(gameObject+" doesn't handle Hand full with "+ hand_container[hand]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue