1
0
Fork 0
This commit is contained in:
Florian RICHER (MrDev023) 2019-01-27 15:09:43 +01:00
parent ca8b74707d
commit ce32d399d7
5 changed files with 225 additions and 221 deletions

View file

@ -17,27 +17,35 @@ public class Tent : MonoBehaviour
public bool playerIsSafe()
{
return Vector2.Distance(this.transform.position, player.transform.position) < this.GetComponent<Tent>().protectionZone;
return Vector2.Distance(this.transform.position, player.transform.position) < this.protectionZone;
}
public bool isHouse()
{
return protectionZone >= houseLevel;
}
// Update is called once per frame
void Update()
{
if (Vector2.Distance(player.transform.position, this.transform.position) < this.protectionZone &&
player.GetComponent<PlayerScript>().GetNumberOfWood() >= 30)
if (playerIsSafe())
{
player.GetComponent<PlayerScript>().SetInteractMessage(true, protectionZone >= houseLevel ? "maison" : "tente");
if (Input.GetKey(KeyCode.E) || Manette.IsUse())
if (player.GetComponent<PlayerScript>().GetNumberOfWood() >= 30)
{
player.GetComponent<PlayerScript>().SetInteractMessage(false, "");
player.GetComponent<PlayerScript>().BurnObjects(300);
protectionZone += 1;
player.GetComponent<PlayerScript>().SetInteractMessage(true, protectionZone >= houseLevel ? "maison" :
string.Format("tente ({0} / {1})", 5 - (houseLevel - protectionZone), 5));
if (protectionZone >= houseLevel)
if (Input.GetKey(KeyCode.E) || Manette.IsUse())
{
this.GetComponent<SpriteRenderer>().sprite = maison;
this.GetComponent<Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezeAll;
player.GetComponent<PlayerScript>().SetInteractMessage(false, "");
player.GetComponent<PlayerScript>().BurnObjects(300);
protectionZone += 1;
if (isHouse())
{
this.GetComponent<SpriteRenderer>().sprite = maison;
this.GetComponent<Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezeAll;
}
}
}
}