コード例 #1
0
        static void Main(string[] args)
        {
            Auxiliary.VTBS.API.VTBS服务器CDN.根据CDN更新VTBS_Url();
            MMPU.配置文件初始化(1);
            new Task(() =>
            {
                DDTVLiveRecWebServer.Program.Main(new string[] { });
            }).Start();

            new Task(() =>
            {
                while (true)
                {
                    try
                    {
                        string 务器版本号 = MMPU.TcpSend(Server.RequestCode.GET_VER, "{}", true, 50);
                        if (!string.IsNullOrEmpty(务器版本号))
                        {
                            bool 检测状态 = true;
                            foreach (var item in MMPU.检测的版本号)
                            {
                                if (务器版本号 == item)
                                {
                                    检测状态 = false;
                                }
                            }
                            if (MMPU.版本号 != 务器版本号 && 检测状态)
                            {
                                MMPU.更新公告   = MMPU.TcpSend(Server.RequestCode.GET_UPDATE_ANNOUNCEMENT, "{}", true, 100);
                                MMPU.是否有新版本 = true;
                                InfoLog.InfoPrintf("检测到版本更新,更新内容:\n" + MMPU.TcpSend(Server.RequestCode.GET_VERTEXT, "{}", true, 100) + "\n\n", InfoLog.InfoClass.载必要提示);
                            }
                        }
                    }
                    catch (Exception) { }
                    Thread.Sleep(3600 * 1000);
                }
            }).Start();
            MMPU.缓存路径 = MMPU.载储存目录;
            InfoLog.InfoPrintf(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ": " + "DDTVLiveRec启动完成", InfoLog.InfoClass.载必要提示);
            while (true)
            {
                Thread.Sleep(10);
            }
        }
コード例 #2
0
        private bool PlayMusicCallback(FMOD.Sound sound)
        {
            FMOD.RESULT result;

            lock (syncMusicCallback)
            {
                bool isPlaying = false;
                manualMusicEnd = false;

                if (channel != null)
                {
                    channel.isPlaying(ref isPlaying);
                }
                else
                {
                    isPlaying = false;
                }

                if (isPlaying && channel != null)
                {
                    manualMusicEnd = true;
                    InfoLog.WriteInfo(DateTime.Now.ToString() + "   | Music is playing, Manual music end: " + manualMusicEnd, EPrefix.AudioEngine);
                    channel.setMute(true);
                    channel.stop();
                    channel = null;
                }
                else
                {
                    InfoLog.WriteInfo(DateTime.Now.ToString() + "   | Music is not playing, Manual music end: " + manualMusicEnd, EPrefix.AudioEngine);
                }

                result = system.playSound(FMOD.CHANNELINDEX.REUSE, sound, true, ref channel);
                if (result == FMOD.RESULT.OK && channel != null)
                {
                    channel.setVolume(volume);
                    channel.setCallback(FMOD.CHANNEL_CALLBACKTYPE.END, endPlayCallback, 0);
                    InfoLog.WriteInfo(DateTime.Now.ToString() + "   | Before Play music begin", EPrefix.AudioEngine);
                    channel.setPaused(false);
                }
            }

            InfoLog.WriteInfo(DateTime.Now.ToString() + "   | After Play music begin, result: " + result, EPrefix.AudioEngine);

            return(FMOD.ERROR.ERRCHECK(result));
        }
コード例 #3
0
ファイル: Player.cs プロジェクト: corefan/yad2
        public void ReceiveMessages()
        {
            byte type;

            while (true)
            {
                try {
                    type = _readStream.ReadByte();
                }
                catch (Exception) {
                    ExecuteOnConnectionLost();
                    return;
                }
                if (type == (byte)MessageType.TurnAsk)
                {
                    _tac.Set();
                }
                if (_data != null)
                {
                    InfoLog.WriteInfo("Player " + this.Login + " sent message", EPrefix.MessageReceivedInfo);
                }
                else
                {
                    InfoLog.WriteInfo("Player unknown sent message", EPrefix.MessageReceivedInfo);
                }
                Message msg = MessageFactory.Create((MessageType)type);
                InfoLog.WriteInfo("Received message with type " + type, EPrefix.MessageReceivedInfo);
                if (null == msg)
                {
                    InfoLog.WriteInfo("Received unknown message", EPrefix.MessageReceivedInfo);
                    continue;
                }
                try {
                    msg.Deserialize(_readStream);
                }
                catch (Exception) {
                    ExecuteOnConnectionLost();
                    return;
                }

                msg.SenderId = Id;
                ExecuteOnReceiveMessage(msg);
                Thread.Sleep(0);
            }
        }
コード例 #4
0
        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            // 清除回復、重複步驟記錄
            //List<string> undoKeys = AppConfig.AppPropertySetting.Instance().GetCollectionPropertyNames(AppConfig.AppPropSection.UndoCollection);
            //undoKeys.ForEach(key => AppConfig.AppPropertySetting.Instance().RemoveProperty(key, AppConfig.AppPropSection.UndoCollection));
            //AppConfig.AppPropertySetting.Instance().AddProperty(new AppConfig.AppPropElement("Undo_Base_00", "DoNotRemove"), AppConfig.AppPropSection.UndoCollection);
            List <string> undoKeys = AppJsonConfig.AppPropertySetting.Instance().ConfigRoot.properties.AppPropSetting.Undo;

            undoKeys.RemoveAll(s => !s.StartsWith("Undo_Base"));
            //List<string> redoKeys = AppConfig.AppPropertySetting.Instance().GetCollectionPropertyNames(AppConfig.AppPropSection.RedoCollection);
            //redoKeys.ForEach(key => AppConfig.AppPropertySetting.Instance().RemoveProperty(key, AppConfig.AppPropSection.RedoCollection));
            //AppConfig.AppPropertySetting.Instance().AddProperty(new AppConfig.AppPropElement("Redo_Base_00", "DoNotRemove"), AppConfig.AppPropSection.RedoCollection);
            List <string> redoKeys = AppJsonConfig.AppPropertySetting.Instance().ConfigRoot.properties.AppPropSetting.Redo;

            redoKeys.RemoveAll(s => !s.StartsWith("Redo_Base"));

            InfoLog.Log("BRSTestDataGenerator", "MainForm", "MainForm of [BRS Test Data Generator] Closed.");
        }
コード例 #5
0
        private void ProcessLogin(LoginMessage msg)
        {
            //Pobranie gracza z listy niezalogowanych
            Player player = _server.GetPlayerUnlogged(msg.SenderId);

            InfoLog.WriteInfo(string.Format(ProcessStringFormat, "Login", msg.SenderId), EPrefix.ServerProcessInfo);
            //Jesli gracza nie ma, lub jego stan jest jakis dziwny - koniec obslugi
            if (null == player || player.State != MenuState.Unlogged)
            {
                return;
            }

            if ((Login(msg.SenderId, msg.Login, msg.Password) || !Settings.Default.DBAvail) && !IsPlayerAlreadyLogged(msg.Login))
            {
                MenuState state = PlayerStateMachine.Transform(player.State, MenuAction.Login);
                if (state == MenuState.Invalid)
                {
                    SendMessage(Utils.CreateResultMessage(ResponseType.Login, ResultType.Unsuccesful), player.Id);
                    return;
                }
                LoggingTransfer(player);
                player.State = state;
                if (!Settings.Default.DBAvail)
                {
                    PlayerData pd = new PlayerData();
                    pd.Login  = msg.Login;
                    pd.LossNo = pd.WinNo = 0;
                    pd.Id     = msg.SenderId;
                    player.SetData(pd);
                }
            }
            else
            {
                SendMessage(Utils.CreateResultMessage(ResponseType.Login, ResultType.Unsuccesful), player.Id);
                InfoLog.WriteInfo("Player: " + msg.Login + "failed to login", EPrefix.ServerProcessInfo);
                return;
            }

            SendMessage(Utils.CreateResultMessage(ResponseType.Login, ResultType.Successful), player.Id);
            NumericMessage idmsg = (NumericMessage)MessageFactory.Create(MessageType.IdInformation);

            idmsg.Number = player.Id;
            SendMessage(idmsg, player.Id);
        }
コード例 #6
0
        /// <summary>
        /// rotate if target is out of range
        /// </summary>
        /// <param name="ob">target</param>
        /// <returns>if rotation was needed</returns>
        protected bool RotateIfNeededInternal(BoardObject ob)
        {
            int alfaTarget          = GetAlfa(ob.Position.X - this.Position.X, ob.Position.Y - this.Position.Y);
            int tankRotation        = ConvertToNumber(Direction);
            int turretRotationDelta = ConvertToNumber(turretDirectionFromTankDirection);

            int turretRotation = turretRotationDelta + tankRotation;


            turretRotation %= 360;
            int delta = turretRotation - alfaTarget;

            delta += 360;
            delta %= 360;
            InfoLog.WriteInfo("## turret rot " + turretRotationDelta + " tank rot: " + tankRotation + "# target: " + alfaTarget + "### " + delta, EPrefix.SimulationInfo);
            int turn = 0;

            if (delta < 360 - 23 && delta >= 180)
            {
                // rotate clockwise
                turn = 45;
                turretRotationDelta += turn;
                turretRotationDelta += 360;
                turretRotationDelta %= 360;
                turretDirectionFromTankDirection = ConvertToDirection(turretRotationDelta);
                return(true);
            }
            else if (delta > 23 && delta < 180)
            {
                // rotate counterclockwise
                turn = -45;
                turretRotationDelta += turn;
                turretRotationDelta += 360;
                turretRotationDelta %= 360;
                turretDirectionFromTankDirection = ConvertToDirection(turretRotationDelta);

                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #7
0
        /*
         * public void Add(short id, string name, bool building, OwnerDrawPictureButton pictureButton) {
         *  InfoLog.WriteInfo("Add", EPrefix.Stripe);
         *  if (buttons.ContainsKey(id)) return;
         *  Insert(id, name, building, pictureButton);
         *
         * }*/



        public void Remove(int id)
        {
            OwnerDrawPictureButton but = buttons[id];

            SuspendFlowLayout();
            if (but != null)
            {
                //this.flowLayoutPanel1.Controls.Remove(but);
                RemoveButton(but);
                this.isBuilding.Remove(id);
                this.buttons.Remove(id);
                this.buttonsToId.Remove(but);
                ids.Remove(id);
            }
            InfoLog.WriteInfo("Remove", EPrefix.Stripe);
            num--;
            UpdateFlowLayoutPanelSize();
            ResumeFlowLayout();
        }
コード例 #8
0
        /// <summary>
        /// 上传到OneDrive
        /// </summary>
        /// <param name="uploadInfo">传入上传信息</param>
        public void doUpload(UploadInfo uploadInfo)
        {
            Process proc = new Process();

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                proc.StartInfo.FileName = @".\OneDriveUploader.exe"; //windows下的程序位置
            }
            else
            {
                proc.StartInfo.FileName = "OneDriveUploader";
            }
            DateTime showTime = DateTime.Now;

            proc.StartInfo.Arguments              = $"-f -c \"{configFile}\" -s \"{uploadInfo.srcFile}\" -r \"{Uploader.oneDrivePath+uploadInfo.remotePath}\"";
            proc.StartInfo.UseShellExecute        = false;
            proc.StartInfo.RedirectStandardOutput = true;
            proc.StartInfo.RedirectStandardError  = true;
            proc.StartInfo.RedirectStandardInput  = true;
            proc.StartInfo.CreateNoWindow         = true; // 不显示窗口。
            proc.EnableRaisingEvents              = true;
            proc.StartInfo.StandardOutputEncoding = Encoding.UTF8;
            proc.OutputDataReceived += delegate(object sender, DataReceivedEventArgs e)
            {
                string stringResults = e.Data;
                if (stringResults == "" || stringResults == null)
                {
                    return;
                }
                uploadInfo.status["OneDrive"].comments = System.Text.RegularExpressions.Regex.Replace(stringResults, @"(.*\[)(.*)(\].*)", "$2");
                InfoLog.InfoPrintf($"Onedrive: {stringResults}", InfoLog.InfoClass.必要提示);
            };                          // 捕捉的信息
            proc.Start();
            proc.BeginOutputReadLine(); // 开始异步读取
            proc.Exited += Process_Exited;
            proc.WaitForExit();
            proc.Close();
            GC.Collect();
            if (exitCode != 0)
            {
                throw new UploadFailure("fail to upload");
            }
        }
コード例 #9
0
 /// <summary>
 /// 初始化上传信息
 /// </summary>
 /// <param name="downIofo">下载信息</param>
 public UploadInfo(DownIofoData downIofo)
 {
     try
     {
         streamerName = downIofo.主播名称;
         streamTitle  = downIofo.标题;
         srcFile      = downIofo.文件保存路径;
         fileName     = System.IO.Path.GetFileName(srcFile);
         fileSize     = (double)new FileInfo(srcFile).Length;
         remotePath   = $"{downIofo.主播名称}_{downIofo.房间_频道号}/{MMPU.Unix转换为DateTime(downIofo.开始时间.ToString()).ToString("yyyyMMdd")}_{downIofo.标题}/";
         type         = null;
         retries      = 0;
     }
     catch
     {
         InfoLog.InfoPrintf($"创建{srcFile}上传任务失败,无法获取文件信息", InfoLog.InfoClass.系统错误信息);
         throw new CreateUploadTaskFailure("fail to ctreate upload task");//处理获取文件名、文件大小的错误
     }
 }
コード例 #10
0
ファイル: Program.cs プロジェクト: Tarqrafi/DDTV2
        static void Main(string[] args)
        {
#if false
            载("14275133");
#else
            Auxiliary.VTBS.API.VTBS服务器CDN.根据CDN更新VTBS_Url();
            MMPU.配置文件初始化(1);
            new Task(() => {
                DDTVLiveRecWebServer.Program.Main(new string[] { });
            }).Start();
#endif
            new Task(() =>
            {
                try
                {
                    string 务器版本号 = MMPU.TcpSend(20013, "{}", true, 50);
                    if (!string.IsNullOrEmpty(务器版本号))
                    {
                        bool 检测状态 = true;
                        foreach (var item in MMPU.检测的版本号)
                        {
                            if (务器版本号 == item)
                            {
                                检测状态 = false;
                            }
                        }
                        if (MMPU.版本号 != 务器版本号 && 检测状态)
                        {
                            MMPU.是否有新版本 = true;
                            InfoLog.InfoPrintf("检测到版本更新,更新公告:\n" + MMPU.TcpSend(20014, "{}", true, 100) + "\n\n", InfoLog.InfoClass.载必要提示);
                            //Console.ReadKey();
                        }
                    }
                }
                catch (Exception) { }
            }).Start();
            MMPU.载储存目录 = MMPU.缓存路径;
            InfoLog.InfoPrintf(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ": " + "DDTVLiveRec启动完成", InfoLog.InfoClass.载必要提示);
            while (true)
            {
                Thread.Sleep(10);
            }
        }
コード例 #11
0
        public void Init(ISynchronizeInvoke newInvoker)
        {
            if (!Settings.Default.AudioEngineAvail)
            {
                InitErrorCheck(FMOD.RESULT.ERR_OFF_MANUALLY);
                return;
            }

            uint version = 0;

            /* Create a System object and initialize */
            if (!InitErrorCheck(FMOD.Factory.System_Create(ref system)))
            {
                return;
            }

            if (!InitErrorCheck(system.getVersion(ref version)))
            {
                return;
            }

            if (version < FMOD.VERSION.number)
            {
                InitErrorCheck(FMOD.RESULT.ERR_VERSION);
                return;
            }

            if (!InitErrorCheck(system.init(32, FMOD.INITFLAG.NORMAL, (IntPtr)null)))
            {
                return;
            }

            isInitialized = true;
            invoker       = newInvoker;
            music         = new Music(system, invoker);
            sound         = new Sound(system, invoker);

            timer.Start();

            music.MusicEnd += new MusicEndEventHandler(music_MusicEnd);

            InfoLog.WriteInfo("Audio initialized successfully", EPrefix.AudioEngine);
        }
コード例 #12
0
ファイル: Unit.cs プロジェクト: corefan/yad2
        private bool RotateBodyInternal(BoardObject ob, Direction weaponDelta)
        {
            int alfaTarget          = GetAlfa(ob.Position.X - this.Position.X, ob.Position.Y - this.Position.Y);
            int unitRotation        = ConvertToNumber(Direction);
            int weaponRotationDelta = ConvertToNumber(weaponDelta);

            int weaponRotation = weaponRotationDelta + unitRotation;


            weaponRotation %= 360;
            int delta = weaponRotation - alfaTarget;

            delta += 360;
            delta %= 360;
            InfoLog.WriteInfo("## weapon rot " + weaponRotationDelta + " unit rot: " + unitRotation + "# target: " + alfaTarget + "### " + delta, EPrefix.SimulationInfo);
            int turn = 0;

            if (delta < 360 - 23 && delta >= 180)
            {
                // rotate clockwise
                turn          = 45;
                unitRotation += turn;
                unitRotation += 360;
                unitRotation %= 360;
                Direction     = ConvertToDirection(unitRotation);
                return(true);
            }
            else if (delta > 23 && delta < 180)
            {
                // rotate counterclockwise
                turn          = -45;
                unitRotation += turn;
                unitRotation += 360;
                unitRotation %= 360;
                Direction     = ConvertToDirection(unitRotation);

                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #13
0
ファイル: Unit.cs プロジェクト: corefan/yad2
        /// <summary>
        /// Sets object to attack (building or unit) by this unit.
        /// </summary>
        /// <param name="objectID"></param>
        public void OrderAttack(BoardObject boardObject, bool isBuilding)
        {
            attackedObject = boardObject;
            orderedAttack  = true;
            if (CheckRangeToShoot(boardObject) == false)
            {
                MoveTo(boardObject.Position);
                state = UnitState.orderedAttack;
            }
            else
            {
                // will shoot ordered.
                state = UnitState.stopped;
                StopMoving();
            }
            this.attackingBuilding = isBuilding;

            InfoLog.WriteInfo("Unit:AI: attacking!!!! ", EPrefix.SimulationInfo);
        }
コード例 #14
0
 void Awake()
 {
     endImg = GameObject.Find("EndImg");
     endImg.SetActive(false);
     winImg = GameObject.Find("WinImg");
     winImg.SetActive(false);
     infoLog   = GameObject.Find("InfoBox").GetComponent <InfoLog>();
     menuPanel = GameObject.Find(Const.MenuPanel).GetComponent <MenuPanel>();
     // 出战位置确定
     playerActPos = GameObject.Find(Const.PlayerActPos).transform;
     enemyActPos  = GameObject.Find(Const.EnemyActPos).transform;
     // 玩家初始位置
     playerPos_1 = GameObject.Find(Const.PlayerPos_1).transform;
     playerPos_2 = GameObject.Find(Const.PlayerPos_2).transform;
     playerPos_3 = GameObject.Find(Const.PlayerPos_3).transform;
     // 敌人初始位置
     enemyPos_1 = GameObject.Find(Const.EnemyPos_1).transform;
     enemyPos_2 = GameObject.Find(Const.EnemyPos_2).transform;
     enemyPos_3 = GameObject.Find(Const.EnemyPos_3).transform;
 }
コード例 #15
0
        public void AcceptConnections()
        {
            TcpClient client = null;

            try {
                client = _listener.AcceptTcpClient();
            }
            catch (Exception) {
                _serverEnd = true;
                return;
            }
            InfoLog.WriteInfo("Server accepted new client");
            Player player = new Player(playerID + 1, client);

            player.OnReceiveMessage += new ReceiveMessageDelegate(_msgHandler.OnReceivePlayerMessage);
            player.OnConnectionLost += new ConnectionLostDelegate(OnConnectionLost);
            player.Start();
            lock (((ICollection)_playersUnlogged).SyncRoot)
                _playersUnlogged.Add(++playerID, player);
        }
コード例 #16
0
 /// 上传一个分片
 private void UploadPart(int partNumber, long partSize, string srcPath)
 {
     try
     {
         UploadPartRequest request = new UploadPartRequest(bucket, key, partNumber,
                                                           this.uploadId, srcPath, partSize * (partNumber - 1), partSize);
         //执行请求
         UploadPartResult result = cosXml.UploadPart(request);
         //请求成功
         //获取返回分块的eTag,用于后续CompleteMultiUploads
         partNumberAndETags.Add(partNumber, result.eTag);
         //Console.WriteLine(result.GetResultInfo());
     }
     catch (COSXML.CosException.CosClientException clientEx)
     {
         //请求失败
         Console.WriteLine("CosClientException: " + clientEx);
         InfoLog.InfoPrintf($"Cos: CosClientException: {clientEx}", InfoLog.InfoClass.系统错误信息);
     }
 }
コード例 #17
0
        void rightStripe_onBuildingChosen(int id)
        {
            InfoLog.WriteInfo("rightStripe_onBuildChosen " + id, EPrefix.GameGraphics);
            int playerCredits = _gameLogic.CurrentPlayer.Credits;
            int cost          = GlobalSettings.Wrapper.buildingsMap[(short)id].Cost;

            if (playerCredits >= cost)
            {
                int creator = _buildManager.RightBuildingClick(id, false);
                if (creator != -1)
                {
                    PlaceBuilding((short)id, creator);
                }
            }
            else
            {
                /* Sound */
                AudioEngine.Instance.Sound.PlayMisc(MiscSoundType.Cannot);
            }
        }
コード例 #18
0
 private void ProcessRegister(RegisterMessage msg)
 {
     if (Settings.Default.DBAvail)
     {
         InfoLog.WriteInfo(string.Format(ProcessStringFormat, "Register", msg.SenderId), EPrefix.ServerProcessInfo);
         if (YadDB.Register(msg.Login, msg.Password, msg.Mail))
         {
             InfoLog.WriteInfo("Player registered successfully", EPrefix.ServerProcessInfo);
             SendMessage(Utils.CreateResultMessage(ResponseType.Register, ResultType.Successful), msg.SenderId);
         }
         else
         {
             SendMessage(Utils.CreateResultMessage(ResponseType.Register, ResultType.Unsuccesful), msg.SenderId);
         }
         InfoLog.WriteInfo("Player registered unsucessfully", EPrefix.ServerProcessInfo);
     }
     else
     {
         SendMessage(Utils.CreateResultMessage(ResponseType.Register, ResultType.Successful), msg.SenderId);
     }
 }
コード例 #19
0
        private void ProcessCreateGame(GameInfoMessage msg)
        {
            Player player = _server.GetPlayer(msg.SenderId);

            InfoLog.WriteInfo(string.Format(ProcessStringFormat, "Create game", msg.SenderId), EPrefix.ServerProcessInfo);
            MenuState     state  = PlayerStateMachine.Transform(player.State, MenuAction.GameJoinEntry);
            ResultMessage resMsg = Utils.CreateResultMessage(ResponseType.CreateGame, ResultType.Unsuccesful);
            ResultType    result = ResultType.Unsuccesful;

            if (state == MenuState.GameJoin)
            {
                result = CreateGame(msg);
                if (result == ResultType.Successful)
                {
                    lock (player.SyncRoot)
                        player.State = state;
                }
            }
            //resMsg.Result = (byte)result;
            //SendMessage(resMsg, msg.SenderId);
        }
コード例 #20
0
        private void miniMap_MouseDown(object sender, MouseEventArgs e)
        {
            InfoLog.WriteInfo("miniMap MouseDown", EPrefix.UIManager);

            switch (e.Button)
            {
            case MouseButtons.Left:
                HandleMiniMapLeftButtonDown(e);
                break;

            case MouseButtons.Right:
                HandleMiniMapRightButtonDown(e);
                break;

            case MouseButtons.XButton1:
            case MouseButtons.XButton2:
            case MouseButtons.None:
            default:
                break;
            }
        }
コード例 #21
0
 private void onPauseResume(bool isPause)
 {
     if (isPause)
     {
         try {
             OnMenuOptionChange(new MenuOptionArg(MenuOption.Pause, this, true));
         }
         catch (NotImplementedException niex) {
             InfoLog.WriteException(niex);
         }
     }
     else
     {
         try {
             OnMenuOptionChange(new MenuOptionArg(MenuOption.Continue, this, true));
         }
         catch (NotImplementedException niex) {
             InfoLog.WriteException(niex);
         }
     }
 }
コード例 #22
0
        public int UploadFiles()
        {
            try
            {
                FileEntity fileEntity = new FileEntity();
                fileEntity.I_Owner      = int.Parse(HttpContext.Current.Request["I_Owner"]);
                fileEntity.I_Category   = Convert.ToInt32(HttpContext.Current.Request["I_Category"]);
                fileEntity.C_Remark     = HttpContext.Current.Request["C_Remark"];
                fileEntity.I_Uploader   = Convert.ToInt32(HttpContext.Current.Request["I_Uploader"]);
                fileEntity.D_Upload     = DateTime.Now;
                fileEntity.C_OriginName = HttpContext.Current.Request.Files[0].FileName;

                InfoLog.Info(string.Format("登录名:{0}, 上传文件:{1}", SessionState["C_Login"].ToString(), Newtonsoft.Json.JsonConvert.SerializeObject(fileEntity)));
                string fileUploadPath = ConfigurationManager.AppSettings["FileUpload"].ToString();

                int index = fileEntity.C_OriginName.LastIndexOf('.');
                if (index == -1)
                {
                    index = 0;
                }
                fileEntity.C_FileName = DateTime.Now.ToString("yyyyMMddHHmmssfff") + fileEntity.C_OriginName.Substring(index);

                if (HttpContext.Current.Request.Files[0].ContentLength > 0)
                {
                    string path = System.IO.Path.Combine(fileUploadPath, fileEntity.I_Owner.ToString());
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }
                    HttpContext.Current.Request.Files[0].SaveAs(path + "\\" + fileEntity.C_FileName);
                    DataHelper.ExecuteNonQuery("Usp_File_Insert", fileEntity);
                    return(1);
                }
                return(-1);
            }
            catch (Exception ex)
            {
                return(-1);
            }
        }
コード例 #23
0
 private void openGLView_KeyDown(object sender, KeyEventArgs e)
 {
     InfoLog.WriteInfo(e.KeyCode.ToString());
     if (e.KeyCode == Keys.Z)
     {
         Settings.Default.UseSafeRendering = !Settings.Default.UseSafeRendering;
     }
     else if (e.KeyCode == Keys.Q)
     {
         GameGraphics.Zoom(-1);
     }
     else if (e.KeyCode == Keys.E)
     {
         GameGraphics.Zoom(1);
     }
     else if (e.KeyCode == Keys.A)
     {
         GameGraphics.OffsetX(-Settings.Default.ScrollingSpeed);
     }
     else if (e.KeyCode == Keys.D)
     {
         GameGraphics.OffsetX(Settings.Default.ScrollingSpeed);
     }
     else if (e.KeyCode == Keys.W)
     {
         GameGraphics.OffsetY(Settings.Default.ScrollingSpeed);
     }
     else if (e.KeyCode == Keys.S)
     {
         GameGraphics.OffsetY(-Settings.Default.ScrollingSpeed);
     }
     else if (e.KeyCode == Keys.X)
     {
         _gameLogic.DeployMCV();
     }
     else if (e.KeyCode == Keys.U)
     {
         AudioEngine.Instance.Sound.PlayMisc(MiscSoundType.ComeToPappa);
     }
 }
コード例 #24
0
ファイル: Unit.cs プロジェクト: corefan/yad2
        public virtual void Destroy()
        {
            state = UnitState.destroyed;
            InfoLog.WriteInfo("Unit:Destroy() Not implemented", EPrefix.SimulationInfo);

            if (_damageDestroy == 0)
            {
                return;
            }

            Position p = this.Position;
            int      count;

            Position[] viewSpiral = RangeSpiral(this.DamageDestroyRange, out count);
            for (int i = 0; i < count; ++i)
            {
                Position spiralPos = viewSpiral[i];
                if (p.X + spiralPos.X >= 0 &&
                    p.X + spiralPos.X < _map.Width &&
                    p.Y + spiralPos.Y >= 0 &&
                    p.Y + spiralPos.Y < _map.Height)
                {
                    ICollection <Unit> units    = _map.Units[p.X + spiralPos.X, p.Y + spiralPos.Y];
                    Unit[]             unitsArr = new Unit[units.Count];
                    units.CopyTo(unitsArr, 0);
                    foreach (Unit unit in unitsArr)
                    {
                        _simulation.handleAttackUnit(unit, this, this._damageDestroy);
                    }

                    ICollection <Building> buildings    = _map.Buildings[p.X + spiralPos.X, p.Y + spiralPos.Y];
                    Building[]             buildingsArr = new Building[buildings.Count];
                    buildings.CopyTo(buildingsArr, 0);
                    foreach (Building building in buildingsArr)
                    {
                        _simulation.handleAttackBuilding(building, this, this._damageDestroy);
                    }
                }
            }
        }
コード例 #25
0
 public void Close()
 {
     try
     {
         bilibili.已经使用的服务器组.Remove(wss_S);
     }
     catch (Exception)
     { }
     try
     {
         m_innerRts.Cancel();
     }
     catch (Exception)
     {}
     try
     {
         m_client.Dispose();
         InfoLog.InfoPrintf($"{TroomId}房间LCL连接已断开,ClientWebSocket对象回收完成:", InfoLog.InfoClass.Debug);
     }
     catch (Exception) {
         InfoLog.InfoPrintf($"×{TroomId}房间LCL连接已断开,ClientWebSocket对象回收失败:", InfoLog.InfoClass.Debug);
     }
     try
     {
         m_innerRts.Dispose();
         InfoLog.InfoPrintf($"{TroomId}房间LCL连接已断开,CancellationTokenSource对象回收完成:", InfoLog.InfoClass.Debug);
     }
     catch (Exception) {
         InfoLog.InfoPrintf($"×{TroomId}房间LCL连接已断开,CancellationTokenSource对象回收失败:", InfoLog.InfoClass.Debug);
     }
     try
     {
         m_ReceiveBuffer = null;
     }
     catch (Exception)
     {
         //throw;
     }
 }
コード例 #26
0
ファイル: GameServer.cs プロジェクト: corefan/yad2
        public GameServer(ServerGameInfo sgInfo) : base()
        {
            _playerCollection = new Dictionary <short, Player>();
            _serverGameInfo   = sgInfo;
            _simulation       = new MockServerSimulation();

            lock (((ICollection)sgInfo.Players).SyncRoot) {
                foreach (IPlayerID pid in sgInfo.Players.Values)
                {
                    ServerPlayerInfo spi = pid as ServerPlayerInfo;
                    lock (((ICollection)_playerCollection).SyncRoot) {
                        _playerCollection.Add(new KeyValuePair <short, Player>(spi.Id, spi.Player));
                        _simulation.AddPlayer(spi.Id, (PlayerData)spi.Player.PlayerData.Clone());
                    }
                }
            }

            MessageHandler = new GameMessageHandler(this);
            MessageHandler.SetSender(_msgSender);

            InfoLog.WriteInfo("Game server for game: " + sgInfo.Name + "created successfully", EPrefix.ServerInformation);
        }
コード例 #27
0
        public void AddLog(LogRequest logRequest)
        {
            if (logRequest == null || logRequest.Content == null)
            {
                throw new ArgumentException(nameof(logRequest), "日志内容不能为空!");
            }

            //取业务Id 如果没有则新建业务
            var business = _BusinessAccess.IfNotInAddReturnEntity(logRequest.AppId, logRequest.BusinessPosition);
            var entity   = new InfoLog()
            {
                Content          = logRequest.Content.ToJson(),
                BusinessId       = business.Id,
                BusinessPosition = business.BusinessLink,
                PlatformId       = business.PlatformId,
                TraceInfo        = logRequest.TraceInfo,
                CreationTime     = logRequest.CreatTime,
                RequestId        = logRequest.RequestId
            };

            DbProvider.Insert(entity);
        }
コード例 #28
0
        private void IncreaseTurn(short id, PauseAction pauseAction)
        {
            InfoLog.WriteInfo("Increasing turn for player: " + id, EPrefix.GameMessageProccesing);
            int minTurnBefore = _gameServer.Simulation.GetMinTurn();
            int maxTurn       = _gameServer.Simulation.GetMaxTurn();
            int actualTurn    = _gameServer.Simulation.GetPlayerTurn(id);
            int delta         = 1;

            if (actualTurn < maxTurn)
            {
                delta = maxTurn - actualTurn;
            }
            _gameServer.Simulation.IncPlayerTurn(id, delta);

            int minTurnAfter = _gameServer.Simulation.GetMinTurn();

            // if this is slowest player then tell him to speed up
            DoTurnMessage dtm = (DoTurnMessage)MessageFactory.Create(MessageType.DoTurn);

            dtm.Pause     = (byte)pauseAction;
            dtm.TurnsToGo = (short)delta;
            if (minTurnBefore != minTurnAfter)
            {
                dtm.SpeedUp = true;
            }
            //
            SendMessage(dtm, id);
            if (minTurnAfter != minTurnBefore)
            {
                InfoLog.WriteInfo("Waking waiting players", EPrefix.GameMessageProccesing);
                short[] stoppedWaiting = _gameServer.Simulation.StopWaiting();
                InfoLog.WriteInfo("Players to wake: " + stoppedWaiting.ToString(), EPrefix.GameMessageProccesing);
                for (int i = 0; i < stoppedWaiting.Length; ++i)
                {
                    _gameServer.Simulation.IncPlayerTurn(stoppedWaiting[i]);
                    SendMessage(MessageFactory.Create(MessageType.DoTurn), stoppedWaiting[i]);
                }
            }
        }
コード例 #29
0
        public ResultType CreateGame(GameInfo gi)
        {
            if (GameNumber == MaxGameNumber)
            {
                return(ResultType.MaxServerGameError);
            }
            ResultType result;

            lock (((ICollection)_games).SyncRoot) {
                result = IsValid(gi);
                if (result != ResultType.Successful)
                {
                    return(result);
                }
                ServerGameInfo sgi = new ServerGameInfo(gi, _sender);
                _games.Add(gi.Name, sgi);
                SendCreateGameMessage(sgi);
                InfoLog.WriteInfo(string.Format(Resources.ActionStringFormat, "create game"), EPrefix.ServerAction);
                InfoLog.WriteInfo("Created game: " + gi.Name, EPrefix.ServerAction);
            }
            return(result);
        }
コード例 #30
0
        public bool PlayNext(MusicType mt)
        {
            if (!isInitialized)
            {
                return(false);
            }

            List <FMOD.Sound> tracks = music[(short)mt];

            if (tracks.Count == 0)
            {
                return(false);
            }

            musicType = mt;

            short index = indices[(short)mt] = (short)((indices[(short)mt] + 1) % tracks.Count);

            InfoLog.WriteInfo(DateTime.Now.ToString() + "  - Changed track to: " + index + ", Music Type: " + mt.ToString(), EPrefix.AudioEngine);

            return(this.Play(tracks[index]));
        }