Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
No results found
Show changes
Showing
with 5280 additions and 1532 deletions
This diff is collapsed.
fileFormatVersion: 2 fileFormatVersion: 2
guid: 5097a5d46361eda43b5a45ce166e49aa guid: 81e39c4f6e44e7345849a14cbef3b3ea
folderAsset: yes folderAsset: yes
DefaultImporter: DefaultImporter:
externalObjects: {} externalObjects: {}
......
...@@ -16,7 +16,7 @@ public class LoseNature : MonoBehaviour ...@@ -16,7 +16,7 @@ public class LoseNature : MonoBehaviour
{ {
nbFactory = GameObject.FindGameObjectsWithTag("factory").Length; nbFactory = GameObject.FindGameObjectsWithTag("factory").Length;
Debug.Log("il pert de la vie: " + nbFactory * damageByFactory); Debug.Log("il pert de la vie: " + nbFactory * damageByFactory);
//collision.GetComponent<PlayerNature>().LooseNature(damageByFactory * nbFactory); collision.GetComponent<PlayerNature>().LooseNature(damageByFactory * nbFactory);
this.lostLife = true; this.lostLife = true;
} }
} }
......
fileFormatVersion: 2 fileFormatVersion: 2
guid: 66de21900d4274ff1a31fa90b52cefb2 guid: acdefb31f22c752ac90ddf2bf056e45c
MonoImporter: MonoImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2
......
...@@ -14,7 +14,7 @@ public class Dialog : MonoBehaviour ...@@ -14,7 +14,7 @@ public class Dialog : MonoBehaviour
// singleton // singleton
public static Dialog instance; public static Dialog instance;
private void Awake() private void Awake()
{ {
if (instance != null) if (instance != null)
{ {
...@@ -46,33 +46,13 @@ public class Dialog : MonoBehaviour ...@@ -46,33 +46,13 @@ public class Dialog : MonoBehaviour
this.dialog = 0; this.dialog = 0;
string[] DialogsLvl1 = { string[] DialogsLvl1 = {
"Coucou", "Ach... Encore eine gute chournée dans mon fillage!",
"Je fais un test pour le niveau 1", "Ch'ai très enfie te me balader",
"Ca marche bien nan ?", "Che defrai aller au Nord dans la forêt ja !",
"Melvyn t moch", "pour me déplacer, je dois utiliser mes muscles 'flèches directionnelles'"
"Valentin aussi",
"Raff est pas bo"
}; };
this.ListDialogs.Add("start", DialogsLvl1); this.ListDialogs.Add("start", DialogsLvl1);
string[] Dialogsraff = {
"Salut",
"cava ?",
"Je te mange tes morts"
};
this.ListDialogs.Add("pnj", Dialogsraff);
string[] DialogsTest = {
"Je fais un test",
"ca marche ? ou pas ?",
"bisous"
};
this.ListDialogs.Add("test", DialogsTest);
string[] boutiqueChaussure = { string[] boutiqueChaussure = {
"Je fous prendrais zes chauzzures en taille Zweiundvierzig Bitte !", "Je fous prendrais zes chauzzures en taille Zweiundvierzig Bitte !",
...@@ -127,19 +107,7 @@ public class Dialog : MonoBehaviour ...@@ -127,19 +107,7 @@ public class Dialog : MonoBehaviour
if ((Input.GetKeyDown(KeyCode.Space) || Input.GetKeyDown("joystick button 0")) && dialogActive) if ((Input.GetKeyDown(KeyCode.Space) || Input.GetKeyDown("joystick button 0")) && dialogActive)
this.Next(); this.Next();
// DEBUG if (this.dialogActive)
if ((Input.GetKeyDown(KeyCode.H) || Input.GetKeyDown("joystick button 1")))
this.dialogActive = !this.dialogActive;
// DEBUG
if (Input.GetKeyDown(KeyCode.F))
{
Debug.Log("tut");
this.setSituation("marchand");
}
if(this.dialogActive)
{ {
this.dialogBox.GetComponent<CanvasRenderer>().SetAlpha(1f); this.dialogBox.GetComponent<CanvasRenderer>().SetAlpha(1f);
this.dialogText.GetComponent<CanvasRenderer>().SetAlpha(1f); this.dialogText.GetComponent<CanvasRenderer>().SetAlpha(1f);
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class PanneauDisplay : MonoBehaviour
{
public string TextToDisplay = "Ceci est le texte de base du panneau";
public GameObject backgroundPanelDisplay;
public GameObject textPanelDisplay;
// Start is called before the first frame update
void Start()
{
backgroundPanelDisplay.GetComponent<CanvasRenderer>().SetAlpha(0f);
textPanelDisplay.GetComponent<CanvasRenderer>().SetAlpha(0f);
}
// Update is called once per frame
void Update()
{
}
private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.CompareTag("Player"))
{
textPanelDisplay.GetComponent<Text>().text = TextToDisplay;
backgroundPanelDisplay.GetComponent<CanvasRenderer>().SetAlpha(1f);
textPanelDisplay.GetComponent<CanvasRenderer>().SetAlpha(1f);
}
}
private void OnTriggerExit2D(Collider2D collision)
{
if (collision.CompareTag("Player"))
{
backgroundPanelDisplay.GetComponent<CanvasRenderer>().SetAlpha(0f);
textPanelDisplay.GetComponent<CanvasRenderer>().SetAlpha(0f);
}
}
}
fileFormatVersion: 2 fileFormatVersion: 2
guid: 4ae30febc4f91474fa9164b85521aaf5 guid: 4c8875f970794c24fb1d22c9a0d2bb56
DefaultImporter: MonoImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData: userData:
assetBundleName: assetBundleName:
assetBundleVariant: assetBundleVariant:
...@@ -26,6 +26,10 @@ public class GenerateMap : MonoBehaviour ...@@ -26,6 +26,10 @@ public class GenerateMap : MonoBehaviour
public GameObject textE; public GameObject textE;
public GameObject textEObject; public GameObject textEObject;
public GameObject GO_Panneau;
public GameObject displayBox;
public GameObject displayText;
//Les coordonées x dans l'ordre //Les coordonées x dans l'ordre
...@@ -121,6 +125,11 @@ public class GenerateMap : MonoBehaviour ...@@ -121,6 +125,11 @@ public class GenerateMap : MonoBehaviour
float x = shop.transform.position.x + xOffset; float x = shop.transform.position.x + xOffset;
float y = shop.transform.position.y + yOffset; float y = shop.transform.position.y + yOffset;
Instantiate(goToSell, new Vector3(x, y, 0), Quaternion.identity); Instantiate(goToSell, new Vector3(x, y, 0), Quaternion.identity);
GameObject panneau = Instantiate(GO_Panneau, new Vector3(shop.transform.position.x +5.5f, shop.transform.position.y + 2.48f, 0), Quaternion.identity);
panneau.GetComponent<PanneauDisplay>().textPanelDisplay = displayText;
panneau.GetComponent<PanneauDisplay>().backgroundPanelDisplay = displayBox;
panneau.GetComponent<PanneauDisplay>().TextToDisplay = "Boutique de "+itemToSell.nom;
} }
else else
Debug.LogError("Mauvais paramètre pour objetVente: "+ objetVente); Debug.LogError("Mauvais paramètre pour objetVente: "+ objetVente);
......
...@@ -7,6 +7,7 @@ public class Border : MonoBehaviour ...@@ -7,6 +7,7 @@ public class Border : MonoBehaviour
public Item itemNeeded; public Item itemNeeded;
public BoxCollider2D forestCollider; public BoxCollider2D forestCollider;
private void OnCollisionEnter2D(Collision2D collision) private void OnCollisionEnter2D(Collision2D collision)
{ {
if (collision.transform.CompareTag("Player")) if (collision.transform.CompareTag("Player"))
...@@ -15,13 +16,15 @@ public class Border : MonoBehaviour ...@@ -15,13 +16,15 @@ public class Border : MonoBehaviour
Debug.Log("JE TOUCHE LA BORDEER"); Debug.Log("JE TOUCHE LA BORDEER");
if (Inventory.instance.hasItem(itemNeeded)) if (Inventory.instance.hasItem(itemNeeded))
{ {
Debug.Log("Je possde l'item ncessaire"); Debug.Log("Je poss?de l'item n?cessaire");
GameObject player = GameObject.FindGameObjectWithTag("Player");
//Debug.Log(player.GetComponent<PlayerMovement>().ispassed[itemNeeded.id - 1]);
player.GetComponent<PlayerMovement>().ispassed[itemNeeded.id - 1] = true;
forestCollider.enabled = false; forestCollider.enabled = false;
} }
else else
{ {
Debug.Log("Je n'ai pas l'item ncessaire"); Debug.Log("Je n'ai pas l'item n?cessaire");
switch (itemNeeded.id) switch (itemNeeded.id)
{ {
...@@ -35,7 +38,7 @@ public class Border : MonoBehaviour ...@@ -35,7 +38,7 @@ public class Border : MonoBehaviour
Dialog.instance.setSituation("borderRechaud"); Dialog.instance.setSituation("borderRechaud");
break; break;
case 4: case 4:
Dialog.instance.setSituation("borderTente"); Dialog.instance.setSituation("borderTente");
break; break;
} }
} }
......
...@@ -15,10 +15,12 @@ public class PlayerMovement : MonoBehaviour ...@@ -15,10 +15,12 @@ public class PlayerMovement : MonoBehaviour
{ {
public float speed; public float speed;
private Rigidbody2D myRigidbody; private Rigidbody2D myRigidbody;
private Vector3 change; private Vector2 moveDirection;
private Animator animator; private Animator animator;
public PlayerState currentState; public PlayerState currentState;
public GameObject player;
public bool[] ispassed;
public int stage;
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start()
...@@ -27,45 +29,51 @@ public class PlayerMovement : MonoBehaviour ...@@ -27,45 +29,51 @@ public class PlayerMovement : MonoBehaviour
animator = GetComponent<Animator>(); animator = GetComponent<Animator>();
myRigidbody = GetComponent<Rigidbody2D>(); myRigidbody = GetComponent<Rigidbody2D>();
animator.SetFloat("moveX", 0); animator.SetFloat("moveX", 0);
animator.SetFloat("moveY", -1); animator.SetFloat("moveY", -1);
ispassed = new bool[] { false, false, false, false };
stage = 0;
} }
// Update is called once per frame // Update is called once per frame
void Update() void Update()
{ {
ProcessInputs();
change = Vector3.zero;
change.x = Input.GetAxisRaw("Horizontal");
change.y = Input.GetAxisRaw("Vertical");
if(currentState == PlayerState.walk) if(currentState == PlayerState.walk)
{ {
UpdateAnimationAndMove(); UpdateAnimationAndMove();
} }
Vector3 pos = Camera.main.WorldToViewportPoint(transform.position); Vector3 pos = Camera.main.WorldToViewportPoint(transform.position);
pos.x = Mathf.Clamp01(pos.x); pos.x = Mathf.Clamp01(pos.x);
pos.y = Mathf.Clamp01(pos.y); pos.y = Mathf.Clamp01(pos.y);
transform.position = Camera.main.ViewportToWorldPoint(pos); transform.position = Camera.main.ViewportToWorldPoint(pos);
gameIntelligence();
}
private void FixedUpdate()
{
moveDirection.Normalize();
myRigidbody.velocity = new Vector2(moveDirection.x * speed, moveDirection.y * speed);
} }
void MoveCharacter() private void ProcessInputs()
{ {
change.Normalize(); float moveX = Input.GetAxisRaw("Horizontal");
myRigidbody.MovePosition(transform.position + change * speed * Time.deltaTime); float moveY = Input.GetAxisRaw("Vertical");
moveDirection = new Vector2(moveX, moveY);
} }
void UpdateAnimationAndMove() void UpdateAnimationAndMove()
{ {
if (change != Vector3.zero) if (moveDirection != Vector2.zero)
{ {
MoveCharacter();
animator.SetFloat("moveX", change.x); animator.SetFloat("moveX", moveDirection.x);
animator.SetFloat("moveY", change.y); animator.SetFloat("moveY", moveDirection.y);
animator.SetBool("moving", true); animator.SetBool("moving", true);
} }
...@@ -74,4 +82,48 @@ public class PlayerMovement : MonoBehaviour ...@@ -74,4 +82,48 @@ public class PlayerMovement : MonoBehaviour
animator.SetBool("moving", false); animator.SetBool("moving", false);
} }
} }
void gameIntelligence()
{
if (this.GetComponent<PlayerNature>().currentNature >= 100 && stage == 0)
{
GenerateMap.instance.generateBoutique(0, 0, "chaussure");
stage++;
}
else if (stage == 1 && ispassed[0] == true)
{
GenerateMap.instance.generateUsine(0, 1);
stage++;
}
else if (this.GetComponent<PlayerNature>().currentNature >= 100 && stage == 2)
{
GenerateMap.instance.generateBoutique(0, 2, "baton");
stage++;
}
else if (stage == 3 && ispassed[1] == true)
{
GenerateMap.instance.generateUsine(1, 1);
stage++;
}
else if (this.GetComponent<PlayerNature>().currentNature >= 100 && stage == 4)
{
GenerateMap.instance.generateBoutique(1, 2, "rechaud");
stage++;
}
else if (stage == 5 && ispassed[2] == true)
{
GenerateMap.instance.generateUsine(2, 0);
stage++;
}
else if (this.GetComponent<PlayerNature>().currentNature >= 100 && stage == 6)
{
GenerateMap.instance.generateBoutique(2, 1, "tente");
stage++;
}
else if (stage == 7 && ispassed[3] == true)
{
GenerateMap.instance.generateUsine(1, 0);
//stage++;
}
}
} }
...@@ -69,6 +69,9 @@ public class PlayerNature : MonoBehaviour ...@@ -69,6 +69,9 @@ public class PlayerNature : MonoBehaviour
{ {
this.currentNature += bonus; this.currentNature += bonus;
if (this.currentNature >= 100)
this.currentNature = 100;
this.natureBar.SetValue(this.currentNature); this.natureBar.SetValue(this.currentNature);
} }
......
...@@ -31,7 +31,7 @@ public class loadScene : MonoBehaviour ...@@ -31,7 +31,7 @@ public class loadScene : MonoBehaviour
SceneManager.LoadScene(scene); SceneManager.LoadScene(scene);
} }
...@@ -42,11 +42,6 @@ public class loadScene : MonoBehaviour ...@@ -42,11 +42,6 @@ public class loadScene : MonoBehaviour
// Update is called once per frame // Update is called once per frame
void Update() void Update()
{ {
if(PlayerNature.instance.currentNature <= 0)
{
ChargerScene();
PlayerNature.instance.currentNature = 100;
}
} }
public void ExitGame() public void ExitGame()
......
fileFormatVersion: 2 fileFormatVersion: 2
guid: 2cda990e2423bbf4892e6590ba056729 guid: 1d113792a68e92533a5ae096013dedfd
folderAsset: yes
DefaultImporter: DefaultImporter:
externalObjects: {} externalObjects: {}
userData: userData:
......
...@@ -7,7 +7,7 @@ public class Shopping : MonoBehaviour ...@@ -7,7 +7,7 @@ public class Shopping : MonoBehaviour
{ {
private bool playerInRange; private bool playerInRange;
private bool isBuy=false; private bool isBuy = false;
public Item sellItem = null; public Item sellItem = null;
//public GameObject[] itemForSale = new GameObject[2]; //public GameObject[] itemForSale = new GameObject[2];
public List<GameObject> itemForSale = new List<GameObject>(); public List<GameObject> itemForSale = new List<GameObject>();
...@@ -27,57 +27,61 @@ public class Shopping : MonoBehaviour ...@@ -27,57 +27,61 @@ public class Shopping : MonoBehaviour
Ebutton.GetComponent<CanvasRenderer>().SetAlpha(0f); Ebutton.GetComponent<CanvasRenderer>().SetAlpha(0f);
textEbutton.GetComponent<CanvasRenderer>().SetAlpha(0f); textEbutton.GetComponent<CanvasRenderer>().SetAlpha(0f);
textEbuttonObject.GetComponent<CanvasRenderer>().SetAlpha(0f); textEbuttonObject.GetComponent<CanvasRenderer>().SetAlpha(0f);
} }
// Update is called once per frame // Update is called once per frame
void Update() void Update()
{ {
if(playerInRange) if (playerInRange)
{ {
switch (sellItem.id) switch (sellItem.id)
{ {
case 1: case 1:
textEbuttonObject.GetComponent<Text>().text="Chaussures de marche"; textEbuttonObject.GetComponent<Text>().text = "Chaussures de marche";
break; break;
case 2: case 2:
textEbuttonObject.GetComponent<Text>().text="Bâton de marche"; textEbuttonObject.GetComponent<Text>().text = "Bâton de marche";
break; break;
case 3: case 3:
textEbuttonObject.GetComponent<Text>().text="Réchaud"; textEbuttonObject.GetComponent<Text>().text = "Réchaud";
break; break;
case 4: case 4:
textEbuttonObject.GetComponent<Text>().text="Tente"; textEbuttonObject.GetComponent<Text>().text = "Tente";
break; break;
} }
} }
if (Input.GetKeyDown(KeyCode.E) && playerInRange && sellItem && itemForSale.Count>0) if ((Input.GetKeyDown(KeyCode.E) || Input.GetKeyDown("joystick button 1")) && playerInRange && sellItem && itemForSale.Count > 0)
{ {
if (!isBuy)
PlayerNature.instance.LooseNature(20);
switch (sellItem.id) switch (sellItem.id)
{ {
case 1: case 1:
Dialog.instance.setSituation("boutiqueChaussure"); Dialog.instance.setSituation("boutiqueChaussure");
isBuy=true; isBuy = true;
break; break;
case 2: case 2:
Dialog.instance.setSituation("boutiqueBaton"); Dialog.instance.setSituation("boutiqueBaton");
isBuy=true; isBuy = true;
break; break;
case 3: case 3:
Dialog.instance.setSituation("boutiqueRechaud"); Dialog.instance.setSituation("boutiqueRechaud");
isBuy=true; isBuy = true;
break; break;
case 4: case 4:
Dialog.instance.setSituation("boutiqueTente"); Dialog.instance.setSituation("boutiqueTente");
isBuy=true; isBuy = true;
break; break;
} }
panelEbutton.GetComponent<CanvasRenderer>().SetAlpha(0f); panelEbutton.GetComponent<CanvasRenderer>().SetAlpha(0f);
Ebutton.GetComponent<CanvasRenderer>().SetAlpha(0f); Ebutton.GetComponent<CanvasRenderer>().SetAlpha(0f);
textEbutton.GetComponent<CanvasRenderer>().SetAlpha(0f); textEbutton.GetComponent<CanvasRenderer>().SetAlpha(0f);
textEbuttonObject.GetComponent<CanvasRenderer>().SetAlpha(0f); textEbuttonObject.GetComponent<CanvasRenderer>().SetAlpha(0f);
Inventory.instance.addItem(sellItem); Inventory.instance.addItem(sellItem);
Debug.Log(sellItem.name.ToString() + " a bien ete ajouté a l'inventaire"); Debug.Log(sellItem.name.ToString() + " a bien ete ajouté a l'inventaire");
} }
...@@ -88,14 +92,14 @@ public class Shopping : MonoBehaviour ...@@ -88,14 +92,14 @@ public class Shopping : MonoBehaviour
if (collision.CompareTag("Player")) if (collision.CompareTag("Player"))
{ {
playerInRange = true; playerInRange = true;
if(isBuy==false) if (isBuy == false)
{ {
panelEbutton.GetComponent<CanvasRenderer>().SetAlpha(1f); panelEbutton.GetComponent<CanvasRenderer>().SetAlpha(1f);
Ebutton.GetComponent<CanvasRenderer>().SetAlpha(1f); Ebutton.GetComponent<CanvasRenderer>().SetAlpha(1f);
textEbutton.GetComponent<CanvasRenderer>().SetAlpha(1f); textEbutton.GetComponent<CanvasRenderer>().SetAlpha(1f);
textEbuttonObject.GetComponent<CanvasRenderer>().SetAlpha(1f); textEbuttonObject.GetComponent<CanvasRenderer>().SetAlpha(1f);
} }
} }
} }
......
fileFormatVersion: 2 fileFormatVersion: 2
guid: b0d67e78638d146bd8a6878c5027f9c5 guid: 3aca29e63a372841dabe9b809fff6d12
MonoImporter: MonoImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2
......
File added
File added
File added
File added
File added