Skip to content
Snippets Groups Projects
Commit 44aa681e authored by BLOCH VALENTIN's avatar BLOCH VALENTIN
Browse files

Merge branch 'master' into 'master'

Systeme de dialogue qui marche

See merge request chirz/cityescape!28
parents 535b15e9 e4967a9a
No related merge requests found
File added
fileFormatVersion: 2
guid: f87b456a2cdbb5140a790b3e369cb961
TrueTypeFontImporter:
externalObjects: {}
serializedVersion: 4
fontSize: 16
forceTextureCase: -2
characterSpacing: 0
characterPadding: 1
includeFontData: 1
fontNames:
- Fipps
fallbackFontReferences: []
customCharacters:
fontRenderingMode: 0
ascentCalculationMode: 1
useLegacyBoundsCalculation: 0
shouldRoundAdvanceValue: 1
userData:
assetBundleName:
assetBundleVariant:
......@@ -11,6 +11,7 @@ GameObject:
- component: {fileID: 1835591788233434329}
- component: {fileID: 7952431289706890423}
- component: {fileID: 1778026432316727230}
- component: {fileID: 1755674381398346320}
m_Layer: 5
m_Name: TexteDeLaBulle
m_TagString: Untagged
......@@ -79,6 +80,24 @@ MonoBehaviour:
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: Je mange tes morts sale batard
--- !u!114 &1755674381398346320
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 512403696824737883}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 96efccd7704b37949a51739ed18bbd7d, type: 3}
m_Name:
m_EditorClassIdentifier:
dialogBox: {fileID: 1705879581494847332}
dialogText: {fileID: 1778026432316727230}
cr: {fileID: 4793196200597776703}
dialog: 0
dialogActive: 1
situation:
--- !u!1 &1705879581494847332
GameObject:
m_ObjectHideFlags: 0
......@@ -104,7 +123,7 @@ RectTransform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1705879581494847332}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
......
......@@ -254,10 +254,18 @@ PrefabInstance:
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: -6286016664533736427, guid: a53c5cae22cca3445bbb7e30f12f7110, type: 3}
propertyPath: period
value: 1
objectReference: {fileID: 0}
- target: {fileID: -6286016664533736427, guid: a53c5cae22cca3445bbb7e30f12f7110, type: 3}
propertyPath: natureBar
value:
objectReference: {fileID: 965246246}
- target: {fileID: -6286016664533736427, guid: a53c5cae22cca3445bbb7e30f12f7110, type: 3}
propertyPath: TimeDamage
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1206561506436264874, guid: a53c5cae22cca3445bbb7e30f12f7110, type: 3}
propertyPath: m_Size.y
value: 1.0000005
......
......@@ -10,10 +10,29 @@ using UnityEngine.SceneManagement;
public class Dialog : MonoBehaviour
{
// singleton
public static Dialog instance;
private void Awake()
{
if (instance != null)
{
Debug.LogWarning("Il y a + d'une instance de PlayerNature");
return;
}
instance = this;
}
public GameObject dialogBox;
public Text dialogText;
public CanvasRenderer cr;
public int dialog;
public bool dialogActive;
public string situation;
// clé : nom de la scène
......@@ -23,6 +42,7 @@ public class Dialog : MonoBehaviour
// Start is called before the first frame update
void Start()
{
this.dialog = 0;
string[] DialogsLvl1 = {
......@@ -30,13 +50,38 @@ public class Dialog : MonoBehaviour
"Je fais un test pour le niveau 1",
"Ca marche bien nan ?",
"Melvyn t moch",
"Valentin aussi"
"Valentin aussi",
"Raff est pas bo"
};
this.ListDialogs.Add("sceneTanguy", 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[] DialogMarchand = {
"Ouvrir le menu c'est avec",
"la touche E chacal"
};
this.ListDialogs.Add("marchand", DialogMarchand);
if (this.dialogActive)
this.dialogText.text = this.ListDialogs[SceneManager.GetActiveScene().name][0];
this.Situation("start");
}
// Update is called once per frame
......@@ -49,26 +94,45 @@ public class Dialog : MonoBehaviour
if ((Input.GetKeyDown(KeyCode.H) || Input.GetKeyDown("joystick button 1")))
this.dialogActive = !this.dialogActive;
if (!dialogActive)
// DEBUG
if (Input.GetKeyDown(KeyCode.F))
{
Debug.Log("tut");
this.Situation("marchand");
}
if(this.dialogActive)
{
this.dialogBox.SetActive(false);
this.dialogBox.GetComponent<CanvasRenderer>().SetAlpha(1f);
this.dialogText.GetComponent<CanvasRenderer>().SetAlpha(1f);
}
else
{
this.dialogBox.SetActive(true);
this.dialogBox.GetComponent<CanvasRenderer>().SetAlpha(0f);
this.dialogText.GetComponent<CanvasRenderer>().SetAlpha(0f);
}
}
void Next()
{
string sceneActuelle = SceneManager.GetActiveScene().name;
if (this.dialog >= this.ListDialogs[sceneActuelle].Length)
if (this.dialog >= this.ListDialogs[this.situation].Length)
this.dialogActive = false;
else
{
this.dialogText.text = this.ListDialogs[sceneActuelle][this.dialog];
this.dialogText.text = this.ListDialogs[this.situation][this.dialog];
this.dialog++;
}
}
// Ouvre une bulle de dialogue dans une situation donnée
void Situation(string sit)
{
this.situation = sit;
this.dialog = 0;
this.dialogActive = true;
this.Next();
}
}
......@@ -44,7 +44,7 @@ public class PlayerNature : MonoBehaviour
void Update()
{
//on
//toutes les x secondes => on perd un certain nombre de secondes
if (Time.time > nextActionTime)
{
nextActionTime += period;
......@@ -57,10 +57,13 @@ public class PlayerNature : MonoBehaviour
}
// Perd un certain nombre de points de nature
public void LooseNature(int damage)
{
this.currentNature -= damage;
if(this.currentNature < 0)
this.currentNature = 0;
this.natureBar.SetValue(this.currentNature);
}
......
......@@ -12,15 +12,12 @@ EditorUserSettings:
value: 22424703114646680e0b0227036c71190012193f6c7a68252320092a
flags: 0
RecentlyUsedScenePath-2:
value: 22424703114646680e0b0227036c71190012193f7e66333e243d04
value: 22424703114646680e0b0227036c72151802563f22213229
flags: 0
RecentlyUsedScenePath-3:
value: 22424703114646680e0b0227036c72151a010124623d28393930
value: 22424703114646680e0b0227036c71190012193f7e66333e243d04
flags: 0
RecentlyUsedScenePath-4:
value: 22424703114646680e0b0227036c72151802563f22213229
flags: 0
RecentlyUsedScenePath-5:
value: 22424703114646680e0b0227036c71190012193f7d66333e243d04
flags: 0
vcSharedLogLevel:
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment