Example #1
0
    private DBNode <T> GetItemAt(int index)
    {
        //判空
        if (IsEmpty())
        {
            LogTool.Log(string.Format("链表为空"), LogEnum.NormalLog);
            return(null);
        }

        var ptr = new DBNode <T>();

        ptr = Head;

        // 如果是第一个node
        if (0 == index)
        {
            return(ptr);
        }

        var j = 0;

        while (ptr.Next != null && j < index)
        {
            j++;
            ptr = ptr.Next;
            if (j == index)
            {
                return(ptr);
            }
        }

        LogTool.Log(string.Format("节点并不存在"), LogEnum.NormalLog);
        return(null);
    }
Example #2
0
        /// <summary>
        /// 检测Resource资源中的Effect是否有效
        /// </summary>
        public void CheckEffectInResource()
        {
            //获取所有资源路径
            mEffectResources.Clear();
            //Resource资源路径
            string resourcePath = Application.dataPath + "/Resources/effect";

            string[] files = Directory.GetFiles(resourcePath, "*.*", SearchOption.AllDirectories);
            foreach (string file in files)
            {
                string suffix = GetFileSuffix(file);
                if (suffix == "meta")
                {
                    continue;
                }
                //查找预制件件
                if (suffix == "prefab")
                {
                    string realFile = file.Replace("\\", "/");
                    realFile = realFile.Replace(Application.dataPath, "Assets");
                    mEffectResources.Add(realFile);
                }
            }

            LogTool.Log(string.Format("Check finised!"), LogEnum.NormalLog);
        }
Example #3
0
        public static void CleanResGOConfig()
        {
            var genPath   = Application.dataPath + "/Addressable Asset/";
            var filesPath = Directory.GetFiles(genPath, "*.prefab", SearchOption.AllDirectories);
            var info      = "";
            var index     = 0;

            for (int i = 0; i < filesPath.Length; i++)
            {
                filesPath[i] = filesPath[i].Substring(filesPath[i].IndexOf("Assets", StringComparison.Ordinal));
                var prefab   = AssetDatabase.LoadAssetAtPath(filesPath[i], typeof(GameObject)) as GameObject;
                var progress = (float)i / filesPath.Length;
                EditorUtility.DisplayProgressBar("资源配置清除进度...", info, progress);
                if (prefab != null)
                {
                    var goBase = prefab.GetComponent <ObjectBase>();
                    if (goBase != null)
                    {
                        goBase.ResID = 0;
                        index++;
                    }
                }
            }

            EditorUtility.ClearProgressBar();
            LogTool.Log($"共清除 {index} 个GO", LogEnum.Editor);
        }
        public ChallengerPlugin()
        {
            if (!Directory.Exists($"{Environment.CurrentDirectory}/Plugins/{GetType().Name}"))
            {
                Directory.CreateDirectory($"{Environment.CurrentDirectory}/Plugins/{GetType().Name}");
            }

            if (this is IConfigurable c)
            {
                string configPath = $"{Environment.CurrentDirectory}/Plugins/{GetType().Name}/{GetType().Name}.yaml";

                if (!File.Exists(configPath))
                {
                    using (StreamWriter s = new StreamWriter(configPath))
                    {
                        Serializer sz = new Serializer();
                        sz.Serialize(s, c.ConfigurationValues());
                    }
                }

                Configuration = new ChallengerConfiguration(GetType().Name);
            }

            LogTool.Log($"{GetType().Name} loaded!", LogTool.Severity.INFO);
        }
Example #5
0
        private SessionMessageBase DeserializeMessage(SessionFragmentMessage fragment)
        {
            var type = SessionMessageTypeAttribute.GetTypeForMessageType(fragment.Header.SessionMessageType);

            if (type == null)
            {
                LogTool.Log("Incoming decrypted has no impl: " +
                            JsonConvert.SerializeObject(fragment, Formatting.Indented));
            }

            var message = CreateFromMessageType(fragment.Header.SessionMessageType);

            if (fragment.Header.IsFragment)
            {
                message = new FragmentMessage();
            }

            message.Header.ChannelId          = fragment.Header.ChannelId;
            message.Header.RequestAcknowledge = fragment.Header.RequestAcknowledge;
            message.Header.IsFragment         = fragment.Header.IsFragment;
            message.Header.SessionMessageType = fragment.Header.SessionMessageType;
            message.Header.Version            = fragment.Header.Version;

            message.Deserialize(new EndianReader(fragment.Fragment));

            return(message);
        }
Example #6
0
    protected override IEnumerator Task()
    {
        LogTool.Log($"{TaskName.Value}", LogEnum.TaskLog);
        yield return(new WaitForFixedUpdate());

        IsFinish = true;
    }
Example #7
0
    void InitCinemaNativeInterface(string packageName)
    {
#if UNITY_ANDROID && !UNITY_EDITOR
        AndroidJavaClass nativeInterfaceClass = new AndroidJavaClass(string.Format("com.ssnwt.vr.{0}.jni.NativeInterface", packageName));
        if (nativeInterfaceClass == null)
        {
            return;
        }
        AndroidJavaObject AndroidInterface = nativeInterfaceClass.CallStatic <AndroidJavaObject>("getInstance");
        if (AndroidInterface == null)
        {
            return;
        }

        AndroidInterface.Call("init", GlobalAppManage.GetJApplication());

        switch (packageName)
        {
        case "mediascan":
            AndroidMediaScanInterface = AndroidInterface;
            break;

        case "playermanager":
            AndroidPlayerInterface = AndroidInterface;
            break;
        }
        LogTool.Log("AndroidInterface通过jApplication初始化, InitCinemaNativeInterface");
#endif
    }
Example #8
0
        public override void UpdateData()
        {
            var goals = agent.AgentGoalMgr.FindGoals();

            if (planHandler.IsComplete || cacheGoal == null || cacheGoal != goals.GoalsSortPriority())
            {
                if (goals.Count <= 0)
                {
                    LogTool.Log($"无计划制定");
                    planHandler.CurrActionHandlers.Clear();
                    planHandler.CurrActionHandlers.AddLast(agent.AgentActionMgr.GetHandler(ActionTag.Idle));
                    return;
                }

                if (planHandler.CurrGoal == null || goals.GoalsSortPriority() != planHandler.CurrGoal)
                {
                    //目标没有时候执行
                    //目标发生改变时候执行
                    planHandler.CurrGoal           = goals.GoalsSortPriority();
                    cacheGoal                      = planHandler.CurrGoal;
                    planHandler.CurrActionHandlers = planHandler.Planner.BuildPlan(planHandler.CurrGoal);
                }
                else
                {
                    LogTool.Log($"目标相同 {planHandler.CurrGoal}");
                }
            }

            agent.AgentActionMgr.ExcuteHandler(planHandler.HandlerAction());
        }
Example #9
0
 public static void Print()
 {
     foreach (var t in currentThread)
     {
         LogTool.Log(t.Name + " is running");
     }
 }
Example #10
0
        public override void InitBuffer(GPUBufferVariable <T> other)
        {
            LogTool.Log("Use InitAppendBuffer(GPUBufferAppendConsume<T> other)", LogLevel.Warning);
            LogTool.AssertIsTrue(other is GPUBufferAppendConsume <T>);

            this.InitAppendBuffer(other as GPUBufferAppendConsume <T>);
        }
Example #11
0
        protected void Start()
        {
            this.problem = new Problem()
            {
                temperature    = 1,
                minTemperature = 0.0001f,
                k     = 1,
                alpha = 0.99f
            };
            this.SA = new SimulatedAnnealing(this.problem, new Delta(), this.mode);
            this.SA.TryToRun();


            // this.SA.PerStep((p, s, dt, a) =>
            // {
            //     var state = (p as Problem).Current as HimmelblauState.Data;
            //     var next = (p as Problem).Next as HimmelblauState.Data;

            //     LogTool.Log("Current: " + state.CurrentX + " " + state.Evaluate(null), LogLevel.Info);
            //     LogTool.Log("Next: " + next.CurrentX + " " + next.Evaluate(null), LogLevel.Info);
            // });

            this.SA.End((p, s, dt, a) =>
            {
                var state = (p as Problem).Current as HimmelblauState.Data;
                LogTool.Log("Solution: " + state.CurrentX + " min= " + state.Evaluate(null), LogLevel.Info);
            });
        }
Example #12
0
 /// <summary>
 /// 初始化数据
 /// 必须手动填写已经添加的数据
 /// </summary>
 public void Init()
 {
     ConfigUnitSet.Add(GoalElementTag.Conditon, Condition);
     ConfigUnitSet.Add(GoalElementTag.Priority, Priority);
     ConfigUnitSet.Add(GoalElementTag.Target, Target);
     LogTool.Log($"{this.name} , GoalConfigUnit数据已经加载完成", LogEnum.AssetLog);
 }
Example #13
0
    /// <summary>
    /// 根据元素位置得到指定的节点
    /// </summary>
    /// <param name="index"></param>
    /// <returns></returns>
    private DBNode <T> GetNodeAt(int index)
    {
        if (IsEmpty())
        {
            LogTool.Log(string.Format("链表为空"), LogEnum.NormalLog);
            return(null);
        }

        var ptr = new DBNode <T>();

        ptr = this.Head;

        if (0 == index)
        {
            return(ptr);
        }

        var j = 0;

        while (ptr.Next != null && j < index)
        {
            j++;
            ptr = ptr.Next;
        }

        if (j == index)
        {
            return(ptr);
        }
        else
        {
            LogTool.Log(string.Format("节点并不存在"), LogEnum.NormalLog);
            return(null);
        }
    }
Example #14
0
    /// <summary>
    /// 根据元素的值查找索引
    /// </summary>
    /// <param name="value"></param>
    /// <returns></returns>
    public int IndexOf(T value)
    {
        if (IsEmpty())
        {
            LogTool.Log(string.Format("链表为空"), LogEnum.NormalLog);
            return(-1);
        }

        var ptr = new DBNode <T>();

        ptr = Head;
        var index = 0;

        while (ptr.Next != null && !ptr.Data.Equals(value)) //查找value相同的item
        {
            ptr = ptr.Next;
            index++;
        }

        if (ptr.Data.Equals(value))
        {
            return(index);
        }
        else
        {
            return(-1);
        }
    }
Example #15
0
    /// <summary>
    /// Major role is set data source
    /// </summary>
    /// <param name="svrVideoInfo">BaseVideoInfo data</param>
    public void PreparedPlayVideo(JVideoDescriptionInfo svrVideoInfo)
    {
#if UNITY_ANDROID
        if (VideoPlayerPtr == IntPtr.Zero)
        {
            Debug.Log("VideoPlayerPtr:为IntPtr.Zero");
            return;
        }

        MediaStretchPlayerPrefsDetector.GetInstance().SetMediaId(svrVideoInfo.id.ToString());
        string json = JsonUtility.ToJson(svrVideoInfo);
        Debug.Log("svrVideoInfo json:" + json);
        IsVideoReady = false;

        VideoPlayerPtr     = SetDataSource(VideoPlayerPtr, json);
        IsNeedFreeTexeture = true;
        IssuePlayerEvent(VideoPlayerEventBase, RenderCommand.InitializePlayer);

        //shemi:: 之后需要更换为扫描本地字幕,扫描回调中再设置字幕
        //string path = svrVideoInfo.uri;
        //path = MediaManage.GetPath((int)MediaType.Video ,path);
        //path = path.Substring(0, path.LastIndexOf("."));
        //SetSubtitleSource(VideoPlayerPtr, string.Format("{0}.srt", path));

        VideoWidth  = svrVideoInfo.width;
        VideoHeight = svrVideoInfo.height;
        Debug.Log("VideoScreenWidth:" + VideoWidth + " VideoScreenHeight:" + VideoHeight);
        LogTool.Log("SetDataSource success");
#endif
    }
Example #16
0
 public override void OnRemove()
 {
     //Clean up listeners just as you do with EventDispatcher
     scoreChangedSignal.RemoveListener(onScoreChange);
     view.clickSignal.RemoveListener(onViewClicked);
     LogTool.Log("Mediator OnRemove");
 }
Example #17
0
    public static Vector3[] GetBeizerList(int segmentNum, params Vector3[] points)
    {
        var path = new Vector3[segmentNum];

        for (int i = 1; i <= segmentNum; i++)
        {
            var t     = i / (float)segmentNum;
            var pixel = new Vector3();
            switch (points.Length)
            {
            case 2:
                pixel = CalculateBezierPoint(t, points[0], points[1]);
                break;

            case 3:
                pixel = CalculateBezierPoint(t, points[0], points[1], points[2]);
                break;

            case 4:
                pixel = CalculateBezierPoint(t, points[0], points[1], points[2], points[3]);
                break;
            }

            path[i - 1] = pixel;
            LogTool.Log(path[i - 1].ToString(), LogEnum.NormalLog);
        }

        return(path);
    }
Example #18
0
 private void onViewClicked()
 {
     LogTool.Log("View click detected");
     //Dispatch a Signal. We're adding a string value (different from MyFirstContext,
     //just to show how we can Inject values into commands)
     callWebServiceSignal.Dispatch(view.currentText);
 }
Example #19
0
 /// <summary>
 /// Accept是BeginAccept的回调函数,它做了如下3件事情
 //(1)给新的连接分配connect
 //(2)异步接收客户端数据
 ///(3)再次调用BeginAccept实现循环
 /// </summary>
 /// <param name="ar">句柄</param>
 private void AyscAccept(IAsyncResult ar)
 {
     LogTool.Log(isRunning);
     if (isRunning)
     {
         Socket server = (Socket)ar.AsyncState;
         Socket client = server.EndAccept(ar);
         //检查是否达到最大的允许的客户端数目
         if (clientCount >= maxConnectCount)
         {
             //C-TODO 触发事件
             RaiseOtherException(null);
         }
         else
         {
             AsyncSocketState state = new AsyncSocketState(client);
             if (!clientDic.ContainsKey(state.ClientSocket.RemoteEndPoint))
             {
                 LogTool.Log("新增客户端:" + state.ClientSocket.RemoteEndPoint);
                 clientDic.Add(state.ClientSocket.RemoteEndPoint, state);
             }
             RaiseClientConnected(state); //触发客户端连接事件
             state.InitBuffer();
             //开始接受来自该客户端的数据
             client.BeginReceive(state.RecvDataBuffer, 0, state.RecvDataBuffer.Length, SocketFlags.None,
                                 new AsyncCallback(HandleDataReceived), state);
         }
         //接受下一个请求
         server.BeginAccept(new AsyncCallback(AyscAccept), ar.AsyncState);
     }
 }
Example #20
0
        protected virtual void OnEnable()
        {
            this.CleanUp();
            if (this.global)
            {
                this.userList.AddRange(ObjectTool.FindAllObject <ILauncherUser>());
            }
            else
            {
                this.userList.AddRange(this.GetComponentsInChildren <ILauncherUser>());
            }

            this.environment = this.OnCreateEnv();
            this.ConfigureEnvironment();

            foreach (var u in this.userList)
            {
                u.Runtime = this.environment;
            }

            this.userList = this.userList.OrderBy(ul => ul.Order).ToList();
            foreach (var u in this.userList)
            {
                LogTool.Log("Init order " + u.Order + " " + u.ToString());
                u.OnLaunchEvent(this.data, LaunchEvent.Init);
            }
        }
    /// <summary>
    /// unity内部执行外部exe或者shell命令
    /// </summary>
    /// <param name="command"></param>
    /// <param name="argument"></param>
    private static void ProcessCommand(string command, string argument)
    {
        ProcessStartInfo startInfo = new ProcessStartInfo(command);

        startInfo.Arguments       = argument;
        startInfo.CreateNoWindow  = false;
        startInfo.ErrorDialog     = false;
        startInfo.UseShellExecute = false;
        if (startInfo.UseShellExecute)
        {
            startInfo.RedirectStandardOutput = false;
            startInfo.RedirectStandardError  = false;
            startInfo.RedirectStandardInput  = false;
        }
        else
        {
            startInfo.RedirectStandardOutput = true;
            startInfo.RedirectStandardError  = true;
            startInfo.RedirectStandardInput  = true;
            startInfo.StandardOutputEncoding = System.Text.UTF8Encoding.UTF8;
            startInfo.StandardErrorEncoding  = System.Text.UTF8Encoding.UTF8;
        }
        Process p = Process.Start(startInfo);

        {
            LogTool.Log("output=" + p.StandardOutput.ReadToEnd());
            LogTool.Log("errorLog=" + p.StandardError.ReadToEnd());
        }
        p.WaitForExit();
        p.Close();
    }
Example #22
0
        /// <summary>
        /// 播放错误信息
        /// 初始化播放视频断网时,底层直接推送123-103网络错误信息
        /// </summary>
        /// <param name="model"></param>
        /// <param name="what"></param>
        public void onError(int model, int code, string serverCode)
        {
            ExceptionEvent errorCode  = ExceptionEvent.KTTV_PLAYER_ERROR;
            string         errMessage = string.Format("{0}-{1}-{2}", model, code, serverCode);

            LogTool.Log(TAG, errMessage);
            if (isMatchIpLimit(code.ToString()) || isMatchIpLimit(serverCode))
            {
                //版权原因,无法观看
                errorCode = ExceptionEvent.KTTV_IPLIMIT;
            }
            //else if (isMatchLogin(code.ToString()) || isMatchLogin(serverCode))
            //    //登录设备达到上限
            //    errorCode = ExceptionEvent.KTTV_LOGIN;
            else if (isMatchNetwork(code.ToString()) || !GlobalVariable.IsInternetReachability())
            {
                errorCode = ExceptionEvent.EXCEPTION_NETWORK_ERROR;
            }
            else
            {
                //播放错误
                errorCode = ExceptionEvent.KTTV_PLAYER_ERROR;
            }

            mPlayer.OnVideoError(errorCode, errMessage);
        }
Example #23
0
 public override void OnRemove()
 {
     //Clean up listeners when the view is about to be destroyed
     view.dispatcher.RemoveListener(ExampleView.CLICK_EVENT, onViewClicked);
     dispatcher.RemoveListener(ExampleEvent.SCORE_CHANGE, onScoreChange);
     LogTool.Log("Mediator OnRemove");
 }
Example #24
0
    public void setDataSource(string vid, string cid)
    {
#if UNITY_ANDROID && !UNITY_EDITOR
        LogTool.Log(TAG, string.Format("Player-{0}-{1}", vid, cid));
        mKTTVPlayer.Call("setDataSource", cid, vid, 0);
#endif
    }
Example #25
0
        public Task SendAsync(SessionMessageBase message)
        {
            lock (_lockObject)
            {
                _sequenceNumber = _sequenceNumber + 1;
                var sequenceNumber = _sequenceNumber;

                LogTool.Log($"Sending message #{sequenceNumber} ({message}) ...");

                if (message.Header.RequestAcknowledge)
                {
                    return(Common.TaskExtensions.WithRetries(async() =>
                    {
                        var ackMessage = await WaitForMessageAsync <AckMessage>(
                            TimeSpan.FromSeconds(1),
                            async() => await SendFragmentAsync(message, sequenceNumber),
                            ack => ack.ProcessedList.Contains(sequenceNumber) ||
                            ack.RejectedList.Contains(sequenceNumber));

                        if (ackMessage.RejectedList.Contains(sequenceNumber))
                        {
                            throw new SmartGlassException("Message rejected by server.");
                        }

                        LogTool.Log($"Got ack for outbound #{sequenceNumber}");
                    },
                                                             messageRetries));
                }
                else
                {
                    return(SendFragmentAsync(message, sequenceNumber));
                }
            }
        }
Example #26
0
    public void setDataSource(string vid, string cid, long startTime)
    {
#if UNITY_ANDROID && !UNITY_EDITOR
        LogTool.Log(TAG, string.Format("Player-{0}-{1}-{2}", vid, cid, startTime));
        mKTTVPlayer.Call("setDataSource", cid, vid, (int)startTime);
#endif
    }
Example #27
0
        private void FindInGO(GameObject g)
        {
            go_count++;
            Component[] components = g.GetComponents <Component>();
            for (int i = 0; i < components.Length; i++)
            {
                components_count++;
                if (components[i] == null)
                {
                    missing_count++;
                    string    s = g.name;
                    Transform t = g.transform;
                    while (t.parent != null)
                    {
                        s = t.parent.name + "/" + s;
                        t = t.parent;
                    }

                    LogTool.Log(string.Format("{0} has an empty script attached in position: {1} {2}", s, i, g), LogEnum.Editor);
                }
            }

            // LocalNow recurse through each child GO (if there are any):
            foreach (Transform childT in g.transform)
            {
                FindInGO(childT.gameObject);
            }
        }
Example #28
0
    public void DataReceived(IAsyncResult ar)
    {
        AsyncSocketState state  = (AsyncSocketState)ar.AsyncState;
        Socket           client = state.ClientSocket;
        int len = -1;

        try
        {
            len          = socket.EndReceiveFrom(ar, ref sender);
            state.remote = (IPEndPoint)sender;
            //TODO 处理数据
            string msg = Encoding.UTF8.GetString(state.RecvDataBuffer, 0, len);
        }
        catch (Exception e)
        {
            //TODO 处理异常
            LogTool.Log(e);
        }
        finally
        {
            if (isRunning && socket != null)
            {
                client.BeginReceiveFrom(state.RecvDataBuffer, 0, state.RecvDataBuffer.Length, SocketFlags.None, ref sender, new AsyncCallback(DataReceived), state);
            }
        }
    }
Example #29
0
    // [MenuItem("工具/Check")]
    // public static void Check(){
    //     string targetPath = BundleTargetPath;
    //     string srcPath = Application.streamingAssetsPath;
    //     FileTool.Copy(targetPath,srcPath);
    // }

    //弃用
    public static void Copy(string srcPath, string targetPath)
    {
        if (!Directory.Exists(targetPath))
        {
            Directory.CreateDirectory(targetPath);
        }
        string dir = Path.Combine(targetPath, Path.GetFileName(srcPath));

        //判断文件夹是否存在
        if (Directory.Exists(srcPath))
        {
            dir += Path.DirectorySeparatorChar;
        }
        //目录下的所有文件夹
        string[] files = Directory.GetFileSystemEntries(srcPath);
        foreach (string file in files)
        {
            if (Directory.Exists(file))
            {
                Copy(file, dir);
            }
            else
            {
                LogTool.Log(dir, dir + Path.GetFileName(file));
                //File.Copy(file,dir + Path.GetFileName(file),true);
            }
        }
        LogTool.Log(dir);
    }
Example #30
0
 void LogList(List <StudentSort1> list)
 {
     for (int i = 0; i < list.Count; i++)
     {
         LogTool.Log($"第{i}个=" + list[i].ToString());
     }
 }