public void Generate()
        {
            Prepare();

            var template = new MacroTemplate(_random);

            Land = template;

            //Fully generate Macro Map
            Macro = template.CreateMacroMap(this);

            var microtimer = Stopwatch.StartNew();

            Micro = new MicroMap(Macro, this);

            foreach (var zone in Macro.Zones)
            {
                template.GenerateMicroZone(Macro, zone, Micro);
            }
            Micro.GenerateHeightmap();

            microtimer.Stop();

            Micro.Changed += MicroOnChanged;

            Debug.LogFormat("Created micromap in {0} msec", microtimer.ElapsedMilliseconds);
        }
Esempio n. 2
0
    private static void SetName()
    {
        Debug.LogFormat("{0}Start set resources' bundle name...", PACKTAG);
        Stopwatch sw = new Stopwatch();

        sw.Start();

        List <string> fileAllPath = new List <string>();

        foreach (var path in ResourcesPath)
        {
            fileAllPath.AddRange(GetFiles(path, ResourceExt));
        }

        foreach (var file in fileAllPath)
        {
            string localPath = "";
            if (file.Contains("/Assets/"))
            {
                localPath = file.Substring(file.IndexOf("/Assets/") + 1);
            }
            //需要以Assets目录开头的路径
            AssetImporter improter = AssetImporter.GetAtPath(localPath);
            if (improter != null)
            {
                improter.assetBundleName = Path.GetFileNameWithoutExtension(localPath);
            }
        }
        AssetDatabase.RemoveUnusedAssetBundleNames();
        AssetDatabase.Refresh();

        sw.Stop();
        Debug.LogFormat("[{0}]set name finished; cost {1}ms", PACKTAG, sw.ElapsedMilliseconds);
    }
Esempio n. 3
0
        private BehaviourTreeStatus FindSafety_Action()
        {
            if (this.RoomIsSafe(CurrentTile))
            {
                // Already in a safe place.
                AbandonMove();
                return(BehaviourTreeStatus.Success);
            }

            if (this.RoomIsSafe(DestinationTile))
            {
                // Already heading to a safe place.
                return(BehaviourTreeStatus.Success);
            }

            // Look for a safe room nearby.
            var targetRoomTile = FindNearestSafeRoom();

            if (targetRoomTile == null)
            {
                // Debug.Log("Could not find a safe room!");
                return(BehaviourTreeStatus.Failure);
            }

            Debug.LogFormat("{0} finding safety", Name);

            DestinationTile = targetRoomTile;
            return(BehaviourTreeStatus.Success);
        }
 private void DebugCommands()
 {
     for (int i = 0; i < _mPendingCommands.Count; ++i)
     {
         Debug.LogFormat("{0} - Command - {1}", i, _mPendingCommands[i]);
     }
 }
Esempio n. 5
0
        /// <summary>
        /// 连接到服务器
        /// </summary>
        protected void ConnectInternal(string ip, short port, IConnection conn, INetworkMessageHandler handler = null)
        {
            if (connection != null && connection.IsConnected)
            {
                connection.Close();
            }
            if (!string.IsNullOrEmpty(connectorTypeName))
            {
                connection = (IConnection)Activator.CreateInstance(Type.GetType(connectorTypeName, true, true));
            }
            if (!string.IsNullOrEmpty(messageHandlerName))
            {
                messageHandler = (INetworkMessageHandler)Activator.CreateInstance(Type.GetType(messageHandlerName, true, true));
            }
            if (messageHandler == null)
            {
                messageHandler = handler ?? new DefaultMessageHandler();
            }
            if (connection == null)
            {
                connection = conn ?? new TCPConnection();
            }
            NetworkAddress = new NetworkAddress {
                ip = ip, port = port
            };
            ping = new Ping(ip);
            Connect();
#if UNITY_EDITOR
            Debug.LogFormat("Connect to server , <color=cyan>Addr:[{0}:{1}] ,connector:{2} ,wrapper:{3}.</color>", ip, port, connection.GetType(), messageHandler.GetType());
#endif
        }
Esempio n. 6
0
        public static bool Send(object cmd, object buf = null, Action <INetworkMessage> callback = null, params object[] parameters)
        {
            if (!IsConnected)
            {
                return(false);
            }

            try
            {
                var message = messageHandler.PackMessage(cmd, buf, parameters);
                var buffer  = message.GetBuffer(IsLittleEndian);
                if (!responseActions.ContainsKey(message.Command))
                {
                    responseActions.Add(message.Command, new Queue <Action <INetworkMessage> >());
                }
                responseActions[message.Command].Enqueue(callback);
                connection.Send(buffer);
                prevSendTime = Time.time;
#if UNITY_EDITOR || DEVELOPMENT_BUILD
                if (Instance.enableLogging)
                {
                    Debug.LogFormat("<color=cyan>[TCPNetwork]</color> [Send] >> CMD:{0},TIME:{1}", cmd, DateTime.Now);
                }
#endif
            }
            catch (Exception ex)
            {
                Debug.LogException(ex);
                return(false);
            }

            return(true);
        }
Esempio n. 7
0
 private static void UnityLogFormat(LogType type, LogOption option, Object context, string tag, string format, params object[] args)
 {
     try
     {
         if (args.Length > 0)
         {
             Debug.LogFormat(type, option, context, string.Concat(tag, ":", format), args);
         }
         else
         {
             if (type == LogType.Log)
             {
                 Debug.Log(string.Concat(tag, ":", format), context);
             }
             else if (type == LogType.Warning)
             {
                 Debug.LogWarning(string.Concat(tag, ":", format), context);
             }
             else if (type == LogType.Error)
             {
                 Debug.LogError(string.Concat(tag, ":", format), context);
             }
         }
     }
     catch (Exception ex)
     {
         DebugUtility.LogError(LoggerTags.Engine, "The formatting-string or argument is abnormal.");
         DebugUtility.LogException(ex);
     }
 }
Esempio n. 8
0
        public static AppInstallStatus GetInstallStatus(ConnectInfo connectInfo)
        {
            using (var client = new TimeoutWebClient())
            {
                client.Credentials = new NetworkCredential(connectInfo.User, connectInfo.Password);
                string query      = string.Format(API_InstallStatusQuery, connectInfo.IP);
                string statusJSON = client.DownloadString(query);
                var    status     = JsonUtility.FromJson <InstallStatus>(statusJSON);

                if (status == null)
                {
                    return(AppInstallStatus.Installing);
                }

                Debug.LogFormat("Install Status: {0}|{1}|{2}|{3}", status.Code, status.CodeText, status.Reason, status.Success);

                if (status.Success == false)
                {
                    Debug.LogError(status.Reason + "(" + status.CodeText + ")");
                    return(AppInstallStatus.InstallFail);
                }

                return(AppInstallStatus.InstallSuccess);
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Uninstalls the target application on the target device.
        /// </summary>
        /// <param name="packageFamilyName"></param>
        /// <param name="targetDevice"></param>
        /// <param name="showDialog"></param>
        /// <returns>True, if uninstall was a success.</returns>
        public static bool UninstallApp(string packageFamilyName, ConnectInfo targetDevice, bool showDialog = true)
        {
            AppDetails appDetails = QueryAppDetails(packageFamilyName, targetDevice);

            if (appDetails == null)
            {
                Debug.Log(string.Format("Application '{0}' not found", packageFamilyName));
                return(false);
            }

            string query = string.Format("{0}?package={1}",
                                         string.Format(API_InstallQuery, FinalizeUrl(targetDevice.IP)),
                                         WWW.EscapeURL(appDetails.PackageFullName));

            bool        success       = WebRequestDelete(query, GetBasicAuthHeader(targetDevice), showDialog);
            MachineName targetMachine = GetMachineName(targetDevice);

            if (success)
            {
                Debug.LogFormat("Successfully uninstalled {0} on {1}.", packageFamilyName, targetMachine.ComputerName);
            }
            else
            {
                Debug.LogErrorFormat("Failed to uninstall {0} on {1}", packageFamilyName, targetMachine.ComputerName);
            }

            return(success);
        }
Esempio n. 10
0
        public static void StartBackup()
        {
            if (backuping || (!FastZip.isSupported && !SevenZip.isSupported) && !EditorApplication.isPlaying)
            {
                return;
            }

            EditorSceneManager.SaveScene(EditorSceneManager.GetActiveScene());
            AssetDatabase.SaveAssets();

            var        path                = string.Format("{0}/{1}_backup_{2}.zip", saveLocation, productNameForFile, DateTime.Now.ToString(@"yyyy-dd-MM-HH-mm"));
            var        assetsPath          = Application.dataPath;
            var        projectSettingsPath = Application.dataPath.Replace("/Assets", "/ProjectSettings");
            var        startTime           = EditorApplication.timeSinceStartup;
            ZipProcess zip;

            if ((mode == ZipModes.FastZip && FastZip.isSupported) || !SevenZip.isSupported)
            {
                zip = new FastZip(path, assetsPath, projectSettingsPath);
                (zip as FastZip).packLevel       = packLevel;
                (zip as FastZip).threads         = threads;
                (zip as FastZip).earlyOutPercent = earlyOut;
            }
            else
            {
                zip = new SevenZip(path, assetsPath, projectSettingsPath);
            }

            zip.onExit += (o, a) => {
                backuping  = false;
                lastBackup = DateTime.Now;

                if (zip.process.ExitCode == 0)
                {
                    var zipSize = File.ReadAllBytes(path).Length;
                    var time    = (EditorApplication.timeSinceStartup - startTime).ToString("0.00");

                    if (logToConsole)
                    {
                        Debug.LogFormat("Backuped project into {0} in {1} seconds @ {2}", EditorUtility.FormatBytes(zipSize), time, System.DateTime.Now);
                    }
                }
                else if (logToConsole)
                {
                    Debug.LogWarning("Something went wrong while zipping");
                }
            };

            backuping = zip.Start();

            if (logToConsole)
            {
                Debug.Log(backuping ? "Backuping..." : "Error starting zip process");
            }
            if (!backuping)
            {
                lastBackup = DateTime.Now;
            }
        }
Esempio n. 11
0
 public static void Info(string format, params object[] args)
 {
     if (!IsDebug())
     {
         return;
     }
     Debug.LogFormat(format, args);
 }
Esempio n. 12
0
 void OnInpTxtChange(string val)
 {
     if (IptConnectInfo && !string.IsNullOrEmpty(IptConnectInfo.text))
     {
         ChosedServer = IptConnectInfo.text;
         Debug.LogFormat("select server:{0}", ChosedServer);
     }
 }
Esempio n. 13
0
 void OnChoseServer(int selIdx)
 {
     if (selIdx < DropSerList.options.Count)
     {
         ChosedServer = DropSerList.options[selIdx].text;
         Debug.LogFormat("select server:{0}", ChosedServer);
     }
 }
 public static void LogFormat(this string format, params object[] args)
 {
     if (debugable)
     {
         string message = string.Format(format, args);
         UnityDebug.LogFormat(string.Format("{0} {1}", InfoFormat, message));
     }
 }
Esempio n. 15
0
 /// <summary>
 /// Log profiling results regarding calls to IEnumerator.MoveNext().
 /// </summary>
 public void LogProfilingData()
 {
     foreach (var record in _profilingData)
     {
         Debug.LogFormat("{0}\t{1}",
                         record.TaskType, record.Milliseconds);
     }
 }
    public void SwitchEndPoint()
    {
        var endPointField = typeof(Endpoints).GetField("CloudSaveEndpoint", BindingFlags.Static | BindingFlags.Public);

        GameManager.Instance._endpoint = _endpoint;
        endPointField.SetValue(null, GameManager.Instance.EndPoints[GameManager.Instance._endpoint]);
        Debug.LogFormat("EndPoint switch to {0}", endPointField.GetValue(null));
    }
Esempio n. 17
0
 static public void LogFormat(Object context, string message, params object[] args)
 {
     if (EnableLog)
     {
         LogToFile(message);
         Debug.LogFormat(context, message, args);
     }
 }
Esempio n. 18
0
        private void OnFoundGround(RaycastHit hit, int numAttempts, string customMessage)
        {
            this.transform.position = hit.point + Vector3.up * characterController.height * 1.5f;
            this.Velocity           = Vector3.zero;

            Debug.LogFormat("Found ground at {0}, distance {1}, object name {2}, num attempts {3}, {4}", hit.point, hit.distance,
                            hit.transform.name, numAttempts, customMessage);
        }
    void OnDisable()
    {
        Debug.LogFormat("compile + schedule ticks: {0} , execution ticks: {1}",
                        compileAndScheduleTimeTicks, immediateCompletionTimeTicks);

        Util.Stopwatch.Reset();
        job.Dispose();
    }
Esempio n. 20
0
    private void FindFacesAndEdges()
    {
        Debug.LogFormat("{0}: There should be {1} edges or less.", name, indexBuffer.Length);
        Debug.LogFormat("{0}: There should be {1} faces.", name, indexBuffer.Length / 3);
        Debug.LogFormat("{0}: There are {1} vertices.", name, mesh.vertexCount);

        Stopwatch stopwatch = new Stopwatch();

        stopwatch.Start();

        Dictionary <Edge, Edge> edgesDictionary = new Dictionary <Edge, Edge>(indexBuffer.Length);
        Edge temp;

        for (int i = 0; i <= indexBuffer.Length - 3; i += 3)
        {
            Face face = new Face(indexBuffer[i], indexBuffer[i + 1], indexBuffer[i + 2], vertexBuffer);
            faces.Add(face);
            int faceIndex = faces.Count - 1;

            Edge edge = new Edge(indexBuffer[i], indexBuffer[i + 1], faceIndex);
            if (!edgesDictionary.TryGetValue(edge, out temp))
            {
                edgesDictionary.Add(edge, edge);
            }
            else
            {
                temp.FaceB = faceIndex;
            }

            edge = new Edge(indexBuffer[i + 1], indexBuffer[i + 2], faceIndex);
            if (!edgesDictionary.TryGetValue(edge, out temp))
            {
                edgesDictionary.Add(edge, edge);
            }
            else
            {
                temp.FaceB = faceIndex;
            }

            edge = new Edge(indexBuffer[i + 2], indexBuffer[i], faceIndex);
            if (!edgesDictionary.TryGetValue(edge, out temp))
            {
                edgesDictionary.Add(edge, edge);
            }
            else
            {
                temp.FaceB = faceIndex;
            }
        }

        edges = edgesDictionary.Values.ToList();

        Debug.LogFormat("{0}: There were {1} unique edges found.", name, edges.Count);
        Debug.LogFormat("{0}: There were {1} faces found.", name, faces.Count);

        stopwatch.Stop();
        Debug.LogFormat("{0}: Finding edges took {1}ms", name, stopwatch.ElapsedMilliseconds);
    }
        public static void UpdateResVersion()
        {
            var    curVer  = GetCurResVersion();
            var    nextVer = new Version(curVer.Major, curVer.Minor, curVer.Build + 1);
            string text    = nextVer.ToString();

            File.WriteAllText(ResVerPath, text);
            Debug.LogFormat("[UpdateResVersion] res_ver: {0}", text);
        }
Esempio n. 22
0
 public static EditorTaskInfo DoEditorTask( String title, TaskActions _taskList, bool breakIfException = false ) {
     if ( _taskList == null || _taskList.Count == 0 ) {
         return null;
     }
     title = title ?? "unknown editor task";
     var taskInfo = new EditorTaskInfo( title );
     EditorApplication.CallbackFunction tick = null;
     // we handle task item from the end of list
     _taskList.Reverse();
     int totalTaskCount = _taskList.Count;
     taskInfo._breakIfException = breakIfException;
     taskInfo._totalTaskCount = totalTaskCount;
     if ( totalTaskCount > 0 ) {
         taskInfo._taskList = _taskList;
         EditorTaskInfo._allTasks.Add( taskInfo );
         tick = () => {
             if ( _taskList.Count > 0 ) {
                 var item = _taskList[ _taskList.Count - 1 ];
                 _taskList.RemoveAt( _taskList.Count - 1 );
                 taskInfo._curTaskCount = _taskList.Count;
                 taskInfo._curTask = item.name;
                 Debug.LogFormat( "DoEditorTask: {0}", item.name );
                 if ( EditorUtility.DisplayCancelableProgressBar( title, item.name, ( totalTaskCount - _taskList.Count ) / ( float )totalTaskCount ) ) {
                     _taskList.RemoveAll( _e => _e.breakAble );
                     return;
                 }
                 try {
                     if ( item.action != null ) {
                         item.action();
                     }
                 } catch ( Exception e ) {
                     if ( taskInfo._breakIfException ) {
                         _taskList.RemoveAll( _e => _e.breakAble );
                     }
                     Debug.LogErrorFormat( "Process {0} failed: {1}", item.name, e.ToString() );
                 }
             } else {
                 EditorApplication.update -= tick;
                 taskInfo._isWorking = false;
                 taskInfo._totalTaskCount = 0;
                 taskInfo._curTask = String.Empty;
                 EditorUtility.ClearProgressBar();
                 if ( taskInfo._curTaskCount == 0 ) {
                     Debug.LogFormat( title + " done. total: {0}", totalTaskCount );
                 } else {
                     Debug.LogFormat( title + " canceled. total: {0}, done:{1}, remain: {2}", totalTaskCount, ( totalTaskCount - taskInfo._curTaskCount ), taskInfo._curTaskCount );
                 }
                 taskInfo._done = true;
                 taskInfo._curTaskCount = 0;
                 EditorTaskInfo._allTasks.Remove( taskInfo );
             }
         };
         EditorApplication.update += tick;
     }
     return taskInfo;
 }
Esempio n. 23
0
    private static void IsTextureTheSame()
    {
        List <string> textureList = Selection.GetFiltered <Texture2D>(SelectionMode.DeepAssets)
                                    .Select(texture2d => AssetDatabase.GetAssetPath(texture2d)).ToList();

        List <List <string> > sameTextureListList = new List <List <string> >();
        Stopwatch             sw = new Stopwatch();

        sw.Start();

        foreach (string texture in textureList)
        {
            if (sameTextureListList.Count <= 0)
            {
                sameTextureListList.Add(new List <string>()
                {
                    texture
                });
            }
            else
            {
                bool findSame = false;
                foreach (List <string> sameTextureList in sameTextureListList)
                {
                    if (UIUtility.IsSameTexture(texture, sameTextureList[0]))
                    {
                        sameTextureList.Add(texture);
                        findSame = true;
                        break;
                    }
                }
                if (!findSame)
                {
                    sameTextureListList.Add(new List <string>()
                    {
                        texture
                    });
                }
            }
        }
        sw.Stop();
        sameTextureListList = sameTextureListList.Where(list => list.Count > 1).ToList();
        if (sameTextureListList.Count > 0)
        {
            foreach (List <string> sameTextureList in sameTextureListList)
            {
                Debug.LogFormat("[UIAtlasLookOptimizeTool.IsTextureTheSame]相同图片:<color=cyan>{0}</color>", sameTextureList.ToString());
            }

            Debug.LogFormat("[UIAtlasLookOptimizeTool.IsTextureTheSame]查找相同图片执行结束,查找了{0}个图片,耗时{1}毫秒", textureList.Count, sw.ElapsedMilliseconds);
        }
        else
        {
            Debug.LogFormat("[UIAtlasLookOptimizeTool.IsTextureTheSame]没有找到任何相同图片,查找了{0}个图片,耗时{1}毫秒", textureList.Count, sw.ElapsedMilliseconds);
        }
    }
Esempio n. 24
0
        public string ToString(bool printLog = false)
        {
            var toString = string.Format("{0}:{1}", ServerIp, ServerPort);

            if (printLog)
            {
                Debug.LogFormat(toString);
            }
            return(toString);
        }
        /// Gets the subpart of the msbuild.exe command to save log information
        /// in the given logFileName.
        /// </summary>
        /// <remarks>
        /// Will return an empty string if logDirectory is not set.
        /// </remarks>
        private static string GetMSBuildLoggingCommand(string logDirectory, string logFileName)
        {
            if (String.IsNullOrEmpty(logDirectory))
            {
                Debug.LogFormat(LogType.Log, LogOption.NoStacktrace, null, "{0}", $"Not logging {logFileName} because no logDirectory was provided");
                return("");
            }

            return($"-fl -flp:logfile={Path.Combine(logDirectory, logFileName)};verbosity=detailed");
        }
Esempio n. 26
0
        private static void WriteAssetPackConfig(IEnumerable <AssetPackBundle> packBundles)
        {
            AssetPackBundleConfig config = GetOrCreateConfig();

            config.packs = packBundles.Select(pack => pack.Name).ToArray();
            Debug.LogFormat("[{0}.{1}] path={2}", nameof(AssetPackBuilder), nameof(WriteAssetPackConfig), AssetPackBundleConfig.PATH);
            EditorUtility.SetDirty(config);
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
        }
Esempio n. 27
0
        private async void OnAsyncParallelButtonClicked()
        {
            Debug.LogFormat("3 LoadParallelAsync()");
            Stopwatch stopwatch = Stopwatch.StartNew();

            await LoadParallelAsync();

            //This log occurs AFTER the operations
            Debug.LogFormat("Elapsed: {0} milliseconds", stopwatch.ElapsedMilliseconds);
        }
Esempio n. 28
0
        private void OnSyncSerialButtonClicked()
        {
            Debug.Log("1 LoadSerial()");
            Stopwatch stopwatch = Stopwatch.StartNew();

            LoadSerialSync();

            //This log occurs BEFORE the operations
            Debug.LogFormat("Elapsed: {0} milliseconds", stopwatch.ElapsedMilliseconds);
        }
Esempio n. 29
0
 void OnTriggerEnter2D(Collider2D other)
 {
     Debug.LogFormat("Boing with {0}, while current = {1} et max == {2}", other.name, _currentFill, maxFill);
     if (other.name == "WaterHole" && _currentFill >= maxFill)
     {
         GetComponent <SpriteRenderer>().sprite = EmptyBucket;
         GameObject.Find("ModuleManager").SendMessage("ReceiveValidation", "BucketSuccess");
         _currentFill = 0;
     }
 }
Esempio n. 30
0
 public void PrintPlayer(C2S_UPDATE_PLAYER player)
 {
     if (player == null)
     {
         Debug.LogError("player is null");
         return;
     }
     Debug.LogFormat("{0}", player.ToString());
     Debug.LogFormat("id:{0},hp:{1},mp:{2}", player.Id, player.Hp, player.Mp);
 }