private void CreatePlayer_Load(object sender, EventArgs e) { string root = GlobalB.GetRootPath(); bg = Bitmap.FromFile(root + @"\Medias\Loading_Bk.png"); mess_187x92 = Bitmap.FromFile(root + @"\Medias\Logon_Register.png"); }
private void Form1_Load_Player() { var rootPath = GlobalB.GetRootPath() + @"\Setting\PlayerData"; if (Directory.Exists(rootPath) == false) { return; } players.Clear(); DirectoryInfo dirs = new DirectoryInfo(rootPath); foreach (var dir in dirs.GetDirectories()) { var player = new PlayerData(); bool poi = Data.XML.XmlPlayer.ReadPlayer(dir.FullName, player); if (poi == true) { players.Add(player); comboBox1.Items.Add(player.GetQQ() + " - " + player.GetName()); } } if (comboBox1.Items.Count > 0) { comboBox1.SelectedIndex = 0; } }
public void Load() { string path = GlobalB.GetRootPath() + @"\balloon\BalloonElemnet.xml"; if (!File.Exists(path)) { MessageBox.Show("无法打开: " + path, "ERROR"); return; } Clear(); //将XML文件加载进来 XDocument document = XDocument.Load(path); //获取到XML的根元素进行操作 XElement root = document.Root; Load_BackGrounds(root.Element("BackGrounds")); Load_Static_Element(root.Element("Static_Element")); Load_Fly_Element(root.Element("Fly_Element")); Load_NPCs(root.Element("NPCs")); Load_Propertys(root.Element("Propertys")); Load_Vanes(root.Element("Vanes")); Load_Traps(root.Element("Traps")); Load_Players(root.Element("Players")); Load_Balloons(root.Element("Balloons")); Load_Build_Slave(root.Element("Build_Slave")); Load_Primers(root.Element("Primers")); Load_Floats(root.Element("Floats")); Load_Gates(root.Element("Gates")); Load_Stabbers(root.Element("Stabbers")); Load_Spouts(root.Element("Spouts")); Load_Barrier(root.Element("Barrier")); Load_Player_Bases(root.Element("Player_Bases")); }
private void FormGame_FormClosed(object sender, FormClosedEventArgs e) { Global.GetReplayManager().End(); XmlPlayer.WritePlayer(GlobalB.GetRootPath() + @"\Setting\", Global.GetPlayer()); FormParent.AddTextGame("玩家数据保存成功"); Global.GetSoundManager().DelRes(); Global.SetSoundManager(null); Global.DelRes(); FormParent.formGame = null; Global.IsFormGameOpen = false; }
private void Form1_Save_Config() { //保存窗口设置 string path = GlobalB.GetRootPath() + @"\Setting"; if (Directory.Exists(path) == false) { Directory.CreateDirectory(path); } path = path + @"\config.xml"; if (File.Exists(path)) { File.Delete(path); } string[,] str = new string[, ] { { "选择玩家", "" + comboBox1.SelectedIndex }, { "音乐音量", "" + trackBar1.Value }, { "音效音量", "" + trackBar2.Value }, { "窗口解锁", checkBox2.Checked?"是":"否" }, { "调试模式", checkBox1.Checked?"是":"否" }, { "IP地址", textBox3.Text }, { "端口", textBox4.Text }, }; XmlDocument xmlDoc = new XmlDocument(); //创建Xml声明部分,即<?xml version="1.0" encoding="utf-8" ?> XmlDeclaration Declaration = xmlDoc.CreateXmlDeclaration("1.0", "gb2312", null); //创建根节点 XmlNode rootNode = xmlDoc.CreateElement("Root"); for (int i = 0; i < str.Length / 2; i++) { //创建student子节点 XmlNode childNode = xmlDoc.CreateElement(str[i, 0]); //创建一个属性 XmlAttribute value = xmlDoc.CreateAttribute("Value"); value.Value = str[i, 1]; //xml节点附件属性 childNode.Attributes.Append(value); //附加子节点到根节点 rootNode.AppendChild(childNode); } //附加根节点 xmlDoc.AppendChild(rootNode); xmlDoc.InsertBefore(Declaration, xmlDoc.DocumentElement); //保存Xml文档 xmlDoc.Save(path); }
public PPDevice(System.Windows.Forms.Control handle, Action draw) { string path = GlobalB.GetRootPath() + @"\ResPoi\"; _Engine = new RenderEngine(handle); _Sprite = new RenderSprite(_Engine); _Engine.OnRender += draw; device = _Engine.Device; green = LoadBitmapFromFile(path + @"green.png"); blue1 = LoadBitmapFromFile(path + @"blue1.png"); blue2 = LoadBitmapFromFile(path + @"blue2.png"); red = LoadBitmapFromFile(path + @"red.png"); pink = LoadBitmapFromFile(path + @"pink.png"); }
private void SavePlayer() { //保存玩家数据 string path = GlobalB.GetRootPath() + @"\Setting\"; if (Global.GetPlayer() != null) { var player = Global.GetPlayer(); if (player.ExID != "0") { Data.XML.XmlPlayer.WritePlayer(path, Global.GetPlayer()); } } }
public Texture LoadBitmapFromFile(string file) { System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(file); int w = GlobalB.Get2Min(bitmap.Size.Width); int h = GlobalB.Get2Min(bitmap.Size.Height); var bitmap2 = new System.Drawing.Bitmap(w, h); var g = System.Drawing.Graphics.FromImage(bitmap2); g.DrawImage(bitmap, new System.Drawing.Rectangle(0, 0, bitmap.Size.Width, bitmap.Size.Height)); g.Save(); var tex = CreateTextureFromBitmap(bitmap2); bitmap.Dispose(); bitmap2.Dispose(); g.Dispose(); return(tex); //return Texture.FromFile(device, file); //return _Engine.CreateTextureFromFile(file); //return _Engine.CreateTextureFromBitmap(new System.Drawing.Bitmap(file)); }
private void button1_Click(object sender, EventArgs e) { string root = GlobalB.GetRootPath() + @"\Setting\"; Random rand = new Random(); var time = DateTime.Now; string year = time.Year + ""; string month = GlobalB.IntToString(time.Month, 1); string day = GlobalB.IntToString(time.Day, 1); string hour = GlobalB.IntToString(time.Hour, 1); string min = GlobalB.IntToString(time.Minute, 1); string sec = GlobalB.IntToString(time.Second, 1); string msec = GlobalB.IntToString(time.Millisecond, 2); string ran = GlobalB.IntToString((rand.Next() % 1000), 3); var player = new PlayerData(); player.name = textBox2.Text; player.QQ = textBox1.Text; player.ExID = "01" + year + month + day + hour + min + sec + msec + ran; Data.XML.XmlPlayer.WritePlayer(root, player); this.Close(); }
public B(GlobalB gb) { _gb = gb; }
public int UpdateInput() { if (Global.IsConnect()) { //游戏是否开始 if (Global.GetMapManager() != null && Global.GetMapManager().situation <= 1) { if (inputManager.IsComplete()) { //发送到服务端 { var dat = new ClientData(); if (Global.IsCameraFree) { dat.CreateInput(inputManager.GetTime(), Global.GetInput().GetKeyBoolNull()); } else { dat.CreateInput(inputManager.GetTime(), Global.GetInput().GetKeyBool()); } Global.GetClientC().AddData(dat); } var rep = Global.GetReplayManager(); var sw = rep.GetSw(); if (inputManager.IsBegin()) { var player = Global.GetPlayer(); string path = GlobalB.GetRootPath() + @"\Setting\PlayerData\" + (player.GetQQ() + "_" + player.GetExID() + @"\Replay"); if (Directory.Exists(path) == false) { Directory.CreateDirectory(path); } var time = DateTime.Now; int[] times = new int[6] { time.Year, time.Month, time.Day, time.Hour, time.Minute, time.Second }; string timeStr = ""; for (int i = 0; i < 6; i++) { if (i == 3) { timeStr = timeStr + "_"; } if (times[i] < 10) { timeStr = timeStr + "0"; } timeStr = timeStr + times[i]; } path = path + "\\" + timeStr + ".rep"; rep.Start(path); sw = rep.GetSw(); sw.WriteLine("" + GetPlayerNum()); // bool[] dat = new bool[6]; for (int i = 0; i < 6; i++) { dat[i] = (players[i].player != null); } inputManager.SetPlayer(dat); } int index = 0; for (int i = 0; i < 6; i++) { if (inputManager.IsIn(i)) { var player = players[i].player; if (player != null) { var inp = inputManager.GetInput(i); { //player.input.UpdateKey(inp); //???? //创建的player有误? Global.GetMapManager().pla.list[index].player.input.UpdateKey(inp); index++; } for (int j = 0; j < 9; j++) { if (inp[j]) { sw.Write('1'); } else { sw.Write('0'); } } sw.Write(' '); } } } sw.WriteLine(); inputManager.Update(); } else { return(1); } } } else { //本地更新 if (Global.IsCameraFree) { Global.GetPlayer().input.UpdateKey(Global.GetInput().GetKeyBoolNull()); } else { Global.GetPlayer().input.UpdateKey(Global.GetInput().GetKeyBool()); } } return(0); }
public void OnCreate() { bgm_path = GlobalB.GetRootPath() + @"\balloon\music\"; effect_path = GlobalB.GetRootPath() + @"\balloon\effect\"; bgm_str = new string[] { "cityoftoys.mp3", "Draw.mp3", "flag_mic_win.mp3", "flag_toy_win.mp3", "hall.mp3", "Lose.mp3", "map_deadmode_1.mp3", "map_deadmode_2.mp3", "map_lootmode.mp3", "map_maccity.mp3", "room.mp3", "Win.mp3" }; effect_str = new string[] { "bighit.wav", "But_Click.wav", "Dart_Begin.wav", "Dart_Circle.wav", "Dart_Hit.wav", "Dart_Lose.wav", "dm_dida.wav", "dm_hint.wav", "Entropy_Full.wav", "flag_mic_get.wav", "flag_mic_levelup.wav", "flag_toy_get.wav", "flag_toy_levelup.wav", "hit.wav", "lm_ts1.wav", "lm_ts2.wav", "lm_ts3.wav", "lm_ts4.wav", "lm_ufo.wav", "lm_ufo_throw.wav", "VS.wav", "按钮1.wav", "按钮2.wav", "爆炸.wav", "被电.wav", "冰霜陷阱.wav", "吹气.wav", "大炮陷阱_爆炸.wav", "大炮陷阱_发射.wav", "道具1.wav", "道具2.wav", "地图.wav", "滑动1.wav", "滑动2.wav", "火焰陷阱.wav", "击杀.wav", "激光陷阱.wav", "角色滑动.wav", "禁止.wav", "巨锤陷阱.wav", "碰撞2.wav", "启动.wav", "气球破裂.wav", "蜘蛛陷阱.wav", }; }
private void Form1_Load_Config() { //加载窗口设置 string path = GlobalB.GetRootPath() + @"\Setting\config.xml"; if (File.Exists(path) == false) { return; } //将XML文件加载进来 XDocument document = XDocument.Load(path); //获取到XML的根元素进行操作 XElement root = document.Root; foreach (XElement item1 in root.Elements()) { var name = item1.Name.LocalName; if (name == "选择玩家") { int t = XmlManager.Try_Get_Attribute_Value(item1.Attribute("Value")); if (t >= 0 && t < players.Count) { comboBox1.SelectedIndex = t; } } else if (name == "音乐音量") { int t = XmlManager.Try_Get_Attribute_Value(item1.Attribute("Value")); if (t >= 0 && t <= 100) { trackBar1.Value = t; } } else if (name == "音效音量") { int t = XmlManager.Try_Get_Attribute_Value(item1.Attribute("Value")); if (t >= 0 && t <= 100) { trackBar2.Value = t; } } else if (name == "窗口解锁") { string t = XmlManager.Try_Get_Attribute_Value_Str(item1.Attribute("Value")); checkBox2.Checked = (t == "是"); Global.IsCameraFree = checkBox2.Checked; } else if (name == "调试模式") { string t = XmlManager.Try_Get_Attribute_Value_Str(item1.Attribute("Value")); checkBox1.Checked = (t == "是"); Global.IsDebug = checkBox1.Checked; } else if (name == "IP地址") { string t = XmlManager.Try_Get_Attribute_Value_Str(item1.Attribute("Value")); textBox3.Text = t; } else if (name == "端口") { string t = XmlManager.Try_Get_Attribute_Value_Str(item1.Attribute("Value")); textBox4.Text = t; } } }
public void Init() { path = GlobalB.GetRootPath() + "\\"; }
public void OnCreate() { path = GlobalB.GetRootPath() + "\\"; itemPic = new BalloonItemPic(); pic = new BalloonPic(); }