Beispiel #1
0
        public RunningData GetRunningData(int key)
        {
            RunningData data;

            if (mDataDict.TryGetValue(key, out data) && data != null)
            {
                return(data);
            }
            HTLogger.Error("Get RunningData fail.");
            return(null);
        }
Beispiel #2
0
        private void Start()
        {
            UnityDebugListener   unityDebugListener   = new UnityDebugListener();
            UnityWarningListener unityWarningListener = new UnityWarningListener();
            UnityErrorListener   unityErrorListener   = new UnityErrorListener();

            HTLogger.Instance.Init(true);
            HTLogger.Instance.AddListener(HTLogger.Channel.Info, unityDebugListener);
            HTLogger.Instance.AddListener(HTLogger.Channel.Todo, unityDebugListener);
            HTLogger.Instance.AddListener(HTLogger.Channel.Debug, unityDebugListener);
            HTLogger.Instance.AddListener(HTLogger.Channel.Warning, unityWarningListener);
            HTLogger.Instance.AddListener(HTLogger.Channel.Error, unityErrorListener);


            HTLogger.Info("测试 Logger 成功!");
            HTLogger.Todo("测试 Logger 成功!");
            HTLogger.Debug("测试 Logger 成功!");
            HTLogger.Warning("测试 Logger 成功!");
            HTLogger.Error("测试 Logger 成功!");
        }
Beispiel #3
0
        /// <summary>
        /// 随机生成障碍物
        /// </summary>
        /// <param 障碍物生成概率(0,1)="probability"></param>
        /// <param 地图宽="width"></param>
        /// <param 地图高="height"></param>
        /// <param 随机种子="seed"></param>
        /// <returns></returns>
        private List <Node> GenerateObstacleList(float probability, int width, int height, int seed)
        {
            if (probability > 1 || probability < 0)
            {
                HTLogger.Error("障碍物生成概率不合法!");
                return(null);
            }
            List <Node> res           = new List <Node>();
            List <int>  randomNumList = GenerateRandomNumList(1, 100, width * height, seed);
            int         threshold     = Mathf.FloorToInt(probability * 100.0f);

            for (int i = 0, k = 0; i < width; i++)
            {
                for (int j = 0; j < height; j++, k++)
                {
                    if (randomNumList[k] <= threshold)
                    {
                        res.Add(mMapMgr.Map[i, j]);
                    }
                }
            }
            return(res);
        }