示例#1
0
    protected sealed override void PlayerSetting(ILog log)
    {
        _log = log.CreateLogger(this);
        base.PlayerSetting(log);

        _player._stats.CurHP                 = _player._stats.MaxHP = 7;
        _player._stats.Damage                = _player._stats.Damage = 10;
        _player._stats.AttackDuration        = _player._stats.AttackDuration = 2;
        _player._stats.SpecialAttackDuration = _player._stats.SpecialAttackDuration = 1000;
        _player._stats.AttackSpeed           = _player._stats.AttackSpeed = 2;
        _player._stats.JumpPower             = 12;
        _player._stats.MoveSpeed             = 7;

        _renderer        = GetComponent <SpriteRenderer>();
        _rigid2D         = GetComponent <Rigidbody2D>();
        _animtor         = GetComponent <Animator>();
        _animtor.enabled = false;

        _renderer.sprite = _startImg;

        if (_isStart)
        {
            isStart          = true;
            _animtor.enabled = true;
        }
        StartCoroutine(CR_ScreenHitFX());
    }
示例#2
0
        private void WriteMtl(ThreeDModel m3d, string mtlfn)
        {
            var opts  = Program.Options;
            var clr   = opts.OverrideColor;
            var dn    = this.fi.Directory.FullName;
            var p     = Path.Combine(dn, string.Concat(mtlfn, ".mtl"));
            var mtlfi = new FileInfo(p);

            using (var fs = mtlfi.Create())
                using (var sw = new StreamWriter(fs, new UTF8Encoding(false)))
                {
                    sw.NewLine = "\n";

                    sw.WriteLine("# Generated using MSET Converter by John Cena of PTF");
                    sw.WriteLine("# mset Version: {0}", Program.GetAssemblyVersion());
                    sw.WriteLine("# mset-obj Version: {0}", this.VersionID);
                    sw.WriteLine();
                    sw.WriteLine("# Default MSET material");
                    sw.WriteLine("newmtl JCMSet");
                    sw.WriteLine("Kd {0:0.000000} {1:0.000000} {2:0.000000}", clr.RFloat, clr.GFloat, clr.BFloat);
                    sw.WriteLine("d  {0:0.000000}", clr.AFloat);
                    sw.WriteLine("Tr {0:0.000000}", 1F - clr.AFloat);
                    sw.WriteLine();

                    sw.Flush();
                }

            if (opts.VerboseMode)
            {
                ULogger.W("OBJMTL", "Written MTL: {0}", mtlfi.FullName);
            }
        }
示例#3
0
 void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
 {
     //可以记录日志并转向错误bug窗口友好提示用户
     e.Handled = true;
     MessageBox.Show("消息:" + e.Exception.Message + "\r\n" + e.Exception.StackTrace);
     ULogger.WriteException(e.Exception);
 }
示例#4
0
        private void _CheckConnectionState()
        {
            // This is how you can determine whether a socket is still connected. 
            var blockingState = _client.Client.Blocking;

            try {
                _client.Client.Blocking = false;
                Send(new _TcpCheckPacket());
                if (showLog)
                {
                    ULogger.Info($"<{serviceName}> Send _TcpCheckPacket.");
                }
            } catch (SocketException e) {
                Debug.Log(e);
                // 10035 == WSAEWOULDBLOCK 
                if (!e.NativeErrorCode.Equals(10035))
                {
                    _HandleConnectionClosedByRemote();
                }
            } finally {
                if (_client != null)
                {
                    _client.Client.Blocking = blockingState;
                }
            }
        }
示例#5
0
        /// <summary>
        /// 通过网络时间设置时间差
        /// </summary>
        private async void SetDeltaTimeByNet()
        {
            await Task.Run(() =>
            {
                BtnSetDeltaTimeByNet.Dispatcher.Invoke(() =>
                {
                    BtnSetDeltaTimeByNet.IsEnabled = false;
                });
                try
                {
                    string t = File.ReadAllText(Settings.Default.NetPath);
                    Settings.Default.deltaTime = Convert.ToInt32(t);
                    BtnSetDeltaTimeByNet.Dispatcher.Invoke(() =>
                    {
                        BtnSetDeltaTimeByNet.IsEnabled = true;
                        BtnSetDeltaTimeByNet.Content   = ":)";
                    }); Thread.Sleep(1000);//如果成功,给予一个美丽的微笑!
                    BtnSetDeltaTimeByNet.Dispatcher.Invoke(() =>
                    {
                        BtnSetDeltaTimeByNet.Content = "立即刷新";
                    });
                }
                catch (Exception ex)
                {
                    ULogger.WriteException(ex);
#if !DEBUG
                    MessageBox.Show(@"在试图获取网络时间时出错,若一直出现此错误请关闭'网络时间'功能");
#endif
                }
                BtnSetDeltaTimeByNet.Dispatcher.Invoke(() =>
                {
                    BtnSetDeltaTimeByNet.IsEnabled = true;
                });
            });
        }
示例#6
0
 public void Init(ILog log, ActorRepository repo, ActorSettings settings, AreaHolder areas)
 {
     _logger  = log.CreateLogger(this);
     _repo    = repo;
     Settings = settings;
     Areas    = areas;
 }
示例#7
0
 public void Startup()
 {
     if (CurrentState != ServiceState.Stopped)
     {
         return;
     }
     try {
         _Startup();
         RuntimeErrorMessage = null;
         _started            = true;
         enabled             = true;
         ULogger.Info($"Service {serviceName} started");
         Started.Trigger();
     } catch (Exception e) {
         // 启动服务失败,若设置了自动重启间隔,则在指定间隔后尝试重启
         RuntimeErrorMessage = $"{e.GetType ().Name}: {e.Message}";
         _started            = false;
         enabled             = false;
         ULogger.Warning(
             $"Start service {serviceName} failed due to {RuntimeErrorMessage}");
         if (retryInterval != 0)
         {
             Invoke(nameof(Startup), retryInterval);
         }
     }
 }
示例#8
0
文件: AI.cs 项目: ekjh22/ProjectBase
    protected sealed override void AISetting(ILog log)
    {
        _log = log.CreateLogger(this);
        _log.Message("AI 셋팅");

        base.AISetting(log);
    }
示例#9
0
 public bool Send(Packet.Packet packet)
 {
     try {
         if (!IsRunning)
         {
             throw new ServiceException($"{serviceName} is not running.");
         }
         var remoteEp   = new IPEndPoint(IPAddress.Parse(remoteIP), remotePort);
         var packetData = packet.Data;
         var packetCode = _packetForwardService.GetPacketCode(packet.GetType());
         var writer     = new _NetWriter(packetCode, packetData, _seq);
         while (true)
         {
             try {
                 _buffStream.Seek(0, SeekOrigin.Begin);
                 var bytesWritten =
                     writer.WriteNextSubPacket(new BinaryWriter(_buffStream));
                 _client.Send(_buffStream.GetBuffer(), (int)bytesWritten, remoteEp);
             } catch (EndOfStreamException) {
                 break;
             }
         }
         if (showLog)
         {
             ULogger.Info($"<{serviceName}> {packet.GetType ().FullName} was sent.");
         }
         return(true);
     } catch (Exception e) {
         ULogger.Warning($"<{serviceName}> Send {packet.GetType ().FullName} failed.", e);
         return(false);
     }
 }
示例#10
0
 public RequestController(ILog log, IEvent events, TimeController time, UserController user)
 {
     _log    = log.CreateLogger(this);
     _events = events;
     _time   = time;
     _user   = user;
 }
示例#11
0
 public bool Send(Packet.Packet packet)
 {
     try {
         if (!IsRunning)
         {
             throw new ServiceException($"{serviceName} is not running.");
         }
         if (_client == null || !_client.Connected)
         {
             throw new ServiceException($"{serviceName} is not in connection.");
         }
         var packetData = packet.Data;
         var packetCode = _packetForwardService.GetPacketCode(typeof(T));
         var writer     = new _NetWriter(packetCode, packetData);
         writer.WriteNextSubPacket(new BinaryWriter(_client.GetStream()));
         if (showLog)
         {
             ULogger.Info($"<{serviceName}> {packet.GetType ().FullName} was sent.");
         }
         return(true);
     } catch (Exception e) {
         ULogger.Warning($"<{serviceName}> Send {packet.GetType ().FullName} failed.", e);
         return(false);
     }
 }
示例#12
0
 public ClientMoodController(ILog log, IEvent events, GameRules rules, ClientController client, RequestController request)
 {
     _logger  = log.CreateLogger(this);
     _event   = events;
     _rules   = rules;
     _client  = client;
     _request = request;
 }
示例#13
0
        static void Main(string[] args)
        {
            ULogger logger = new ULogger()
            {
                LocalFilePath = "Logs\\testingLogs.txt"
            };

            logger.Debug("Test");
        }
示例#14
0
 /// <summary>
 /// 转发数据包至所有绑定的接收者。
 /// </summary>
 /// <param name="packet">数据包</param>
 /// <seealso cref="BindReceiver{T}"/>
 public void ForwardPacket(Packet packet)
 {
     if (!_handlers.TryGetValue(packet.GetType(), out var receivers))
     {
         ULogger.Warning($"{packet.GetType ().FullName} has not been set in protocal");
         return;
     }
     receivers?.Receive(packet);
 }
示例#15
0
 void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
 {
     //可以记录日志并转向错误bug窗口友好提示用户
     if (e.ExceptionObject is Exception ex)
     {
         MessageBox.Show(ex.Message);
         ULogger.WriteException(ex);
     }
 }
示例#16
0
        public UpgradeController(ILog log, GameSettings settings, ServerController server, FinanceController finance)
        {
            _log     = log.CreateLogger(this);
            _server  = server;
            _finance = finance;

            _clientLevels = LoadLevels(settings.ClientUpgrades);
            _customLevels = LoadLevels(settings.CustomUpgrades);
        }
示例#17
0
 public void Resume()
 {
     if (CurrentState != ServiceState.Paused)
     {
         return;
     }
     enabled = true;
     ULogger.Info($"Service {serviceName} resumed");
     Resumed.Trigger();
 }
示例#18
0
        private void _AcceptConnectionToClient()
        {
            _client = _listener.AcceptTcpClient();
            _listener.Stop();
            _lastCheckTime = Time.realtimeSinceStartup;
            var clientEP = (IPEndPoint)_client.Client.RemoteEndPoint;

            ULogger.Info(
                $"<{serviceName}> Client has been connected: {clientEP.Address}:{clientEP.Port}.");
        }
示例#19
0
 public void Pause()
 {
     if (CurrentState != ServiceState.Running)
     {
         return;
     }
     enabled = false;
     ULogger.Info($"Service {serviceName} paused");
     Paused.Trigger();
 }
示例#20
0
 private void TbDeltaTime_TextChanged(object sender, TextChangedEventArgs e)
 {
     try
     {
         Settings.Default.deltaTime = int.Parse(TbDeltaTime.Text.ToString());
     }
     catch (Exception ex)
     {
         ULogger.WriteException(ex);
     }
 }
示例#21
0
 private void Tbdpi_TextChanged(object sender, TextChangedEventArgs e)
 {
     try
     {
         Settings.Default.dpi = double.Parse(Tbdpi.Text.ToString());
     }
     catch (Exception ex)
     {
         ULogger.WriteException(ex);
     }
 }
示例#22
0
        private void Timer1000_Tick(object sender, EventArgs e)
        {
            if (Settings.Default.isCheckIn)
            {
                OpenCheckIn.Check();
            }

            foreach (var item in windows)
            {
                if (item.Window is FunctionWindow window)
                {
                    if (window.IsVisible && FunctionWindow.ColorActive)
                    {
                        window.ChangeColor();
                    }
                    window.Topmost = true;
                }
            }
            Public.SettingWindow.TbChangeHeTime.Text = "长河时间 " + Public.ChangHeTime().ToString();
#if !DEBUG
            try
            {
                Core.Load(Public.pathTime, Public.pathClass);
                Core.CurrentTime = Public.ChangHeTime();
            }
            catch (Exception ex)
            {
                ULogger.WriteException(ex);
                Public.timeTableWindow.ErrorLoad();
                Public.classTableWindow.ErrorLoad();
                return;
            }
#else
            Core.Load(Public.pathTime, Public.pathClass);
            Core.CurrentTime = Public.ChangHeTime();
#endif
            //timeWindow.Topmost = true;
            Public.timeTableWindow.Changedata(Core.CurrentTimeSection, Core.FormatProgress(Core.Progress));
            Public.timeTableWindow.MoveLineProgress(Core.Progress);
            Public.timeWindow.ChangeTime();
            int week = (int)Public.ChangHeTime().DayOfWeek;
            if (Public.ChangHeTime().CompareTo(Core.LastClassEndTime[week]) > 0 && Settings.Default.isTomorrowClass)
            {
                //明天课表
                Public.classTableWindow.ChangeClass(Core.GetClass((int)Public.ChangHeTime().AddDays(1).DayOfWeek), true);
                Public.classTableWindow.ChangeWeek(Public.ChangHeTime().AddDays(1).DayOfWeek);
            }
            else
            {
                //今天课表
                Public.classTableWindow.ChangeClass(Core.GetClass());
                Public.classTableWindow.ChangeWeek(Public.ChangHeTime().DayOfWeek);
            }
        }
示例#23
0
        public static ULogger GetLogger(string catagoryName)
        {
            ULogger logger = null;

            if (_cachedLoggers.TryGetValue(catagoryName, out logger))
            {
                return(logger);
            }
            logger = new ULoggerDefault(catagoryName);
            return(logger);
        }
        private static bool Prefix(ItemObject item, ref ItemDrop __result)
        {
            if (IgnoreItems.allMatchedIDs.Contains(item.ItemDataId))
            {
                ULogger.LogTrace("Dropped item ignored; ID={0}, name={1}",
                                 item.ItemDataId, item.ItemBase.Name);
                __result = ( ItemDrop )null;
                return(false);
            }

            return(true);
        }
示例#25
0
    protected sealed override void AISetting(ILog log)
    {
        _log = log.CreateLogger(this);

        _animtor = GetComponent <Animator>();

        base.AISetting(log);

        Kind           = ObjectKind.NPC;
        MyStats.CurHP  = MyStats.MaxHP = 100;
        MyStats.Radius = 5f;
    }
示例#26
0
    protected sealed override void AISetting(ILog log)
    {
        _log = log.CreateLogger(this);

        base.AISetting(log);

        Kind              = ObjectKind.Item;
        MyStats.CurHP     = MyStats.MaxHP = 99;
        MyStats.Radius    = 5f;
        MyStats.MoveSpeed = 5f;
        MyStats.IsPatrol  = false;
    }
示例#27
0
 private void LoadCboFileList()
 {
     try
     {
         filesName             = GetFiles();
         CboStus.ItemsSource   = filesName;
         CboStus.SelectedIndex = CboStus.Items.Count - 1;
     }
     catch (Exception ex)
     {
         ULogger.WriteException(ex);
     }
 }
示例#28
0
 private void _HandleConnectionClosedByRemote(_TcpClosePacket packet = null)
 {
     ULogger.Info(packet != null ?
                  $"<{serviceName}> Connection closed by remote." :
                  $"<{serviceName}> Connection to remote is lost.");
     _client.Dispose();
     _client = null;
     Shutdown();
     if (retryInterval > 0)
     {
         Startup();
     }
 }
示例#29
0
 internal void DoMainLoop()
 {
     if (CurrentState != ServiceState.Running)
     {
         return;
     }
     try {
         _Update();
     } catch (Exception e) {
         RuntimeErrorMessage = $"{e.GetType ().Name}: {e.Message}";
         ULogger.Warning($"Service {serviceName} incurs {RuntimeErrorMessage}");
     }
 }
示例#30
0
    protected sealed override void AISetting(ILog log)
    {
        _log = log.CreateLogger(this);

        _animtor = GetComponent <Animator>();

        base.AISetting(log);

        Kind          = ObjectKind.Obstacle;
        MyStats.CurHP = MyStats.MaxHP = maxHp;


        originPos = transform.position;
    }