예제 #1
0
    public static bool Save(string fileName, byte[] bytes)
    {
        if (!NGUITools.fileAccess)
        {
            return(false);
        }
        string path = Application.persistentDataPath + "/" + fileName;

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

        try
        {
            fileStream = File.Create(path);
        }
        catch (Exception ex)
        {
            NGUIDebug.Log(new object[]
            {
                ex.ToString()
            });
            return(false);
        }
        fileStream.Write(bytes, 0, bytes.Length);
        fileStream.Close();
        return(true);
    }
예제 #2
0
        /// <summary>
        /// 解密
        /// </summary>
        /// <returns>解密得到的明文</returns>
        /// <exception cref="Exception">如果路径指向的文件不存在</exception>
        public static string Decrypt()
        {
            if (!isInit)
            {
                InitRijndaelManaged();                     //保证初始化
            }
            string OutPlainText = null;

            if (!File.Exists(FilePath))
            {
                throw new Exception(FilePath);
            }
            //读取密文
            byte[] getFromFile = File.ReadAllBytes(FilePath);
            NGUIDebug.Log(getFromFile.Length);

            ICryptoTransform decryptor = rijndaelManaged.CreateDecryptor();

            using (MemoryStream msDecrypt = new MemoryStream(getFromFile))
            {
                using (CryptoStream csDecrypt = new CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read))
                {
                    using (StreamReader srDecrypt = new StreamReader(csDecrypt))
                    {
                        OutPlainText = srDecrypt.ReadToEnd();
                    }
                }
            }
            return(OutPlainText);
        }
예제 #3
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
		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
	}
예제 #4
0
    ///////////////////////////////////////////////////////////////////////////////

    public void UpDateOn()
    {
        NGUIDebug.Log(string.Format("{0}, {1}", PhoneRealWidthSize, PhoneRealHeightSize));

        GetXRate();
        SetViewRate();
    }
예제 #5
0
    // Use this for initialization
    void Start()
    {
        InitLuaPath();

        mLuaState.Start();


        mLuaState.DoFile("Main.lua");

        if (DebugMode())
        {
            NGUIDebug.debugRaycast = true;

            NGUIDebug.Log(LuaConst.luaDir);
            NGUIDebug.Log(LuaConst.toluaDir);
        }

        LuaHelper.CallFunction("Main", "Start");

        //string[] array = new string[2];
        //array[0] = "first";
        //array[1] = "second";

        //LuaHelper.CallFunction("Main", "Test1",array);
    }
예제 #6
0
 //编辑器模式下使用MonoBehaviour 默认。
 //带flag则使用NGUI DEBUG 打印输出到屏幕.
 public static void     print(object message, bool flag)
 {
     if (Debug.isDebugBuild == true)
     {
         NGUIDebug.Log(message.ToString());
     }
 }
예제 #7
0
 public static void Log(string text)
 {
     if (NGUIDebug.debugRaycast)
     {
         NGUIDebug.Log(text);
     }
 }
예제 #8
0
    static public void ReadJson()
    {
        string filedirName = "Assets/StreamingAssets/file/";
        string filename    = "";

        UnityEngine.Object[] objects = Selection.objects;
        for (int iter = 0; iter < objects.Length; ++iter)
        {
            filename = objects[iter].name;
            string    path      = filedirName + filename + ".txt";
            TextAsset textAsset = AssetDatabase.LoadAssetAtPath(path, typeof(TextAsset)) as TextAsset;
            Debug.Log("change..... " + textAsset.text);
            JsonData[] data = JsonMapper.ToObject <JsonData[]>(textAsset.text);
            int        i    = 0;

            GameObject parentobj = new GameObject("PosObj");
            parentobj.name = "PosObj";
            foreach (JsonData jd in data)
            {
                Vector3    vec = Util.StrToVector3(jd["pos_" + i.ToString()].ToString(), ',');
                GameObject obj = new GameObject("pos_" + i.ToString(), typeof(GameObject));
                obj.transform.parent   = parentobj.transform;
                obj.transform.position = vec;
                obj.name = "pos_" + i.ToString();
                NGUIDebug.Log("vec   " + vec.ToString());
                i++;
            }
        }
    }
예제 #9
0
    public async void Init()
    {
        client = new EasyClient();
        client.Initialize(new MyTerminatorReceiveFilter(), (request) => {
            // handle the received request
            //syncManager.Add(() =>
            //{
            //    callBack(request.Key, request.Body, request.Parameters);
            //});
            Debug.Log(request.Body);
            //NGUIDebug.Log(request.Body);
        });

        client.Error += (s, e) =>
        {
            NGUIDebug.Log(e.Exception.Message);
        };

        client.Closed += (s, e) => {
        };


        //   client.NewPackageReceived += Client_NewPackageReceived;

        // string IP = Config.parse("ServerIP");
        var connected = await client.ConnectAsync(new IPEndPoint(IPAddress.Parse("192.168.100.68"), 9000));

        if (connected)
        {
            //  NGUIDebug.Log("connet success");
            Debug.Log("connet success");
            // Send data to the server
            client.Send(Encoding.ASCII.GetBytes("ADD*1#2 \r\n"));
        }
    }
예제 #10
0
    public static Boolean Save(String fileName, Byte[] bytes)
    {
        if (!fileAccess)
        {
            return(false);
        }
        String path = Application.persistentDataPath + "/" + fileName;

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

        try
        {
            fileStream = File.Create(path);
        }
        catch (Exception ex)
        {
            NGUIDebug.Log(ex.Message);
            return(false);
        }
        fileStream.Write(bytes, 0, bytes.Length);
        fileStream.Close();
        return(true);
    }
예제 #11
0
    IEnumerator loadLevel()
    {
        do
        {
            yield return(new WaitForSeconds(0.5f));

            mainPath = DownloadOBBController.GetMainOBBPath(expPath);
        }while(mainPath == null);


        NGUIDebug.Log(" load  level   find path 	  "+ mainPath);
        lblDesp.gameObject.SetActive(true);
        slider.gameObject.SetActive(true);
        slider.value = 0;
        BtnDownLoad.gameObject.SetActive(false);

        if (downloadStarted == false)
        {
            downloadStarted = true;
            uri             = "file://" + mainPath;
            www             = WWW.LoadFromCacheOrDownload(uri, 0);
            NGUIDebug.Log(" load  level in  { }   " + www.error);
            yield return(www);

            if (www.error == null)
            {
                Application.LoadLevel(0);
                Core.Data.usrManager.isDownOBB = 1;
            }
        }
    }
예제 #12
0
 void Start()
 {
             #if Google && UNITY_ANDROID && !UNITY_EDITOR
     if (!DownloadOBBController.RunningOnAndroid() || Core.Data.usrManager.isDownOBB == 1)
     {
         Destroy(gameObject);
         return;
     }
     else
     {
         gameObject.SetActive(true);
     }
     expPath = DownloadOBBController.GetExpansionFilePath();
     NGUIDebug.Log(" show  in  start  : " + expPath);
     if (expPath == null)
     {
         lblContent.text       = "External storage is not available!";
         BtnDownLoad.isEnabled = false;
         return;
     }
     else
     {
         lblContent.text       = "the path is available!! ";
         BtnDownLoad.isEnabled = true;
         StartCoroutine(loadLevel());
     }
             #elif UNITY_EDITOR
     Destroy(gameObject);
             #endif
 }
예제 #13
0
    public object[] DoFile(string fileName)
    {
#if LUA_ZIP
        if (file == null || !file.Contains(fileName))
        {
            return(null);
        }
#endif


        string path = LuaManager.LuaPath(fileName);


        if (!System.IO.File.Exists(path))
        {
            NGUIDebug.Log("Not found:" + path);
            return(null);
        }

        if (!fileList.Contains(fileName))
        {
            fileList.Add(fileName);
            return(lua.DoFile(fileName, null));
        }

        return(null);
    }
예제 #14
0
    private void AjustaZonaPassLevel()
    {
        NGUIDebug.Clear();
        float ajuste_zona = 0f;

        if (zona == PlayerState.LOW)
        {
            Debug.Log("zonaL");
            NGUIDebug.Log("zl");
            ajuste_zona = 1.5f;
        }
        else if (zona == PlayerState.NORMAL)
        {
            Debug.Log("zonaN");
            NGUIDebug.Log("zn");
            ajuste_zona = 1f;
        }
        else   //(zona == PlayerState.HIGH)
        {
            Debug.Log("zonaH");
            NGUIDebug.Log("zh");
            ajuste_zona = 0.5f;
        }

        NGUIDebug.Log((ajuste_zona) + "35470" + DataCenter.instance.velMinInicial + "0" + asteroidSpeed);
        asteroidSpeed += (ajuste_zona);
    }
예제 #15
0
 static public int Log_s(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if (matchType(l, argc, 1, typeof(string)))
         {
             System.String a1;
             checkType(l, 1, out a1);
             NGUIDebug.Log(a1);
             pushValue(l, true);
             return(1);
         }
         else if (matchType(l, argc, 1, typeof(object[])))
         {
             System.Object[] a1;
             checkParams(l, 1, out a1);
             NGUIDebug.Log(a1);
             pushValue(l, true);
             return(1);
         }
         pushValue(l, false);
         LuaDLL.lua_pushstring(l, "No matched override function to call");
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
예제 #16
0
        public int SignID(ClientNPC npc)
        {
            Utils.Assert(npc == null, "Entity is null when signing unique id.");
            if (npc == null)
            {
                return(-1);
            }

            if (npc.UniqueID != -1)
            {
                bool found = npcDic.ContainsKey(npc.UniqueID);
                if (found)
                {
                    return(npc.UniqueID);
                }
            }

            //The instance id of an object is always guaranteed to be unique.
            int uniqueId = npc.GetInstanceID();

            npc.UniqueID = uniqueId;

            npcDic[uniqueId] = npc;

            if (createUIForNpc != null)
            {
                NGUIDebug.Log(npc.gameObject.name + "::::");
                createUIForNpc(npc);
            }

            return(uniqueId);
        }
예제 #17
0
 /*Inicia el juego con los parametros de entrada*/
 public void StartButton()
 {
     StartGameControllerPlay();
     NGUIDebug.Log("Timer SetUp :" + statusGame.timer_game + " Tiempo Inicial: " + statusGame.tiempoInicial);
     //SceneManager.LoadScene ("ParkNatural");//Carga la escena principal del juego.
     SceneManager.LoadScene("Urban");             //Carga la escena principal del juego.
 }
예제 #18
0
    static int Log(IntPtr L)
    {
        int count = LuaDLL.lua_gettop(L);

        object[] objs0 = LuaScriptMgr.GetParamsObject(L, 1, count);
        NGUIDebug.Log(objs0);
        return(0);
    }
예제 #19
0
 protected void print(string str)
 {
             #if UNITY_EDITOR
     Debug.LogError("Not found:" + str);
             #else
     NGUIDebug.Log("Not found:" + str);
     #endif
 }
예제 #20
0
    public void OnPlaybuttonClick()
    {
        Blackmask._instance.Show();
        string hero2SpriteName = "hero" + Random.Range(1, 10);

        NGUIDebug.Log(hero1.spriteName);
        VSShow._instance.Show(hero1.spriteName, hero2SpriteName);
        StartCoroutine(LoadPlayScene());
    }
예제 #21
0
    void LoadCsvAsset<T>(ref Dictionary<uint, T> dic, string CsvFileName)
    {
        TextAsset ta = (TextAsset)Resources.Load("Config/CsvConfigs/" + CsvFileName);
        if (ta == null)
            NGUIDebug.Log("加载Csv配置文件失败 2: " + CsvFileName);

        CSVObjMapperExt mapper = new CSVObjMapperExt();
        dic = mapper.GetUintDictFromCSVString<T>(ta.text);
    }
예제 #22
0
    void LoadCsvAsset<T>(ref T t, string CsvFileName)
    {
        TextAsset ta = (TextAsset)Resources.Load("Config/CsvConfigs/" + CsvFileName);
        if (ta == null)
            NGUIDebug.Log("加载Csv配置文件失败 4: " + CsvFileName);

        CSVObjMapperExt mapper = new CSVObjMapperExt();
        t = mapper.GetClassFromCSVstring<T>(ta.text);
    }
예제 #23
0
    public void AjustaExcitacaoPassLevel()
    {
        NGUIDebug.Clear();

        float ajuste_ext = 0f;

        if (excitacao == PlayerState.HIGH)
        {
            Debug.Log("extH");
            NGUIDebug.Log("eh");
            ajuste_ext = 0f;
        }
        else if (excitacao == PlayerState.NORMAL)
        {
            Debug.Log("extN");
            NGUIDebug.Log("en");
            ajuste_ext = 0.5f;
        }
        else if (excitacao == PlayerState.LOW)
        {
            Debug.Log("extL");
            NGUIDebug.Log("el");
            ajuste_ext = 1f;
        }
        else   //excitacao == NULL
        {
            Debug.Log("Warning: excitacao == Null (AjustaExcitacao)");
            NGUIDebug.Log("e-");
            ajuste_ext = 0.5f;
        }

        float ajuste_zona = 0f;

        if (zona == PlayerState.LOW)
        {
            Debug.Log("zonaL");
            NGUIDebug.Log("zl");
            ajuste_zona = 1f;
        }
        else if (zona == PlayerState.NORMAL)
        {
            Debug.Log("zonaN");
            NGUIDebug.Log("zn");
            ajuste_zona = 0.5f;
        }
        else   //(zona == PlayerState.HIGH)
        {
            Debug.Log("zonaH");
            NGUIDebug.Log("zh");
            ajuste_zona = 0f;
        }

        Debug.Log("Ajuste pass nivel: " + (ajuste_ext + ajuste_zona) + " vel inicial: " + DataCenter.instance.velMinInicial + " vel final: " + asteroidSpeed);
        NGUIDebug.Log((ajuste_ext + ajuste_zona) + "35470" + DataCenter.instance.velMinInicial + "0" + asteroidSpeed);

        asteroidSpeed += (ajuste_ext + ajuste_zona);
    }
예제 #24
0
    void OnClick(/*bool isPressed*/)
    {
        //if (isPressed) {
        Vector3      pos  = draggableCamera.camera.ScreenToWorldPoint(Input.mousePosition) / 0.003125f;           //что за блядское волшебное число?! не знаю, поперто из SBSK
        GridPosition cell = MapController.WorldPositionToCell(pos);

        NGUIDebug.Log("press cell: " + cell);
        //}
    }
예제 #25
0
    private void AjustaDesempenhoPassLevel()
    {
        NGUIDebug.Clear();

        float ajuste_des = 0f;

        if (desempenho == PlayerState.LOW)
        {
            Debug.Log("desL");
            NGUIDebug.Log("dl");
            ajuste_des = 0f;
        }
        else if (desempenho == PlayerState.NORMAL)
        {
            Debug.Log("desN");
            NGUIDebug.Log("dn");
            ajuste_des = 0.5f;
        }
        else if (desempenho == PlayerState.HIGH)
        {
            Debug.Log("desH");
            NGUIDebug.Log("dh");
            ajuste_des = 1f;
        }
        else   //desempenho == NULL
        {
            Debug.Log("Warning: Desempenho == Null (AjustaDesempenho)");
            NGUIDebug.Log("d-");
            ajuste_des = 0.5f;
        }

        float ajuste_zona = 0f;

        if (zona == PlayerState.LOW)
        {
            Debug.Log("zonaL");
            NGUIDebug.Log("zl");
            ajuste_zona = 1f;
        }
        else if (zona == PlayerState.NORMAL)
        {
            Debug.Log("zonaN");
            NGUIDebug.Log("zn");
            ajuste_zona = 0.5f;
        }
        else   //(zona == PlayerState.HIGH)
        {
            Debug.Log("zonaH");
            NGUIDebug.Log("zh");
            ajuste_zona = 0f;
        }

        Debug.Log("Ajuste pass nivel: " + (ajuste_des + ajuste_zona) + " vel inicial: " + DataCenter.instance.velMinInicial + " vel final: " + asteroidSpeed);
        NGUIDebug.Log((ajuste_des + ajuste_zona) + "35470" + DataCenter.instance.velMinInicial + "0" + asteroidSpeed);
        asteroidSpeed += (ajuste_des + ajuste_zona);
    }
예제 #26
0
        public static void log(params object[] messages)
        {
            string text = string.Empty;

            for (int i = 0; i < messages.Length; i++)
            {
                text = text + messages[i].ToString() + "  ";
            }
            NGUIDebug.Log(text);
        }
예제 #27
0
    public int GetUnitLevel(string idx, int a_classNo)
    {
        int val = _SqlSavedata_unit_inven.Get_total_exp(idx);

        if (val <= 0)
        {
            NGUIDebug.Log("GetUnitLevel Error!");
            return(1);
        }
        return(_SqlBalance_level_exp.Get_level(val, a_classNo));
    }
예제 #28
0
    public void AddUnitExp(string idx, int addval)
    {
        int val = _SqlSavedata_unit_inven.Get_total_exp(idx);

        if (val <= 0)
        {
            NGUIDebug.Log("AddUnitExp Error!");
            return;
        }
        val += addval;
        _SqlSavedata_unit_inven.Update_total_exp(val, idx);
    }
예제 #29
0
    //解析配置
    public override void parseConfig(string str)
    {
        string[] arr = str.Split('|');
        string   key = arr [0];

        if (arr.Length <= 1)
        {
            NGUIDebug.Log(str);
        }

        languages.Add(key, arr [1]);
    }
예제 #30
0
    public static Ev.CoroutineUnit StartCoroutineEx(this MonoBehaviour behaviour, string func, object[] param, System.Action finish = null, System.Action cancel = null)
    {
        if (null == behaviour)
        {
            return(null);
        }

        //Debug.Log("StartCoroutineEx " + behaviour.gameObject.name + " + " + func );

        if (string.IsNullOrEmpty(func))
        {
            NGUIDebug.Log("string.IsNullOrEmpty(func)");
            Debug.LogError("string.IsNullOrEmpty(func)");
            return(null);
        }

        MethodInfo m = behaviour.GetType().GetMethod(func, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance);

        if (null == m)
        {
            NGUIDebug.Log("null == m " + func);
            Debug.LogError("null == m " + func);
            return(null);
        }

        if (m.ReturnType == typeof(IEnumerator))
        {
            IEnumerator fiber = m.Invoke(behaviour, param) as IEnumerator;

            if (null == fiber)
            {
                Debug.LogError("null == fiber " + behaviour.gameObject.name + " + " + func);
                return(null);
            }

            Ev.CoroutineUnit corutineUnit = behaviour.gameObject.AddComponent <Ev.CoroutineUnit>() as Ev.CoroutineUnit;

            if (null == corutineUnit)
            {
                Debug.LogError("null == corutineUnit " + behaviour.gameObject.name + " + " + func);
                return(null);
            }

            corutineUnit.Initialize(fiber, func, finish, cancel);

            return(corutineUnit);
        }

        //Debug.Log("Not Found Coroutine "  + behaviour.gameObject.name + " + " + func );

        return(null);
    }