e
This commit is contained in:
@@ -1,60 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
public class SceneMonsterManager : MonoBehaviour
|
||||
{
|
||||
[SerializeField, Header("怪物列表")] private List<GameObject> monsters = new List<GameObject>();
|
||||
|
||||
[SerializeField, Header("怪物生成速率")] private float timer;
|
||||
|
||||
public Transform teleporte;
|
||||
public bool isTeleport = false;
|
||||
|
||||
public GameObject box;
|
||||
|
||||
private int count = 0;
|
||||
|
||||
private float t = 0;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
foreach (var item in monsters)
|
||||
{
|
||||
item.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
t += Time.deltaTime;
|
||||
if (t >= timer)
|
||||
{
|
||||
Debug.Log(isTeleport);
|
||||
ABC();
|
||||
ProtectedMonster();
|
||||
}
|
||||
}
|
||||
void ProtectedMonster()
|
||||
{
|
||||
if (count >= monsters.Count)
|
||||
{
|
||||
return;
|
||||
}
|
||||
monsters[count].SetActive(true);
|
||||
count += 1;
|
||||
t = 0;
|
||||
}
|
||||
void ABC()
|
||||
{
|
||||
if(transform.childCount==0&&!isTeleport)
|
||||
{
|
||||
//UIManager.Instance.Show<UILottery>();
|
||||
Instantiate(box);
|
||||
isTeleport = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3c6d37fb46cffe1408e982d6d1b9a190
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,49 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
namespace Manager
|
||||
{
|
||||
class SenceManager:MonoSingleton<SenceManager>
|
||||
{
|
||||
UnityAction<float> onProgress = null;
|
||||
|
||||
public void LoadScene(int name)
|
||||
{
|
||||
StartCoroutine(LoadLevel(name));
|
||||
|
||||
}
|
||||
|
||||
IEnumerator LoadLevel( int id)
|
||||
{
|
||||
Debug.LogFormat("LoadLevel: {0}", name);
|
||||
AsyncOperation async = UnityEngine.SceneManagement.SceneManager.LoadSceneAsync(id);
|
||||
|
||||
async.allowSceneActivation = true;
|
||||
async.completed += LevelLoadCompleted;
|
||||
|
||||
//保存数据
|
||||
PlayerInfo.Instance.info.currentMap=id;
|
||||
SaveSystem.SaveDate(PlayerInfo.Instance.info.DatePath, PlayerInfo.Instance.info);
|
||||
|
||||
while (!async.isDone)
|
||||
{
|
||||
if (onProgress != null)
|
||||
onProgress(async.progress);
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void LevelLoadCompleted(AsyncOperation obj)
|
||||
{
|
||||
if (onProgress != null)
|
||||
onProgress(1f);
|
||||
Debug.Log("LevelLoadCompleted:" + obj.progress);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 36641df8733b77f4fb770f6bcfcc598f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,119 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Audio;
|
||||
|
||||
namespace Manager
|
||||
{
|
||||
public class SoundManager : MonoSingleton<SoundManager>
|
||||
{
|
||||
public AudioMixer audioMixer;//»ìÒôÆ÷
|
||||
public AudioSource MusicSource;
|
||||
public AudioSource SoundSource;
|
||||
|
||||
const string MusicPath = "Music/";
|
||||
const string SoundPath = "Sound/";
|
||||
|
||||
private bool musicOn;
|
||||
public bool MusicOn
|
||||
{
|
||||
get { return musicOn; }
|
||||
set
|
||||
{
|
||||
musicOn = value;
|
||||
this.MusicMute(!musicOn);
|
||||
}
|
||||
}
|
||||
private bool soundOn;
|
||||
public bool SoundOn
|
||||
{
|
||||
get { return soundOn; }
|
||||
set
|
||||
{
|
||||
soundOn = value;
|
||||
this.SoundMute(!soundOn);
|
||||
}
|
||||
}
|
||||
|
||||
private int musicVolume;
|
||||
public int MusicVolume
|
||||
{
|
||||
get { return musicVolume; }
|
||||
set
|
||||
{
|
||||
musicVolume = value;
|
||||
if (musicOn) this.SetVolume("MusicVolume", musicVolume);
|
||||
}
|
||||
}
|
||||
private int soundVolume;
|
||||
public int SoundVolume
|
||||
{
|
||||
get { return soundVolume; }
|
||||
set
|
||||
{
|
||||
soundVolume = value;
|
||||
if (soundOn) this.SetVolume("SoundVolume", soundVolume);
|
||||
}
|
||||
}
|
||||
|
||||
public void SoundMute(bool mute)
|
||||
{
|
||||
this.SetVolume("SoundVolume", mute ? 0 : soundVolume);
|
||||
}
|
||||
public void MusicMute(bool mute)
|
||||
{
|
||||
this.SetVolume("MusicVolume", mute ? 0 : musicVolume);
|
||||
}
|
||||
|
||||
void SetVolume(string name, int value)
|
||||
{
|
||||
float volume = value * 0.5f - 50f;
|
||||
this.audioMixer.SetFloat(name, volume);
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
this.MusicVolume = SystemConfig.MusicVolume;
|
||||
this.SoundVolume = SystemConfig.SoundVolume;
|
||||
this.MusicOn = SystemConfig.MusicOn;
|
||||
this.soundOn = SystemConfig.SoundOn;
|
||||
}
|
||||
|
||||
public void PlayMusic(string name)
|
||||
{
|
||||
AudioClip clip = Resloader.Load<AudioClip>(MusicPath + name);
|
||||
if (clip == null)
|
||||
{
|
||||
Debug.LogWarningFormat("PlayMusic:{0} not existed", name);
|
||||
return;
|
||||
}
|
||||
if (MusicSource.isPlaying)
|
||||
{
|
||||
MusicSource.Stop();
|
||||
}
|
||||
MusicSource.clip = clip;
|
||||
MusicSource.Play();
|
||||
}
|
||||
public void PlaySound(string name)
|
||||
{
|
||||
AudioClip clip = Resloader.Load<AudioClip>(SoundPath + name);
|
||||
if (clip == null)
|
||||
{
|
||||
Debug.LogWarningFormat("PlaySound:{0} not existed", name);
|
||||
return;
|
||||
}
|
||||
SoundSource.PlayOneShot(clip);
|
||||
}
|
||||
|
||||
public void PlayEffect(AudioSource audio,AudioClip clip)
|
||||
{
|
||||
if (clip == null)
|
||||
{
|
||||
Debug.LogWarningFormat("PlaySound:{0} not existed", name);
|
||||
return;
|
||||
}
|
||||
audio.PlayOneShot(clip);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1e3d9918daf58924b994f65a2ebd4d19
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1c686aebb47a67b45a336c23bb0a616c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,71 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
public static class SaveSystem
|
||||
{
|
||||
public static bool IsHaveFile(string FilePath)
|
||||
{
|
||||
if (File.Exists(FilePath))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
public static void CreateFile(string FilePath, bool IfHaveFileIsCreate = false)
|
||||
{
|
||||
if (!File.Exists(FilePath))
|
||||
{
|
||||
File.CreateText(FilePath);
|
||||
}
|
||||
}
|
||||
|
||||
public static void SaveDate(string fileName, object date)
|
||||
{
|
||||
var json = JsonUtility.ToJson(date);
|
||||
|
||||
string path = Path.Combine(Application.persistentDataPath, fileName);
|
||||
|
||||
if (!IsHaveFile(path))
|
||||
{
|
||||
//Debug.Log("文件不存在");
|
||||
CreateFile(path);
|
||||
}
|
||||
try
|
||||
{
|
||||
File.WriteAllText(path, json);
|
||||
Debug.Log("存档成功");
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Debug.Log("存档创建失败");
|
||||
SaveDate(fileName,date);
|
||||
}
|
||||
}
|
||||
public static T LoadDate<T>(string fileName)
|
||||
{
|
||||
|
||||
var path = Path.Combine(Application.persistentDataPath, fileName);
|
||||
|
||||
if (IsHaveFile(path))
|
||||
{
|
||||
var json = File.ReadAllText(path);
|
||||
|
||||
T date = JsonUtility.FromJson<T>(json);
|
||||
Debug.Log("读档成功}");
|
||||
return date;
|
||||
}
|
||||
return default;
|
||||
}
|
||||
public static void DeleteDate(string fileName)
|
||||
{
|
||||
var path = Path.Combine(Application.persistentDataPath, fileName);
|
||||
if (!IsHaveFile(path))
|
||||
{
|
||||
return;//不存在
|
||||
}
|
||||
File.Delete(path);
|
||||
Debug.Log("删除成功");
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c2a8ed3c5fdface4383fffaf797a0b23
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,17 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class SoundDefine
|
||||
{
|
||||
#region music
|
||||
public const string LoadingMusic= "select";
|
||||
public const string Map_1Music = "map_01";
|
||||
public const string Map_2Music = "map_02";
|
||||
public const string Map_3Music = "map_03";
|
||||
#endregion
|
||||
|
||||
#region fix
|
||||
public const string BoxOpen = "BoxOpen";
|
||||
#endregion
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9836183019983914fb04067f5ceb6760
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,17 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Singleton<T> where T : new()
|
||||
{
|
||||
static T instance;
|
||||
public static T Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (instance == null)
|
||||
return instance = new T();
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 07784bad47cfbe64faab332768e5f00a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,47 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class SaveItem : MonoBehaviour, IPointerClickHandler
|
||||
{
|
||||
public Text _PlayerName;
|
||||
public Text _PlayerLevel;
|
||||
|
||||
public string DateFileName;
|
||||
|
||||
public Text DateName;
|
||||
|
||||
private CharInfo info;
|
||||
|
||||
public UISaveDate root;
|
||||
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
|
||||
root.Select(info, DateName.text, DateFileName);
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
public void Init()
|
||||
{
|
||||
//初始化存档数据
|
||||
var date = SaveSystem.LoadDate<CharInfo>(DateFileName);
|
||||
if (date != null)
|
||||
{
|
||||
//数据加载
|
||||
info = date;
|
||||
_PlayerName.text = info.playerName;
|
||||
_PlayerLevel.text = "LV " + info.Level.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
_PlayerName.text = "空白存档";
|
||||
_PlayerLevel.text = "LV 1";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 897a5a659802d994da33b1d1acd76890
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user