Exemple #1
0
	/// <summary>
	/// Ensure we have an instance present.
	/// </summary>

	static public void CreateInstance ()
	{
		if (mInstance == null) {
			GameObject go = new GameObject ("_NGUI Debug");
			mInstance = go.AddComponent<NGUIDebug> ();
			DontDestroyOnLoad (go);
		}
	}
 public static void CreateInstance()
 {
     if (mInstance == null)
     {
         GameObject target = new GameObject("_NGUI Debug");
         mInstance = target.AddComponent<NGUIDebug>();
         UnityEngine.Object.DontDestroyOnLoad(target);
     }
 }
Exemple #3
0
 public static void CreateInstance()
 {
     if (NGUIDebug.mInstance == null)
     {
         GameObject gameObject = new GameObject("_NGUI Debug");
         NGUIDebug.mInstance = gameObject.AddComponent<NGUIDebug>();
         UnityEngine.Object.DontDestroyOnLoad(gameObject);
     }
 }
Exemple #4
0
    public static void Log(string text)
    {
        //Debug.Log(text);

        if (mLines.Count > 20) mLines.RemoveAt(0);
        mLines.Add(text);

        if (mInstance == null)
        {
            GameObject go = new GameObject("_NGUI Debug");
            mInstance = go.AddComponent<NGUIDebug>();
            DontDestroyOnLoad(go);
        }
    }
Exemple #5
0
	/// <summary>
	/// Ensure we have an instance present.
	/// </summary>

	static public void CreateInstance ()
	{
		#if UNITY_IPHONE && !UNITY_EDITOR
			if(!m_getDebug)
			{
				return;
			}
		#endif
		if (mInstance == null)
		{
			GameObject go = new GameObject("_NGUI Debug");
			mInstance = go.AddComponent<NGUIDebug>();
			DontDestroyOnLoad(go);
		}
	}
Exemple #6
0
	static public void Log (string text)
	{
		if (Application.isPlaying)
		{
			//Mogo.Util.LoggerHelper.Debug(text);

			if (mLines.Count > 20) mLines.RemoveAt(0);
			mLines.Add(text);

			if (mInstance == null)
			{
				GameObject go = new GameObject("_NGUI Debug");
				mInstance = go.AddComponent<NGUIDebug>();
				DontDestroyOnLoad(go);
			}
		}
		else
		{
			Mogo.Util.LoggerHelper.Debug(text);
		}
	}
Exemple #7
0
 public static void Log(string text)
 {
     if (!Application.isPlaying)
     {
         Debug.Log(text);
     }
     else
     {
         if (NGUIDebug.mLines.Count > 20)
         {
             NGUIDebug.mLines.RemoveAt(0);
         }
         NGUIDebug.mLines.Add(text);
         if (NGUIDebug.mInstance == null)
         {
             GameObject gameObject = new GameObject("_NGUI Debug");
             NGUIDebug.mInstance = gameObject.AddComponent<NGUIDebug>();
             UnityEngine.Object.DontDestroyOnLoad(gameObject);
         }
     }
 }
Exemple #8
0
    /// <summary>
    /// Save the specified binary data into the specified file.
    /// </summary>

    static public bool Save(string fileName, byte[] bytes)
    {
#if UNITY_WEBPLAYER || UNITY_FLASH || UNITY_METRO || UNITY_WP8
        return(false);
#else
        if (!NGUITools.fileAccess)
        {
            return(false);
        }

        string path = Application.persistentDataPath + "/" + fileName;

        if (bytes == null)
        {
            if (File.Exists(path))
            {
                File.Delete(path);
            }
            return(true);
        }

        FileStream file = null;

        try
        {
            file = File.Create(path);
        }
        catch (System.Exception ex)
        {
            NGUIDebug.Log(ex.Message);
            return(false);
        }

        file.Write(bytes, 0, bytes.Length);
        file.Close();
        return(true);
#endif
    }
Exemple #9
0
    static public void Log(string text)
    {
        if (Application.isPlaying)
        {
            //Debug.Log(text);

            if (mLines.Count > 20)
            {
                mLines.RemoveAt(0);
            }
            mLines.Add(text);

            if (mInstance == null)
            {
                GameObject go = new GameObject("_NGUI Debug");
                mInstance = go.AddComponent <NGUIDebug>();
                DontDestroyOnLoad(go);
            }
        }
        else
        {
            Debug.Log(text);
        }
    }
    static public string Read()
    {
        TextAsset ta = (TextAsset)Resources.Load(VersionFilePath);

        if (ta == null)
        {
            NGUIDebug.Log("加载记录版本文件失败: " + VersionFilePath);
            return("");
        }
        ByteReader reader = new ByteReader(ta);

        try
        {
            CurRecordVersion = reader.ReadLine();

            Debug.Log("读取:" + CurRecordVersion);
        }
        catch (Exception ex)
        {
            throw ex;
        }

        return(CurRecordVersion);
    }
Exemple #11
0
    public static void Log(params object[] objs)
    {
        if (NGUIDebug.miOpenLog <= 0 || NGUIDebug.miOpenLog > 3)
        {
            return;
        }
        string text = string.Empty;

        for (int i = 0; i < objs.Length; i++)
        {
            if (objs[i] != null)
            {
                if (i == 0)
                {
                    text += objs[i].ToString();
                }
                else
                {
                    text = text + ", " + objs[i].ToString();
                }
            }
        }
        NGUIDebug.LogString(text);
    }
Exemple #12
0
 static int Clear(IntPtr L)
 {
     LuaScriptMgr.CheckArgsCount(L, 0);
     NGUIDebug.Clear();
     return(0);
 }
Exemple #13
0
 static int CreateInstance(IntPtr L)
 {
     LuaScriptMgr.CheckArgsCount(L, 0);
     NGUIDebug.CreateInstance();
     return(0);
 }
Exemple #14
0
 public unsafe static long $Invoke2(long instance, long *args)
 {
     NGUIDebug.DrawBounds(*(*(IntPtr *)args));
     return(-1L);
 }
Exemple #15
0
 public unsafe static long $Invoke4(long instance, long *args)
 {
     NGUIDebug.Log((object[])GCHandledObjects.GCHandleToPinnedArrayObject(*args));
     return(-1L);
 }
Exemple #16
0
    // lê todos os números maiores que id
    //vou usar essa. o id vou salvar antes.
    //se calcularExcitacao for true, calcula a excitacao. Se for false, apenas le os dados (usado para descartar os dados do questionario)
    IEnumerator GetReadBigger(bool calcularExcitacao)
    {
        Debug.Log("Entrou no GetReadBigger com id==" + ultimo_id_lido);
        using (UnityWebRequest www = UnityWebRequest.Get("http://localhost/android_connect/read_bigger.php" + "?id=" + ultimo_id_lido)) {
            www.SetRequestHeader("Content-Type", "application/json");
            yield return(www.SendWebRequest());

            if ((www.isNetworkError || www.isHttpError))
            {
                NGUIDebug.Log("Erro de conecção");
                Debug.Log("Erro de conecção");
                Debug.Log(www.error);
            }
            else
            {
                string jsonString = www.downloadHandler.text;
                System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); //para converter os Doubles considerando '.' e nao ','
                sinais = JsonUtility.FromJson <EDASignals>(jsonString);
                if (sinais.eda.Count > 0)
                {
                    ultimo_id_lido = sinais.eda[sinais.eda.Count - 1].id;
                }
                else
                {
                    ultimo_id_lido = 0; //caso dê clear no banco de dados no meio da partida
                }

                NGUIDebug.Clear();
                if (calcularExcitacao)
                {
                    NGUIDebug.Log(sinais.eda.Count + "lid");
                    Debug.Log(sinais.eda.Count + " sinais lidos");
                }
                else
                {
                    NGUIDebug.Log(sinais.eda.Count + "desc");
                    Debug.Log(sinais.eda.Count + " sinais descartados");
                }
                if (calcularExcitacao)
                {
                    picos.Clear();
                    CalculaPicos(); //pontos máximos e minimos relativos
                    NGUIDebug.Log(picos.Count + "pic");
                    Debug.Log(picos.Count + " picos achados");
                    if (picos.Count > 1)
                    {
                        CaclulaExcitacao();
                    }
                    else if (sinais.eda.Count > 0)
                    {
                        Debug.Log("Warning: Excitação: NORMAL (picos.Count <= 0");
                        DDAAply.instance.excitacao = State.PlayerState.NORMAL; //normal pq temos poucos sinais, entao pouca variacao
                    }
                    else
                    {
                        Debug.Log("Warning: Excitação: NULL (sinais.eda.Count <= 0");
                        DDAAply.instance.excitacao = State.PlayerState.NULL; //null pq nao temos nenhum sinal
                    }
                    DDAAply.instance.AjustaExcitacaoPassLevel();
                }
            }
        }
        calculandoExcitacao = false;
    }
Exemple #17
0
 public unsafe static long $Invoke0(long instance, long *args)
 {
     NGUIDebug.Clear();
     return(-1L);
 }
Exemple #18
0
    private void SetTextDesExtZon()
    {
        DDAAply inst = DDAAply.instance;
        string  desempenho, excitacao, zona;


        if (inst.desempenho == State.PlayerState.HIGH)
        {
            desempenho = "h";
        }
        else if (inst.desempenho == State.PlayerState.NORMAL)
        {
            desempenho = "n";
        }
        else if (inst.desempenho == State.PlayerState.LOW)
        {
            desempenho = "l";
        }
        else
        {
            desempenho = "-";
        }

        if (inst.excitacao == State.PlayerState.HIGH)
        {
            excitacao = "h";
        }
        else if (inst.excitacao == State.PlayerState.NORMAL)
        {
            excitacao = "n";
        }
        else if (inst.excitacao == State.PlayerState.LOW)
        {
            excitacao = "l";
        }
        else
        {
            excitacao = "-";
        }

        if (inst.zona == State.PlayerState.HIGH)
        {
            zona = "h";
        }
        else if (inst.zona == State.PlayerState.NORMAL)
        {
            zona = "n";
        }
        else if (inst.zona == State.PlayerState.LOW)
        {
            zona = "l";
        }
        else
        {
            zona = "-";
        }

        if (inst.IsDesempenho)
        {
            if (DataCenter.instance.numberOfLevelDeaths == 1)
            {
                NGUIDebug.Clear(); //o afetivo ja faz o clear antes
                NGUIDebug.Log("d" + desempenho + "z" + zona);
            }
        }
        else if (inst.IsAfetivo)
        {
            if (DataCenter.instance.numberOfLevelDeaths == 1)
            {
                NGUIDebug.Log("e" + excitacao + "z" + zona);
            }
        }
        else if (inst.IsZona)
        {
            if (DataCenter.instance.numberOfLevelDeaths == 1)
            {
                NGUIDebug.Clear(); //o afetivo ja faz o clear antes
                NGUIDebug.Log("z" + zona);
            }
        }

        TextEnable.SetHiperspaceText("Pressione Espaço");
        flagAuxBugFixGambiarra = false;
    }
Exemple #19
0
 static NGUIDebug()
 {
     NGUIDebug.mLines = new List<string>();
     NGUIDebug.mInstance = null;
 }
Exemple #20
0
 public static void PrintScreen(string message)
 {
     #if NGUI
     NGUIDebug.Log(message);
     #endif
 }
Exemple #21
0
        public void Update()
        {
            switch (estadoBatalla)
            {
            case Freya.Esperando:
                if (proxTurno.Count > 0)
                {
                    estadoBatalla = Freya.TomarAccion;
                }
                break;

            case Freya.TomarAccion:
                GameObject proceso = GameObject.Find(proxTurno[0].enemigo);
                if (proxTurno[0].tipo == "Enemigo")
                {
                    EnemigoMEstados EME = proceso.GetComponent <EnemigoMEstados>();
                    for (int n = 0; n < aliados.Count; n++)
                    {
                        if (proxTurno[0].objetivoEnemigo == aliados[n])
                        {
                            EME.posicionAliado = proxTurno[0].objetivoEnemigo;
                            EME.estadoTurno    = EstadoTurno.Accion;
                            break;
                        }
                        else
                        {
                            proxTurno[0].objetivoEnemigo = aliados[Random.Range(0, aliados.Count)];
                            EME.posicionAliado           = proxTurno[0].objetivoEnemigo;
                            EME.estadoTurno = EstadoTurno.Accion;
                        }
                    }
                }

                if (proxTurno[0].tipo == "Aliado")
                {
                    AliadoMEstados AME = proceso.GetComponent <AliadoMEstados>();
                    AME.posicionEnemigo = proxTurno[0].objetivoEnemigo;
                    AME.estadoTurno     = EstadoTurno.Accion;
                }
                estadoBatalla = Freya.RealizarAccion;
                break;

            case Freya.RealizarAccion:
                break;

            case Freya.ComprobarVida:
                if (aliados.Count < 1)
                {
                    // Ganar Batalla
                    estadoBatalla = Freya.Derrota;
                }
                else if (enemigos.Count < 1)
                {
                    // Perder Batalla
                    estadoBatalla = Freya.Ganar;
                }
                else
                {
                    // Limpiar panel
                    ClearPanelAtaque();
                    aliadoGUI = AliadoGUI.Activado;
                }
                break;

            case Freya.Derrota:
                NGUIDebug.Log("Has perdido la batalla");
                for (int i = 0; i < enemigos.Count; i++)
                {
                    enemigos[0].GetComponent <EnemigoMEstados>().estadoTurno = EstadoTurno.Esperando;
                }
                break;

            case Freya.Ganar:
                NGUIDebug.Log("Has ganado la batalla");
                for (int i = 0; i < aliados.Count; i++)
                {
                    aliados[0].GetComponent <AliadoMEstados>().estadoTurno = EstadoTurno.Esperando;
                }
                break;
            }

            switch (aliadoGUI)
            {
            case AliadoGUI.Activado:
                if (ManagerAliado.Count > 0)
                {
                    ManagerAliado[0].transform.Find("Selector").gameObject.SetActive(true);
                    eleccionAliado = new clsControlTurno();

                    panelAcciones.SetActive(true);

                    CrearBtnAtaques();


                    aliadoGUI = AliadoGUI.Esperando;
                }

                break;

            case AliadoGUI.Esperando:
                Time.timeScale = 0.0f;
                break;

            case AliadoGUI.Finalizado:
                AliadoTurnoTerminado();
                break;
            }
        }
Exemple #22
0
 static NGUIDebug()
 {
     NGUIDebug.mLines    = new List <string>();
     NGUIDebug.mInstance = null;
 }
Exemple #23
0
 public unsafe static long $Invoke5(long instance, long *args)
 {
     NGUIDebug.LogString(Marshal.PtrToStringUni(*(IntPtr *)args));
     return(-1L);
 }
Exemple #24
0
	private void FF9FieldMapMain(Int32 MapNo)
	{
		EBin eBin = this.ee.eBin;
		Int32 varManually = eBin.getVarManually(6357);
		if ((this.FF9.attr & 256u) == 0u)
		{
			if (!MBG.IsNull)
			{
				Singleton<fldfmv>.Instance.ff9fieldFMVService();
			}
			if ((this.FF9.attr & 2u) == 0u)
			{
				Int32 varManually2 = eBin.getVarManually(6357);
				if (varManually2 != this.prevPrg)
				{
					this.prevPrg = varManually2;
					if (varManually2 != 1 || this.FF9.fldMapNo != 50)
					{
						if (this.FF9.fldMapNo != 150 || varManually2 != 5)
						{
							if (this.FF9.fldMapNo != 404)
							{
								if (this.FF9.fldMapNo == 404)
								{
								}
							}
						}
					}
				}
				Int32 num = this.ee.ServiceEvents();
				HonoluluFieldMain.eventEngineRunningCount++;
				this.updatePlayerObj();
				switch (num)
				{
				case 3:
					this.FF9Sys.attr |= 8u;
					this.FF9FieldMap.nextMode = 2;
					this.fieldmap.ff9fieldInternalBattleEncountStart();
					this.ee.BackupPosObjData();
					FF9StateSystem.Battle.isDebug = false;
					FF9StateSystem.Battle.mappingBattleIDWithMapList = false;
					NGUIDebug.Clear();
					break;
				case 4:
					if (this.FF9FieldMap.nextMapNo == 16000)
					{
						this.FF9FieldMap.nextMode = 4;
						this.FF9Sys.attr |= 2u;
					}
					else
					{
						this.FF9FieldMap.nextMode = 1;
						this.FF9Sys.attr |= 8u;
					}
					break;
				case 5:
					this.FF9FieldMap.nextMode = 3;
					this.FF9Sys.attr |= 2u;
					break;
				case 7:
					this.FF9FieldMap.nextMode = 9;
					this.FF9Sys.attr |= 2u;
					break;
				case 8:
					this.FF9FieldMap.nextMode = 7;
					this.FF9Sys.attr |= 2u;
					this.FF9.attr |= 2u;
					PersistenSingleton<EventEngine>.Instance.eTb.InitMessage();
					PersistenSingleton<UIManager>.Instance.SetMenuControlEnable(false);
					this.shutdownField();
					EventService.OpenGameOver();
					break;
				}
			}
			if ((this.FF9.attr & 4u) == 0u && this.fieldmap != (UnityEngine.Object)null)
			{
				this.fieldmap.ff9fieldCharService();
			}
			if ((this.FF9.attr & 8u) == 0u && FF9StateSystem.Common.FF9.fldMapNo != 70 && this.fieldmap.walkMesh != null)
			{
				this.fieldmap.walkMesh.BGI_simService();
			}
			if ((this.FF9Field.attr & 16u) == 0u)
			{
				vib.VIB_service();
			}
			if ((this.FF9Field.attr & 8u) == 0u)
			{
				this.fieldmap.rainRenderer.ServiceRain();
			}
			Boolean flag = !MBG.IsNull && MBG.Instance.isFMV55D;
			if ((this.FF9Field.attr & 2048u) == 0u || flag)
			{
				SceneDirector.ServiceFade();
			}
			if ((this.FF9Field.attr & 4u) == 0u)
			{
				this.fieldmap.ff9fieldInternalBattleEncountService();
			}
		}
		this.ff9fieldInternalLoopEnd();
		UInt32 num2 = this.FF9Sys.attr & 15u;
		if (num2 != 0u)
		{
			if (this.ff9fieldDiscCondition())
			{
				this.FF9FieldMap.nextMode = 1;
				this.FF9FieldMap.nextMapNo = (Int16)PersistenSingleton<EventEngine>.Instance.GetFldMapNoAfterChangeDisc();
			}
			this.shutdownField();
			switch (this.FF9FieldMap.nextMode)
			{
			case 1:
				SceneDirector.Replace("FieldMap", SceneTransition.FadeOutToBlack_FadeIn, false);
				break;
			case 2:
				if (FF9StateSystem.Common.FF9.fldMapNo == 1663)
				{
					Int32 varManually3 = PersistenSingleton<EventEngine>.Instance.eBin.getVarManually(EBin.SC_COUNTER_SVR);
					Int32 varManually4 = PersistenSingleton<EventEngine>.Instance.eBin.getVarManually(EBin.MAP_INDEX_SVR);
					if (varManually3 == 6950 && varManually4 == 40)
					{
						global::Debug.Log("Force close all dialog for <SQEX> #3105");
						PersistenSingleton<UIManager>.Instance.Dialogs.CloseAll();
					}
				}
				SFX_Rush.SetCenterPosition(0);
				SceneDirector.Replace("BattleMap", SceneTransition.SwirlInBlack, true);
				break;
			case 3:
				SceneDirector.Replace("WorldMap", SceneTransition.FadeOutToBlack_FadeIn, false);
				break;
			case 4:
				SceneDirector.Replace("Ending", SceneTransition.FadeOutToBlack_FadeIn, false);
				break;
			case 9:
				SceneDirector.Replace("QuadMist", SceneTransition.FadeOutToBlack_FadeIn, true);
				break;
			}
		}
	}
Exemple #25
0
 void Start()
 {
     NGUIDebug.Log("设置的显示级别为" + QualitySettings.GetQualityLevel());
     EngineInitialize.Init();
 }
Exemple #26
0
 public unsafe static long $Invoke1(long instance, long *args)
 {
     NGUIDebug.CreateInstance();
     return(-1L);
 }
Exemple #27
0
        private static void AddObjectMetadata(Type type)
        {
            if (object_metadata.ContainsKey(type))
            {
                return;
            }

            ObjectMetadata data = new ObjectMetadata();

            if (type.GetInterface("System.Collections.IDictionary") != null)
            {
                data.IsDictionary = true;
            }

            data.Properties = new Dictionary <string, PropertyMetadata> ();

            foreach (PropertyInfo p_info in type.GetProperties())
            {
                if (p_info.Name == "Item")
                {
                    ParameterInfo[] parameters = p_info.GetIndexParameters();

                    if (parameters.Length != 1)
                    {
                        continue;
                    }

                    if (parameters[0].ParameterType == typeof(string))
                    {
                        data.ElementType = p_info.PropertyType;
                    }

                    continue;
                }

                PropertyMetadata p_data = new PropertyMetadata();
                p_data.Info = p_info;
                p_data.Type = p_info.PropertyType;

                data.Properties.Add(p_info.Name, p_data);
            }

            foreach (FieldInfo f_info in type.GetFields())
            {
                PropertyMetadata p_data = new PropertyMetadata();
                p_data.Info    = f_info;
                p_data.IsField = true;
                p_data.Type    = f_info.FieldType;
#if UNITY_EDITOR
                if (data.Properties.ContainsKey(f_info.Name))
                {
                    NGUIDebug.Log(f_info.Name);
                }
                else
#endif
                data.Properties.Add(f_info.Name, p_data);
            }

            lock (object_metadata_lock) {
                try {
                    object_metadata.Add(type, data);
                } catch (ArgumentException) {
                    return;
                }
            }
        }
Exemple #28
0
 public virtual void Reposition()
 {
     NGUIDebug.Log(string.Format("{0}, {1}", PhoneRealWidthSize, PhoneRealHeightSize));
     GetXRate();
     SetViewRate();
 }
Exemple #29
0
        private static object ReadValue(Type inst_type, JsonReader reader)
        {
            reader.Read();

            if (reader.Token == JsonToken.ArrayEnd)
            {
                return(null);
            }

            if (reader.Token == JsonToken.Null)
            {
                if (!inst_type.IsClass)
                {
                    throw new JsonException(String.Format(
                                                "Can't assign null to an instance of type {0}",
                                                inst_type));
                }

                return(null);
            }

            //Debug.Log(reader.Token + " " + reader.Value);
            if (reader.Token == JsonToken.Single ||
                reader.Token == JsonToken.Double ||
                reader.Token == JsonToken.Int ||
                reader.Token == JsonToken.Long ||
                reader.Token == JsonToken.String ||
                reader.Token == JsonToken.Boolean)
            {
                Type json_type = reader.Value.GetType();

                if (inst_type.IsAssignableFrom(json_type))
                {
                    return(reader.Value);
                }

                // If there's a custom importer that fits, use it
                if (custom_importers_table.ContainsKey(json_type) &&
                    custom_importers_table[json_type].ContainsKey(
                        inst_type))
                {
                    ImporterFunc importer =
                        custom_importers_table[json_type][inst_type];

                    return(importer(reader.Value));
                }

                // Maybe there's a base importer that works
                if (base_importers_table.ContainsKey(json_type) &&
                    base_importers_table[json_type].ContainsKey(
                        inst_type))
                {
                    ImporterFunc importer =
                        base_importers_table[json_type][inst_type];

                    return(importer(reader.Value));
                }

                // Maybe it's an enum
                if (inst_type.IsEnum)
                {
                    if (json_type.Name == "String")
                    {
                        int re = 0;
                        int.TryParse(reader.Value as string, out re);
                        return(Enum.ToObject(inst_type, re));
                    }
                    else if (json_type.Name == "Boolean")
                    {
                        return(Enum.ToObject(inst_type, ((bool)(reader.Value))?1:0));
                    }

                    return(Enum.ToObject(inst_type, reader.Value));
                }

                // Try using an implicit conversion operator
                MethodInfo conv_op = GetConvOp(inst_type, json_type);

                if (conv_op != null)
                {
                    return(conv_op.Invoke(null,
                                          new object[] { reader.Value }));
                }

                //////////////////////////////////// ADD ////////////////////////////////////
                // ÀàÐÍת»»
                if (inst_type.Name == "String" && json_type.Name != "String")
                {
                    return(reader.Value.ToString());
                }
                else if (json_type.Name == "String")
                {
                    if (inst_type.Name == "Int32")
                    {
                        int re = 0;
                        int.TryParse(reader.Value as string, out re);
                        return(re);
                    }
                    else if (inst_type.Name == "Single")
                    {
                        float re = 0;
                        float.TryParse(reader.Value as string, out re);
                        return(re);
                    }
                    else if (inst_type.Name == "Double")
                    {
                        double re = 0;
                        double.TryParse(reader.Value as string, out re);
                        return(re);
                    }
                    else if (inst_type.Name == "Boolean")
                    {
                        if (reader.Value == "0")
                        {
                            return(false);
                        }
                        else
                        {
                            return(true);
                        }
                    }
                }
                else if (inst_type.Name == "Int32" && json_type.Name == "Double")
                {
                    return(Convert.ToInt32((double)(reader.Value)));
                }
                else if (inst_type.Name == "Double" && json_type.Name == "Int32")
                {
                    return((double)(reader.Value));
                }
                else if (inst_type.Name == "Single" && json_type.Name == "Double")
                {
                    return(Convert.ToSingle((double)(reader.Value)));
                }
                else if (inst_type.Name == "Single" && json_type.Name == "Int32")
                {
                    return(Convert.ToSingle((int)(reader.Value)));
                }
                else if (inst_type.Name == "Int32" && json_type.Name == "Single")
                {
                    return(Convert.ToInt32((float)(reader.Value)));
                }
                else if (inst_type.Name == "Double" && json_type.Name == "Single")
                {
                    return(Convert.ToDouble((float)(reader.Value)));
                }
                else if (inst_type.Name == "Boolean")
                {
                    return(Convert.ToBoolean(reader.Value));
                }


                NGUIDebug.Log((inst_type.Name == "Boolean") + "  " + (json_type.Name == "String"));
                ////////////////////////////////// ADD OVER /////////////////////////////////
                // No luck
                throw new JsonException(String.Format(
                                            "Can't assign value '{0}' (type {1}) to type {2}",
                                            reader.Value, json_type.Name, inst_type.Name));
            }

            object instance = null;

            if (reader.Token == JsonToken.ArrayStart)
            {
                AddArrayMetadata(inst_type);
                ArrayMetadata t_data = array_metadata[inst_type];

                if (!t_data.IsArray && !t_data.IsList)
                {
                    throw new JsonException(String.Format(
                                                "Type {0} can't act as an array",
                                                inst_type));
                }

                IList list;
                Type  elem_type;

                if (!t_data.IsArray)
                {
                    list      = (IList)Activator.CreateInstance(inst_type);
                    elem_type = t_data.ElementType;
                }
                else
                {
                    list      = new ArrayList();
                    elem_type = inst_type.GetElementType();
                }

                while (true)
                {
                    object item = ReadValue(elem_type, reader);
                    if (item == null && reader.Token == JsonToken.ArrayEnd)
                    {
                        break;
                    }

                    list.Add(item);
                }

                if (t_data.IsArray)
                {
                    int n = list.Count;
                    instance = Array.CreateInstance(elem_type, n);

                    for (int i = 0; i < n; i++)
                    {
                        ((Array)instance).SetValue(list[i], i);
                    }
                }
                else
                {
                    instance = list;
                }

                ////Debug.Log("JsonToken.ArrayStart " + instance.ToString());

                //foreach (var info in list)
                //{
                //    Debug.Log("info = " + info);
                //}
            }
            else if (reader.Token == JsonToken.ObjectStart)
            {
                AddObjectMetadata(inst_type);
                ObjectMetadata t_data = object_metadata[inst_type];

                instance = Activator.CreateInstance(inst_type);

                while (true)
                {
                    reader.Read();

                    if (reader.Token == JsonToken.ObjectEnd)
                    {
                        break;
                    }

                    string property = (string)reader.Value;

                    if (t_data.Properties.ContainsKey(property))
                    {
                        PropertyMetadata prop_data =
                            t_data.Properties[property];

                        if (prop_data.IsField)
                        {
                            ((FieldInfo)prop_data.Info).SetValue(
                                instance, ReadValue(prop_data.Type, reader));
                        }
                        else
                        {
                            PropertyInfo p_info =
                                (PropertyInfo)prop_data.Info;

                            if (p_info.CanWrite)
                            {
                                //object obj = ReadValue(prop_data.Type, reader);
                                //Debug.Log("yyy property = " + instance + " " + property + " " + p_info);
                                p_info.SetValue(
                                    instance,
                                    ReadValue(prop_data.Type, reader), //obj,//
                                    null);
                            }
                            else
                            {
                                ReadValue(prop_data.Type, reader);
                            }
                        }
                    }
                    else
                    {
                        if (!t_data.IsDictionary)
                        {
                            if (!reader.SkipNonMembers)
                            {
                                throw new JsonException(String.Format(
                                                            "The type {0} doesn't have the " +
                                                            "property '{1}'",
                                                            inst_type, property));
                            }
                            else
                            {
                                ReadSkip(reader);
                                continue;
                            }
                        }

                        ((IDictionary)instance).Add(
                            property, ReadValue(
                                t_data.ElementType, reader));
                    }
                }
            }

            return(instance);
        }
Exemple #30
0
    /// <summary>
    /// Opens the INI file at the given path and enumerates the values in the IniParser.
    /// </summary>
    /// <param name="iniPath">Full path to INI file.</param>
    public IniParser(string _loadPath)
    {
        String strLine     = null;
        String currentRoot = null;

        String[] keyPair = null;

        TextAsset ta = (TextAsset)Resources.Load(_loadPath);

        if (ta == null)
        {
            NGUIDebug.Log("加载Ini配置文件失败: " + _loadPath);
            return;
        }
        ByteReader reader = new ByteReader(ta);

        try
        {
            strLine = reader.ReadLine();

            while (strLine != null)
            {
                strLine = strLine.Trim().ToUpper();

                if (strLine != "")
                {
                    if (strLine.StartsWith("[") && strLine.EndsWith("]"))
                    {
                        currentRoot = strLine.Substring(1, strLine.Length - 2);
                    }
                    else
                    {
                        keyPair = strLine.Split(new char[] { '=' }, 2);

                        SectionPair sectionPair;
                        String      value = null;

                        if (currentRoot == null)
                        {
                            currentRoot = "ROOT";
                        }

                        sectionPair.Section = currentRoot;
                        sectionPair.Key     = keyPair[0];

                        if (keyPair.Length > 1)
                        {
                            value = keyPair[1];
                        }

                        keyPairs.Add(sectionPair, value);
                    }
                }
                strLine = reader.ReadLine();
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
Exemple #31
0
 void OnS2C_ResponseProofTime(BaseEvent evt)
 {
     clientmsg.S2CProofTime prooftime = (clientmsg.S2CProofTime)evt.Params["protomsg"];
     NGUIDebug.Log("prooftime id  " + prooftime.charid + "   prooftime timestamp     " + prooftime.time_stamp);
 }
Exemple #32
0
 public void OnDownload()
 {
     StartCoroutine(loadLevel());
     NGUIDebug.Log(" click  btn ");
 }
Exemple #33
0
    void LoadData()
    {
        if (_HeroType == E_HeroType.main)
        {
            _slot_no = 1;
        }
        ST_S_unit_invenRec saveUnit = new ST_S_unit_invenRec();

        saveUnit = DataManager.Instance._SqlSavedata_unit_inven.Get_All_From_slot_no(_slot_no);
        if (saveUnit.idx > 0)
        {
            GameObject prefab = GameWorld.Instance._UnitList.GetPrefab_Unit(saveUnit.unit_code);
            if (prefab)
            {
                GameObject childObj = (GameObject)Instantiate(prefab);
                if (_HeroType == E_HeroType.sub && _JointRoot != null)
                {
                    _JointRoot.parent         = null;
                    childObj.transform.parent = _JointRoot;
                }
                else
                {
                    childObj.transform.parent = this.transform;
                }

                childObj.transform.localPosition = new Vector3(0f, 0f, 0f);
                childObj.transform.localScale    = new Vector3(1f, 1f, 1f);
                _UnitRoot = childObj.transform;

                _UnitInfo      = _UnitRoot.GetComponentInChildren <UnitInfo>();
                _AniController = _UnitRoot.GetComponentInChildren <wt_AnimationController>();

                _UnitInfo._Table_idx = saveUnit.idx;
                _UnitInfo._unit_code = saveUnit.unit_code;
                _UnitInfo._ClassNo   = saveUnit.class_no;
                _UnitInfo._Level     = DataManager.Instance.GetUnitLevel(_UnitInfo._Table_idx.ToString(), _UnitInfo._ClassNo);
                _UnitInfo._TotalExp  = DataManager.Instance._SqlSavedata_unit_inven.Get_total_exp(_UnitInfo._Table_idx.ToString());

                _FireType = _UnitInfo._FireType;
            }
            else
            {
                NGUIDebug.Log("Error LoadData() -- GetPrefab_Unit");
            }
        }
        else
        {
            NGUIDebug.Log("Error LoadData() 1");
        }

        ST_B_UnitRec balanceUnit = new ST_B_UnitRec();

        balanceUnit = DataManager.Instance._SqlBalance_unit.Get_UnitRec(_UnitInfo._unit_code, _UnitInfo._Level, _UnitInfo._ClassNo);
        if (balanceUnit.class_no > 0)
        {
            _UnitInfo._HP_Default = _UnitInfo._HP = balanceUnit.hp;
            _UnitInfo._Attack     = balanceUnit.attack;
        }
        else
        {
            Debug.Log("Error LoadData() 2-->" + "," + _UnitInfo._unit_code + "," + _UnitInfo._Level + "," + _UnitInfo._ClassNo);
        }

        if (_HeroType == E_HeroType.sub)
        {
            /* 타입별로 포지션 정해지게끔 수정 함.
             *         Vector2 pos = DataManager.Instance.Get_pos_slot(_slot_no);
             *         this.transform.localPosition = pos;
             *         Collider2D col = GetComponentInChildren <Collider2D>();
             *         if(col)
             *         {
             *             Debug.Log("~~~~~~~ " + col.gameObject.name);
             *             col.enabled = true;
             *         }
             * */
        }
    }