Merge with main
This commit is contained in:
commit
28c9cb85c7
@ -613,7 +613,7 @@ MonoBehaviour:
|
|||||||
m_OnCullStateChanged:
|
m_OnCullStateChanged:
|
||||||
m_PersistentCalls:
|
m_PersistentCalls:
|
||||||
m_Calls: []
|
m_Calls: []
|
||||||
m_text: Five Up
|
m_text: Return Map
|
||||||
m_isRightToLeft: 0
|
m_isRightToLeft: 0
|
||||||
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
||||||
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
||||||
@ -1891,7 +1891,7 @@ MonoBehaviour:
|
|||||||
m_OnCullStateChanged:
|
m_OnCullStateChanged:
|
||||||
m_PersistentCalls:
|
m_PersistentCalls:
|
||||||
m_Calls: []
|
m_Calls: []
|
||||||
m_text: Return
|
m_text: Retry
|
||||||
m_isRightToLeft: 0
|
m_isRightToLeft: 0
|
||||||
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
||||||
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
||||||
|
|||||||
@ -537,6 +537,42 @@ PrefabInstance:
|
|||||||
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Target
|
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Target
|
||||||
value:
|
value:
|
||||||
objectReference: {fileID: 1340105976}
|
objectReference: {fileID: 1340105976}
|
||||||
|
- target: {fileID: 1388419616670829464, guid: 4a2f48781c26ad247b697aa368358f88, type: 3}
|
||||||
|
propertyPath: m_AnchoredPosition.x
|
||||||
|
value: 828
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1388419616670829464, guid: 4a2f48781c26ad247b697aa368358f88, type: 3}
|
||||||
|
propertyPath: m_AnchoredPosition.y
|
||||||
|
value: -327.58
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1388419616670829465, guid: 4a2f48781c26ad247b697aa368358f88, type: 3}
|
||||||
|
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.size
|
||||||
|
value: 1
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1388419616670829465, guid: 4a2f48781c26ad247b697aa368358f88, type: 3}
|
||||||
|
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Mode
|
||||||
|
value: 1
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1388419616670829465, guid: 4a2f48781c26ad247b697aa368358f88, type: 3}
|
||||||
|
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Target
|
||||||
|
value:
|
||||||
|
objectReference: {fileID: 1340105976}
|
||||||
|
- target: {fileID: 1388419616670829465, guid: 4a2f48781c26ad247b697aa368358f88, type: 3}
|
||||||
|
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_CallState
|
||||||
|
value: 2
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1388419616670829465, guid: 4a2f48781c26ad247b697aa368358f88, type: 3}
|
||||||
|
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
|
||||||
|
value: WorldReinitialition
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1388419616670829465, guid: 4a2f48781c26ad247b697aa368358f88, type: 3}
|
||||||
|
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_TargetAssemblyTypeName
|
||||||
|
value: WorldMapManager, GameAssembly
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1388419616670829465, guid: 4a2f48781c26ad247b697aa368358f88, type: 3}
|
||||||
|
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_ObjectArgumentAssemblyTypeName
|
||||||
|
value: UnityEngine.Object, UnityEngine
|
||||||
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1388419617042242050, guid: 4a2f48781c26ad247b697aa368358f88, type: 3}
|
- target: {fileID: 1388419617042242050, guid: 4a2f48781c26ad247b697aa368358f88, type: 3}
|
||||||
propertyPath: m_Pivot.x
|
propertyPath: m_Pivot.x
|
||||||
value: 0
|
value: 0
|
||||||
|
|||||||
@ -13,8 +13,11 @@ public class VictoryDefeat : MonoBehaviour
|
|||||||
private bool _lastWaveCompleted = false;
|
private bool _lastWaveCompleted = false;
|
||||||
private bool _isShowingVictoryOrDefeat = false;
|
private bool _isShowingVictoryOrDefeat = false;
|
||||||
|
|
||||||
|
private WorldMapSave _wms;
|
||||||
|
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
|
_wms = new WorldMapSave();
|
||||||
_isShowingVictoryOrDefeat = false;
|
_isShowingVictoryOrDefeat = false;
|
||||||
|
|
||||||
EventAggregator.Instance.GetEvent<LastWaveCompletedEvent>().Attach(HandleLastWaveCompletedEvent);
|
EventAggregator.Instance.GetEvent<LastWaveCompletedEvent>().Attach(HandleLastWaveCompletedEvent);
|
||||||
@ -42,6 +45,7 @@ public class VictoryDefeat : MonoBehaviour
|
|||||||
_victoryAnimator.Play("ShowVictoryOrDefeat");
|
_victoryAnimator.Play("ShowVictoryOrDefeat");
|
||||||
_isShowingVictoryOrDefeat = true;
|
_isShowingVictoryOrDefeat = true;
|
||||||
// win !
|
// win !
|
||||||
|
_wms.UnlockNextLevel();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lose if one of the enemies arrives behind our line of defense.
|
// Lose if one of the enemies arrives behind our line of defense.
|
||||||
@ -56,4 +60,5 @@ public class VictoryDefeat : MonoBehaviour
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,7 +22,9 @@ public class WorldMapManager : MonoBehaviour
|
|||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
//TODO: getMajorSaveFile() //Call et obtiens le chemin du fichier de sauvegarde;
|
//TODO: getMajorSaveFile() //Call et obtiens le chemin du fichier de sauvegarde;
|
||||||
|
|
||||||
_worldMapSave = new WorldMapSave();
|
_worldMapSave = new WorldMapSave();
|
||||||
|
_worldMapSave.WorldInitialition();
|
||||||
UnlockLevels();
|
UnlockLevels();
|
||||||
|
|
||||||
PlayerPrefs.SetInt("LevelToLoad", -1);
|
PlayerPrefs.SetInt("LevelToLoad", -1);
|
||||||
@ -54,6 +56,13 @@ public class WorldMapManager : MonoBehaviour
|
|||||||
counterIndex++;
|
counterIndex++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void WorldReinitialition()
|
||||||
|
{
|
||||||
|
_worldMapSave.WorldReinitialition();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private void ShowLockedIcon(GameObject currentLevelButton)
|
private void ShowLockedIcon(GameObject currentLevelButton)
|
||||||
{
|
{
|
||||||
currentLevelButton.GetComponent<Image>().sprite = _lockedIcon;
|
currentLevelButton.GetComponent<Image>().sprite = _lockedIcon;
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using System.IO;
|
||||||
|
using System.Runtime.Serialization.Formatters.Binary;
|
||||||
|
|
||||||
public class WorldMapSave
|
public class WorldMapSave
|
||||||
{
|
{
|
||||||
@ -11,21 +13,78 @@ public class WorldMapSave
|
|||||||
SAVED
|
SAVED
|
||||||
}
|
}
|
||||||
|
|
||||||
private LevelState[] levelUnlocked = { LevelState.UNLOCKED, LevelState.UNLOCKED, LevelState.UNLOCKED, LevelState.UNLOCKED,
|
private LevelState[] levelUnlocked = { LevelState.SAVED, LevelState.LOCKED, LevelState.LOCKED, LevelState.LOCKED,
|
||||||
LevelState.UNLOCKED, LevelState.SAVED, LevelState.LOCKED, LevelState.LOCKED, LevelState.LOCKED, LevelState.LOCKED, LevelState.LOCKED };
|
LevelState.LOCKED, LevelState.LOCKED, LevelState.LOCKED, LevelState.LOCKED, LevelState.LOCKED, LevelState.LOCKED, LevelState.LOCKED };
|
||||||
|
|
||||||
public void UnlockNextLevel(int levelNumber)
|
private string filePath;
|
||||||
|
|
||||||
|
public void WorldInitialition()
|
||||||
{
|
{
|
||||||
if(levelNumber == 10)
|
|
||||||
|
filePath = Application.persistentDataPath + "/data.dat";
|
||||||
|
|
||||||
|
if (File.Exists(filePath))
|
||||||
{
|
{
|
||||||
//UnlockNextWorld();
|
ReadData();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
levelUnlocked[levelNumber + 1] = LevelState.UNLOCKED;
|
WriteData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void WriteData()
|
||||||
|
{
|
||||||
|
BinaryFormatter formatter = new BinaryFormatter();
|
||||||
|
FileStream fileStream = File.Create(filePath);
|
||||||
|
formatter.Serialize(fileStream, levelUnlocked);
|
||||||
|
fileStream.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ReadData()
|
||||||
|
{
|
||||||
|
BinaryFormatter formatter = new BinaryFormatter();
|
||||||
|
FileStream fileStream = File.Open(filePath, FileMode.Open);
|
||||||
|
levelUnlocked = (LevelState[])formatter.Deserialize(fileStream);
|
||||||
|
fileStream.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private int GetSavedLevelIndex()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < levelUnlocked.Length; i++)
|
||||||
|
{
|
||||||
|
if (levelUnlocked[i] == LevelState.SAVED)
|
||||||
|
{
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If LevelState.SAVED not find
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UnlockNextLevel()
|
||||||
|
{
|
||||||
|
filePath = Application.persistentDataPath + "/data.dat";
|
||||||
|
ReadData();
|
||||||
|
//int actuelLevel = PlayerPrefs.GetInt(LevelToLoad,NoLevel);
|
||||||
|
//Debug.Log(actuelLevel);
|
||||||
|
levelUnlocked[GetSavedLevelIndex() + 1] = LevelState.SAVED;
|
||||||
|
levelUnlocked[GetSavedLevelIndex()] = LevelState.UNLOCKED;
|
||||||
|
WriteData();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void WorldReinitialition()
|
||||||
|
{
|
||||||
|
if (File.Exists(filePath))
|
||||||
|
{
|
||||||
|
File.Delete(filePath);
|
||||||
|
levelUnlocked = new LevelState[] { LevelState.SAVED, LevelState.LOCKED, LevelState.LOCKED, LevelState.LOCKED, LevelState.LOCKED, LevelState.LOCKED, LevelState.LOCKED, LevelState.LOCKED, LevelState.LOCKED, LevelState.LOCKED, LevelState.LOCKED };
|
||||||
|
}
|
||||||
|
WorldInitialition();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public LevelState GetLevelState(int index)
|
public LevelState GetLevelState(int index)
|
||||||
{
|
{
|
||||||
return levelUnlocked[index];
|
return levelUnlocked[index];
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user