using System.Collections; using System.Collections.Generic; using UnityEngine; //============================================= // Audio Manager //============================================= public class AudioManager: MonoBehaviour { public static AudioManager instance = null; // // , void Start () { // , if (instance == null) { // instance = this; // } else if(instance == this){ // Destroy(gameObject); // } // , // DontDestroyOnLoad(gameObject); // InitializeManager(); } // private void InitializeManager(){ /* TODO: */ } }
using System.Collections; using System.Collections.Generic; using UnityEngine; //============================================= // Audio Manager //============================================= public class AudioManager: MonoBehaviour { public static AudioManager instance = null; // public static bool music = true; // public static bool sounds = true; // // , void Start () { // , if (instance == null) { // instance = this; // } else if(instance == this){ // Destroy(gameObject); // } // , // DontDestroyOnLoad(gameObject); // InitializeManager(); } // private void InitializeManager(){ // PlayerPrefs music = System.Convert.ToBoolean (PlayerPrefs.GetString ("music", "true")); sounds = System.Convert.ToBoolean (PlayerPrefs.GetString ("sounds", "true")); } // public static void saveSettings(){ PlayerPrefs.SetString ("music", music.ToString ()); // PlayerPrefs.SetString ("sounds", sounds.ToString ()); // PlayerPrefs.Save(); // } }
using System.Collections; using System.Collections.Generic; using UnityEngine; //============================================= // Audio Muter Class //============================================= public class AudioMuter : MonoBehaviour { // public bool is_music = false; // ? // private AudioSource _as; // Audio Source private float base_volume = 1F; // // void Start () { _as = this.gameObject.GetComponent<AudioSource> (); // AS base_volume = _as.volume; // AS } // void Update () { // , if (is_music) { _as.volume = (AudioManager.music)?base_volume:0F; } else { _as.volume = (AudioManager.sounds)?base_volume:0F; } } }
using System.Collections; using System.Collections.Generic; using UnityEngine; //============================================= // Game Classes Loader //============================================= public class GameLoader : MonoBehaviour { // public GameObject game_manager; // Game Base Manager public GameObject audio_manager; // Audio Manager public GameObject lang_manager; // Language Manager public GameObject net_manager; // Network Manager // ( ) void Awake () { // if (GameBase.instance == null) { Instantiate (game_manager); } // if (AudioManager.instance == null) { Instantiate (audio_manager); } // if (LangManager.instance == null) { Instantiate (lang_manager); } // if (NetworkManager.instance == null) { Instantiate (net_manager); } } }
using System.Collections; using System.Collections.Generic; using UnityEngine; [System.Serializable] public class responceModel{ public bool complete = false; // public string message = ""; // ( complete = false) }
{ complete: true, // data: {} // }
{ complete: false, // message: "" // }
responceModel responce = JsonUtility.FromJson<responceModel>(request.text); // JSON if(responce.complete){ /* TODO: - */ Debug.Log(responce.data); }else{ /* TODO: */ Debug.Log(responce.message); }
using System.Collections; using System.Collections.Generic; using UnityEngine; //============================================= // PLAYER CONTROLLER //============================================= public class PlayerController : MonoBehaviour { // [Header ("Player Body Parts")] public GameObject[] hairs; public GameObject[] faces; public GameObject[] special; // void Start () { } // void Update () { } // public void updateParts (){ // for (int i = 0; i < hairs.Length; i++) { if (i == NetworkManager.instance.auth.player_data.profile_data.body.hairs) { hairs [i].SetActive (true); } else { hairs [i].SetActive (false); } } /* TODO: */ } }
if (i == NetworkManager.instance.auth.player_data.profile_data.body.hairs){
public bool _hair = NetworkManager.instance.auth.player_data.profile_data.body.hairs;
public bool _sounds = AudioManager.sounds;
// - public delegate void OnComplete(); public delegate void OnError(string message); // , public void checkNumber(int number, OnComplete success, OnError fail){ if(number<10){ success(); // OnComplete }else{ fail(" 10!"); // } }
public void testMethod(){ int _number = Random.Range(0,50); // // checkNumber(_number, (()=>{ // Success /* TODO: - */ Debug.Log(" !"); }), ((string text)=>{ // Fail Debug.Log(text); // , Callback testMethod(); // , <10 })); }
using System.Collections; using System.Collections.Generic; using UnityEngine; //============================================= // Network Manager //============================================= public class NetworkManager : MonoBehaviour { // public static NetworkManager instance = null; // public static string server = "https://mysite.com/api"; // URL // public APIAuth auth; // public APIUtils utils; // // void Awake () { // if (instance == null) { instance = this; } else if(instance == this){ Destroy(gameObject); } // , DontDestroyOnLoad(gameObject); // InitializeManager(); } // public void InitializeManager(){ auth = new APIAuth (server + "/auth/"); // utils = new APIUtils (server + "/utils/"); // } } //============================================= // API Auth Manager //============================================= public class APIAuth{ // private string controllerURL = ""; // Controller URL //============================================= // //============================================= public APIAuth(string controller){ controllerURL = controller; } //============================================= // //============================================= public delegate void OnLoginComplete(); public delegate void OnLoginError(string message); public IEnumerator SingIn(string login, string password, OnLoginComplete complete, OnLoginError error){ // WWWForm data = new WWWForm(); data.AddField("login", login); data.AddField("password", password); data.AddField("lang", LangManager.language); // WWW request = new WWW(controllerURL + "/login/", data); yield return request; // if (request.error != null) { // error (" "); } else { // try{ responceModel responce = JsonUtility.FromJson<responceModel>(request.text); if(responce.complete){ complete(); // Success Callback }else{ error (responce.message); // Do error Debug.Log("API Error: " + responce.message); } }catch{ error (" "); Debug.Log(" . : " + request.text); } } } /* TODO: */ } //============================================= // //============================================= public class APIUtils{ private string controllerURL = ""; // public APIUtils(string controller){ controllerURL = controller; } //============================================= // //============================================= public delegate void OnClientVersionChecked(); public delegate void OnClientVersionError(string message); public IEnumerator CheckClientVersion(string version, OnClientVersionChecked complete, OnClientVersionError error){ // WWWForm data = new WWWForm(); data.AddField("version", version); data.AddField("lang", LangManager.language); // WWW request = new WWW(controllerURL + "/checkVersion/", data); yield return request; // if (request.error != null) { error (" "); } else { try{ responceModel responce = JsonUtility.FromJson<responceModel>(request.text); if(responce.complete){ complete(); }else{ error (responce.message); Debug.Log("API Error: " + responce.message); } }catch{ error (" "); Debug.Log(" . : " + request.text); } } } }
// public void checkMyGame(){ StartCoroutine(NetworkManager.instance.utils.CheckClientVersion(Application.version, (()=>{ // /* TODO: */ }), ((string msg) => { // /* TODO: */ Debug.Log(msg); }))); }
Source: https://habr.com/ru/post/341830/
All Articles